idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
40,500
function productCategoriesNames ( ) { $ catNames = array ( ) ; $ categories = $ this -> attribute ( 'product_categories' ) ; if ( $ categories ) { foreach ( $ categories as $ cat ) $ catNames [ ] = $ cat [ 'name' ] ; } return $ catNames ; }
Return names of product categories associated with the rule .
40,501
function removeProductCategories ( $ ruleID = false ) { if ( $ ruleID === false ) $ ruleID = $ this -> ID ; $ ruleID = ( int ) $ ruleID ; $ db = eZDB :: instance ( ) ; $ db -> query ( "DELETE FROM ezvatrule_product_category WHERE vatrule_id = $ruleID" ) ; }
Remove product categories with the rule from DB .
40,502
static function removeReferencesToProductCategory ( $ cartegoryID ) { $ db = eZDB :: instance ( ) ; $ query = "DELETE FROM ezvatrule_product_category WHERE product_category_id=" . ( int ) $ cartegoryID ; $ db -> query ( $ query ) ; }
Remove references to the given product category .
40,503
public static function clearCache ( ) { $ expiryHandler = eZExpiryHandler :: instance ( ) ; if ( $ expiryHandler -> hasTimestamp ( ezpRestRouter :: ROUTE_CACHE_KEY ) ) { $ expiryHandler -> setTimestamp ( ezpRestRouter :: ROUTE_CACHE_KEY , 0 ) ; $ expiryHandler -> store ( ) ; } }
Force Route cache expiration so that APC cache will be flushed and regenerated next REST call
40,504
public function restore ( $ id , $ attributes = array ( ) , $ search = false ) { if ( $ this -> isCacheEnabled === false ) { return false ; } $ this -> clusterCacheFile = eZClusterFileHandler :: instance ( $ this -> properties [ 'location' ] . $ this -> generateIdentifier ( $ id , $ attributes ) ) ; $ result = $ this -> clusterCacheFile -> processCache ( array ( $ this , 'clusterRetrieve' ) , null , $ this -> properties [ 'options' ] [ 'ttl' ] , null , compact ( 'id' , 'attributes' , 'fileName' ) ) ; if ( ! $ result instanceof eZClusterFileFailure ) { return $ result ; } return false ; }
Restore data from the cache .
40,505
public function delete ( $ id = null , $ attributes = array ( ) , $ search = false ) { if ( ! isset ( $ this -> clusterCacheFile ) ) { $ this -> clusterCacheFile = eZClusterFileHandler :: instance ( $ this -> properties [ 'location' ] . $ this -> generateIdentifier ( $ id , $ attributes ) ) ; } $ this -> clusterCacheFile -> purge ( ) ; return $ id ; }
Delete data from the cache .
40,506
public function countDataItems ( $ id = null , $ attributes = array ( ) ) { if ( ! isset ( $ this -> clusterCacheFile ) ) { $ this -> clusterCacheFile = eZClusterFileHandler :: instance ( $ this -> properties [ 'location' ] . $ this -> generateIdentifier ( $ id , $ attributes ) ) ; } return $ this -> clusterCacheFile -> exists ( ) ? 1 : 0 ; }
Return the number of items in the cache matching a certain criteria .
40,507
public static function isEnabled ( ) { if ( eZINI :: instance ( ) -> variable ( 'SiteAccessSettings' , 'DetectMobileDevice' ) === 'enabled' ) { $ mobileSaList = eZINI :: instance ( ) -> variable ( 'SiteAccessSettings' , 'MobileSiteAccessList' ) ; if ( ! empty ( $ mobileSaList ) ) { return true ; } else { eZDebug :: writeError ( "DetectMobileDevice is enabled and MobileSiteAccessList is empty, please check your site.ini configuration" , __METHOD__ ) ; } } return false ; }
Checks whether mobile device detection is enabled or not
40,508
public static function fetchById ( $ id ) { $ stateGroups = self :: fetchByConditions ( array ( "ezcobj_state_group.id=$id" ) , 1 , 0 ) ; $ stateGroup = count ( $ stateGroups ) > 0 ? $ stateGroups [ 0 ] : false ; return $ stateGroup ; }
Fetches a content object state group by its numerical ID
40,509
public static function fetchByIdentifier ( $ identifier ) { $ db = eZDB :: instance ( ) ; $ identifier = $ db -> escapeString ( $ identifier ) ; $ stateGroups = self :: fetchByConditions ( array ( "ezcobj_state_group.identifier='$identifier'" ) , 1 , 0 ) ; $ stateGroup = count ( $ stateGroups ) > 0 ? $ stateGroups [ 0 ] : false ; return $ stateGroup ; }
Fetches a content object state group by its identifier
40,510
private static function fetchByConditions ( $ conditions , $ limit , $ offset ) { $ db = eZDB :: instance ( ) ; $ defaultConditions = array ( 'ezcobj_state_group_language.contentobject_state_group_id=ezcobj_state_group.id' , eZContentLanguage :: languagesSQLFilter ( 'ezcobj_state_group' ) , eZContentLanguage :: sqlFilter ( 'ezcobj_state_group_language' , 'ezcobj_state_group' ) ) ; $ conditions = array_merge ( $ conditions , $ defaultConditions ) ; $ conditionsSQL = implode ( ' AND ' , $ conditions ) ; $ sql = "SELECT * " . "FROM ezcobj_state_group, ezcobj_state_group_language " . "WHERE $conditionsSQL" ; $ rows = $ db -> arrayQuery ( $ sql , array ( 'limit' => $ limit , 'offset' => $ offset ) ) ; $ stateGroups = array ( ) ; foreach ( $ rows as $ row ) { $ stateGroup = new eZContentObjectStateGroup ( $ row ) ; $ stateGroupLanguage = new eZContentObjectStateGroupLanguage ( $ row ) ; $ stateGroup -> setLanguageObject ( $ stateGroupLanguage ) ; $ stateGroups [ ] = $ stateGroup ; } return $ stateGroups ; }
Fetches content object state groups by certain conditions
40,511
public function availableLanguages ( ) { $ languages = array ( ) ; $ languageObjects = $ this -> languages ( ) ; foreach ( $ languageObjects as $ languageObject ) { $ languages [ ] = $ languageObject -> attribute ( 'locale' ) ; } return $ languages ; }
Get the languages the state group exists in .
40,512
public function store ( $ fieldFilters = null ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ languageMask = 1 ; foreach ( $ this -> AllTranslations as $ translation ) { if ( $ translation -> hasData ( ) ) { $ languageID = $ translation -> attribute ( 'real_language_id' ) ; if ( empty ( $ this -> DefaultLanguageID ) ) { $ this -> DefaultLanguageID = $ languageID & ~ 1 ; } if ( $ languageID & $ this -> DefaultLanguageID ) { $ translation -> setAttribute ( 'language_id' , $ languageID | 1 ) ; } else { $ translation -> setAttribute ( 'language_id' , $ languageID & ~ 1 ) ; } $ languageMask = $ languageMask | $ languageID ; } } $ this -> setAttribute ( 'language_mask' , $ languageMask ) ; eZPersistentObject :: storeObject ( $ this , $ fieldFilters ) ; foreach ( $ this -> AllTranslations as $ translation ) { if ( ! $ translation -> hasData ( ) ) { if ( $ translation -> attribute ( 'contentobject_state_group_id' ) !== null ) { $ translation -> remove ( ) ; } } else { if ( $ translation -> attribute ( 'contentobject_state_group_id' ) != $ this -> ID ) { $ translation -> setAttribute ( 'contentobject_state_group_id' , $ this -> ID ) ; } $ translation -> store ( ) ; } } $ handler = eZExpiryHandler :: instance ( ) ; $ handler -> setTimestamp ( 'state-limitations' , time ( ) ) ; $ db -> commit ( ) ; }
Stores the content object state group and its translations .
40,513
public function fetchHTTPPersistentVariables ( ) { $ translations = $ this -> allTranslations ( ) ; $ http = eZHTTPTool :: instance ( ) ; eZHTTPPersistence :: fetch ( 'ContentObjectStateGroup' , eZContentObjectStateGroup :: definition ( ) , $ this , $ http , false ) ; eZHTTPPersistence :: fetch ( 'ContentObjectStateGroup' , eZContentObjectStateGroupLanguage :: definition ( ) , $ translations , $ http , true ) ; }
Fetches the HTTP persistent variables for this content object state group and its localizations .
40,514
public static function limitations ( ) { static $ limitations ; if ( $ limitations === null ) { $ db = eZDB :: instance ( ) ; $ dbName = md5 ( $ db -> DB ) ; $ cacheDir = eZSys :: cacheDirectory ( ) ; $ phpCache = new eZPHPCreator ( $ cacheDir , 'statelimitations_' . $ dbName . '.php' , '' , array ( 'clustering' => 'statelimitations' ) ) ; $ handler = eZExpiryHandler :: instance ( ) ; $ storedTimeStamp = $ handler -> hasTimestamp ( 'state-limitations' ) ? $ handler -> timestamp ( 'state-limitations' ) : false ; $ expiryTime = $ storedTimeStamp !== false ? $ storedTimeStamp : 0 ; if ( $ phpCache -> canRestore ( $ expiryTime ) ) { $ var = $ phpCache -> restore ( array ( 'state_limitations' => 'state_limitations' ) ) ; $ limitations = $ var [ 'state_limitations' ] ; } else { $ limitations = array ( ) ; $ groups = self :: fetchByConditions ( array ( "identifier NOT LIKE 'ez%'" ) , false , false ) ; foreach ( $ groups as $ group ) { $ name = 'StateGroup_' . $ group -> attribute ( 'identifier' ) ; $ limitations [ $ name ] = array ( 'name' => $ name , 'values' => array ( ) , 'class' => __CLASS__ , 'function' => 'limitationValues' , 'parameter' => array ( $ group -> attribute ( 'id' ) ) ) ; } $ phpCache -> addVariable ( 'state_limitations' , $ limitations ) ; $ phpCache -> store ( ) ; } if ( $ storedTimeStamp === false ) { $ handler -> setTimestamp ( 'state-limitations' , time ( ) ) ; } } return $ limitations ; }
Returns an array of limitations useable by the policy system
40,515
public static function limitationValues ( $ groupID ) { $ group = self :: fetchById ( $ groupID ) ; $ states = array ( ) ; if ( $ group !== false ) $ states = $ group -> attribute ( 'states' ) ; $ limitationValues = array ( ) ; foreach ( $ states as $ state ) { $ limitationValues [ ] = array ( 'name' => $ state -> attribute ( 'current_translation' ) -> attribute ( 'name' ) , 'id' => $ state -> attribute ( 'id' ) ) ; } return $ limitationValues ; }
Returns an array of limitation values useable by the policy system
40,516
public function buildAutoloadArrays ( ) { $ phpFiles = $ this -> fetchFiles ( ) ; $ phpClasses = array ( ) ; foreach ( $ phpFiles as $ mode => $ fileList ) { $ phpClasses [ $ mode ] = $ this -> getClassFileList ( $ fileList , $ mode ) ; } $ maxClassNameLength = $ this -> checkMaxClassLength ( $ phpClasses ) ; $ this -> autoloadArrays = $ this -> dumpArray ( $ phpClasses , $ maxClassNameLength ) ; if ( $ this -> options -> writeFiles ) { $ this -> writeAutoloadFiles ( ) ; } }
Searches specified directories for classes and build autoload arrays .
40,517
protected function handleDefaultExcludeFile ( ) { $ defaultExcludeFile = $ this -> options -> basePath . DIRECTORY_SEPARATOR . self :: DEFAULT_EXCLUDE_FILE ; if ( ! file_exists ( $ defaultExcludeFile ) ) { return $ this -> options -> excludeDirs ; } $ defaultExcludeArray = explode ( "\n" , trim ( file_get_contents ( $ defaultExcludeFile ) ) ) ; return array_merge ( $ defaultExcludeArray , $ this -> options -> excludeDirs ) ; }
Adds exclude directories specified in the default excludes files to the exclude array .
40,518
protected function fetchFiles ( ) { $ path = $ this -> options -> basePath ; $ excludeDirs = $ this -> handleDefaultExcludeFile ( ) ; $ sanitisedBasePath = DIRECTORY_SEPARATOR == '/' ? $ path : strtr ( $ path , DIRECTORY_SEPARATOR , '/' ) ; $ dirSep = preg_quote ( DIRECTORY_SEPARATOR ) ; $ extraExcludeDirs = array ( ) ; if ( $ excludeDirs !== false and is_array ( $ excludeDirs ) ) { foreach ( $ excludeDirs as $ dir ) { $ extraExcludeDirs [ ] = "@^{$sanitisedBasePath}{$dirSep}{$dir}@" ; } } $ retFiles = array ( ) ; $ activeModes = $ this -> checkMode ( ) ; foreach ( $ activeModes as $ modusOperandi ) { switch ( $ modusOperandi ) { case self :: MODE_KERNEL : $ extraExcludeKernelDirs = $ extraExcludeDirs ; $ extraExcludeKernelDirs [ ] = "@^{$sanitisedBasePath}{$dirSep}extension@" ; $ extraExcludeKernelDirs [ ] = "@^{$sanitisedBasePath}{$dirSep}tests@" ; $ retFiles [ $ modusOperandi ] = $ this -> buildFileList ( $ sanitisedBasePath , $ extraExcludeKernelDirs ) ; break ; case self :: MODE_EXTENSION : case self :: MODE_KERNEL_OVERRIDE : $ extraExcludeExtensionDirs = $ extraExcludeDirs ; $ extraExcludeExtensionDirs [ ] = "@^{$sanitisedBasePath}{$dirSep}extension{$dirSep}[^{$dirSep}]+{$dirSep}tests@" ; $ retFiles [ $ modusOperandi ] = $ this -> buildFileList ( "$sanitisedBasePath/extension" , $ extraExcludeExtensionDirs ) ; break ; case self :: MODE_TESTS : $ retFiles [ $ modusOperandi ] = $ this -> buildFileList ( "$sanitisedBasePath/tests" , $ extraExcludeDirs ) ; $ extraExcludeExtensionDirs = $ extraExcludeDirs ; $ extraExcludeExtensionDirs [ ] = "@^{$sanitisedBasePath}{$dirSep}extension{$dirSep}[^{$dirSep}]+{$dirSep}(?!tests)@" ; $ extensionTestFiles = $ this -> buildFileList ( "$sanitisedBasePath/extension" , $ extraExcludeExtensionDirs ) ; $ retFiles [ $ modusOperandi ] = array_merge ( $ retFiles [ $ modusOperandi ] , $ extensionTestFiles ) ; break ; case self :: MODE_SINGLE_EXTENSION : $ retFiles = array ( $ modusOperandi => $ this -> buildFileList ( "$sanitisedBasePath" , $ extraExcludeDirs ) ) ; break ; } } foreach ( $ retFiles as & $ fileBundle ) { foreach ( $ fileBundle as $ key => & $ file ) { if ( DIRECTORY_SEPARATOR != '/' ) { $ file = strtr ( $ file , '/' , DIRECTORY_SEPARATOR ) ; } $ fileBundle [ $ key ] = ezcBaseFile :: calculateRelativePath ( $ file , $ path ) ; } } unset ( $ file , $ fileBundle ) ; return $ retFiles ; }
Returns an array indexed by location for classes and their filenames .
40,519
public static function findRecursive ( $ sourceDir , array $ includeFilters = array ( ) , array $ excludeFilters = array ( ) , eZAutoloadGenerator $ gen ) { $ gen -> log ( "Scanning for PHP-files." ) ; $ gen -> startProgressOutput ( self :: OUTPUT_PROGRESS_PHASE1 ) ; $ context = new ezpAutoloadFileFindContext ( ) ; $ context -> generator = $ gen ; self :: walkRecursive ( $ sourceDir , $ includeFilters , $ excludeFilters , array ( 'eZAutoloadGenerator' , 'findRecursiveCallback' ) , $ context ) ; sort ( $ context -> elements ) ; $ gen -> stopProgressOutput ( self :: OUTPUT_PROGRESS_PHASE1 ) ; $ gen -> log ( "Scan complete. Found {$context->count} PHP files." ) ; return $ context -> elements ; }
Uses the walker in ezcBaseFile to find files .
40,520
public static function findRecursiveCallback ( ezpAutoloadFileFindContext $ context , $ sourceDir , $ fileName , $ fileInfo ) { if ( $ fileInfo [ 'mode' ] & 0x4000 ) { return ; } $ context -> elements [ ] = $ sourceDir . DIRECTORY_SEPARATOR . $ fileName ; $ context -> count ++ ; $ context -> generator -> updateProgressOutput ( eZAutoloadGenerator :: OUTPUT_PROGRESS_PHASE1 ) ; }
Callback used ezcBaseFile
40,521
protected function dumpArray ( $ sortedArray , $ length ) { $ retArray = array ( ) ; foreach ( $ sortedArray as $ location => $ sorted ) { $ ret = '' ; $ offset = $ length [ $ location ] + 2 ; foreach ( $ sorted as $ class => $ path ) { $ ret .= sprintf ( " %-{$offset}s => '%s'," . PHP_EOL , "'{$class}'" , $ path ) ; } $ retArray [ $ location ] = $ ret ; } return $ retArray ; }
Build string version of the autoload array with correct indenting .
40,522
protected function runMode ( ) { $ mode = self :: MODE_NONE ; if ( $ this -> options -> basePath !== getcwd ( ) ) { $ mode |= self :: MODE_SINGLE_EXTENSION ; return $ mode ; } if ( $ this -> options -> searchKernelOverride ) { $ mode |= self :: MODE_KERNEL_OVERRIDE ; return $ mode ; } if ( ! $ this -> options -> searchKernelFiles and ! $ this -> options -> searchExtensionFiles and ! $ this -> options -> searchTestFiles ) { $ mode |= self :: MODE_EXTENSION ; } if ( $ this -> options -> searchKernelFiles ) { $ mode |= self :: MODE_KERNEL ; } if ( $ this -> options -> searchExtensionFiles ) { $ mode |= self :: MODE_EXTENSION ; } if ( $ this -> options -> searchTestFiles ) { $ mode |= self :: MODE_TESTS ; } return $ mode ; }
Generates the active bitmask for this instance of the autoload generation script depending on the parameters it sets the corresponding flags .
40,523
protected function nameTable ( $ lookup ) { $ names = array ( self :: MODE_EXTENSION => "ezp_extension.php" , self :: MODE_SINGLE_EXTENSION => basename ( $ this -> options -> basePath ) . '_autoload.php' , self :: MODE_KERNEL => "ezp_kernel.php" , self :: MODE_TESTS => "ezp_tests.php" , self :: MODE_KERNEL_OVERRIDE => "ezp_override.php" , ) ; if ( array_key_exists ( $ lookup , $ names ) ) { return $ names [ $ lookup ] ; } return false ; }
Table to look up file names to use for different run modes .
40,524
protected function targetTable ( $ lookup ) { $ targets = array ( self :: MODE_EXTENSION => "var/autoload" , self :: MODE_TESTS => "var/autoload" , self :: MODE_KERNEL => "autoload" , self :: MODE_SINGLE_EXTENSION => $ this -> options -> basePath . DIRECTORY_SEPARATOR . 'autoload' , self :: MODE_KERNEL_OVERRIDE => "var/autoload" , ) ; if ( array_key_exists ( $ lookup , $ targets ) ) { return $ targets [ $ lookup ] ; } return false ; }
Provides a look - up for which base directory to use depending on mode .
40,525
protected function dumpArrayStart ( $ part ) { $ description = "" ; switch ( $ part ) { case self :: MODE_SINGLE_EXTENSION : $ description = basename ( $ this -> options -> basePath ) . ' extension' ; break ; case self :: MODE_EXTENSION : case self :: MODE_KERNEL : case self :: MODE_TESTS : case self :: MODE_KERNEL_OVERRIDE : $ description = $ this -> modeName [ $ part ] ; break ; } return <<<ENDL<?php/** * Autoloader definition for eZ Publish $description files. * * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// * @package kernel * */return array(ENDL ; }
Prints generated code used for the autoload files
40,526
protected function classCanBeAdded ( $ class , $ file , $ mode , $ inProgressAutoloadArray ) { $ addClass = true ; $ sameRepositoryConflict = false ; $ kernelRepositoryConflict = false ; if ( empty ( $ this -> existingAutoloadArrays [ self :: MODE_KERNEL ] ) ) { $ this -> logWarning ( "No existing kernel override found. Please generate kernel autoloads first." ) ; } switch ( $ mode ) { case self :: MODE_KERNEL : $ sameRepositoryConflict = $ this -> classExistsInArray ( $ class , $ mode , $ file , $ inProgressAutoloadArray , $ mode ) ; if ( $ sameRepositoryConflict ) { $ addClass = false ; } break ; case self :: MODE_EXTENSION : case self :: MODE_TESTS : case self :: MODE_SINGLE_EXTENSION : $ kernelRepositoryConflict = $ this -> classExistsInArray ( $ class , self :: MODE_KERNEL , $ file , null , $ mode ) ; $ sameRepositoryConflict = $ this -> classExistsInArray ( $ class , $ mode , $ file , $ inProgressAutoloadArray , $ mode ) ; if ( $ kernelRepositoryConflict or $ sameRepositoryConflict ) { $ addClass = false ; } break ; case self :: MODE_KERNEL_OVERRIDE : $ kernelRepositoryConflict = $ this -> classExistsInArray ( $ class , self :: MODE_KERNEL , $ file , $ inProgressAutoloadArray , $ mode ) ; $ sameRepositoryConflict = $ this -> classExistsInArray ( $ class , $ mode , $ file , $ inProgressAutoloadArray , $ mode ) ; if ( ( $ sameRepositoryConflict and ! $ kernelRepositoryConflict ) or ( $ sameRepositoryConflict and $ kernelRepositoryConflict ) or ( ! $ kernelRepositoryConflict and ! $ sameRepositoryConflict ) ) { $ addClass = false ; } break ; } return $ addClass ; }
Determines if a class can be added to the autoload array .
40,527
protected function classExistsInArray ( $ class , $ checkMode , $ file , $ inProgressAutoloadArray = null , $ generatingMode = null ) { if ( ( $ checkMode === $ generatingMode ) and $ inProgressAutoloadArray !== null ) { $ classCollision = array_key_exists ( $ class , $ inProgressAutoloadArray ) ; } else { $ classCollision = array_key_exists ( $ class , $ this -> existingAutoloadArrays [ $ checkMode ] ) ; } if ( $ classCollision ) { $ this -> logIssue ( $ class , $ checkMode , $ file , $ inProgressAutoloadArray , $ generatingMode ) ; return true ; } return false ; }
Internal method used to check if an class exist autoload arrays .
40,528
protected function logIssue ( $ class , $ checkMode , $ file , $ inProgressAutoloadArray , $ generatingMode ) { $ conflictFile = ( $ checkMode === $ generatingMode ) ? $ inProgressAutoloadArray [ $ class ] : $ this -> existingAutoloadArrays [ $ checkMode ] [ $ class ] ; if ( $ generatingMode === self :: MODE_KERNEL_OVERRIDE and $ checkMode === self :: MODE_KERNEL ) { if ( $ inProgressAutoloadArray !== null and array_key_exists ( $ class , $ inProgressAutoloadArray ) ) { return ; } $ message = "Class {$class}" ; $ message .= " in file {$file}" ; $ message .= " will override:\n" ; $ message .= "{$conflictFile} ({$this->targetTable($checkMode)}/{$this->nameTable($checkMode)})" ; $ this -> log ( $ message ) ; } else { $ message = "Class {$class}" ; $ message .= " in file {$file}" ; $ message .= " is already defined in:\n" ; $ message .= "{$conflictFile} ({$this->targetTable($checkMode)}/{$this->nameTable($checkMode)})" ; $ message .= "\nThis class was not added to the autoload array." ; $ this -> logWarning ( $ message ) ; } }
Helper method for giving user feedback when check for class collisions .
40,529
protected function emit ( $ message , $ messageType ) { if ( $ this -> outputCallback === null ) { return ; } call_user_func ( $ this -> outputCallback , $ message , $ messageType ) ; }
Will call output callback if defined .
40,530
public function printAutoloadArray ( $ printForMode = null ) { if ( $ printForMode !== null ) { if ( array_key_exists ( $ printForMode , $ this -> autoloadArrays ) ) { $ this -> log ( $ this -> dumpArrayStart ( $ printForMode ) . $ this -> autoloadArrays [ $ printForMode ] . $ this -> dumpArrayEnd ( ) ) ; } return ; } foreach ( $ this -> autoloadArrays as $ location => $ data ) { $ this -> log ( $ this -> dumpArrayStart ( $ location ) . $ data . $ this -> dumpArrayEnd ( ) ) ; } }
Prints out the generated autoload arrays .
40,531
protected function updateProgressOutput ( $ phase ) { if ( ! $ this -> options -> displayProgress || $ this -> output === null ) { return ; } $ this -> output -> updateProgress ( $ phase ) ; }
Calls updateProgress on the output object .
40,532
protected function incrementProgressStat ( $ phase , $ stat ) { if ( $ this -> output === null ) { return ; } $ statArray = $ this -> output -> getData ( $ phase ) ; $ statArray [ $ stat ] ++ ; $ this -> output -> updateData ( $ phase , $ statArray ) ; }
Increment counters used for statistics in the progress output .
40,533
public function filterRequestUri ( ) { if ( ! empty ( $ this -> versionToken ) ) { $ versionSearch = '/' . $ this -> versionToken ; $ versionPos = strpos ( $ this -> request -> uri , $ versionSearch ) ; if ( $ versionPos !== false ) { $ this -> request -> uri = substr_replace ( $ this -> request -> uri , '' , $ versionPos , strlen ( $ versionSearch ) ) ; } } if ( ! empty ( $ this -> apiProviderToken ) ) { $ providerSearch = '/' . $ this -> apiProviderToken ; $ providerPos = strpos ( $ this -> request -> uri , $ providerSearch ) ; if ( $ providerPos !== false ) { $ this -> request -> uri = substr_replace ( $ this -> request -> uri , '' , $ providerPos , strlen ( $ providerSearch ) ) ; } } }
Filters the URI property of the given ezcMvcRequest object removing any version token from it .
40,534
public static function fetchById ( $ id ) { $ states = self :: fetchByConditions ( array ( "ezcobj_state.id=$id" ) , 1 , 0 ) ; $ state = count ( $ states ) > 0 ? $ states [ 0 ] : false ; return $ state ; }
Fetches a content object state by its numerical ID .
40,535
public static function fetchByIdentifier ( $ identifier , $ groupID ) { $ db = eZDB :: instance ( ) ; $ identifier = $ db -> escapeString ( $ identifier ) ; $ states = self :: fetchByConditions ( array ( "ezcobj_state.identifier='$identifier'" , "ezcobj_state_group.id=$groupID" ) , 1 , 0 ) ; $ state = count ( $ states ) > 0 ? $ states [ 0 ] : false ; return $ state ; }
Fetches a content object state by its identifier and group ID
40,536
private static function fetchByConditions ( $ conditions , $ limit , $ offset ) { $ db = eZDB :: instance ( ) ; $ defaultConditions = array ( 'ezcobj_state.group_id=ezcobj_state_group.id' , 'ezcobj_state_language.contentobject_state_id=ezcobj_state.id' , eZContentLanguage :: languagesSQLFilter ( 'ezcobj_state' ) , eZContentLanguage :: sqlFilter ( 'ezcobj_state_language' , 'ezcobj_state' ) ) ; $ conditions = array_merge ( $ conditions , $ defaultConditions ) ; $ conditionsSQL = implode ( ' AND ' , $ conditions ) ; $ sql = "SELECT ezcobj_state.*, ezcobj_state_language.* " . "FROM ezcobj_state, ezcobj_state_group, ezcobj_state_language " . "WHERE $conditionsSQL " . "ORDER BY ezcobj_state.priority" ; $ rows = $ db -> arrayQuery ( $ sql , array ( 'limit' => $ limit , 'offset' => $ offset ) ) ; $ states = array ( ) ; foreach ( $ rows as $ row ) { $ state = new eZContentObjectState ( $ row ) ; $ stateLanguage = new eZContentObjectStateLanguage ( $ row ) ; $ state -> setLanguageObject ( $ stateLanguage ) ; $ states [ ] = $ state ; } return $ states ; }
Fetches content object states by conditions .
40,537
public static function fetchByGroup ( $ groupID , $ limit = false , $ offset = false ) { return self :: fetchByConditions ( array ( "ezcobj_state_group.id=$groupID" ) , $ limit , $ offset ) ; }
Fetches all content object states of a content object state group
40,538
public function store ( $ fieldFilters = null ) { if ( $ fieldFilters === null ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ languageMask = 1 ; foreach ( $ this -> AllTranslations ( ) as $ translation ) { if ( $ translation -> hasData ( ) ) { $ languageID = $ translation -> attribute ( 'language_id' ) ; if ( empty ( $ this -> DefaultLanguageID ) ) { $ this -> DefaultLanguageID = $ languageID & ~ 1 ; } if ( $ languageID & $ this -> DefaultLanguageID ) { $ translation -> setAttribute ( 'language_id' , $ languageID | 1 ) ; } else if ( $ languageID & 1 ) { $ translation -> setAttribute ( 'language_id' , $ languageID & ~ 1 ) ; } $ languageMask = $ languageMask | $ languageID ; } } $ assignToObjects = false ; if ( ! isset ( $ this -> ID ) ) { $ rows = $ db -> arrayQuery ( "SELECT MAX(priority) AS max_priority FROM ezcobj_state WHERE group_id=" . $ this -> GroupID ) ; if ( count ( $ rows ) > 0 && $ rows [ 0 ] [ 'max_priority' ] !== null ) { $ this -> setAttribute ( 'priority' , $ rows [ 0 ] [ 'max_priority' ] + 1 ) ; } else { $ assignToObjects = true ; } } $ this -> setAttribute ( 'language_mask' , $ languageMask ) ; eZPersistentObject :: storeObject ( $ this , $ fieldFilters ) ; foreach ( $ this -> AllTranslations as $ translation ) { if ( ! $ translation -> hasData ( ) ) { if ( $ translation -> attribute ( 'contentobject_state_id' ) !== null ) { $ translation -> remove ( ) ; } } else { if ( $ translation -> attribute ( 'contentobject_state_id' ) != $ this -> ID ) { $ translation -> setAttribute ( 'contentobject_state_id' , $ this -> ID ) ; } $ translation -> store ( ) ; } } if ( $ assignToObjects ) { $ stateID = $ this -> ID ; $ db -> query ( "INSERT INTO ezcobj_state_link (contentobject_id, contentobject_state_id) SELECT id, $stateID FROM ezcontentobject" ) ; } $ db -> commit ( ) ; } else { parent :: store ( $ fieldFilters ) ; } }
Stores the content object state and its translations .
40,539
public function isValid ( & $ messages = array ( ) ) { $ isValid = true ; if ( ! isset ( $ this -> Identifier ) || $ this -> Identifier == '' ) { $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , 'Identifier: input required' ) ; $ isValid = false ; } else { $ trans = eZCharTransform :: instance ( ) ; $ validIdentifier = $ trans -> transformByGroup ( $ this -> Identifier , 'identifier' ) ; if ( strcmp ( $ validIdentifier , $ this -> Identifier ) != 0 ) { $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , 'Identifier: invalid, it can only consist of characters in the range a-z, 0-9 and underscore.' ) ; $ isValid = false ; } else if ( strlen ( $ this -> Identifier ) > self :: MAX_IDENTIFIER_LENGTH ) { $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , 'Identifier: invalid, maximum %max characters allowed.' , null , array ( '%max' => self :: MAX_IDENTIFIER_LENGTH ) ) ; $ isValid = false ; } else if ( isset ( $ this -> GroupID ) ) { $ existingState = self :: fetchByIdentifier ( $ this -> Identifier , $ this -> GroupID ) ; if ( $ existingState && ( ! isset ( $ this -> ID ) || $ existingState -> attribute ( 'id' ) !== $ this -> ID ) ) { $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , 'Identifier: a content object state group with this identifier already exists, please give another identifier' ) ; $ isValid = false ; } } } $ translationsWithData = 0 ; foreach ( $ this -> AllTranslations as $ translation ) { if ( $ translation -> hasData ( ) ) { $ translationsWithData ++ ; if ( ! $ translation -> isValid ( $ messages ) ) { $ isValid = false ; } } else if ( ( $ translation -> attribute ( 'language_id' ) & ~ 1 ) == $ this -> DefaultLanguageID ) { $ isValid = false ; $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , '%language_name: this language is the default but neither name or description were provided for this language' , null , array ( '%language_name' => $ translation -> attribute ( 'language' ) -> attribute ( 'locale_object' ) -> attribute ( 'intl_language_name' ) ) ) ; } } if ( $ translationsWithData == 0 ) { $ isValid = false ; $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , 'Translations: you need to add at least one localization' ) ; } else if ( empty ( $ this -> DefaultLanguageID ) && $ translationsWithData > 1 ) { $ isValid = false ; $ messages [ ] = ezpI18n :: tr ( 'kernel/state/edit' , 'Translations: there are multiple localizations but you did not specify which is the default one' ) ; } return $ isValid ; }
Checks if all data is valid and can be stored to the database .
40,540
public function fetchHTTPPersistentVariables ( ) { $ translations = $ this -> allTranslations ( ) ; $ http = eZHTTPTool :: instance ( ) ; eZHTTPPersistence :: fetch ( 'ContentObjectState' , eZContentObjectState :: definition ( ) , $ this , $ http , false ) ; eZHTTPPersistence :: fetch ( 'ContentObjectState' , eZContentObjectStateLanguage :: definition ( ) , $ translations , $ http , true ) ; }
Fetches the HTTP persistent variables for this content object state and its localizations .
40,541
public static function removeByID ( $ id ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ db -> query ( "DELETE FROM ezcobj_state_link WHERE contentobject_state_id=$id" ) ; eZPersistentObject :: removeObject ( eZContentObjectStateLanguage :: definition ( ) , array ( 'contentobject_state_id' => $ id ) ) ; eZPersistentObject :: removeObject ( eZContentObjectState :: definition ( ) , array ( 'id' => $ id ) ) ; $ db -> commit ( ) ; }
Removes a content object state by its numerical ID
40,542
function fetchSectionObject ( $ sectionID = false , $ sectionIdentifier = false ) { if ( $ sectionID !== false ) { if ( $ sectionIdentifier !== false ) { $ sectionObject = null ; } else { $ sectionObject = eZSection :: fetch ( $ sectionID ) ; } } else { if ( $ sectionIdentifier === false ) { $ sectionObject = null ; } else { $ sectionObject = eZSection :: fetchByIdentifier ( $ sectionIdentifier ) ; } } if ( $ sectionObject === null ) return array ( 'error' => array ( 'error_type' => 'kernel' , 'error_code' => eZError :: KERNEL_NOT_FOUND ) ) ; return array ( 'result' => $ sectionObject ) ; }
Fetch section object given either section id or section identifier . There should be one and only one parameter .
40,543
protected function getSiteAccessIni ( ) { if ( $ this -> destinationSiteAccessIni === null ) { $ this -> destinationSiteAccessIni = eZSiteAccess :: getIni ( $ this -> destinationSiteAccess , 'site.ini' ) ; } return $ this -> destinationSiteAccessIni ; }
Get instance siteaccess specific site . ini
40,544
protected function isLocaleAvailableAsFallback ( ) { $ currentContentObjectLocale = eZINI :: instance ( ) -> variable ( 'RegionalSettings' , 'ContentObjectLocale' ) ; $ saIni = $ this -> getSiteAccessIni ( ) ; $ siteLanguageList = $ saIni -> variable ( 'RegionalSettings' , 'SiteLanguageList' ) ; return in_array ( $ currentContentObjectLocale , $ siteLanguageList , true ) ; }
Checks if the current content object locale is available in destination siteaccess .
40,545
protected static function addPathPrefixIfNeeded ( $ url ) { $ siteINI = eZINI :: instance ( 'site.ini' ) ; if ( $ siteINI -> hasVariable ( 'SiteAccessSettings' , 'PathPrefix' ) ) { $ pathPrefix = $ siteINI -> variable ( 'SiteAccessSettings' , 'PathPrefix' ) ; if ( ! empty ( $ pathPrefix ) ) { $ url = $ pathPrefix . '/' . $ url ; } } return $ url ; }
Prepend PathPrefix from the current SA to url if applicable
40,546
public function process ( ) { $ saIni = $ this -> getSiteAccessIni ( ) ; $ this -> destinationLocale = $ saIni -> variable ( 'RegionalSettings' , 'ContentObjectLocale' ) ; $ indexFile = trim ( eZSys :: indexFile ( false ) , '/' ) ; switch ( $ GLOBALS [ 'eZCurrentAccess' ] [ 'type' ] ) { case eZSiteAccess :: TYPE_URI : eZURI :: transformURI ( $ host , true , 'full' ) ; break ; default : $ host = $ saIni -> variable ( 'SiteSettings' , 'SiteURL' ) ; $ host = eZSys :: serverProtocol ( ) . "://" . $ host ; break ; } $ this -> baseDestinationUrl = "{$host}{$indexFile}" ; }
This is a hook which is called by the language switcher module on implementation classes .
40,547
public static function setupTranslationSAList ( $ url = null ) { $ ini = eZINI :: instance ( ) ; if ( ! $ ini -> hasVariable ( 'RegionalSettings' , 'TranslationSA' ) ) { return array ( ) ; } $ ret = array ( ) ; $ translationSiteAccesses = $ ini -> variable ( 'RegionalSettings' , 'TranslationSA' ) ; foreach ( $ translationSiteAccesses as $ siteAccessName => $ translationName ) { $ switchLanguageLink = "/switchlanguage/to/{$siteAccessName}/" ; if ( $ url !== null && ( is_string ( $ url ) || is_numeric ( $ url ) ) ) { $ switchLanguageLink .= $ url ; } $ ret [ $ siteAccessName ] = array ( 'url' => $ switchLanguageLink , 'text' => $ translationName , 'locale' => eZSiteAccess :: getIni ( $ siteAccessName ) -> variable ( 'RegionalSettings' , 'ContentObjectLocale' ) ) ; } return $ ret ; }
Creates an array of corresponding language switcher links and logical names .
40,548
static function fetchProductCountByCategory ( $ categoryID ) { $ ini = eZINI :: instance ( 'shop.ini' ) ; if ( ! $ ini -> hasVariable ( 'VATSettings' , 'ProductCategoryAttribute' ) || ! $ categoryAttrName = $ ini -> variable ( 'VATSettings' , 'ProductCategoryAttribute' ) ) return 0 ; $ db = eZDB :: instance ( ) ; $ categoryID = ( int ) $ categoryID ; $ categoryAttrName = $ db -> escapeString ( $ categoryAttrName ) ; $ query = "SELECT COUNT(*) AS count " . " FROM ezcontentobject_attribute coa, ezcontentclass_attribute cca, ezcontentobject co " . "WHERE " . " cca.id=coa.contentclassattribute_id " . " AND coa.contentobject_id=co.id " . " AND cca.data_type_string='ezproductcategory' " . " AND cca.identifier='$categoryAttrName' " . " AND coa.version=co.current_version " . " AND coa.data_int=$categoryID" ; $ rows = $ db -> arrayQuery ( $ query ) ; return $ rows [ 0 ] [ 'count' ] ; }
Returns number of products belonging to the given category .
40,549
static function removeByID ( $ id ) { $ id = ( int ) $ id ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; eZVatRule :: removeReferencesToProductCategory ( $ id ) ; $ ini = eZINI :: instance ( 'shop.ini' ) ; if ( $ ini -> hasVariable ( 'VATSettings' , 'ProductCategoryAttribute' ) && $ categoryAttrName = $ ini -> variable ( 'VATSettings' , 'ProductCategoryAttribute' ) ) { $ categoryAttrName = $ db -> escapeString ( $ categoryAttrName ) ; $ query = "SELECT coa.id FROM ezcontentobject_attribute coa, ezcontentclass_attribute cca, ezcontentobject co " . "WHERE " . " cca.id=coa.contentclassattribute_id " . " AND coa.contentobject_id=co.id " . " AND cca.data_type_string='ezproductcategory' " . " AND cca.identifier='$categoryAttrName' " . " AND coa.version=co.current_version " . " AND coa.data_int=$id" ; $ rows = $ db -> arrayQuery ( $ query ) ; foreach ( $ rows as $ row ) { $ query = "UPDATE ezcontentobject_attribute SET data_int=0, sort_key_int=0 WHERE id=" . ( int ) $ row [ 'id' ] ; $ db -> query ( $ query ) ; } } eZPersistentObject :: removeObject ( eZProductCategory :: definition ( ) , array ( "id" => $ id ) ) ; $ db -> commit ( ) ; }
Remove the given category and all references to it .
40,550
public function store ( eZContentClass $ class , array $ attributes , array & $ unorderedParameters ) { $ oldClassAttributes = $ class -> fetchAttributes ( $ class -> attribute ( 'id' ) , true , eZContentClass :: VERSION_STATUS_DEFINED ) ; foreach ( $ oldClassAttributes as $ oldClassAttribute ) { $ attributeExists = false ; $ oldClassAttributeID = $ oldClassAttribute -> attribute ( 'id' ) ; foreach ( $ class -> fetchAttributes ( ) as $ newClassAttribute ) { if ( $ oldClassAttributeID == $ newClassAttribute -> attribute ( 'id' ) ) { $ attributeExists = true ; break ; } } if ( ! $ attributeExists ) { foreach ( eZContentObjectAttribute :: fetchSameClassAttributeIDList ( $ oldClassAttributeID ) as $ objectAttribute ) { $ objectAttribute -> removeThis ( $ objectAttribute -> attribute ( 'id' ) ) ; } $ oldClassAttribute -> datatype ( ) -> deleteNotVersionedStoredClassAttribute ( $ oldClassAttribute ) ; } } $ class -> storeDefined ( $ attributes ) ; foreach ( $ attributes as $ newClassAttribute ) { $ attributeExists = false ; $ newClassAttributeID = $ newClassAttribute -> attribute ( 'id' ) ; foreach ( $ oldClassAttributes as $ oldClassAttribute ) { if ( $ newClassAttributeID == $ oldClassAttribute -> attribute ( 'id' ) ) { $ attributeExists = true ; break ; } } if ( ! $ attributeExists ) { $ newClassAttribute -> initializeObjectAttributes ( $ objects ) ; } } }
Store the modification made to an eZContentClass .
40,551
function xOffset ( ) { $ xOffset = $ this -> ez [ 'xOffset' ] ; if ( $ xOffset == 0 || $ this -> leftMargin ( ) > $ this -> ez [ 'xOffset' ] ) { $ xOffset = $ this -> leftMargin ( ) ; } return $ xOffset ; }
Get the current X offset
40,552
function callAnchor ( $ info ) { $ paramArray = explode ( ':' , $ info [ 'p' ] ) ; $ this -> addDestination ( $ paramArray [ 0 ] , $ paramArray [ 1 ] , $ this -> yOffset ( ) + $ this -> getFontHeight ( $ this -> fontSize ) ) ; }
Callback function to set anchor
40,553
function callHeader ( $ params ) { $ options = array ( ) ; if ( isset ( $ params [ 'size' ] ) ) { $ options [ 'fontSize' ] = $ params [ 'size' ] ; } if ( isset ( $ params [ 'justification' ] ) ) { $ options [ 'justification' ] = $ params [ 'justification' ] ; } if ( isset ( $ params [ 'fontName' ] ) ) { $ options [ 'fontName' ] = 'lib/ezpdf/classes/fonts/' . $ params [ 'fontName' ] ; } $ this -> addToPreStack ( $ options ) ; $ label = $ params [ 'label' ] ; $ level = $ params [ 'level' ] ; return '<C:callInsertTOC:' . $ label . ',' . $ level . '>' ; }
Callback function to set header
40,554
function callKeyword ( $ info ) { $ keyWord = $ this -> fixWhitespace ( rawurldecode ( $ info [ 'p' ] ) ) ; $ page = $ this -> ezWhatPageNumber ( $ this -> ezGetCurrentPageNumber ( ) ) ; if ( ! isset ( $ this -> KeywordArray [ $ keyWord ] ) ) { $ this -> KeywordArray [ $ keyWord ] = array ( ) ; } if ( ! isset ( $ this -> KeywordArray [ $ keyWord ] [ ( string ) $ page ] ) ) { $ label = $ info [ 'p' ] . ':' . $ page ; $ this -> KeywordArray [ $ keyWord ] [ ( string ) $ page ] = array ( 'label' => $ label ) ; $ this -> addDestination ( 'keyword:' . $ label , 'FitH' , $ this -> yOffset ( ) ) ; } }
function for inserting keyword
40,555
function callInsertTOC ( $ info ) { $ params = explode ( ',' , $ info [ 'p' ] ) ; $ label = $ params [ 0 ] ; $ level = $ params [ 1 ] ; $ tocCount = count ( $ this -> TOC ) ; $ this -> TOC [ ] = array ( 'label' => $ this -> fixWhitespace ( rawurldecode ( $ label ) ) , 'localPageNumber' => $ this -> ezWhatPageNumber ( $ this -> ezGetCurrentPageNumber ( ) ) , 'level' => $ level , 'pageNumber' => $ this -> ezGetCurrentPageNumber ( ) ) ; $ this -> addDestination ( 'toc' . $ tocCount , 'FitH' , $ this -> yOffset ( ) + $ this -> getFontHeight ( $ this -> fontSize ( ) ) ) ; }
function for inserting TOC
40,556
function callTOC ( $ info ) { $ params = array ( ) ; eZPDFTable :: extractParameters ( $ info [ 'p' ] , 0 , $ params , true ) ; $ sizes = isset ( $ params [ 'size' ] ) ? explode ( ',' , $ params [ 'size' ] ) : '' ; $ indents = isset ( $ params [ 'indent' ] ) ? explode ( ',' , $ params [ 'indent' ] ) : '' ; $ dots = isset ( $ params [ 'dots' ] ) ? $ params [ 'dots' ] : '' ; $ contentText = isset ( $ params [ 'contentText' ] ) ? $ params [ 'contentText' ] : ezpI18n :: tr ( 'lib/ezpdf/classes' , 'Contents' , 'Table of contents' ) ; $ this -> insertTOC ( $ sizes , $ indents , $ dots , $ contentText ) ; }
Callback function for inserting TOC
40,557
function callFont ( $ params ) { $ options = array ( ) ; $ keyArray = array ( 'c' , 'm' , 'y' , 'k' ) ; if ( isset ( $ params [ 'cmyk' ] ) ) { $ params [ 'cmyk' ] = explode ( ',' , $ params [ 'cmyk' ] ) ; foreach ( array_keys ( $ params [ 'cmyk' ] ) as $ key ) { $ options [ 'cmyk' ] [ $ keyArray [ $ key ] ] = $ params [ 'cmyk' ] [ $ key ] ; } $ this -> setStrokeColor ( $ params [ 'cmyk' ] ) ; } if ( isset ( $ params [ 'name' ] ) ) { $ options [ 'fontName' ] = 'lib/ezpdf/classes/fonts/' . $ params [ 'name' ] ; } if ( isset ( $ params [ 'size' ] ) ) { $ options [ 'fontSize' ] = $ params [ 'size' ] ; } if ( isset ( $ params [ 'justification' ] ) ) { $ options [ 'justification' ] = $ params [ 'justification' ] ; } $ this -> addToPreStack ( $ options ) ; return '' ; }
Callback function to set font
40,558
function extractFunction ( & $ text , $ offSet , & $ functionName , & $ parameters , $ type = 'ezCall' ) { $ offSet ++ ; $ offSet += strlen ( $ type . ':' ) ; $ funcEnd = strpos ( $ text , ':' , $ offSet ) ; if ( $ funcEnd === false || strpos ( $ text , '>' , $ offSet ) < $ funcEnd ) { $ funcEnd = strpos ( $ text , '>' , $ offSet ) ; } $ functionName = substr ( $ text , $ offSet , $ funcEnd - $ offSet ) ; return eZPDFTable :: extractParameters ( $ text , $ funcEnd , $ parameters ) ; }
Function for extracting function name and parameters from text .
40,559
function outputDocSpecification ( ) { foreach ( array_keys ( $ this -> DocSpecification ) as $ key ) { $ outputElement = & $ this -> DocSpecification [ $ key ] ; $ documentSpec = & $ outputElement [ 'docSpec' ] ; if ( isset ( $ documentSpec [ 'fontName' ] ) ) { $ this -> selectFont ( $ documentSpec [ 'fontName' ] ) ; } if ( isset ( $ documentSpec [ 'fontSize' ] ) ) { $ size = $ documentSpec [ 'fontSize' ] ; } else { $ size = $ this -> fontSize ( ) ; } if ( isset ( $ documentSpec [ 'cmyk' ] ) ) { $ this -> setColor ( $ documentSpec [ 'cmyk' ] ) ; } if ( isset ( $ outputElement [ 'isFunction' ] ) && $ outputElement [ 'isFunction' ] === true ) { $ return = call_user_func_array ( array ( & $ this , $ outputElement [ 'functionName' ] ) , $ outputElement [ 'parameters' ] ) ; } else { $ return = Cezpdf :: ezText ( $ outputElement [ 'text' ] , $ size , array ( 'justification' => $ documentSpec [ 'justification' ] ) ) ; } } return $ return ; }
Loop through all document specification settings and print specified text
40,560
function callText ( $ params ) { $ options = array ( ) ; if ( isset ( $ params [ 'font' ] ) ) { $ options [ 'fontName' ] = 'lib/ezpdf/classes/fonts/' . $ params [ 'font' ] ; } if ( isset ( $ params [ 'size' ] ) ) { $ options [ 'fontSize' ] = $ params [ 'size' ] ; } if ( isset ( $ params [ 'justification' ] ) ) { $ options [ 'justification' ] = $ params [ 'justification' ] ; } if ( isset ( $ params [ 'cmyk' ] ) ) { $ keyArray = array ( 'c' , 'm' , 'y' , 'k' ) ; $ options [ 'cmyk' ] = array ( ) ; $ params [ 'cmyk' ] = explode ( ',' , $ params [ 'cmyk' ] ) ; foreach ( array_keys ( $ params [ 'cmyk' ] ) as $ key ) { $ options [ 'cmyk' ] [ $ keyArray [ $ key ] ] = $ params [ 'cmyk' ] [ $ key ] ; } } $ this -> addToPreStack ( $ options ) ; return '' ; }
Callback function for adding text
40,561
function addDocSpecification ( $ text ) { $ docSpec = array_pop ( $ this -> PreStack ) ; $ this -> DocSpecification [ ] = array ( 'docSpec' => $ docSpec , 'text' => $ text ) ; $ this -> PreStack [ ] = $ docSpec ; }
Function for adding text to doc specification
40,562
function addDocSpecFunction ( $ functionName , $ parameters ) { $ docSpec = array_pop ( $ this -> PreStack ) ; $ this -> DocSpecification [ ] = array ( 'docSpec' => $ docSpec , 'isFunction' => true , 'functionName' => $ functionName , 'parameters' => $ parameters ) ; $ this -> PreStack [ ] = $ docSpec ; }
Function for adding function to doc specification
40,563
function addToPreStack ( $ options = array ( ) ) { $ currentElement = array ( ) ; $ prevElement = array_pop ( $ this -> PreStack ) ; if ( isset ( $ options [ 'justification' ] ) ) { $ currentElement [ 'justification' ] = $ options [ 'justification' ] ; } else { $ currentElement [ 'justification' ] = $ prevElement [ 'justification' ] ; } if ( isset ( $ options [ 'fontSize' ] ) ) { $ currentElement [ 'fontSize' ] = $ options [ 'fontSize' ] ; } else { $ currentElement [ 'fontSize' ] = $ prevElement [ 'fontSize' ] ; } if ( isset ( $ options [ 'fontName' ] ) ) { $ currentElement [ 'fontName' ] = $ options [ 'fontName' ] ; } else { $ currentElement [ 'fontName' ] = $ prevElement [ 'fontName' ] ; } if ( isset ( $ options [ 'cmyk' ] ) ) { $ currentElement [ 'cmyk' ] = $ options [ 'cmyk' ] ; } else { $ currentElement [ 'cmyk' ] = $ prevElement [ 'cmyk' ] ; } $ this -> PreStack [ ] = $ prevElement ; $ this -> PreStack [ ] = $ currentElement ; }
function for adding font specification to PreStack array
40,564
function initialize ( $ currentVersion = null , $ originalContentObjectAttribute = null ) { if ( $ originalContentObjectAttribute === null ) $ originalContentObjectAttribute = $ this ; $ classAttribute = $ this -> contentClassAttribute ( ) ; $ dataType = $ classAttribute -> dataType ( ) ; if ( $ dataType ) $ dataType -> initializeObjectAttribute ( $ this , $ currentVersion , $ originalContentObjectAttribute ) ; }
Initializes the attribute by using the datatype
40,565
function cloneContentObjectAttribute ( $ newVersionNumber , $ currentVersionNumber , $ contentObjectID = false , $ newLanguageCode = false ) { $ tmp = clone $ this ; $ tmp -> setAttribute ( "version" , $ newVersionNumber ) ; if ( $ contentObjectID != false ) { if ( $ contentObjectID != $ tmp -> attribute ( 'contentobject_id' ) ) { $ exAttr = eZPersistentObject :: fetchObject ( eZContentObjectAttribute :: definition ( ) , null , array ( 'contentobject_id' => $ contentObjectID , 'contentclassattribute_id' => $ tmp -> attribute ( 'contentclassattribute_id' ) , 'language_code' => $ tmp -> attribute ( 'language_code' ) ) , true ) ; if ( is_object ( $ exAttr ) ) $ id = $ exAttr -> attribute ( 'id' ) ; else $ id = null ; $ tmp -> setAttribute ( 'id' , $ id ) ; } $ tmp -> setAttribute ( 'contentobject_id' , $ contentObjectID ) ; } else { $ tmp -> setAttribute ( 'language_id' , $ tmp -> attribute ( 'language_id' ) & ~ 1 ) ; } if ( $ newLanguageCode != false && $ tmp -> attribute ( 'language_code' ) != $ newLanguageCode ) { $ exAttr = eZPersistentObject :: fetchObject ( eZContentObjectAttribute :: definition ( ) , null , array ( 'contentobject_id' => $ contentObjectID ? $ contentObjectID : $ tmp -> attribute ( 'contentobject_id' ) , 'contentclassattribute_id' => $ tmp -> attribute ( 'contentclassattribute_id' ) , 'language_code' => $ newLanguageCode ) , true ) ; if ( is_object ( $ exAttr ) ) { $ id = $ exAttr -> attribute ( 'id' ) ; } else { $ id = null ; } $ tmp -> setAttribute ( 'id' , $ id ) ; $ tmp -> setAttribute ( 'language_code' , $ newLanguageCode ) ; $ tmp -> setAttribute ( 'language_id' , eZContentLanguage :: idByLocale ( $ newLanguageCode ) ) ; } $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ tmp -> sync ( ) ; $ tmp -> initialize ( $ currentVersionNumber , $ this ) ; $ tmp -> sync ( ) ; $ tmp -> postInitialize ( $ currentVersionNumber , $ this ) ; $ db -> commit ( ) ; return $ tmp ; }
Clones the attribute to a new version
40,566
function dataType ( ) { $ dataType = null ; if ( $ this -> DataTypeString !== null ) $ dataType = eZDataType :: create ( $ this -> DataTypeString ) ; return $ dataType ; }
Returns the data type class for the current attribute .
40,567
public static function removeRelationsByContentClassAttributeId ( $ attributeId ) { $ id = ( int ) $ attributeId ; $ db = eZDB :: instance ( ) ; $ db -> query ( "DELETE FROM ezcontentobject_link WHERE contentclassattribute_id=$id" ) ; }
Removes all links for a given Class Attribute Id .
40,568
function appendLineParagraph ( $ element , $ newParent ) { eZDebugSetting :: writeDebug ( 'kernel-datatype-ezxmltext' , $ newParent , 'eZSimplifiedXMLInputParser::appendLineParagraph new parent' ) ; $ ret = array ( ) ; $ parent = $ element -> parentNode ; if ( ! $ parent instanceof DOMElement ) { return $ ret ; } $ parentName = $ parent -> nodeName ; $ newParentName = $ newParent != null ? $ newParent -> nodeName : '' ; if ( $ parentName == 'line' || $ this -> XMLSchema -> isInline ( $ parent ) ) { return $ ret ; } if ( $ newParentName == 'line' ) { $ element = $ parent -> removeChild ( $ element ) ; $ newParent -> appendChild ( $ element ) ; $ newLine = $ newParent ; $ ret [ 'result' ] = $ newParent ; } else if ( $ parentName === 'header' && ( $ parent -> getElementsByTagName ( 'line' ) -> length || $ parent -> getElementsByTagName ( 'br' ) -> length ) ) { $ newLine = $ this -> createAndPublishElement ( 'line' , $ ret ) ; $ element = $ parent -> replaceChild ( $ newLine , $ element ) ; $ newLine -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ newLine ; } elseif ( $ parentName == 'paragraph' ) { $ newLine = $ this -> createAndPublishElement ( 'line' , $ ret ) ; $ element = $ parent -> replaceChild ( $ newLine , $ element ) ; $ newLine -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ newLine ; } elseif ( $ newParentName == 'paragraph' ) { $ newLine = $ this -> createAndPublishElement ( 'line' , $ ret ) ; $ element = $ parent -> removeChild ( $ element ) ; $ newParent -> appendChild ( $ newLine ) ; $ newLine -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ newLine ; } elseif ( $ this -> XMLSchema -> check ( $ parent , 'paragraph' ) ) { $ newLine = $ this -> createAndPublishElement ( 'line' , $ ret ) ; $ newPara = $ this -> createAndPublishElement ( 'paragraph' , $ ret ) ; $ element = $ parent -> replaceChild ( $ newPara , $ element ) ; $ newPara -> appendChild ( $ newLine ) ; $ newLine -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ newLine ; } return $ ret ; }
Structure handler for inline nodes .
40,569
function structHandlerCustom ( $ element , & $ params ) { $ ret = null ; if ( $ this -> XMLSchema -> isInline ( $ element ) ) { $ ret = $ this -> appendLineParagraph ( $ element , $ params ) ; } else { $ ret = $ this -> appendParagraph ( $ element , $ params ) ; } return $ ret ; }
Structure handler for custom tag .
40,570
function structHandlerLists ( $ element , & $ params ) { $ ret = array ( ) ; $ parent = $ element -> parentNode ; $ parentName = $ parent -> nodeName ; if ( $ parentName == 'paragraph' ) { return $ ret ; } if ( $ parentName == 'ol' || $ parentName == 'ul' ) { $ prev = $ element -> previousSibling ; if ( ! $ prev ) { $ li = $ this -> Document -> createElement ( 'li' ) ; $ li = $ parent -> insertBefore ( $ li , $ element ) ; $ element = $ parent -> removeChild ( $ element ) ; $ li -> appendChild ( $ element ) ; } else { $ lastChild = $ prev -> lastChild ; if ( $ lastChild -> nodeName != 'paragraph' ) { $ para = $ this -> Document -> createElement ( 'paragraph' ) ; $ element = $ parent -> removeChild ( $ element ) ; $ prev -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ para ; } else { $ element = $ parent -> removeChild ( $ element ) ; $ lastChild -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ lastChild ; } return $ ret ; } } if ( $ parentName == 'li' ) { $ prev = $ element -> previousSibling ; if ( $ prev ) { $ element = $ parent -> removeChild ( $ element ) ; $ prev -> appendChild ( $ element ) ; $ ret [ 'result' ] = $ prev ; return $ ret ; } } $ ret = $ this -> appendParagraph ( $ element , $ params ) ; return $ ret ; }
Structure handler for ul and ol tags .
40,571
function publishHandlerParagraph ( $ element , & $ params ) { $ ret = null ; $ line = $ element -> lastChild ; if ( $ element -> childNodes -> length == 1 && $ line -> nodeName == 'line' ) { $ lineChildren = array ( ) ; $ lineChildNodes = $ line -> childNodes ; foreach ( $ lineChildNodes as $ lineChildNode ) { $ lineChildren [ ] = $ lineChildNode ; } $ line = $ element -> removeChild ( $ line ) ; foreach ( $ lineChildren as $ lineChild ) { $ element -> appendChild ( $ lineChild ) ; } } return $ ret ; }
Publish handler for paragraph element .
40,572
function publishHandlerObject ( $ element , & $ params ) { $ ret = null ; $ objectID = $ element -> getAttribute ( 'id' ) ; if ( $ objectID == $ this -> contentObjectID ) { $ this -> isInputValid = false ; $ this -> Messages [ ] = ezpI18n :: tr ( 'kernel/classes/datatypes' , 'Object %1 can not be embeded to itself.' , false , array ( $ objectID ) ) ; return $ ret ; } if ( ! in_array ( $ objectID , $ this -> relatedObjectIDArray ) ) { $ this -> relatedObjectIDArray [ ] = $ objectID ; } $ href = $ element -> getAttributeNS ( $ this -> Namespaces [ 'image' ] , 'ezurl_href' ) ; $ href = str_replace ( array ( '\'' , '"' ) , array ( '%27' , '%22' ) , $ href ) ; $ urlID = $ element -> getAttributeNS ( $ this -> Namespaces [ 'image' ] , 'ezurl_id' ) ; if ( $ href != null ) { $ urlID = eZURL :: registerURL ( $ href ) ; $ element -> setAttributeNS ( $ this -> Namespaces [ 'image' ] , 'image:ezurl_id' , $ urlID ) ; $ element -> removeAttributeNS ( $ this -> Namespaces [ 'image' ] , 'ezurl_href' ) ; } if ( $ urlID != null ) { $ this -> urlIDArray [ ] = $ urlID ; } $ this -> convertCustomAttributes ( $ element ) ; return $ ret ; }
Publish handler for object element .
40,573
function publishHandlerCustom ( $ element , & $ params ) { $ ret = null ; $ element -> removeAttribute ( 'inline' ) ; $ this -> convertCustomAttributes ( $ element ) ; return $ ret ; }
Publish handler for custom element .
40,574
static function instance ( $ transport = false , $ forceNewInstance = false ) { $ ini = eZINI :: instance ( 'notification.ini' ) ; if ( $ transport == false ) { $ transport = $ ini -> variable ( 'TransportSettings' , 'DefaultTransport' ) ; } $ transportImpl = & $ GLOBALS [ 'eZNotificationTransportGlobalInstance_' . $ transport ] ; $ class = $ transportImpl !== null ? strtolower ( get_class ( $ transportImpl ) ) : '' ; $ fetchInstance = false ; if ( ! preg_match ( '/.*?transport/' , $ class ) ) $ fetchInstance = true ; if ( $ forceNewInstance ) { $ fetchInstance = true ; } if ( $ fetchInstance ) { $ extraPluginPathArray = $ ini -> variable ( 'TransportSettings' , 'TransportPluginPath' ) ; $ pluginPathArray = array_merge ( array ( 'kernel/classes/notification/' ) , $ extraPluginPathArray ) ; foreach ( $ pluginPathArray as $ pluginPath ) { $ transportFile = $ pluginPath . $ transport . 'notificationtransport.php' ; if ( file_exists ( $ transportFile ) ) { include_once ( $ transportFile ) ; $ className = $ transport . 'notificationtransport' ; $ impl = new $ className ( ) ; break ; } } } if ( ! isset ( $ impl ) ) { $ impl = new eZNotificationTransport ( ) ; eZDebug :: writeError ( 'Transport implementation not supported: ' . $ transport , __METHOD__ ) ; } return $ impl ; }
Returns a shared instance of the eZNotificationTransport class .
40,575
public static function isShellExecution ( ) { $ sapiType = php_sapi_name ( ) ; if ( $ sapiType == 'cli' ) return true ; if ( substr ( $ sapiType , 0 , 3 ) == 'cgi' ) { if ( ! self :: serverVariable ( 'HTTP_HOST' , true ) ) return true ; else return false ; } return false ; }
Determines if the current process has been started from the web or the shell
40,576
public static function escapeShellArgument ( $ argument ) { $ escapeChar = self :: instance ( ) -> ShellEscapeCharacter ; if ( $ escapeChar == "'" ) { $ argument = str_replace ( "'" , "'\\''" , $ argument ) ; } else { $ argument = str_replace ( $ escapeChar , "\\" . $ escapeChar , addcslashes ( $ argument , '\\' ) ) ; } return $ escapeChar . $ argument . $ escapeChar ; }
Returns an escaped string to be used as a shell argument
40,577
public static function storageDirectory ( ) { $ ini = eZINI :: instance ( ) ; $ varDir = self :: varDirectory ( ) ; $ storageDir = $ ini -> variable ( 'FileSettings' , 'StorageDir' ) ; return eZDir :: path ( array ( $ varDir , $ storageDir ) ) ; }
Returns the current storage directory
40,578
public static function cacheDirectory ( ) { $ ini = eZINI :: instance ( ) ; $ cacheDir = $ ini -> variable ( 'FileSettings' , 'CacheDir' ) ; if ( $ cacheDir [ 0 ] == "/" ) { return eZDir :: path ( array ( $ cacheDir ) ) ; } else { return eZDir :: path ( array ( self :: varDirectory ( ) , $ cacheDir ) ) ; } }
Returns the current cache directory .
40,579
public static function rootDir ( ) { $ instance = self :: instance ( ) ; if ( ! $ instance -> RootDir ) { $ cwd = getcwd ( ) ; $ self = $ instance -> serverVariable ( 'PHP_SELF' ) ; if ( file_exists ( $ cwd . $ instance -> FileSeparator . $ self ) or file_exists ( $ cwd . $ instance -> FileSeparator . $ instance -> IndexFile ) ) { $ instance -> RootDir = $ cwd ; } else { $ instance -> RootDir = null ; } } return $ instance -> RootDir ; }
Returns the absolute path to the eZ Publish root directory
40,580
public static function indexFile ( $ withAccessPath = true ) { $ sys = self :: instance ( ) ; $ text = $ sys -> IndexFile ; if ( $ withAccessPath && ( isset ( $ sys -> AccessPath [ 'siteaccess' ] [ 'url' ] [ 0 ] ) || isset ( $ sys -> AccessPath [ 'path' ] [ 'url' ] [ 0 ] ) ) ) { $ ini = eZINI :: instance ( ) ; if ( isset ( $ sys -> AccessPath [ 'siteaccess' ] [ 'url' ] [ 0 ] ) && $ ini -> variable ( 'SiteAccessSettings' , 'RemoveSiteAccessIfDefaultAccess' ) === 'enabled' ) { $ defaultAccess = $ ini -> variable ( 'SiteSettings' , 'DefaultAccess' ) ; if ( $ sys -> AccessPath [ 'siteaccess' ] [ 'name' ] === $ defaultAccess ) $ accessPath = implode ( '/' , $ sys -> AccessPath [ 'path' ] [ 'url' ] ) ; elseif ( $ sys -> AccessPath [ 'siteaccess' ] [ 'name' ] === 'undefined' && $ sys -> AccessPath [ 'siteaccess' ] [ 'url' ] [ 0 ] === $ defaultAccess ) { $ accessPathArray = $ sys -> AccessPath ; array_shift ( $ accessPathArray [ 'siteaccess' ] [ 'url' ] ) ; $ accessPath = implode ( '/' , array_merge ( $ accessPathArray [ 'siteaccess' ] [ 'url' ] , $ accessPathArray [ 'path' ] [ 'url' ] ) ) ; } else $ accessPath = implode ( '/' , array_merge ( $ sys -> AccessPath [ 'siteaccess' ] [ 'url' ] , $ sys -> AccessPath [ 'path' ] [ 'url' ] ) ) ; } else { $ accessPath = implode ( '/' , array_merge ( $ sys -> AccessPath [ 'siteaccess' ] [ 'url' ] , $ sys -> AccessPath [ 'path' ] [ 'url' ] ) ) ; } $ text .= '/' . $ accessPath ; if ( $ text === '/' ) $ text = '' ; } return $ text ; }
Returns the filepath for the index file with the access path appended
40,581
public static function hostname ( ) { $ hostName = null ; $ forwardedHostsString = self :: serverVariable ( 'HTTP_X_FORWARDED_HOST' , true ) ; if ( $ forwardedHostsString ) { $ forwardedHosts = explode ( ',' , $ forwardedHostsString ) ; $ hostName = trim ( $ forwardedHosts [ 0 ] ) ; } if ( ! $ hostName && self :: serverVariable ( 'HTTP_HOST' , true ) ) { $ hostName = self :: serverVariable ( 'HTTP_HOST' ) ; } if ( ! $ hostName ) { $ siteUrl = eZINI :: instance ( ) -> variable ( 'SiteSettings' , 'SiteURL' ) ; $ hostName = parse_url ( "http://{$siteUrl}" , PHP_URL_HOST ) ; } return $ hostName ; }
Returns the current hostname .
40,582
public static function clientIP ( ) { $ customHTTPHeader = eZINI :: instance ( ) -> variable ( 'HTTPHeaderSettings' , 'ClientIpByCustomHTTPHeader' ) ; if ( $ customHTTPHeader && $ customHTTPHeader != 'false' ) { $ phpHeader = 'HTTP_' . str_replace ( '-' , '_' , strtoupper ( $ customHTTPHeader ) ) ; $ forwardedClientsString = eZSys :: serverVariable ( $ phpHeader , true ) ; if ( $ forwardedClientsString ) { $ forwardedClients = explode ( ',' , $ forwardedClientsString ) ; if ( ! empty ( $ forwardedClients ) ) { return trim ( $ forwardedClients [ 0 ] ) ; } } } return self :: serverVariable ( 'REMOTE_ADDR' , true ) ; }
Returns the client IP whether he s behind a proxy or not
40,583
public static function isSSLNow ( ) { $ ini = eZINI :: instance ( ) ; $ sslPort = $ ini -> variable ( 'SiteSettings' , 'SSLPort' ) ; if ( ! $ sslPort ) $ sslPort = eZSSLZone :: DEFAULT_SSL_PORT ; $ nowSSL = ( self :: serverPort ( ) == $ sslPort ) ; if ( ! $ nowSSL ) { if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) ) { $ nowSSL = ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] == 'https' ) ; } else if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ) ) { $ sslPort = $ ini -> variable ( 'SiteSettings' , 'SSLPort' ) ; $ nowSSL = ( $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] == $ sslPort ) ; } else if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_SERVER' ] ) ) { $ sslProxyServerName = $ ini -> variable ( 'SiteSettings' , 'SSLProxyServerName' ) ; $ nowSSL = ( $ sslProxyServerName == $ _SERVER [ 'HTTP_X_FORWARDED_SERVER' ] ) ; } } return $ nowSSL ; }
Determines if SSL is enabled and protocol HTTPS is used .
40,584
public static function serverPort ( ) { if ( empty ( $ GLOBALS [ 'eZSysServerPort' ] ) ) { $ hostname = self :: hostname ( ) ; if ( preg_match ( "/.*:([0-9]+)/" , $ hostname , $ regs ) ) { $ port = ( int ) $ regs [ 1 ] ; } else { $ port = ( int ) self :: serverVariable ( 'SERVER_PORT' , true ) ; } if ( ! $ port ) { $ port = 80 ; } $ GLOBALS [ 'eZSysServerPort' ] = $ port ; } return $ GLOBALS [ 'eZSysServerPort' ] ; }
Returns the server port or 80 as default if the server port can not be retrieved from the hostname or the server variable SERVER_PORT
40,585
public static function environmentVariable ( $ variableName , $ quiet = false ) { if ( getenv ( $ variableName ) === false ) { if ( ! $ quiet ) { eZDebug :: writeError ( "Environment variable '$variableName' does not exist" , __METHOD__ ) ; } return null ; } return getenv ( $ variableName ) ; }
Returns an environment variable or null if it is not available
40,586
protected static function getValidwwwDir ( $ phpSelf , $ scriptFileName , $ index ) { if ( ! isset ( $ phpSelf [ 1 ] ) || empty ( $ index ) || strpos ( $ phpSelf , $ index ) === false ) return false ; if ( strpos ( $ scriptFileName , $ index ) === false ) return null ; if ( $ phpSelf === "/{$index}" ) return '' ; $ phpSelfParts = explode ( $ index , $ phpSelf ) ; $ validateDir = $ phpSelfParts [ 0 ] ; if ( $ phpSelf [ 1 ] === '~' ) { $ uri = explode ( '/' , ltrim ( $ validateDir , '/' ) ) ; $ userName = ltrim ( array_shift ( $ uri ) , "~" ) ; if ( ! strpos ( $ scriptFileName , $ userName . "/" ) ) { return null ; } $ validateDir = '/' . implode ( '/' , $ uri ) ; } if ( ! empty ( $ validateDir ) ) { if ( strpos ( $ scriptFileName , $ validateDir ) !== false ) return trim ( $ phpSelfParts [ 0 ] , '/' ) ; if ( strpos ( $ scriptFileName , str_replace ( '/' , '\\' , $ validateDir ) ) !== false ) return trim ( $ phpSelfParts [ 0 ] , '/' ) ; } return null ; }
Generate wwwdir from phpSelf if valid accoring to scriptFileName and return null if invalid and false if there is no index in phpSelf
40,587
public static function ezcrc32 ( $ string ) { $ ini = eZINI :: instance ( ) ; if ( $ ini -> variable ( 'SiteSettings' , '64bitCompatibilityMode' ) === 'enabled' ) $ checksum = sprintf ( '%u' , crc32 ( $ string ) ) ; else $ checksum = crc32 ( $ string ) ; return $ checksum ; }
A wrapper for PHP s crc32 function . Returns the crc32 polynomial as unsigned int
40,588
public static function protocolSchema ( ) { $ schema = '' ; if ( preg_match ( "#^([a-zA-Z]+)/.*$#" , self :: serverVariable ( 'SERVER_PROTOCOL' ) , $ schemaMatches ) ) { $ schema = strtolower ( $ schemaMatches [ 1 ] ) . '://' ; } return $ schema ; }
Returns the schema of the request .
40,589
protected static function simulateGlobBrace ( $ filenames ) { $ result = array ( ) ; foreach ( $ filenames as $ filename ) { if ( strpos ( $ filename , '{' ) === false ) { $ result [ ] = $ filename ; continue ; } if ( preg_match ( '/^(.*)\{(.*?)(?<!\\\\)\}(.*)$/' , $ filename , $ match ) ) { $ variants = preg_split ( '/(?<!\\\\),/' , $ match [ 2 ] ) ; $ newFilenames = array ( ) ; foreach ( $ variants as $ variant ) { $ newFilenames [ ] = $ match [ 1 ] . $ variant . $ match [ 3 ] ; } $ newFilenames = self :: simulateGlobBrace ( $ newFilenames ) ; $ result = array_merge ( $ result , $ newFilenames ) ; } else { $ result [ ] = $ filename ; } } return $ result ; }
Expands a list of filenames like GLOB_BRACE does .
40,590
public function __isset ( $ key ) { return ( array_key_exists ( $ key , $ this -> properties ) || isset ( $ this -> storageOptions -> $ key ) ) ; }
Returns if a option exists .
40,591
public function finishPhase2 ( ) { $ this -> tokenizerProgress -> finish ( ) ; $ this -> output -> outputLine ( ) ; $ this -> output -> outputLine ( ) ; }
Finishes progress output for class search phase .
40,592
private static function getHandler ( array $ args ) { if ( ! isset ( $ args [ 0 ] ) ) { throw new InvalidArgumentException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Unable to find the identifier of ajax upload handler' ) ) ; } $ http = eZHTTPTool :: instance ( ) ; $ handlerData = $ http -> postVariable ( 'AjaxUploadHandlerData' , array ( ) ) ; $ handlerOptions = new ezpExtensionOptions ( ) ; $ handlerOptions -> iniFile = 'ezjscore.ini' ; $ handlerOptions -> iniSection = 'AjaxUploader' ; $ handlerOptions -> iniVariable = 'AjaxUploadHandler' ; $ handlerOptions -> handlerIndex = $ args [ 0 ] ; $ handlerOptions -> handlerParams = $ handlerData ; $ handler = eZExtension :: getHandlerClass ( $ handlerOptions ) ; if ( ! $ handler instanceof ezpAjaxUploaderHandlerInterface ) { throw new InvalidArgumentException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Unable to load the ajax upload handler' ) ) ; } return $ handler ; }
Returns an ajaxuploader handler instance from the ezjscore function arguments .
40,593
static function uploadForm ( $ args ) { $ handler = self :: getHandler ( $ args ) ; if ( ! $ handler -> canUpload ( ) ) { throw new RuntimeException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'You are not allowed to upload a file.' ) ) ; } $ tpl = eZTemplate :: factory ( ) ; return array ( 'meta_data' => false , 'html' => $ tpl -> fetch ( 'design:ajaxuploader/upload.tpl' ) ) ; }
Returns the upload form
40,594
static function upload ( $ args ) { try { $ handler = self :: getHandler ( $ args ) ; $ fileInfo = $ handler -> getFileinfo ( ) ; $ mimeData = $ fileInfo [ 'mime' ] ; $ file = $ fileInfo [ 'file' ] ; $ class = $ handler -> getContentClass ( $ mimeData ) ; if ( $ file -> store ( false , $ mimeData [ 'suffix' ] ) === false ) { throw new RuntimeException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Unable to store the uploaded file.' ) ) ; } else { $ fileHandler = eZClusterFileHandler :: instance ( ) ; $ fileHandler -> fileStore ( $ file -> attribute ( 'filename' ) , 'tmp' , true , $ file -> attribute ( 'mime_type' ) ) ; } $ start = $ handler -> getDefaultParentNodeId ( $ class ) ; $ defaultParentNode = eZContentObjectTreeNode :: fetch ( $ start ) ; if ( ! $ defaultParentNode instanceof eZContentObjectTreeNode ) { throw new RuntimeException ( ezpI18n :: tr ( "extension/ezjscore/ajaxuploader" , "The default parent location for uploads cannot be retrieved! Check user permissions and correctness of settings." ) ) ; } } catch ( Exception $ e ) { return json_encode ( array ( 'error_text' => $ e -> getMessage ( ) , 'content' => '' ) ) ; } $ browseItems = self :: getBrowseItems ( $ defaultParentNode -> attribute ( 'parent' ) , $ class ) ; $ http = eZHTTPTool :: instance ( ) ; $ tpl = eZTemplate :: factory ( ) ; $ tpl -> setVariable ( 'file' , $ file ) ; $ tpl -> setVariable ( 'name' , $ http -> postVariable ( 'UploadName' , $ file -> attribute ( 'original_filename' ) ) ) ; $ tpl -> setVariable ( 'mime_data' , $ mimeData ) ; $ tpl -> setVariable ( 'class' , $ class ) ; $ tpl -> setVariable ( 'browse_start' , $ defaultParentNode -> attribute ( 'parent' ) ) ; $ tpl -> setVariable ( 'default_parent_node' , $ defaultParentNode ) ; $ tpl -> setVariable ( 'browse' , $ browseItems ) ; return json_encode ( array ( 'meta_data' => false , 'html' => rawurlencode ( $ tpl -> fetch ( 'design:ajaxuploader/location.tpl' ) ) ) ) ; }
Stores the uploaded file and returns the location form . The result of this method is always json encoded .
40,595
static function browse ( $ args ) { if ( count ( $ args ) < 2 ) { throw new InvalidArgumentException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Arguments error.' ) ) ; } list ( $ nodeID , $ classId ) = $ args ; $ offset = 0 ; if ( isset ( $ args [ 2 ] ) ) { $ offset = ( int ) $ args [ 2 ] ; } $ node = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; $ class = eZContentClass :: fetch ( $ classId ) ; if ( ! $ node instanceof eZContentObjectTreeNode || ! $ class instanceof eZContentClass ) { throw new InvalidArgumentException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Arguments error.' ) ) ; } else if ( ! $ node -> canRead ( ) ) { throw new InvalidArgumentException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Arguments error.' ) ) ; } $ browseItems = self :: getBrowseItems ( $ node , $ class , $ offset ) ; $ tpl = eZTemplate :: factory ( ) ; $ tpl -> setVariable ( 'browse' , $ browseItems ) ; $ tpl -> setVariable ( 'browse_start' , $ node ) ; $ tpl -> setVariable ( 'default_parent_node' , array ( 'node_id' => 0 ) ) ; $ tpl -> setVariable ( 'class' , $ class ) ; return array ( 'meta_data' => false , 'html' => $ tpl -> fetch ( 'design:ajaxuploader/browse.tpl' ) ) ; }
Browse AJAX action
40,596
static function preview ( $ args ) { $ http = eZHTTPTool :: instance ( ) ; $ handler = self :: getHandler ( $ args ) ; if ( ! $ handler -> canUpload ( ) ) { throw new RuntimeException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'You are not allowed to upload a file.' ) ) ; } $ file = $ http -> postVariable ( 'UploadFile' , false ) ; $ fileHandler = eZClusterFileHandler :: instance ( ) ; if ( $ file === false || ! $ fileHandler -> fileExists ( $ file ) || ! $ fileHandler -> fileFetch ( $ file ) ) { throw new RuntimeException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Unable to retrieve the uploaded file.' ) ) ; } else { $ tmpFile = eZSys :: cacheDirectory ( ) . '/' . eZINI :: instance ( ) -> variable ( 'FileSettings' , 'TemporaryDir' ) . '/' . str_replace ( array ( '/' , '\\' ) , '_' , $ http -> postVariable ( 'UploadOriginalFilename' ) ) ; eZFile :: rename ( $ file , $ tmpFile , true ) ; $ fileHandler -> fileDelete ( $ file ) ; $ fileHandler -> fileDeleteLocal ( $ file ) ; } $ contentObject = $ handler -> createObject ( $ tmpFile , $ http -> postVariable ( 'UploadLocation' , false ) , $ http -> postVariable ( 'UploadName' , '' ) ) ; unlink ( $ tmpFile ) ; $ tpl = eZTemplate :: factory ( ) ; $ tpl -> setVariable ( 'object' , $ contentObject ) ; return array ( 'meta_data' => $ handler -> serializeObject ( $ contentObject ) , 'html' => $ tpl -> fetch ( 'design:ajaxuploader/preview.tpl' ) ) ; }
Creates the object from the uploaded file and displays the preview of it
40,597
static function registerURL ( $ url ) { $ urlID = null ; $ urlObject = self :: fetchByUrl ( $ url ) ; if ( ! $ urlObject instanceof eZURL ) { $ urlObject = self :: create ( $ url ) ; $ urlObject -> store ( ) ; $ urlID = $ urlObject -> attribute ( 'id' ) ; } else { if ( $ urlObject -> attribute ( 'url' ) !== $ url ) { $ urlObject -> setAttribute ( 'url' , $ url ) ; $ urlObject -> setAttribute ( 'original_url_md5' , md5 ( $ url ) ) ; $ urlObject -> setAttribute ( 'modified' , time ( ) ) ; $ urlObject -> store ( array ( 'url' , 'original_url_md5' , 'modified' ) ) ; } $ urlID = $ urlObject -> attribute ( 'id' ) ; } return $ urlID ; }
Registers an URL to the URL database and returns the URL id . If URL is already present the method will check the checksum and update the URL if needed
40,598
public static function fetchByUrl ( $ url , $ asObject = true ) { return parent :: fetchObject ( self :: definition ( ) , null , array ( 'url' => $ url ) , $ asObject ) ; }
Fetches an URL object from an url string
40,599
static public function getToken ( ) { if ( self :: $ token === null ) { self :: $ token = sha1 ( self :: getSecret ( ) . self :: getIntention ( ) . session_id ( ) ) ; } return self :: $ token ; }
Gets the user token from session if it exists or create + store it in session .