idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
40,400
function o_procset ( $ id , $ action , $ options = '' ) { if ( $ action != 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'procset' , 'info' => array ( 'PDF' => 1 , 'Text' => 1 ) ) ; $ this -> o_pages ( $ this -> currentNode , 'procset' , $ id ) ; $ this -> procsetObjectId = $ id ; break ; case 'add' : switch ( $ options ) { case 'ImageB' : case 'ImageC' : case 'ImageI' : $ o [ 'info' ] [ $ options ] = 1 ; break ; } break ; case 'out' : $ res = "\n" . $ id . " 0 obj\n[" ; foreach ( $ o [ 'info' ] as $ label => $ val ) { $ res .= '/' . $ label . ' ' ; } $ res .= "]\nendobj" ; return $ res ; break ; } }
the document procset solves some problems with printing to old PS printers
40,401
function o_info ( $ id , $ action , $ options = '' ) { if ( $ action != 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> infoObject = $ id ; $ date = 'D:' . date ( 'Ymd' ) ; $ this -> objects [ $ id ] = array ( 't' => 'info' , 'info' => array ( 'Creator' => 'eZ Publish CMS, http://ez.no' , 'CreationDate' => $ date ) ) ; break ; case 'Title' : case 'Author' : case 'Subject' : case 'Keywords' : case 'Creator' : case 'Producer' : case 'CreationDate' : case 'ModDate' : case 'Trapped' : $ o [ 'info' ] [ $ action ] = $ options ; break ; case 'out' : if ( $ this -> encrypted ) { $ this -> encryptInit ( $ id ) ; } $ res = "\n" . $ id . " 0 obj\n<<\n" ; foreach ( $ o [ 'info' ] as $ k => $ v ) { $ res .= '/' . $ k . ' (' ; if ( $ this -> encrypted ) { $ res .= $ this -> filterText ( $ this -> ARC4 ( $ v ) ) ; } else { $ res .= $ this -> filterText ( $ v ) ; } $ res .= ")\n" ; } $ res .= ">>\nendobj" ; return $ res ; break ; } }
define the document information
40,402
function o_contents ( $ id , $ action , $ options = '' ) { if ( $ action != 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'contents' , 'c' => '' , 'info' => array ( ) ) ; if ( strlen ( $ options ) && intval ( $ options ) ) { $ this -> objects [ $ id ] [ 'onPage' ] = $ options ; } else if ( $ options == 'raw' ) { $ this -> objects [ $ id ] [ 'raw' ] = 1 ; } break ; case 'add' : foreach ( $ options as $ k => $ v ) { $ o [ 'info' ] [ $ k ] = $ v ; } case 'out' : $ tmp = $ o [ 'c' ] ; $ res = "\n" . $ id . " 0 obj\n" ; if ( isset ( $ this -> objects [ $ id ] [ 'raw' ] ) ) { $ res .= $ tmp ; } else { $ res .= "<<" ; if ( function_exists ( 'gzcompress' ) && $ this -> options [ 'compression' ] ) { $ res .= " /Filter /FlateDecode" ; $ tmp = gzcompress ( $ tmp ) ; } if ( $ this -> encrypted ) { $ this -> encryptInit ( $ id ) ; $ tmp = $ this -> ARC4 ( $ tmp ) ; } foreach ( $ o [ 'info' ] as $ k => $ v ) { $ res .= "\n/" . $ k . ' ' . $ v ; } $ res .= "\n/Length " . strlen ( $ tmp ) . " >>\nstream\n" . $ tmp . "\nendstream" ; } $ res .= "\nendobj\n" ; return $ res ; break ; } }
the contents objects hold all of the content which appears on pages
40,403
function newDocument ( $ pageSize = array ( 0 , 0 , 612 , 792 ) ) { $ this -> numObj = 0 ; $ this -> objects = array ( ) ; $ this -> numObj ++ ; $ this -> o_catalog ( $ this -> numObj , 'new' ) ; $ this -> numObj ++ ; $ this -> o_outlines ( $ this -> numObj , 'new' ) ; $ this -> numObj ++ ; $ this -> o_pages ( $ this -> numObj , 'new' ) ; $ this -> o_pages ( $ this -> numObj , 'mediaBox' , $ pageSize ) ; $ this -> currentNode = 3 ; $ this -> numObj ++ ; $ this -> o_procset ( $ this -> numObj , 'new' ) ; $ this -> numObj ++ ; $ this -> o_info ( $ this -> numObj , 'new' ) ; $ this -> numObj ++ ; $ this -> o_page ( $ this -> numObj , 'new' ) ; $ this -> firstPageId = $ this -> currentContents ; }
intialize a new document if this is called on an existing document results may be unpredictable but the existing document would be lost at minimum this function is called automatically by the constructor function
40,404
function shadedRectangle ( $ x1 , $ y1 , $ width , $ height , $ options ) { $ this -> numObj ++ ; $ shadingLabel = $ this -> o_shading ( $ this -> numObj , 'new' , $ options ) ; $ this -> saveState ( ) ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\n" . sprintf ( '%.3F' , $ x1 ) . ' ' . sprintf ( '%.3F' , $ y1 ) . ' ' . sprintf ( '%.3F' , $ width ) . ' ' . sprintf ( '%.3F' , $ height ) . ' re' ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nW n" ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\n/" . $ shadingLabel . ' sh' ; $ this -> restoreState ( ) ; }
Create shaded rectangle area
40,405
function getFontDecender ( $ size = false ) { if ( ! $ this -> numFonts ) { $ this -> selectFont ( './fonts/Helvetica' ) ; } $ h = $ this -> fonts [ $ this -> currentFont ] [ 'FontBBox' ] [ 1 ] ; if ( $ size === false ) { $ size = $ this -> fontSize ( ) ; } return $ size * $ h / 1000 ; }
return the font decender this will normally return a negative number if you add this number to the baseline you get the level of the bottom of the font it is in the pdf user units
40,406
function PRVTgetTextPosition ( $ x , $ y , $ angle , $ size , $ wa , $ text ) { $ tmp = false ; $ w = $ this -> getTextWidth ( $ size , $ text ) ; $ words = explode ( ' ' , $ text ) ; $ nspaces = count ( $ words ) - 1 ; $ w += $ wa * $ nspaces ; $ a = deg2rad ( ( float ) $ angle ) ; if ( $ tmp ) { return array ( $ this -> xOffset ( ) , - sin ( $ a ) * $ w + $ y ) ; } return array ( cos ( $ a ) * $ w + $ x , - sin ( $ a ) * $ w + $ y ) ; }
given a start position and information about how text is to be laid out calculate where on the page the text will end
40,407
function PRVTcheckTextDirective ( & $ text , $ i , & $ f , $ final = 0 ) { $ x = 0 ; $ y = 0 ; return $ this -> PRVTcheckTextDirective1 ( $ text , $ i , $ f , $ final , $ x , $ y ) ; }
wrapper function for PRVTcheckTextDirective1
40,408
function getTextWidth ( $ size , $ text ) { $ this -> pushTextState ( $ this -> currentTextState ) ; if ( ! $ this -> numFonts ) { $ this -> selectFont ( './fonts/Helvetica' ) ; } $ text = "$text" ; $ w = 0 ; $ len = strlen ( $ text ) ; $ cf = $ this -> currentFont ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ f = 1 ; $ directiveArray = $ this -> PRVTcheckTextDirective ( $ text , $ i , $ f ) ; $ directive = $ directiveArray [ 'directive' ] ; if ( $ directive ) { if ( $ f ) { $ this -> setCurrentFont ( ) ; $ cf = $ this -> currentFont ; } $ i = $ i + $ directive - 1 ; } else { $ char = ord ( $ text [ $ i ] ) ; if ( isset ( $ this -> fonts [ $ cf ] [ 'differences' ] [ $ char ] ) ) { $ name = $ this -> fonts [ $ cf ] [ 'differences' ] [ $ char ] ; if ( isset ( $ this -> fonts [ $ cf ] [ 'C' ] [ $ name ] [ 'WX' ] ) ) { $ w += $ this -> fonts [ $ cf ] [ 'C' ] [ $ name ] [ 'WX' ] ; } } else if ( isset ( $ this -> fonts [ $ cf ] [ 'C' ] [ $ char ] [ 'WX' ] ) ) { $ w += $ this -> fonts [ $ cf ] [ 'C' ] [ $ char ] [ 'WX' ] ; } else { $ w += 700 ; } } } $ this -> popTextState ( ) ; $ this -> setCurrentFont ( ) ; return $ w * $ size / 1000 ; }
calculate how wide a given text string will be on a page at a given size . this can be called externally but is alse used by the other class functions
40,409
function PRVTadjustWrapText ( $ text , $ actual , $ width , & $ x , & $ adjust , $ justification ) { switch ( $ justification ) { case 'left' : return ; break ; case 'right' : $ x += $ width - $ actual ; break ; case 'center' : case 'centre' : $ x += ( $ width - $ actual ) / 2 ; break ; case 'full' : $ words = explode ( ' ' , $ text ) ; $ nspaces = count ( $ words ) - 1 ; if ( $ nspaces > 0 ) { $ adjust = ( $ width - $ actual ) / $ nspaces ; } else { $ adjust = 0 ; } break ; } }
do a part of the calculation for sorting out the justification of the text
40,410
function saveState ( $ pageEnd = 0 ) { if ( $ pageEnd ) { $ opt = $ this -> stateStack [ $ pageEnd ] ; $ this -> setColor ( $ opt [ 'col' ] , 1 ) ; $ this -> setStrokeColor ( $ opt [ 'str' ] , 1 ) ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\n" . $ opt [ 'lin' ] ; } else { $ this -> nStateStack ++ ; $ this -> stateStack [ $ this -> nStateStack ] = array ( 'col' => $ this -> currentColour , 'str' => $ this -> currentStrokeColour , 'lin' => $ this -> currentLineStyle ) ; } $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nq" ; }
this will be called at a new page to return the state to what it was on the end of the previous page before the stack was closed down This is to get around not being able to have open q across pages
40,411
function restoreState ( $ pageEnd = 0 ) { if ( ! $ pageEnd ) { $ n = $ this -> nStateStack ; $ this -> currentColour = $ this -> stateStack [ $ n ] [ 'col' ] ; $ this -> currentStrokeColour = $ this -> stateStack [ $ n ] [ 'str' ] ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\n" . $ this -> stateStack [ $ n ] [ 'lin' ] ; $ this -> currentLineStyle = $ this -> stateStack [ $ n ] [ 'lin' ] ; unset ( $ this -> stateStack [ $ n ] ) ; $ this -> nStateStack -- ; } $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nQ" ; }
restore a previously saved state
40,412
function openObject ( ) { $ this -> nStack ++ ; $ this -> stack [ $ this -> nStack ] = array ( 'c' => $ this -> currentContents , 'p' => $ this -> currentPage ) ; $ this -> numObj ++ ; $ this -> o_contents ( $ this -> numObj , 'new' ) ; $ this -> currentContents = $ this -> numObj ; $ this -> looseObjects [ $ this -> numObj ] = 1 ; return $ this -> numObj ; }
make a loose object the output will go into this object until it is closed then will revert to the current one . this object will not appear until it is included within a page . the function will return the object number
40,413
function reopenObject ( $ id ) { $ this -> nStack ++ ; $ this -> stack [ $ this -> nStack ] = array ( 'c' => $ this -> currentContents , 'p' => $ this -> currentPage ) ; $ this -> currentContents = $ id ; if ( isset ( $ this -> objects [ $ id ] [ 'onPage' ] ) ) { $ this -> currentPage = $ this -> objects [ $ id ] [ 'onPage' ] ; } }
open an existing object for editing
40,414
function closeObject ( ) { if ( $ this -> nStack > 0 ) { $ this -> currentContents = $ this -> stack [ $ this -> nStack ] [ 'c' ] ; $ this -> currentPage = $ this -> stack [ $ this -> nStack ] [ 'p' ] ; $ this -> nStack -- ; } }
close an object
40,415
function addObject ( $ id , $ options = 'add' ) { if ( isset ( $ this -> looseObjects [ $ id ] ) && $ this -> currentContents != $ id ) { switch ( $ options ) { case 'all' : $ this -> addLooseObjects [ $ id ] = 'all' ; case 'add' : if ( isset ( $ this -> objects [ $ this -> currentContents ] [ 'onPage' ] ) ) { $ this -> o_page ( $ this -> objects [ $ this -> currentContents ] [ 'onPage' ] , 'content' , $ id ) ; } break ; case 'even' : $ this -> addLooseObjects [ $ id ] = 'even' ; $ pageObjectId = $ this -> objects [ $ this -> currentContents ] [ 'onPage' ] ; if ( $ this -> objects [ $ pageObjectId ] [ 'info' ] [ 'pageNum' ] % 2 == 0 ) { $ this -> addObject ( $ id ) ; } break ; case 'odd' : $ this -> addLooseObjects [ $ id ] = 'odd' ; $ pageObjectId = $ this -> objects [ $ this -> currentContents ] [ 'onPage' ] ; if ( $ this -> objects [ $ pageObjectId ] [ 'info' ] [ 'pageNum' ] % 2 == 1 ) { $ this -> addObject ( $ id ) ; } break ; case 'next' : $ this -> addLooseObjects [ $ id ] = 'all' ; break ; case 'nexteven' : $ this -> addLooseObjects [ $ id ] = 'even' ; break ; case 'nextodd' : $ this -> addLooseObjects [ $ id ] = 'odd' ; break ; } } }
after an object has been created it wil only show if it has been added using this function .
40,416
function addInfo ( $ label , $ value = 0 ) { if ( is_array ( $ label ) ) { foreach ( $ label as $ l => $ v ) { $ this -> o_info ( $ this -> infoObject , $ l , $ v ) ; } } else { $ this -> o_info ( $ this -> infoObject , $ label , $ value ) ; } }
add content to the documents info object
40,417
function setPreferences ( $ label , $ value = 0 ) { if ( is_array ( $ label ) ) { foreach ( $ label as $ l => $ v ) { $ this -> o_catalog ( $ this -> catalogId , 'viewerPreferences' , array ( $ l => $ v ) ) ; } } else { $ this -> o_catalog ( $ this -> catalogId , 'viewerPreferences' , array ( $ label => $ value ) ) ; } }
set the viewer preferences of the document it is up to the browser to obey these .
40,418
function PRVT_getBytes ( & $ data , $ pos , $ num ) { $ ret = 0 ; for ( $ i = 0 ; $ i < $ num ; $ i ++ ) { $ ret = $ ret * 256 ; $ ret += ord ( $ data [ $ pos + $ i ] ) ; } return $ ret ; }
extract an integer from a position in a byte stream
40,419
function addJpegFromFile ( $ img , $ x , $ y , $ w = 0 , $ h = 0 ) { if ( ! file_exists ( $ img ) ) { return ; } $ tmp = getimagesize ( $ img ) ; $ imageWidth = $ tmp [ 0 ] ; $ imageHeight = $ tmp [ 1 ] ; if ( isset ( $ tmp [ 'channels' ] ) ) { $ channels = $ tmp [ 'channels' ] ; } else { $ channels = 3 ; } if ( $ w <= 0 && $ h <= 0 ) { $ w = $ imageWidth ; } if ( $ w == 0 ) { $ w = $ h / $ imageHeight * $ imageWidth ; } if ( $ h == 0 ) { $ h = $ w * $ imageHeight / $ imageWidth ; } $ fp = fopen ( $ img , 'rb' ) ; $ data = fread ( $ fp , filesize ( $ img ) ) ; fclose ( $ fp ) ; $ this -> addJpegImage_common ( $ data , $ x , $ y , $ w , $ h , $ imageWidth , $ imageHeight , $ channels ) ; }
add a JPEG image into the document from a file
40,420
function addImage ( & $ img , $ x , $ y , $ w = 0 , $ h = 0 , $ quality = 75 ) { if ( $ quality > 75 ) { $ quality = 75 ; } $ imageWidth = imagesx ( $ img ) ; $ imageHeight = imagesy ( $ img ) ; if ( $ w <= 0 && $ h <= 0 ) { return ; } if ( $ w == 0 ) { $ w = $ h / $ imageHeight * $ imageWidth ; } if ( $ h == 0 ) { $ h = $ w * $ imageHeight / $ imageWidth ; } $ tmpDir = '/tmp' ; $ tmpName = tempnam ( $ tmpDir , 'img' ) ; imagejpeg ( $ img , $ tmpName , $ quality ) ; $ fp = fopen ( $ tmpName , 'rb' ) ; if ( $ fp ) { $ data = '' ; while ( ! feof ( $ fp ) ) { $ data .= fread ( $ fp , 1024 ) ; } fclose ( $ fp ) ; } else { $ error = 1 ; $ errormsg = 'trouble opening file' ; } unlink ( $ tmpName ) ; $ this -> addJpegImage_common ( $ data , $ x , $ y , $ w , $ h , $ imageWidth , $ imageHeight ) ; }
add an image into the document from a GD object this function is not all that reliable and I would probably encourage people to use the file based functions
40,421
function addJpegImage_common ( & $ data , $ x , $ y , $ w = 0 , $ h = 0 , $ imageWidth , $ imageHeight , $ channels = 3 ) { $ this -> numImages ++ ; $ im = $ this -> numImages ; $ label = 'I' . $ im ; $ this -> numObj ++ ; $ this -> o_image ( $ this -> numObj , 'new' , array ( 'label' => $ label , 'data' => $ data , 'iw' => $ imageWidth , 'ih' => $ imageHeight , 'channels' => $ channels ) ) ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nq" ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\n" . sprintf ( '%.3F' , $ w ) . " 0 0 " . sprintf ( '%.3F' , $ h ) . " " . sprintf ( '%.3F' , $ x ) . " " . sprintf ( '%.3F' , $ y ) . " cm" ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\n/" . $ label . ' Do' ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nQ" ; }
common code used by the two JPEG adding functions
40,422
function openHere ( $ style , $ a = 0 , $ b = 0 , $ c = 0 ) { $ this -> numObj ++ ; $ this -> o_destination ( $ this -> numObj , 'new' , array ( 'page' => $ this -> currentPage , 'type' => $ style , 'p1' => $ a , 'p2' => $ b , 'p3' => $ c ) ) ; $ id = $ this -> catalogId ; $ this -> o_catalog ( $ id , 'openHere' , $ this -> numObj ) ; }
specify where the document should open when it first starts
40,423
function addDestination ( $ label , $ style , $ a = 0 , $ b = 0 , $ c = 0 ) { $ this -> numObj ++ ; $ this -> o_destination ( $ this -> numObj , 'new' , array ( 'page' => $ this -> currentPage , 'type' => $ style , 'p1' => $ a , 'p2' => $ b , 'p3' => $ c ) ) ; $ id = $ this -> numObj ; $ this -> destinations [ "$label" ] = $ id ; }
create a labelled destination within the document
40,424
function setFontFamily ( $ family , $ options = '' ) { if ( ! is_array ( $ options ) ) { if ( $ family == 'init' ) { $ this -> fontFamilies [ 'Helvetica' ] = array ( 'b' => 'Helvetica-Bold' , 'i' => 'Helvetica-Oblique' , 'bi' => 'Helvetica-BoldOblique' , 'ib' => 'Helvetica-BoldOblique' ) ; $ this -> fontFamilies [ 'Courier' ] = array ( 'b' => 'Courier-Bold' , 'i' => 'Courier-Oblique' , 'bi' => 'Courier-BoldOblique' , 'ib' => 'Courier-BoldOblique' ) ; $ this -> fontFamilies [ 'Times-Roman' ] = array ( 'b' => 'Times-Bold' , 'i' => 'Times-Italic' , 'bi' => 'Times-BoldItalic' , 'ib' => 'Times-BoldItalic' ) ; } } else { if ( strlen ( $ family ) ) { $ this -> fontFamilies [ $ family ] = $ options ; } } }
define font families this is used to initialize the font families for the default fonts and for the user to add new ones for their fonts . The default bahavious can be overridden should that be desired .
40,425
function transaction ( $ action ) { switch ( $ action ) { case 'start' : $ data = get_object_vars ( $ this ) ; $ this -> checkpoint = $ data ; unset ( $ data ) ; break ; case 'commit' : if ( is_array ( $ this -> checkpoint ) && isset ( $ this -> checkpoint [ 'checkpoint' ] ) ) { $ tmp = $ this -> checkpoint [ 'checkpoint' ] ; $ this -> checkpoint = $ tmp ; unset ( $ tmp ) ; } else { $ this -> checkpoint = '' ; } break ; case 'rewind' : if ( is_array ( $ this -> checkpoint ) ) { $ tmp = $ this -> checkpoint ; foreach ( $ tmp as $ k => $ v ) { if ( $ k != 'checkpoint' ) { $ this -> $ k = $ v ; } } unset ( $ tmp ) ; } break ; case 'abort' : if ( is_array ( $ this -> checkpoint ) ) { $ tmp = $ this -> checkpoint ; foreach ( $ tmp as $ k => $ v ) { $ this -> $ k = $ v ; } unset ( $ tmp ) ; } break ; } }
a few functions which should allow the document to be treated transactionally .
40,426
static function removeAllAliases ( $ contentObjectAttribute ) { $ handler = $ contentObjectAttribute -> attribute ( 'content' ) ; if ( ! $ handler -> isImageOwner ( ) ) { return ; } $ attributeData = $ handler -> originalAttributeData ( ) ; $ files = eZImageFile :: fetchForContentObjectAttribute ( $ attributeData [ 'attribute_id' ] , false ) ; $ dirs = array ( ) ; foreach ( $ files as $ filepath ) { $ file = eZClusterFileHandler :: instance ( $ filepath ) ; if ( $ file -> exists ( ) ) { $ file -> fileDelete ( $ filepath ) ; $ dirs [ ] = eZDir :: dirpath ( $ filepath ) ; } } $ dirs = array_unique ( $ dirs ) ; foreach ( $ dirs as $ dirpath ) { eZDir :: cleanupEmptyDirectories ( $ dirpath ) ; } eZImageFile :: removeForContentObjectAttribute ( $ attributeData [ 'attribute_id' ] ) ; }
Removes all image alias files which the attribute refers to .
40,427
public function purgeAllAliases ( ) { $ aliasList = $ this -> aliasList ( false ) ; ezpEvent :: getInstance ( ) -> notify ( 'image/purgeAliases' , array ( $ aliasList [ 'original' ] [ 'url' ] ) ) ; unset ( $ aliasList [ 'original' ] ) ; foreach ( $ aliasList as $ alias ) { if ( $ alias [ 'is_valid' ] ) $ this -> removeAliasFile ( $ alias [ 'url' ] ) ; $ doc = $ this -> ContentObjectAttributeData [ 'DataTypeCustom' ] [ 'dom_tree' ] ; $ domXPath = new DOMXPath ( $ doc ) ; foreach ( $ domXPath -> query ( "//alias[@name='{$alias['name']}']" ) as $ aliasNode ) { $ aliasNode -> parentNode -> removeChild ( $ aliasNode ) ; } } if ( isset ( $ doc ) ) $ this -> storeDOMTree ( $ doc , true , false ) ; }
Removes the images alias while keeping the original image .
40,428
function removeAliases ( ) { $ aliasList = $ this -> aliasList ( ) ; foreach ( $ aliasList as $ alias ) { if ( $ alias [ 'is_valid' ] ) $ this -> removeAliasFile ( $ alias [ 'url' ] ) ; } if ( ! empty ( $ aliasList [ 'original' ] [ 'url' ] ) ) { ezpEvent :: getInstance ( ) -> notify ( 'image/removeAliases' , array ( $ aliasList [ 'original' ] [ 'url' ] ) ) ; } $ this -> generateXMLData ( ) ; }
Removes aliases from the attribute .
40,429
function httpFile ( $ release = false ) { if ( isset ( $ this -> ContentObjectAttributeData [ 'DataTypeCustom' ] [ 'http_file' ] ) ) { $ httpFile = $ this -> ContentObjectAttributeData [ 'DataTypeCustom' ] [ 'http_file' ] ; if ( $ release ) { unset ( $ this -> ContentObjectAttributeData [ 'DataTypeCustom' ] [ 'http_file' ] ) ; } return $ httpFile ; } return false ; }
Returns the stored HTTP file object or false if no object is stored .
40,430
function initializeFromHTTPFile ( $ httpFile , $ imageAltText = false ) { $ this -> increaseImageSerialNumber ( ) ; $ mimeData = eZMimeType :: findByFileContents ( $ httpFile -> attribute ( 'filename' ) ) ; if ( ! $ mimeData [ 'is_valid' ] ) { $ mimeData = eZMimeType :: findByName ( $ httpFile -> attribute ( 'mime_type' ) ) ; if ( ! $ mimeData [ 'is_valid' ] ) { $ mimeData = eZMimeType :: findByURL ( $ httpFile -> attribute ( 'original_filename' ) ) ; } } $ this -> removeAliases ( ) ; $ this -> setOriginalAttributeDataValues ( $ this -> ContentObjectAttributeData [ 'id' ] , $ this -> ContentObjectAttributeData [ 'version' ] , $ this -> ContentObjectAttributeData [ 'language_code' ] ) ; $ contentVersion = eZContentObjectVersion :: fetchVersion ( $ this -> ContentObjectAttributeData [ 'version' ] , $ this -> ContentObjectAttributeData [ 'contentobject_id' ] ) ; $ objectName = $ this -> imageName ( $ this -> ContentObjectAttributeData , $ contentVersion ) ; $ objectPathString = $ this -> imagePath ( $ this -> ContentObjectAttributeData , $ contentVersion , true ) ; eZMimeType :: changeBaseName ( $ mimeData , $ objectName ) ; eZMimeType :: changeDirectoryPath ( $ mimeData , $ objectPathString ) ; $ httpFile -> store ( false , false , $ mimeData ) ; $ originalFilename = $ httpFile -> attribute ( 'original_filename' ) ; return $ this -> initialize ( $ mimeData , $ originalFilename , $ imageAltText ) ; }
Initializes the content object attribute with the uploaded HTTP file
40,431
public static function preCheck ( array & $ siteBasics , eZURI $ uri ) { if ( ! $ siteBasics [ 'user-object-required' ] ) { return null ; } $ ini = eZINI :: instance ( ) ; $ requireUserLogin = ( $ ini -> variable ( 'SiteAccessSettings' , 'RequireUserLogin' ) == 'true' ) ; $ forceLogin = false ; if ( eZSession :: hasStarted ( ) ) { $ http = eZHTTPTool :: instance ( ) ; $ forceLogin = $ http -> hasSessionVariable ( self :: FORCE_LOGIN ) ; } if ( ! $ requireUserLogin && ! $ forceLogin ) { return null ; } return self :: checkUser ( $ siteBasics , $ uri ) ; }
Check if user login is required . If so use login handler to redirect user .
40,432
public function getState ( ) { return array ( 'id' => $ this -> id , 'expirytime' => $ this -> expirytime , 'client_id' => $ this -> client_id , 'user_id' => $ this -> user_id , 'scope' => $ this -> scope , ) ; }
Get the PersistentObject state .
40,433
static function checkMD5Sums ( $ file , $ subDirStr = '' ) { $ result = array ( ) ; $ lines = file ( $ file , FILE_IGNORE_NEW_LINES ) ; if ( $ lines !== false && isset ( $ lines [ 0 ] ) ) { foreach ( $ lines as $ key => $ line ) { if ( isset ( $ line [ 34 ] ) ) { $ md5Key = substr ( $ line , 0 , 32 ) ; $ filename = $ subDirStr . substr ( $ line , 34 ) ; if ( ! file_exists ( $ filename ) || $ md5Key != md5_file ( $ filename ) ) { $ result [ ] = $ filename ; } } } } return $ result ; }
Check MD5 sum file to check if files have changed . Return array of changed files .
40,434
private static function findDesignBase ( eZINI $ ini , $ siteAccess = false ) { if ( $ siteAccess ) { $ ini = eZSiteAccess :: getIni ( $ siteAccess , 'site.ini' ) ; $ standardDesign = $ ini -> variable ( 'DesignSettings' , 'StandardDesign' ) ; $ siteDesign = $ ini -> variable ( 'DesignSettings' , 'SiteDesign' ) ; } else { $ ini = eZINI :: instance ( ) ; $ standardDesign = eZTemplateDesignResource :: designSetting ( 'standard' ) ; $ siteDesign = eZTemplateDesignResource :: designSetting ( 'site' ) ; } $ siteDesignList = $ ini -> variable ( 'DesignSettings' , 'AdditionalSiteDesignList' ) ; array_unshift ( $ siteDesignList , $ siteDesign ) ; $ siteDesignList [ ] = $ standardDesign ; $ siteDesignList = array_unique ( $ siteDesignList ) ; $ designBaseList = array ( ) ; $ extensionDirectory = eZExtension :: baseDirectory ( ) ; $ designStartPath = eZTemplateDesignResource :: designStartPath ( ) ; $ extensions = eZTemplateDesignResource :: designExtensions ( ) ; foreach ( $ siteDesignList as $ design ) { foreach ( $ extensions as $ extension ) { $ path = "$extensionDirectory/$extension/$designStartPath/$design" ; if ( file_exists ( $ path ) ) { $ designBaseList [ ] = $ path ; } } $ path = "$designStartPath/$design" ; if ( file_exists ( $ path ) ) { $ designBaseList [ ] = $ path ; } } return $ designBaseList ; }
Find the location on design bases on the disk
40,435
private static function savesMemoryCache ( array $ designBaseList , $ siteAccess = false ) { if ( $ siteAccess ) $ GLOBALS [ 'eZTemplateDesignResourceSiteAccessBases' ] [ $ siteAccess ] = $ designBaseList ; else $ GLOBALS [ 'eZTemplateDesignResourceBases' ] = $ designBaseList ; }
Stores design base list in memory for the current request
40,436
static function overrideArray ( $ siteAccess = false ) { if ( $ siteAccess === false and self :: $ overrideArrayCache !== null ) { return self :: $ overrideArrayCache ; } $ bases = eZTemplateDesignResource :: allDesignBases ( $ siteAccess ) ; if ( $ siteAccess ) { $ overrideINI = eZSiteAccess :: getIni ( $ siteAccess , 'override.ini' ) ; } else { $ overrideINI = eZINI :: instance ( 'override.ini' ) ; } $ designStartPath = eZTemplateDesignResource :: designStartPath ( ) ; $ matchFileArray = array ( ) ; $ reverseBases = array_reverse ( $ bases ) ; foreach ( $ reverseBases as $ base ) { $ templateResource = $ base . '/templates' ; $ sourceFileArray = eZDir :: recursiveFindRelative ( $ templateResource , "" , "tpl" ) ; foreach ( $ sourceFileArray as $ source ) { $ matchFileArray [ $ source ] [ 'base_dir' ] = $ templateResource ; $ matchFileArray [ $ source ] [ 'template' ] = $ source ; } } $ overrideSettingGroups = $ overrideINI -> groups ( ) ; if ( isset ( $ GLOBALS [ 'eZDesignOverrides' ] ) ) { $ overrideSettingGroups = array_merge ( $ overrideSettingGroups , $ GLOBALS [ 'eZDesignOverrides' ] ) ; } foreach ( $ overrideSettingGroups as $ overrideName => $ overrideSetting ) { if ( ! isset ( $ overrideSetting [ 'Source' ] ) ) { continue ; } $ overrideSource = "/" . $ overrideSetting [ 'Source' ] ; $ overrideMatchFile = $ overrideSetting [ 'MatchFile' ] ; $ triedFiles = array ( ) ; $ fileInfo = eZTemplateDesignResource :: fileMatch ( $ bases , 'override/templates' , $ overrideMatchFile , $ triedFiles ) ; $ resourceInUse = is_array ( $ fileInfo ) ? $ fileInfo [ 'resource' ] : false ; $ overrideMatchFilePath = is_array ( $ fileInfo ) ? $ fileInfo [ 'path' ] : false ; $ customMatchArray = array ( ) ; $ customMatchArray [ 'conditions' ] = isset ( $ overrideSetting [ 'Match' ] ) ? $ overrideSetting [ 'Match' ] : null ; $ customMatchArray [ 'match_file' ] = $ overrideMatchFilePath ; $ customMatchArray [ 'override_name' ] = $ overrideName ; $ matchFileArray [ $ overrideSource ] [ 'custom_match' ] [ ] = $ customMatchArray ; if ( $ resourceInUse && ! isset ( $ matchFileArray [ $ overrideSource ] [ 'base_dir' ] ) ) { $ matchFileArray [ $ overrideSource ] [ 'base_dir' ] = $ resourceInUse ; $ matchFileArray [ $ overrideSource ] [ 'template' ] = $ overrideSource ; } if ( ! $ overrideMatchFilePath ) { eZDebug :: writeError ( "Custom match file: path '$overrideMatchFile' not found in any resource. Check the template settings in settings/override.ini" , __METHOD__ ) ; eZDebug :: writeError ( implode ( ', ' , $ triedFiles ) , __METHOD__ . ' tried files' ) ; } } if ( $ siteAccess === false ) { self :: $ overrideArrayCache = $ matchFileArray ; } return $ matchFileArray ; }
Get an array of all the current templates and overrides for them . The current siteaccess is used if none is specified .
40,437
protected function hasResponseGroup ( $ name ) { return in_array ( $ name , $ this -> defaultResponsegroups ) || ( isset ( $ this -> request -> variables [ 'ResponseGroups' ] ) && in_array ( $ name , $ this -> request -> variables [ 'ResponseGroups' ] ) ) ; }
Checks if a response group has been provided in the requested REST URI
40,438
protected function getResponseGroups ( ) { $ resGroups = $ this -> request -> variables [ 'ResponseGroups' ] ; for ( $ i = 0 , $ iMax = count ( $ this -> defaultResponsegroups ) ; $ i < $ iMax ; ++ $ i ) { if ( ! in_array ( $ this -> defaultResponsegroups [ $ i ] , $ resGroups ) ) $ resGroups [ ] = $ this -> defaultResponsegroups [ $ i ] ; } return $ resGroups ; }
Returns requested response groups
40,439
protected function getContentVariable ( $ name ) { if ( isset ( $ this -> request -> contentVariables [ $ name ] ) ) { return $ this -> request -> contentVariables [ $ name ] ; } return null ; }
Returns requested content variable is it set
40,440
public function createResult ( ) { $ debug = ezpRestDebug :: getInstance ( ) ; $ debug -> startTimer ( 'GeneratingRestResult' , 'RestController' ) ; if ( ! self :: $ isCacheCreated ) { ezcCacheManager :: createCache ( self :: CACHE_ID , $ this -> getCacheLocation ( ) , 'ezpRestCacheStorageClusterObject' , array ( 'ttl' => $ this -> getActionTTL ( ) ) ) ; self :: $ isCacheCreated = true ; } $ cache = ezcCacheManager :: getCache ( self :: CACHE_ID ) ; $ controllerCacheId = $ this -> generateCacheId ( ) ; $ isCacheEnabled = $ this -> isCacheEnabled ( ) ; $ cache -> isCacheEnabled = $ isCacheEnabled ; if ( ( $ res = $ cache -> restore ( $ controllerCacheId ) ) === false ) { try { $ debug -> log ( 'Generating cache' , ezcLog :: DEBUG ) ; $ debug -> switchTimer ( 'GeneratingCache' , 'GeneratingRestResult' ) ; $ res = parent :: createResult ( ) ; $ resGroups = $ this -> getResponseGroups ( ) ; if ( ! empty ( $ resGroups ) ) { $ res -> variables [ 'requestedResponseGroups' ] = $ resGroups ; } if ( $ res instanceof ezpRestMvcResult ) { $ res -> responseGroups = $ resGroups ; } if ( $ isCacheEnabled ) $ cache -> store ( $ controllerCacheId , $ res ) ; $ debug -> stopTimer ( 'GeneratingCache' ) ; } catch ( Exception $ e ) { $ debug -> log ( 'Exception caught, aborting cache generation' , ezcLog :: DEBUG ) ; if ( $ isCacheEnabled ) $ cache -> abortCacheGeneration ( ) ; throw $ e ; } } $ debug -> stopTimer ( 'GeneratingRestResult' ) ; if ( ezpRestDebug :: isDebugEnabled ( ) ) { $ res -> variables [ 'debug' ] = $ debug -> getReport ( ) ; } return $ res ; }
Override to add the requestedResponseGroups variable for every REST requests
40,441
public function doHttpOptions ( ) { $ methods = implode ( ', ' , $ this -> supported_http_methods ) ; $ result = new ezpRestMvcResult ; $ result -> status = new ezpRestStatusResponse ( ezpHttpResponseCodes :: OK , 'Allowed methods are: ' . $ methods , array ( 'Allow' => $ methods ) ) ; return $ result ; }
Default action to handle OPTIONS requests .
40,442
private function getActionTTL ( ) { $ routingInfos = $ this -> getRouter ( ) -> getRoutingInformation ( ) ; $ actionSectionName = $ routingInfos -> controllerClass . '_' . $ routingInfos -> action . '_CacheSettings' ; if ( $ this -> restINI -> hasVariable ( $ actionSectionName , 'CacheTTL' ) ) { return ( int ) $ this -> restINI -> variable ( $ actionSectionName , 'CacheTTL' ) ; } $ controllerSectionName = $ routingInfos -> controllerClass . '_CacheSettings' ; if ( $ this -> restINI -> hasVariable ( $ controllerSectionName , 'CacheTTL' ) ) { return ( int ) $ this -> restINI -> variable ( $ controllerSectionName , 'CacheTTL' ) ; } return ( int ) $ this -> restINI -> variable ( 'CacheSettings' , 'DefaultCacheTTL' ) ; }
Returns cache TTL value for current action as set in rest . ini
40,443
private function generateCacheId ( ) { $ routingInfos = $ this -> getRouter ( ) -> getRoutingInformation ( ) ; $ aCacheId = array ( ezpRestPrefixFilterInterface :: getApiProviderName ( ) , ezpRestPrefixFilterInterface :: getApiVersion ( ) , $ routingInfos -> controllerClass , $ routingInfos -> action ) ; foreach ( $ this -> request -> contentVariables + $ this -> request -> variables as $ name => $ val ) { $ aCacheId [ ] = $ name . '=' . ( is_array ( $ val ) ? implode ( ',' , $ val ) : $ val ) ; } return md5 ( implode ( '-' , $ aCacheId ) ) ; }
Generates unique cache ID for current request .
40,444
protected static function dispositionType ( $ mimeType ) { $ ini = eZINI :: instance ( 'file.ini' ) ; $ mimeTypes = $ ini -> variable ( 'PassThroughSettings' , 'ContentDisposition' , array ( ) ) ; if ( isset ( $ mimeTypes [ $ mimeType ] ) ) { return $ mimeTypes [ $ mimeType ] ; } return $ ini -> variable ( 'PassThroughSettings' , 'DefaultContentDisposition' ) ; }
Checks if a file should be downloaded to disk or displayed inline in the browser .
40,445
static function enabled ( ) { if ( isset ( $ GLOBALS [ 'eZSSLZoneEnabled' ] ) ) return $ GLOBALS [ 'eZSSLZoneEnabled' ] ; $ enabled = false ; $ ini = eZINI :: instance ( ) ; if ( $ ini -> hasVariable ( 'SSLZoneSettings' , 'SSLZones' ) ) $ enabled = ( $ ini -> variable ( 'SSLZoneSettings' , 'SSLZones' ) == 'enabled' ) ; return $ GLOBALS [ 'eZSSLZoneEnabled' ] = $ enabled ; }
\ static Returns true if the SSL zones functionality is enabled false otherwise . The result is cached in memory to save time on multiple invocations .
40,446
static function isKeepModeView ( $ module , $ view ) { $ ini = eZINI :: instance ( ) ; $ viewsModes = $ ini -> variable ( 'SSLZoneSettings' , 'ModuleViewAccessMode' ) ; $ sslViews = array_keys ( $ viewsModes , 'ssl' ) ; $ keepModeViews = array_keys ( $ viewsModes , 'keep' ) ; if ( eZSSLZone :: viewIsInArray ( $ module , $ view , $ keepModeViews ) < eZSSLZone :: viewIsInArray ( $ module , $ view , $ sslViews ) ) { eZDebugSetting :: writeDebug ( 'kernel-ssl-zone' , 'The view cannot choose access mode itself.' ) ; return false ; } return true ; }
\ static \ return true if the view is defined as keep
40,447
static function checkObject ( $ module , $ view , $ object ) { if ( ! eZSSLZone :: enabled ( ) ) return ; if ( ! eZSSLZone :: isKeepModeView ( $ module , $ view ) ) return ; $ pathStringList = eZPersistentObject :: fetchObjectList ( eZContentObjectTreeNode :: definition ( ) , array ( 'path_string' ) , array ( 'contentobject_id' => $ object -> attribute ( 'id' ) ) , null , null , false ) ; if ( is_array ( $ pathStringList ) && count ( $ pathStringList ) ) { array_walk ( $ pathStringList , function ( & $ a ) { $ a = $ a [ 'path_string' ] ; } ) ; } else { $ pathStringList = array ( ) ; $ nodes = $ object -> parentNodes ( $ object -> attribute ( 'current' ) ) ; if ( ! is_array ( $ nodes ) ) { eZDebug :: writeError ( 'Object ' . $ object -> attribute ( 'is' ) . 'does not have neither assigned nor parent nodes.' ) ; } else { foreach ( $ nodes as $ node ) { $ pathStringList [ ] = $ node -> attribute ( 'path_string' ) ; } } } $ inSSL = false ; foreach ( $ pathStringList as $ pathString ) { if ( eZSSLZone :: checkNodePath ( $ module , $ view , $ pathString , false ) ) { $ inSSL = true ; break ; } } eZSSLZone :: switchIfNeeded ( $ inSSL ) ; }
\ static Check whether the given object should cause access mode change . It it should this method does not return .
40,448
static function checkModuleView ( $ module , $ view ) { if ( ! eZSSLZone :: enabled ( ) ) return ; $ ini = eZINI :: instance ( ) ; $ viewsModes = $ ini -> variable ( 'SSLZoneSettings' , 'ModuleViewAccessMode' ) ; $ sslViews = array_keys ( $ viewsModes , 'ssl' ) ; $ keepModeViews = array_keys ( $ viewsModes , 'keep' ) ; $ sslPriority = eZSSLZone :: viewIsInArray ( $ module , $ view , $ sslViews ) ; $ keepModePriority = eZSSLZone :: viewIsInArray ( $ module , $ view , $ keepModeViews ) ; if ( $ sslPriority && $ keepModePriority && $ sslPriority == $ keepModePriority ) { eZDebug :: writeError ( "Configuration error: view $module/$view is defined both as 'ssl' and 'keep'" , 'eZSSLZone' ) ; return ; } if ( $ keepModePriority > $ sslPriority ) { eZDebugSetting :: writeDebug ( 'kernel-ssl-zone' , 'Keeping current access mode...' ) ; return ; } $ inSSL = ( $ sslPriority > 0 ) ; eZDebugSetting :: writeDebug ( 'kernel-ssl-zone' , ( isset ( $ inSSL ) ? ( $ inSSL ? 'yes' : 'no' ) : 'dunno' ) , 'Should we use SSL for this view?' ) ; eZSSLZone :: switchIfNeeded ( $ inSSL ) ; }
\ static Decide whether we should change access mode for this module view or not . Called from index . php .
40,449
public function xmlClassAttributeIds ( ) { if ( $ this -> xmlClassAttributeIdArray === null ) { $ xmlTextAttributes = eZContentClassAttribute :: fetchList ( true , array ( 'data_type' => 'ezxmltext' , 'version' => 0 ) ) ; $ this -> xmlClassAttributeIdArray = array ( ) ; foreach ( $ xmlTextAttributes as $ classAttr ) { $ this -> xmlClassAttributeIdArray [ ] = $ classAttr -> attribute ( 'id' ) ; } unset ( $ xmlTextAttributes ) ; } return $ this -> xmlClassAttributeIdArray ; }
Get an array of all defined class attributes with ezxmltext datatype .
40,450
public function xmlTextContentObjectAttributeCount ( ) { if ( $ this -> xmlAttrCount === null ) { $ this -> xmlAttrCount = eZContentObjectAttribute :: fetchListByClassID ( $ this -> xmlClassAttributeIds ( ) , false , null , false , true ) ; } return $ this -> xmlAttrCount ; }
Retrieve the number of valid ezxmltext occurences
40,451
public function outputString ( $ message , $ label = null , $ groupedEntry = false ) { if ( $ groupedEntry ) { $ this -> finalOutputMessageArray [ $ this -> outputEntryNumber ] [ "messages" ] [ ] = $ message ; } else { $ this -> outputEntryNumber ++ ; $ this -> finalOutputMessageArray [ $ this -> outputEntryNumber ] = array ( "messages" => array ( $ message ) , "label" => $ label ) ; } }
Add a message to the message buffer to be displayed after processData has completed .
40,452
public function processData ( ) { while ( $ this -> processedCount < $ this -> xmlTextContentObjectAttributeCount ( ) ) { $ limit = array ( 'offset' => $ this -> offset , 'length' => $ this -> fetchLimit ) ; $ xmlAttributeChunk = eZContentObjectAttribute :: fetchListByClassID ( $ this -> xmlClassAttributeIds ( ) , false , $ limit , true , false ) ; foreach ( $ xmlAttributeChunk as $ xmlAttr ) { $ result = true ; $ currentEntryLogged = false ; $ currentId = $ xmlAttr -> attribute ( 'id' ) ; $ objectId = $ xmlAttr -> attribute ( 'contentobject_id' ) ; $ version = $ xmlAttr -> attribute ( 'version' ) ; $ languageCode = $ xmlAttr -> attribute ( 'language_code' ) ; $ label = "Attribute [id:{$currentId}] - [Object-id:{$objectId}] - [Version:{$version}] - [Language:{$languageCode}]" ; $ xmlText = eZXMLTextType :: rawXMLText ( $ xmlAttr ) ; if ( empty ( $ xmlText ) ) { if ( $ this -> verboseLevel > 0 ) { $ this -> outputString ( "Empty XML-data" , $ label , $ currentEntryLogged ) ; $ currentEntryLogged = true ; } $ result = false ; continue ; } $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; $ success = $ dom -> loadXML ( $ xmlText ) ; if ( ! $ success ) { if ( $ this -> verboseLevel > 0 ) { $ this -> outputString ( "XML not loaded correctly for attribute" , $ label , $ currentEntryLogged ) ; $ currentEntryLogged = true ; } $ result = false ; continue ; } $ linkNodes = $ dom -> getElementsByTagName ( 'link' ) ; $ urlIdArray = array ( ) ; foreach ( $ linkNodes as $ link ) { if ( $ link -> hasAttribute ( 'url_id' ) ) { $ urlIdArray [ ] = $ link -> getAttribute ( 'url_id' ) ; } } $ urlIdArray = array_unique ( $ urlIdArray ) ; if ( count ( $ urlIdArray ) > 0 ) { if ( $ this -> verboseLevel > 0 ) { $ this -> outputString ( "Found http-link elements in xml-block" , $ label , $ currentEntryLogged ) ; $ currentEntryLogged = true ; } if ( $ this -> doFix ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; eZSimplifiedXMLInput :: updateUrlObjectLinks ( $ xmlAttr , $ urlIdArray ) ; $ db -> commit ( ) ; } } $ this -> script -> iterate ( $ this -> cli , $ result ) ; $ label = null ; } $ this -> processedCount += count ( $ xmlAttributeChunk ) ; $ this -> offset += $ this -> fetchLimit ; unset ( $ xmlAttributeChunk ) ; } }
Search through valid ezxmltext occurrences and fix missing url object links if specified .
40,453
public function showSummary ( ) { foreach ( $ this -> finalOutputMessageArray as $ messageEntry ) { if ( $ messageEntry [ 'label' ] !== null ) { $ this -> cli -> output ( $ this -> cli -> stylize ( 'bold' , $ messageEntry [ 'label' ] ) ) ; } foreach ( $ messageEntry [ 'messages' ] as $ msg ) { $ this -> cli -> output ( $ msg ) ; } $ this -> cli -> output ( ) ; } }
Print a summary of all the messages created during processData .
40,454
public function offset ( $ offset ) { $ offset = ( int ) $ offset ; if ( $ offset >= 0 ) $ this -> offset = $ offset ; return $ this ; }
Sets the offset criteria
40,455
public function limit ( $ limit ) { $ limit = ( int ) $ limit ; if ( $ limit > 0 ) $ this -> limit = $ limit ; return $ this ; }
Sets the limit criteria
40,456
function onPublish ( $ contentObjectAttribute , $ object , $ publishedNodes ) { $ currentVersion = $ object -> currentVersion ( ) ; $ langMask = $ currentVersion -> attribute ( 'language_mask' ) ; $ languageList = eZContentLanguage :: decodeLanguageMask ( $ langMask , true ) ; $ languageList = $ languageList [ 'language_list' ] ; $ identifier = $ contentObjectAttribute -> attribute ( 'contentclass_attribute_identifier' ) ; $ attributeArray = $ object -> fetchAttributesByIdentifier ( array ( $ identifier ) , $ currentVersion -> attribute ( 'version' ) , $ languageList ) ; foreach ( $ attributeArray as $ attribute ) { $ xmlText = eZXMLTextType :: rawXMLText ( $ attribute ) ; $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; if ( ! $ dom -> loadXML ( $ xmlText ) ) continue ; $ urlIdArray = array ( ) ; foreach ( $ dom -> getElementsByTagName ( 'link' ) as $ link ) { if ( $ link -> hasAttribute ( 'url_id' ) ) { $ urlIdArray [ ] = $ link -> getAttribute ( 'url_id' ) ; } } $ urlIdArray = array_unique ( $ urlIdArray ) ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; eZSimplifiedXMLInput :: updateUrlObjectLinks ( $ attribute , $ urlIdArray ) ; $ db -> commit ( ) ; $ linkedObjectIdArray = $ this -> getRelatedObjectList ( $ dom -> getElementsByTagName ( 'link' ) ) ; $ embeddedObjectIdArray = array_merge ( $ this -> getRelatedObjectList ( $ dom -> getElementsByTagName ( 'embed' ) ) , $ this -> getRelatedObjectList ( $ dom -> getElementsByTagName ( 'embed-inline' ) ) ) ; if ( ! empty ( $ embeddedObjectIdArray ) ) { $ object -> appendInputRelationList ( $ embeddedObjectIdArray , eZContentObject :: RELATION_EMBED ) ; } if ( ! empty ( $ linkedObjectIdArray ) ) { $ object -> appendInputRelationList ( $ linkedObjectIdArray , eZContentObject :: RELATION_LINK ) ; } if ( ! empty ( $ linkedObjectIdArray ) || ! empty ( $ embeddedObjectIdArray ) ) { $ object -> commitInputRelations ( $ currentVersion -> attribute ( 'version' ) ) ; } } }
Method triggered on publish for xml text datatype
40,457
public static function getBehaviour ( ) { if ( self :: $ behaviour === null ) { $ return = new ezpContentPublishingBehaviour ; } else { $ return = clone self :: $ behaviour ; if ( self :: $ behaviour -> isTemporary ) { self :: $ behaviour = null ; } } return $ return ; }
Get the currently set behaviour . Returns the default one if one ain t set
40,458
function getProductCategory ( $ object ) { $ ini = eZINI :: instance ( 'shop.ini' ) ; if ( ! $ ini -> hasVariable ( 'VATSettings' , 'ProductCategoryAttribute' ) ) { eZDebug :: writeError ( "Cannot find product category: please specify its attribute identifier " . "in the following setting: shop.ini.[VATSettings].ProductCategoryAttribute" ) ; return null ; } $ categoryAttributeName = $ ini -> variable ( 'VATSettings' , 'ProductCategoryAttribute' ) ; if ( ! $ categoryAttributeName ) { eZDebug :: writeError ( "Cannot find product category: empty attribute name specified " . "in the following setting: shop.ini.[VATSettings].ProductCategoryAttribute" ) ; return null ; } $ productDataMap = $ object -> attribute ( 'data_map' ) ; if ( ! isset ( $ productDataMap [ $ categoryAttributeName ] ) ) { eZDebug :: writeError ( "Cannot find product category: there is no attribute '$categoryAttributeName' in object '" . $ object -> attribute ( 'name' ) . "' of class '" . $ object -> attribute ( 'class_name' ) . "'." ) ; return null ; } $ categoryAttribute = $ productDataMap [ $ categoryAttributeName ] ; $ productCategory = $ categoryAttribute -> attribute ( 'content' ) ; if ( $ productCategory === null ) { eZDebug :: writeNotice ( "Product category is not specified in object '" . $ object -> attribute ( 'name' ) . "' of class '" . $ object -> attribute ( 'class_name' ) . "'." ) ; return null ; } return $ productCategory ; }
Determine object s product category .
40,459
function chooseVatType ( $ productCategory , $ country ) { $ vatRules = eZVatRule :: fetchList ( ) ; $ catID = $ productCategory -> attribute ( 'id' ) ; $ vatPriorities = array ( ) ; foreach ( $ vatRules as $ rule ) { $ ruleCountry = $ rule -> attribute ( 'country_code' ) ; $ ruleCatIDs = $ rule -> attribute ( 'product_categories_ids' ) ; $ ruleVatID = $ rule -> attribute ( 'vat_type' ) ; $ categoryMatch = 0 ; $ countryMatch = 0 ; if ( $ ruleCountry == '*' ) $ countryMatch = 1 ; elseif ( $ ruleCountry == $ country ) $ countryMatch = 2 ; if ( ! $ ruleCatIDs ) $ categoryMatch = 1 ; elseif ( in_array ( $ catID , $ ruleCatIDs ) ) $ categoryMatch = 2 ; if ( $ countryMatch && $ categoryMatch ) $ vatPriority = $ countryMatch * 2 + $ categoryMatch - 2 ; else $ vatPriority = 0 ; if ( ! isset ( $ vatPriorities [ $ vatPriority ] ) ) $ vatPriorities [ $ vatPriority ] = $ ruleVatID ; } krsort ( $ vatPriorities , SORT_NUMERIC ) ; $ bestPriority = 0 ; if ( $ vatPriorities ) { $ tmpKeys = array_keys ( $ vatPriorities ) ; $ bestPriority = array_shift ( $ tmpKeys ) ; } if ( $ bestPriority == 0 ) { eZDebug :: writeError ( "Cannot find a suitable VAT type " . "for country '" . $ country . "'" . " and category '" . $ productCategory -> attribute ( 'name' ) . "'." ) ; return new eZVatType ( array ( "id" => 0 , "name" => ezpI18n :: tr ( 'kernel/shop' , 'None' ) , "percentage" => 0.0 ) ) ; } $ bestVatTypeID = array_shift ( $ vatPriorities ) ; $ bestVatType = eZVatType :: fetch ( $ bestVatTypeID ) ; eZDebug :: writeDebug ( sprintf ( "Best matching VAT for '%s'/'%s' is '%s' (%d%%)" , $ country , $ productCategory -> attribute ( 'name' ) , $ bestVatType -> attribute ( 'name' ) , $ bestVatType -> attribute ( 'percentage' ) ) ) ; return $ bestVatType ; }
Choose the best matching VAT type for given product category and country .
40,460
public static function getRouteFilter ( ) { $ opt = new ezpExtensionOptions ( ) ; $ opt -> iniFile = 'rest.ini' ; $ opt -> iniSection = 'RouteSettings' ; $ opt -> iniVariable = 'RouteSettingImpl' ; $ routeSecurityFilterInstance = eZExtension :: getHandlerClass ( $ opt ) ; if ( ! $ routeSecurityFilterInstance instanceof self ) { throw new ezpRestRouteSecurityFilterNotFoundException ( ) ; } return $ routeSecurityFilterInstance ; }
Returns the currently configured class for handling Route security .
40,461
function downloadFile ( $ url , $ outDir , $ forcedFileName = false ) { $ fileName = $ outDir . "/" . ( $ forcedFileName ? $ forcedFileName : basename ( $ url ) ) ; eZDebug :: writeNotice ( "Downloading file '$fileName' from $url" ) ; if ( ! file_exists ( $ outDir ) ) eZDir :: mkdir ( $ outDir , false , true ) ; if ( extension_loaded ( 'curl' ) ) { $ ch = curl_init ( $ url ) ; $ fp = eZStepSiteTypes :: fopen ( $ fileName , 'wb' ) ; if ( $ fp === false ) { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Cannot write to file' ) . ': ' . $ this -> FileOpenErrorMsg ; return false ; } curl_setopt ( $ ch , CURLOPT_FILE , $ fp ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_FAILONERROR , 1 ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , 30 ) ; $ ini = eZINI :: instance ( ) ; $ proxy = $ ini -> hasVariable ( 'ProxySettings' , 'ProxyServer' ) ? $ ini -> variable ( 'ProxySettings' , 'ProxyServer' ) : false ; if ( $ proxy ) { curl_setopt ( $ ch , CURLOPT_PROXY , $ proxy ) ; $ userName = $ ini -> hasVariable ( 'ProxySettings' , 'User' ) ? $ ini -> variable ( 'ProxySettings' , 'User' ) : false ; $ password = $ ini -> hasVariable ( 'ProxySettings' , 'Password' ) ? $ ini -> variable ( 'ProxySettings' , 'Password' ) : false ; if ( $ userName ) { curl_setopt ( $ ch , CURLOPT_PROXYUSERPWD , "$userName:$password" ) ; } } if ( ! curl_exec ( $ ch ) ) { $ this -> ErrorMsg = curl_error ( $ ch ) ; return false ; } curl_close ( $ ch ) ; fclose ( $ fp ) ; } else { $ parsedUrl = parse_url ( $ url ) ; $ checkIP = isset ( $ parsedUrl [ 'host' ] ) ? ip2long ( gethostbyname ( $ parsedUrl [ 'host' ] ) ) : false ; if ( $ checkIP === false ) { return false ; } if ( ! copy ( $ url , $ fileName ) ) { $ buf = eZHTTPTool :: sendHTTPRequest ( $ url , 80 , false , 'eZ Publish' , false ) ; $ header = false ; $ body = false ; if ( eZHTTPTool :: parseHTTPResponse ( $ buf , $ header , $ body ) ) { eZFile :: create ( $ fileName , false , $ body ) ; } else { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Failed to copy %url to local file %filename' , null , array ( "%url" => $ url , "%filename" => $ fileName ) ) ; return false ; } } } return $ fileName ; }
Downloads file .
40,462
function downloadAndImportPackage ( $ packageName , $ packageUrl , $ forceDownload = false ) { $ package = eZPackage :: fetch ( $ packageName , false , false , false ) ; if ( is_object ( $ package ) ) { if ( $ forceDownload ) { $ package -> remove ( ) ; } else { eZDebug :: writeNotice ( "Skipping download of package '$packageName': package already exists." ) ; return $ package ; } } $ archiveName = $ this -> downloadFile ( $ packageUrl , eZStepSiteTypes :: tempDir ( ) ) ; if ( $ archiveName === false ) { eZDebug :: writeWarning ( "Download of package '$packageName' from '$packageUrl' failed: $this->ErrorMsg" ) ; $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Download of package \'%pkg\' failed. You may upload the package manually.' , false , array ( '%pkg' => $ packageName ) ) ; return false ; } $ package = eZPackage :: import ( $ archiveName , $ packageName , false ) ; $ ezFileHandler = new eZFileHandler ( ) ; $ ezFileHandler -> unlink ( $ archiveName ) ; if ( ! $ package instanceof eZPackage ) { if ( $ package == eZPackage :: STATUS_INVALID_NAME ) { eZDebug :: writeNotice ( "The package name $packageName is invalid" ) ; } else { eZDebug :: writeNotice ( "Invalid package" ) ; } $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Invalid package' ) ; return false ; } return $ package ; }
Downloads and imports package .
40,463
function uploadPackage ( ) { if ( ! eZHTTPFile :: canFetch ( 'PackageBinaryFile' ) ) { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'No package selected for upload' ) . '.' ; return ; } $ file = eZHTTPFile :: fetch ( 'PackageBinaryFile' ) ; if ( ! $ file ) { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Failed fetching upload package file' ) ; return ; } $ packageFilename = $ file -> attribute ( 'filename' ) ; $ packageName = $ file -> attribute ( 'original_filename' ) ; if ( preg_match ( "#^(.+)-[0-9](\.[0-9]+)-[0-9].ezpkg$#" , $ packageName , $ matches ) ) $ packageName = $ matches [ 1 ] ; $ packageName = preg_replace ( array ( "#[^a-zA-Z0-9]+#" , "#_+#" , "#(^_)|(_$)#" ) , array ( '_' , '_' , '' ) , $ packageName ) ; $ package = eZPackage :: import ( $ packageFilename , $ packageName , false ) ; if ( is_object ( $ package ) ) { return ; } elseif ( $ package == eZPackage :: STATUS_ALREADY_EXISTS ) { eZDebug :: writeWarning ( "Package '$packageName' already exists." ) ; } else { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Uploaded file is not an eZ Publish package' ) ; } }
Upload local package .
40,464
function processPostData ( ) { if ( $ this -> Http -> hasPostVariable ( 'UploadPackageButton' ) ) { $ this -> uploadPackage ( ) ; return false ; } if ( ! $ this -> Http -> hasPostVariable ( 'eZSetup_site_type' ) ) { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'No site package chosen.' ) ; return false ; } $ sitePackageInfo = $ this -> Http -> postVariable ( 'eZSetup_site_type' ) ; $ downloaded = false ; if ( preg_match ( '/^(\w+)\|(.+)$/' , $ sitePackageInfo , $ matches ) ) { $ sitePackageName = $ matches [ 1 ] ; $ sitePackageURL = $ matches [ 2 ] ; $ package = $ this -> downloadAndImportPackage ( $ sitePackageName , $ sitePackageURL , true ) ; if ( is_object ( $ package ) ) { $ downloaded = true ; $ this -> Message = ezpI18n :: tr ( 'design/standard/setup/init' , 'Package \'%packageName\' and it\'s dependencies have been downloaded successfully. Press \'Next\' to continue.' , false , array ( '%packageName' => $ sitePackageName ) ) ; } } else { $ sitePackageName = $ sitePackageInfo ; $ package = eZPackage :: fetch ( $ sitePackageName , false , false , false ) ; $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Invalid package' ) . '.' ; } if ( ! is_object ( $ package ) || ! $ this -> selectSiteType ( $ sitePackageName ) ) return false ; $ downloadDependandPackagesResult = $ this -> downloadDependantPackages ( $ package ) ; return $ downloadDependandPackagesResult == false ? false : ! $ downloaded ; }
Process POST data .
40,465
function fetchAvailablePackages ( $ type = false ) { $ typeArray = array ( ) ; if ( $ type ) $ typeArray [ 'type' ] = $ type ; $ packageList = eZPackage :: fetchPackages ( array ( 'db_available' => false ) , $ typeArray ) ; return $ packageList ; }
Fetches list of packages already available locally .
40,466
function retrieveRemotePackagesList ( $ onlySitePackages = false ) { $ idxFileName = $ this -> downloadFile ( $ this -> XMLIndexURL , eZStepSiteTypes :: tempDir ( ) , 'index.xml' ) ; if ( $ idxFileName === false ) { $ destIndexPath = eZStepSiteTypes :: tempDir ( ) . DIRECTORY_SEPARATOR . 'index.xml' ; $ repo = eZPackage :: systemRepositoryInformation ( ) ; if ( $ repo ) { $ sourceIndexPath = $ repo [ 'path' ] . DIRECTORY_SEPARATOR . 'index.xml' ; if ( file_exists ( $ sourceIndexPath ) ) { eZFileHandler :: copy ( $ sourceIndexPath , $ destIndexPath ) ; $ idxFileName = $ destIndexPath ; $ this -> ErrorMsg = false ; } } } if ( $ idxFileName === false ) { $ this -> ErrorMsg = ezpI18n :: tr ( 'design/standard/setup/init' , 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.' ) ; eZDebug :: writeNotice ( "Cannot download remote packages index file from '$this->XMLIndexURL'." ) ; return false ; } $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; $ dom -> preserveWhiteSpace = false ; $ success = $ dom -> load ( realpath ( $ idxFileName ) ) ; @ unlink ( $ idxFileName ) ; if ( ! $ success ) { eZDebug :: writeError ( "Unable to open index file." ) ; return false ; } $ root = $ dom -> documentElement ; if ( $ root -> localName != 'packages' ) { eZDebug :: writeError ( "Malformed index file." ) ; return false ; } $ packageList = array ( ) ; foreach ( $ root -> childNodes as $ packageNode ) { if ( $ packageNode -> localName != 'package' ) continue ; if ( $ onlySitePackages && $ packageNode -> getAttribute ( 'type' ) != 'site' ) continue ; $ packageAttributes = array ( ) ; foreach ( $ packageNode -> attributes as $ attributeNode ) { $ packageAttributes [ $ attributeNode -> localName ] = $ attributeNode -> value ; } $ packageList [ $ packageAttributes [ 'name' ] ] = $ packageAttributes ; } return $ packageList ; }
Retrieve list of packages available to download .
40,467
public static function generateToken ( $ vary ) { mt_srand ( base_convert ( substr ( md5 ( $ vary ) , 0 , 6 ) , 36 , 10 ) * microtime ( true ) ) ; $ a = base_convert ( mt_rand ( ) , 10 , 36 ) ; $ b = base_convert ( mt_rand ( ) , 10 , 36 ) ; $ token = substr ( $ b . $ a , 1 , 8 ) ; $ tokenHash = sha1 ( $ token ) ; return $ tokenHash ; }
Generates a random token .
40,468
public static function fetch ( $ accessToken , $ authCheck = true ) { $ tokenInfo = null ; $ session = ezcPersistentSessionInstance :: get ( ) ; $ q = $ session -> createFindQuery ( __CLASS__ ) ; $ e = $ q -> expr ; $ q -> innerJoin ( 'ezprest_clients' , 'ezprest_token.client_id' , 'ezprest_clients.client_id' ) ; if ( $ authCheck ) { $ q -> innerJoin ( 'ezprest_authorized_clients' , $ e -> lAnd ( $ e -> eq ( 'ezprest_authorized_clients.rest_client_id' , 'ezprest_clients.id' ) , $ e -> eq ( 'ezprest_authorized_clients.user_id' , 'ezprest_token.user_id' ) ) ) ; } $ q -> where ( $ q -> expr -> eq ( 'ezprest_token.id' , $ q -> bindValue ( $ accessToken ) ) ) ; $ tokenInfo = $ session -> find ( $ q , 'ezpRestToken' ) ; if ( ! empty ( $ tokenInfo ) ) { $ tokenInfo = array_shift ( $ tokenInfo ) ; } else { $ tokenInfo = null ; } return $ tokenInfo ; }
Fetches an ezpRestToken persistent object from an access token
40,469
static function fetchAuditNameSettings ( ) { $ ini = eZINI :: instance ( 'audit.ini' ) ; $ auditNames = $ ini -> hasVariable ( 'AuditSettings' , 'AuditFileNames' ) ? $ ini -> variable ( 'AuditSettings' , 'AuditFileNames' ) : array ( ) ; $ varDir = eZINI :: instance ( ) -> variable ( 'FileSettings' , 'VarDir' ) ; $ logDir = $ varDir . '/' ; $ logDir .= $ ini -> hasVariable ( 'AuditSettings' , 'LogDir' ) ? $ ini -> variable ( 'AuditSettings' , 'LogDir' ) : self :: DEFAULT_LOG_DIR ; $ resultArray = array ( ) ; foreach ( array_keys ( $ auditNames ) as $ auditNameKey ) { $ auditNameValue = $ auditNames [ $ auditNameKey ] ; $ resultArray [ $ auditNameKey ] = array ( 'dir' => $ logDir , 'file_name' => $ auditNameValue ) ; } return $ resultArray ; }
Returns an associative array of all names of audit and the log files used by this class Will be fetched from ini settings .
40,470
static function isAuditEnabled ( ) { if ( isset ( $ GLOBALS [ 'eZAuditEnabled' ] ) ) { return $ GLOBALS [ 'eZAuditEnabled' ] ; } $ enabled = eZAudit :: fetchAuditEnabled ( ) ; $ GLOBALS [ 'eZAuditEnabled' ] = $ enabled ; return $ enabled ; }
Returns true if audit should be enabled .
40,471
static function fetchAuditEnabled ( ) { $ ini = eZINI :: instance ( 'audit.ini' ) ; $ auditEnabled = $ ini -> hasVariable ( 'AuditSettings' , 'Audit' ) ? $ ini -> variable ( 'AuditSettings' , 'Audit' ) : 'disabled' ; $ enabled = $ auditEnabled == 'enabled' ; return $ enabled ; }
Returns true if audit should be enabled . Will fetch from ini setting .
40,472
static function auditNameSettings ( ) { if ( isset ( $ GLOBALS [ 'eZAuditNameSettings' ] ) ) { return $ GLOBALS [ 'eZAuditNameSettings' ] ; } $ nameSettings = eZAudit :: fetchAuditNameSettings ( ) ; $ GLOBALS [ 'eZAuditNameSettings' ] = $ nameSettings ; return $ nameSettings ; }
Returns an associative array of all names of audit and the log files used by this class
40,473
static function findPathToSiteAccess ( $ siteAccess ) { $ ini = eZINI :: instance ( ) ; $ siteAccessList = $ ini -> variable ( 'SiteAccessSettings' , 'AvailableSiteAccessList' ) ; if ( ! in_array ( $ siteAccess , $ siteAccessList ) ) return false ; $ currentPath = 'settings/siteaccess/' . $ siteAccess ; if ( file_exists ( $ currentPath ) ) return $ currentPath ; $ activeExtensions = eZExtension :: activeExtensions ( ) ; $ baseDir = eZExtension :: baseDirectory ( ) ; foreach ( $ activeExtensions as $ extension ) { $ currentPath = $ baseDir . '/' . $ extension . '/settings/siteaccess/' . $ siteAccess ; if ( file_exists ( $ currentPath ) ) return $ currentPath ; } return 'settings/siteaccess/' . $ siteAccess ; }
Returns path to site access
40,474
static function matchRegexp ( & $ text , $ reg , $ num ) { $ reg = str_replace ( '/' , "\\/" , $ reg ) ; if ( preg_match ( "/$reg/" , $ text , $ regs ) && $ num < count ( $ regs ) ) { $ text = str_replace ( $ regs [ $ num ] , '' , $ text ) ; return $ regs [ $ num ] ; } return null ; }
Match a regex expression
40,475
static function getIni ( $ siteAccess , $ settingFile = 'site.ini' ) { if ( isset ( $ GLOBALS [ 'eZCurrentAccess' ] [ 'name' ] ) && $ GLOBALS [ 'eZCurrentAccess' ] [ 'name' ] === $ siteAccess ) { return eZINI :: instance ( $ settingFile ) ; } else if ( ! $ siteAccess ) { return eZINI :: instance ( $ settingFile ) ; } $ siteIni = new eZINI ( 'site.ini' , 'settings' , null , null , true ) ; $ access = array ( 'name' => $ siteAccess , 'type' => eZSiteAccess :: TYPE_STATIC , 'uri_part' => array ( ) ) ; $ access = self :: load ( $ access , $ siteIni ) ; if ( $ settingFile === 'site.ini' ) { return $ siteIni ; } $ ini = new eZINI ( $ settingFile , 'settings' , null , null , true ) ; $ ini -> setOverrideDirs ( $ siteIni -> overrideDirs ( false ) ) ; $ ini -> load ( ) ; return $ ini ; }
Loads ini environment for a specific siteaccess
40,476
public static function mapTo ( $ charset ) { $ lowerCharset = strtolower ( $ charset ) ; return isset ( self :: $ mapping [ $ lowerCharset ] ) ? self :: $ mapping [ $ lowerCharset ] : $ charset ; }
Maps an internal charset to one understood by MySQL . If the charset is unknown it will be returned as is .
40,477
public static function mapFrom ( $ charset ) { $ lowerCharset = strtolower ( $ charset ) ; return isset ( self :: $ reverseMapping [ $ lowerCharset ] ) ? self :: $ reverseMapping [ $ lowerCharset ] : $ charset ; }
Maps a MySQL charset to an internal one . If the charset is unknown it will be returned as is .
40,478
protected function getPolicyCheckViewMap ( array $ policyCheckOmitList ) { if ( $ this -> policyCheckViewMap !== null ) return $ this -> policyCheckViewMap ; $ this -> policyCheckViewMap = array ( ) ; foreach ( $ policyCheckOmitList as $ omitItem ) { $ items = explode ( '/' , $ omitItem ) ; if ( count ( $ items ) > 1 ) { $ module = $ items [ 0 ] ; if ( ! isset ( $ this -> policyCheckViewMap [ $ module ] ) ) $ this -> policyCheckViewMap [ $ module ] = array ( ) ; $ this -> policyCheckViewMap [ $ module ] [ $ items [ 1 ] ] = true ; } } return $ this -> policyCheckViewMap ; }
Returns the map for policy check view
40,479
protected function sessionInit ( ) { if ( ! isset ( $ this -> settings [ 'session' ] ) || ! $ this -> settings [ 'session' ] [ 'configured' ] ) { $ ini = eZINI :: instance ( ) ; if ( $ ini -> variable ( 'Session' , 'ForceStart' ) === 'enabled' ) eZSession :: start ( ) ; else eZSession :: lazyStart ( ) ; } else { $ sfHandler = new ezpSessionHandlerSymfony ( $ this -> settings [ 'session' ] [ 'has_previous' ] || $ this -> settings [ 'session' ] [ 'started' ] ) ; $ sfHandler -> setStorage ( $ this -> settings [ 'session' ] [ 'storage' ] ) ; eZSession :: init ( $ this -> settings [ 'session' ] [ 'name' ] , $ this -> settings [ 'session' ] [ 'started' ] , $ this -> settings [ 'session' ] [ 'namespace' ] , $ sfHandler ) ; } $ this -> siteBasics [ 'db-required' ] = eZSession :: getHandlerInstance ( ) -> dbRequired ( ) ; }
Initializes the session . If running through Symfony the session parameters from Symfony override the session parameter from eZ Publish .
40,480
public function runCallback ( \ Closure $ callback , $ postReinitialize = true ) { $ this -> requestInit ( ) ; try { $ return = $ callback ( ) ; } catch ( Exception $ e ) { $ this -> shutdown ( $ postReinitialize ) ; throw $ e ; } $ this -> shutdown ( $ postReinitialize ) ; return $ return ; }
Run a callback function in legacy environment
40,481
function copy ( $ roleID ) { $ params = array ( ) ; $ params [ 'ModuleName' ] = $ this -> attribute ( 'module_name' ) ; $ params [ 'FunctionName' ] = $ this -> attribute ( 'function_name' ) ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ newPolicy = eZPolicy :: createNew ( $ roleID , $ params ) ; foreach ( $ this -> attribute ( 'limitations' ) as $ limitation ) { $ limitation -> copy ( $ newPolicy -> attribute ( 'id' ) ) ; } $ db -> commit ( ) ; return $ newPolicy ; }
Copies the policy and its limitations to another role
40,482
public static function fetchTemporaryCopy ( $ policyID ) { $ policy = eZPersistentObject :: fetchObject ( self :: definition ( ) , null , array ( 'original_id' => $ policyID ) , true ) ; if ( $ policy instanceof eZPolicy ) { return $ policy ; } else { $ policy = self :: fetch ( $ policyID ) ; if ( $ policy === null ) return false ; else { return $ policy -> createTemporaryCopy ( ) ; } } }
Fetches the temporary copy of a policy
40,483
public function createTemporaryCopy ( ) { if ( $ this -> attribute ( 'original_id' ) === 0 ) throw new Exception ( 'eZPolicy #' . $ this -> attribute ( 'id' ) . ' is already a temporary item (original: #' . $ this -> attribute ( 'original_id' ) . ')' ) ; $ policyCopy = self :: copy ( $ this -> attribute ( 'role_id' ) ) ; $ policyCopy -> setAttribute ( 'original_id' , $ this -> attribute ( 'id' ) ) ; $ policyCopy -> store ( ) ; return $ policyCopy ; }
Creates a temporary copy for this policy so that it can be edited . The policies will be linked to the copy
40,484
private function _copyInner ( $ srcFilePath , $ dstFilePath , $ fname , $ metaData ) { $ this -> _delete ( $ dstFilePath , true , $ fname ) ; $ datatype = $ metaData [ 'datatype' ] ; $ filePathHash = md5 ( $ dstFilePath ) ; $ scope = $ metaData [ 'scope' ] ; $ contentLength = $ metaData [ 'size' ] ; $ fileMTime = $ metaData [ 'mtime' ] ; $ nameTrunk = self :: nameTrunk ( $ dstFilePath , $ scope ) ; if ( $ this -> _insertUpdate ( $ this -> dbTable ( $ dstFilePath ) , array ( 'datatype' => $ datatype , 'name' => $ dstFilePath , 'name_trunk' => $ nameTrunk , 'name_hash' => $ filePathHash , 'scope' => $ scope , 'size' => $ contentLength , 'mtime' => $ fileMTime , 'expired' => ( $ fileMTime < 0 ) ? 1 : 0 ) , "datatype=VALUES(datatype), scope=VALUES(scope), size=VALUES(size), mtime=VALUES(mtime), expired=VALUES(expired)" , $ fname ) === false ) { return $ this -> _fail ( $ srcFilePath , "Failed to insert file metadata on copying." ) ; } if ( ! $ this -> dfsbackend -> copyFromDFSToDFS ( $ srcFilePath , $ dstFilePath ) ) { return $ this -> _fail ( $ srcFilePath , "Failed to copy DFS://$srcFilePath to DFS://$dstFilePath" ) ; } return true ; }
Inner function used by _copy to perform the operation in a transaction
40,485
public function _purge ( $ filePath , $ onlyExpired = false , $ expiry = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_purge($filePath)" ; else $ fname = "_purge($filePath)" ; $ sql = "DELETE FROM " . $ this -> dbTable ( $ filePath ) . " WHERE name_hash=" . $ this -> _md5 ( $ filePath ) ; if ( $ expiry !== false ) { $ sql .= " AND mtime<" . ( int ) $ expiry ; } elseif ( $ onlyExpired ) { $ sql .= " AND expired=1" ; } if ( ! $ this -> _query ( $ sql , $ fname ) ) { return $ this -> _fail ( "Purging file metadata for $filePath failed" ) ; } if ( mysqli_affected_rows ( $ this -> db ) == 1 ) { $ this -> dfsbackend -> delete ( $ filePath ) ; } $ this -> eventHandler -> notify ( 'cluster/deleteFile' , array ( $ filePath ) ) ; return true ; }
Purges meta - data and file - data for a file entry
40,486
public function _purgeByLike ( $ like , $ onlyExpired = false , $ limit = 50 , $ expiry = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_purgeByLike($like, $onlyExpired)" ; else $ fname = "_purgeByLike($like, $onlyExpired)" ; $ where = " WHERE name LIKE " . $ this -> _quote ( $ like , true ) ; if ( $ expiry !== false ) $ where .= " AND mtime < " . ( int ) $ expiry ; elseif ( $ onlyExpired ) $ where .= " AND expired = 1" ; if ( $ limit ) $ sqlLimit = " LIMIT $limit" ; else $ sqlLimit = "" ; $ this -> _begin ( $ fname ) ; $ selectSQL = "SELECT name FROM " . $ this -> dbTable ( $ like ) . "{$where} {$sqlLimit} FOR UPDATE" ; if ( ! $ res = $ this -> _query ( $ selectSQL , $ fname ) ) { $ this -> _rollback ( $ fname ) ; return $ this -> _fail ( "Selecting file metadata by like statement $like failed" ) ; } $ resultCount = mysqli_num_rows ( $ res ) ; if ( $ resultCount == 0 ) { $ this -> _rollback ( $ fname ) ; return 0 ; } else { for ( $ i = 0 ; $ i < $ resultCount ; $ i ++ ) { $ row = mysqli_fetch_assoc ( $ res ) ; $ files [ ] = $ row [ 'name' ] ; } } $ deleteSQL = "DELETE FROM " . $ this -> dbTable ( $ like ) . " {$where} {$sqlLimit}" ; if ( ! $ res = $ this -> _query ( $ deleteSQL , $ fname ) ) { $ this -> _rollback ( $ fname ) ; return $ this -> _fail ( "Purging file metadata by like statement $like failed" ) ; } $ deletedDBFiles = mysqli_affected_rows ( $ this -> db ) ; $ commitResult = $ this -> _commit ( $ fname ) ; if ( $ commitResult === true || $ commitResult === null ) { $ this -> dfsbackend -> delete ( $ files ) ; return $ deletedDBFiles ; } return false ; }
Purges meta - data and file - data for files matching a pattern using a SQL LIKE syntax .
40,487
public function _delete ( $ filePath , $ insideOfTransaction = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_delete($filePath)" ; else $ fname = "_delete($filePath)" ; if ( $ insideOfTransaction ) { $ res = $ this -> _deleteInner ( $ filePath , $ fname ) ; if ( ! $ res || $ res instanceof eZMySQLBackendError ) { $ this -> _handleErrorType ( $ res ) ; } } else { $ res = $ this -> _protect ( array ( $ this , '_deleteInner' ) , $ fname , $ filePath , $ insideOfTransaction , $ fname ) ; } $ this -> eventHandler -> notify ( 'cluster/deleteFile' , array ( $ filePath ) ) ; return $ res ; }
Deletes a file from DB
40,488
public function _deleteByLike ( $ like , $ fname = false ) { if ( $ fname ) $ fname .= "::_deleteByLike($like)" ; else $ fname = "_deleteByLike($like)" ; $ return = $ this -> _protect ( array ( $ this , '_deleteByLikeInner' ) , $ fname , $ like , $ fname ) ; if ( $ return ) $ this -> eventHandler -> notify ( 'cluster/deleteByLike' , array ( $ like ) ) ; return $ return ; }
Deletes multiple files using a SQL LIKE statement
40,489
public function _deleteByWildcard ( $ wildcard , $ fname = false ) { if ( $ fname ) $ fname .= "::_deleteByWildcard($wildcard)" ; else $ fname = "_deleteByWildcard($wildcard)" ; return $ this -> _protect ( array ( $ this , '_deleteByWildcardInner' ) , $ fname , $ wildcard , $ fname ) ; }
Deletes multiple DB files by wildcard
40,490
protected function _deleteByWildcardInner ( $ wildcard , $ fname ) { $ regex = '^' . mysqli_real_escape_string ( $ this -> db , $ wildcard ) . '$' ; $ regex = str_replace ( array ( '.' ) , array ( '\.' ) , $ regex ) ; $ regex = str_replace ( array ( '?' , '*' , '{' , '}' , ',' ) , array ( '.' , '.*' , '(' , ')' , '|' ) , $ regex ) ; $ sql = "UPDATE " . $ this -> dbTable ( $ wildcard ) . " SET mtime=-ABS(mtime), expired=1\nWHERE name REGEXP '$regex'" ; if ( ! $ res = $ this -> _query ( $ sql , $ fname ) ) { return $ this -> _fail ( "Failed to delete files by wildcard: '$wildcard'" ) ; } return true ; }
Callback used by _deleteByWildcard to perform the deletion
40,491
private function mkdir_p ( $ dir ) { $ dirElements = explode ( '/' , $ dir ) ; if ( count ( $ dirElements ) == 0 ) return true ; $ result = true ; $ currentDir = $ dirElements [ 0 ] ; if ( $ currentDir != '' && ! file_exists ( $ currentDir ) && ! eZDir :: mkdir ( $ currentDir , false ) ) return false ; for ( $ i = 1 ; $ i < count ( $ dirElements ) ; ++ $ i ) { $ dirElement = $ dirElements [ $ i ] ; if ( strlen ( $ dirElement ) == 0 ) continue ; $ currentDir .= '/' . $ dirElement ; if ( ! file_exists ( $ currentDir ) && ! eZDir :: mkdir ( $ currentDir , false ) ) return false ; $ result = true ; } return $ result ; }
Creates a directory and all parent directories in its path if necessary
40,492
public function _getFileList ( $ scopes = false , $ excludeScopes = false , $ limit = false , $ path = false ) { $ filePathList = array ( ) ; $ tables = array_unique ( array ( $ this -> metaDataTable , $ this -> metaDataTableCache ) ) ; foreach ( $ tables as $ table ) { $ query = 'SELECT name FROM ' . $ table ; if ( is_array ( $ scopes ) && count ( $ scopes ) > 0 ) { $ query .= ' WHERE scope ' ; if ( $ excludeScopes ) $ query .= 'NOT ' ; $ query .= "IN ('" . implode ( "', '" , $ scopes ) . "')" ; } if ( $ path != false && $ scopes == false ) { $ query .= " WHERE name LIKE '" . $ path . "%'" ; } else if ( $ path != false ) { $ query .= " AND name LIKE '" . $ path . "%'" ; } if ( $ limit && array_sum ( $ limit ) ) { $ query .= " LIMIT {$limit[0]}, {$limit[1]}" ; } $ rslt = $ this -> _query ( $ query , "_getFileList( array( " . implode ( ', ' , is_array ( $ scopes ) ? $ scopes : array ( ) ) . " ), $excludeScopes )" ) ; if ( ! $ rslt ) { eZDebug :: writeError ( 'Unable to get file list' , __METHOD__ ) ; throw new Exception ( "dfs/mysqli DB error: " . mysqli_error ( $ this -> db ) . "\nSQL Query: $query" , mysqli_errno ( $ this -> db ) ) ; } while ( $ row = mysqli_fetch_row ( $ rslt ) ) { $ filePathList [ ] = $ row [ 0 ] ; } mysqli_free_result ( $ rslt ) ; } return $ filePathList ; }
Returns the list of cluster files filtered by the optional params
40,493
protected function _begin ( $ fname = false ) { if ( $ fname ) $ fname .= "::_begin" ; else $ fname = "_begin" ; $ this -> transactionCount ++ ; if ( $ this -> transactionCount == 1 ) $ this -> _query ( "BEGIN" , $ fname ) ; }
Starts a new transaction by executing a BEGIN call . If a transaction is already started nothing is executed .
40,494
static function fetchByVatType ( $ vatID ) { return eZPersistentObject :: fetchObjectList ( eZVatRule :: definition ( ) , null , array ( 'vat_type' => ( int ) $ vatID ) , null , null , true , false , null ) ; }
Fetch VAT rules referencing given VAT type .
40,495
static function fetchCountByCategory ( $ categories ) { $ db = eZDB :: instance ( ) ; $ query = "SELECT COUNT(*) AS count FROM ezvatrule vr, ezvatrule_product_category vrpc " . "WHERE vr.id=vrpc.vatrule_id AND " ; if ( is_array ( $ categories ) ) { $ query .= $ db -> generateSQLINStatement ( $ categories , 'vrpc.product_category_id' , false , false , 'int' ) ; } else { $ query .= "vrpc.product_category_id =" . ( int ) $ categories ; } $ rows = $ db -> arrayQuery ( $ query ) ; return $ rows [ 0 ] [ 'count' ] ; }
Fetch number of VAT rules referencing given product categories
40,496
static function fetchCountByVatType ( $ vatID ) { $ rows = eZPersistentObject :: fetchObjectList ( eZVatRule :: definition ( ) , array ( ) , array ( 'vat_type' => ( int ) $ vatID ) , false , null , false , false , array ( array ( 'operation' => 'count( * )' , 'name' => 'count' ) ) ) ; return $ rows [ 0 ] [ 'count' ] ; }
Return number of VAT rules referencing given VAT type .
40,497
static function removeVatRule ( $ id ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; eZVatRule :: removeProductCategories ( $ id ) ; eZPersistentObject :: removeObject ( eZVatRule :: definition ( ) , array ( "id" => $ id ) ) ; $ db -> commit ( ) ; }
Remove given VAT charging rule .
40,498
function productCategoriesString ( ) { $ categories = $ this -> attribute ( 'product_categories' ) ; if ( ! $ categories ) { $ result = ezpI18n :: tr ( 'kernel/shop' , 'Any' ) ; return $ result ; } $ categoriesNames = array ( ) ; foreach ( $ categories as $ cat ) $ categoriesNames [ ] = $ cat [ 'name' ] ; return join ( ', ' , $ categoriesNames ) ; }
Return product categories as string separated with commas .
40,499
function productCategoriesIDs ( ) { $ catIDs = array ( ) ; $ categories = $ this -> attribute ( 'product_categories' ) ; if ( $ categories ) { foreach ( $ categories as $ cat ) $ catIDs [ ] = $ cat [ 'id' ] ; } return $ catIDs ; }
Return IDs of product categories associated with the rule .