idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
40,200 | public static function getFilter ( ) { $ mobileDeviceFilterClass = eZINI :: instance ( ) -> variable ( 'SiteAccessSettings' , 'MobileDeviceFilterClass' ) ; $ mobileDeviceDetectFilter = class_exists ( $ mobileDeviceFilterClass ) ? new $ mobileDeviceFilterClass : null ; if ( $ mobileDeviceDetectFilter instanceof ezpMobileDeviceDetectFilterInterface ) return $ mobileDeviceDetectFilter ; return null ; } | Returns an instance of the ezpMobileDeviceDetectFilterInterface class |
40,201 | static function create ( $ productCollectionItemID , $ optionItemID , $ optionName , $ optionValue , $ optionPrice , $ attributeID ) { $ row = array ( 'item_id' => $ productCollectionItemID , 'option_item_id' => $ optionItemID , 'name' => $ optionName , 'value' => $ optionValue , 'price' => $ optionPrice , 'object_attribute_id' => $ attributeID ) ; return new eZProductCollectionItemOption ( $ row ) ; } | Creates an eZProductCollectionItem |
40,202 | static function fetchList ( $ productCollectionItemID , $ asObject = true ) { return eZPersistentObject :: fetchObjectList ( eZProductCollectionItemOption :: definition ( ) , null , array ( "item_id" => $ productCollectionItemID ) , array ( "id" => "ASC" ) , null , $ asObject ) ; } | Fetches eZProductCollectionItemOption items that match the given item ID sorted by ascending order of option ID |
40,203 | static function cleanupList ( $ itemIDList ) { $ db = eZDB :: instance ( ) ; $ inText = $ db -> generateSQLINStatement ( $ itemIDList , 'item_id' , false , false , 'int' ) ; $ db -> query ( $ q = "DELETE FROM ezproductcollection_item_opt WHERE $inText" ) ; } | Removes all product collections options which are related to the collection items specified in the parameter array |
40,204 | public function redirect ( ) { $ http = eZHTTPTool :: instance ( ) ; $ currentSiteAccess = eZSiteAccess :: current ( ) ; if ( $ http -> hasGetVariable ( 'notmobile' ) ) { setcookie ( 'eZMobileDeviceDetect' , 1 , time ( ) + ( int ) eZINI :: instance ( ) -> variable ( 'SiteAccessSettings' , 'MobileDeviceDetectCookieTimeout' ) , '/' ) ; $ http -> redirect ( eZSys :: indexDir ( ) ) ; eZExecution :: cleanExit ( ) ; } if ( ! isset ( $ _COOKIE [ 'eZMobileDeviceDetect' ] ) && ! in_array ( $ currentSiteAccess [ 'name' ] , eZINI :: instance ( ) -> variable ( 'SiteAccessSettings' , 'MobileSiteAccessList' ) ) ) { $ currentUrl = eZSys :: serverURL ( ) . eZSys :: requestURI ( ) ; $ redirectUrl = eZINI :: instance ( ) -> variable ( 'SiteAccessSettings' , 'MobileSiteAccessURL' ) ; if ( strpos ( $ currentUrl , $ redirectUrl ) !== 0 ) { $ uri = explode ( '/' , ltrim ( eZSys :: requestURI ( ) , '/' ) ) ; if ( array_shift ( $ uri ) == $ currentSiteAccess [ 'name' ] ) { $ http -> redirect ( $ redirectUrl . '/' . implode ( '/' , $ uri ) . eZSys :: queryString ( ) ) ; } else { $ http -> redirect ( $ redirectUrl . eZSys :: requestURI ( ) . eZSys :: queryString ( ) ) ; } } eZExecution :: cleanExit ( ) ; } } | Handles redirection to the mobile optimized interface |
40,205 | public static function fromNode ( eZContentObjectTreeNode $ node , $ checkAccess = true ) { $ object = $ node -> object ( ) ; if ( $ checkAccess && ! $ object -> attribute ( 'can_read' ) ) { throw new ezpContentAccessDeniedException ( $ object -> attribute ( 'id' ) ) ; } $ content = new ezpContent ( ) ; $ content -> fields = ezpContentFieldSet :: fromContentObject ( $ object ) ; $ content -> object = $ object ; $ content -> locations = ezpContentLocation :: fromNode ( $ node ) ; return $ content ; } | Instanciates an ezpContent from an eZContentObjectTreeNode |
40,206 | public static function fromNodeId ( $ nodeId , $ checkAccess = true ) { $ node = eZContentObjectTreeNode :: fetch ( $ nodeId ) ; if ( $ node instanceof eZContentObjectTreeNode ) return self :: fromNode ( $ node , $ checkAccess ) ; else throw new ezpContentNotFoundException ( "Unable to find node with ID $nodeId" ) ; } | Instanciates an ezpContent from an eZContentObjectTreenode Id |
40,207 | public static function fromObjectId ( $ objectId , $ checkAccess = true ) { $ object = eZContentObject :: fetch ( $ objectId ) ; if ( $ object instanceof eZContentObject ) return self :: fromObject ( $ object , $ checkAccess ) ; else throw new ezpContentNotFoundException ( "Unable to find an eZContentObject with ID $objectId" ) ; } | Instanciates an ezpContent from an eZContentObject Id |
40,208 | public static function fromObject ( eZContentObject $ object , $ checkAccess = true ) { if ( $ checkAccess && ! $ object -> attribute ( 'can_read' ) ) { throw new ezpContentAccessDeniedException ( $ object -> attribute ( 'id' ) ) ; } $ content = new ezpContent ( ) ; $ content -> fields = ezpContentFieldSet :: fromContentObject ( $ object ) ; $ content -> object = $ object ; return $ content ; } | Instanciates an ezpContent from an eZContentObject |
40,209 | public function run ( ) { $ redirects = 0 ; $ requestParser = $ this -> getRequestParser ( ) ; $ request = $ requestParser -> createRequest ( ) ; do { $ this -> checkRedirectLimit ( $ redirects ) ; $ continue = false ; $ this -> configuration -> runPreRoutingFilters ( $ request ) ; $ router = $ this -> getRouter ( $ request ) ; try { $ routingInformation = $ router -> getRoutingInformation ( ) ; } catch ( ezcMvcRouteNotFoundException $ e ) { $ request = $ this -> getFatalRedirectRequest ( $ request , new ezcMvcResult , $ e ) ; $ continue = true ; continue ; } catch ( ezpRouteMethodNotAllowedException $ e ) { $ request = $ this -> getFatalRedirectRequest ( $ request , new ezcMvcResult , $ e ) ; $ continue = true ; continue ; } $ filterResult = $ this -> configuration -> runRequestFilters ( $ routingInformation , $ request ) ; if ( $ filterResult instanceof ezcMvcInternalRedirect ) { $ request = $ filterResult -> request ; $ continue = true ; continue ; } $ controller = $ this -> getController ( $ routingInformation , $ request ) ; try { $ result = $ controller -> createResult ( ) ; } catch ( Exception $ e ) { $ request = $ this -> getFatalRedirectRequest ( $ request , new ezcMvcResult , $ e ) ; $ continue = true ; continue ; } if ( $ result instanceof ezcMvcInternalRedirect ) { $ request = $ result -> request ; $ continue = true ; continue ; } if ( ! $ result instanceof ezcMvcResult ) { throw new ezcMvcControllerException ( "The action '{$routingInformation->action}' of controller '{$routingInformation->controllerClass}' did not return an ezcMvcResult object." ) ; } $ this -> configuration -> runResultFilters ( $ routingInformation , $ request , $ result ) ; if ( $ result -> status !== 0 ) { $ response = new ezcMvcResponse ; $ response -> status = $ result -> status ; } else { $ view = $ this -> getView ( $ routingInformation , $ request , $ result ) ; try { $ response = $ view -> createResponse ( ) ; } catch ( Exception $ e ) { $ request = $ this -> getFatalRedirectRequest ( $ request , $ result , $ e ) ; $ continue = true ; continue ; } } $ this -> configuration -> runResponseFilters ( $ routingInformation , $ request , $ result , $ response ) ; $ responseWriter = $ this -> getResponseWriter ( $ routingInformation , $ request , $ result , $ response ) ; $ responseWriter -> handleResponse ( ) ; } while ( $ continue ) ; } | Runs through the request by using the configuration to obtain correct handlers . |
40,210 | static public function resetNodeassignmentOpcodes ( $ objectID , $ versionNum ) { $ object = eZContentObject :: fetch ( $ objectID ) ; $ version = $ object -> version ( $ versionNum ) ; $ nodeAssignments = $ version -> attribute ( 'node_assignments' ) ; foreach ( $ nodeAssignments as $ nodeAssignment ) { if ( ( $ nodeAssignment -> attribute ( 'op_code' ) & 1 ) == eZNodeAssignment :: OP_CODE_EXECUTE ) { $ nodeAssignment -> setAttribute ( 'op_code' , ( $ nodeAssignment -> attribute ( 'op_code' ) & ~ 1 ) ) ; $ nodeAssignment -> store ( ) ; } } } | New function which resets the op_code field when the object is published . |
40,211 | static public function registerSearchObject ( $ objectID , $ version = null , $ isMoved = false ) { $ objectID = ( int ) $ objectID ; eZDebug :: createAccumulatorGroup ( 'search_total' , 'Search Total' ) ; $ ini = eZINI :: instance ( 'site.ini' ) ; $ insertPendingAction = false ; $ object = null ; switch ( $ ini -> variable ( 'SearchSettings' , 'DelayedIndexing' ) ) { case 'enabled' : $ insertPendingAction = true ; break ; case 'classbased' : $ classList = $ ini -> variable ( 'SearchSettings' , 'DelayedIndexingClassList' ) ; $ object = eZContentObject :: fetch ( $ objectID ) ; if ( is_array ( $ classList ) && in_array ( $ object -> attribute ( 'class_identifier' ) , $ classList ) ) { $ insertPendingAction = true ; } } if ( $ insertPendingAction ) { $ action = $ isMoved ? 'index_moved_node' : 'index_object' ; eZDB :: instance ( ) -> query ( "INSERT INTO ezpending_actions( action, param ) VALUES ( '$action', '$objectID' )" ) ; return ; } if ( $ object === null ) $ object = eZContentObject :: fetch ( $ objectID ) ; $ needCommit = eZSearch :: needCommit ( ) ; if ( eZSearch :: needRemoveWithUpdate ( ) ) { eZDebug :: accumulatorStart ( 'remove_object' , 'search_total' , 'remove object' ) ; eZSearch :: removeObjectById ( $ objectID ) ; eZDebug :: accumulatorStop ( 'remove_object' ) ; } eZDebug :: accumulatorStart ( 'add_object' , 'search_total' , 'add object' ) ; if ( ! eZSearch :: addObject ( $ object , $ needCommit ) ) { eZDebug :: writeError ( "Failed adding object ID {$object->attribute( 'id' )} in the search engine" , __METHOD__ ) ; } eZDebug :: accumulatorStop ( 'add_object' ) ; } | Registers the object in search engine . |
40,212 | static public function moveNode ( $ nodeID , $ objectID , $ newParentNodeID ) { if ( ! eZContentObjectTreeNodeOperations :: move ( $ nodeID , $ newParentNodeID ) ) { eZDebug :: writeError ( "Failed to move node $nodeID as child of parent node $newParentNodeID" , __METHOD__ ) ; return array ( 'status' => false ) ; } eZContentObject :: fixReverseRelations ( $ objectID , 'move' ) ; if ( ! eZSearch :: getEngine ( ) instanceof eZSearchEngine ) { eZContentOperationCollection :: registerSearchObject ( $ objectID ) ; } return array ( 'status' => true ) ; } | Moves a node |
40,213 | static public function addAssignment ( $ nodeID , $ objectID , $ selectedNodeIDArray ) { $ userClassIDArray = eZUser :: contentClassIDs ( ) ; $ object = eZContentObject :: fetch ( $ objectID ) ; $ class = $ object -> contentClass ( ) ; $ nodeAssignmentList = eZNodeAssignment :: fetchForObject ( $ objectID , $ object -> attribute ( 'current_version' ) , 0 , false ) ; $ assignedNodes = $ object -> assignedNodes ( ) ; $ parentNodeIDArray = array ( ) ; foreach ( $ assignedNodes as $ assignedNode ) { $ append = false ; foreach ( $ nodeAssignmentList as $ nodeAssignment ) { if ( $ nodeAssignment [ 'parent_node' ] == $ assignedNode -> attribute ( 'parent_node_id' ) ) { $ append = true ; break ; } } if ( $ append ) { $ parentNodeIDArray [ ] = $ assignedNode -> attribute ( 'parent_node_id' ) ; } } $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ locationAdded = false ; $ node = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; foreach ( $ selectedNodeIDArray as $ selectedNodeID ) { if ( ! in_array ( $ selectedNodeID , $ parentNodeIDArray ) ) { $ parentNode = eZContentObjectTreeNode :: fetch ( $ selectedNodeID ) ; $ parentNodeObject = $ parentNode -> attribute ( 'object' ) ; $ canCreate = ( ( $ parentNode -> checkAccess ( 'create' , $ class -> attribute ( 'id' ) , $ parentNodeObject -> attribute ( 'contentclass_id' ) ) == 1 ) || ( $ parentNode -> canAddLocation ( ) && $ node -> canRead ( ) ) ) ; if ( $ canCreate ) { $ insertedNode = $ object -> addLocation ( $ selectedNodeID , true ) ; $ insertedNode -> setAttribute ( 'contentobject_is_published' , 1 ) ; $ insertedNode -> setAttribute ( 'main_node_id' , $ node -> attribute ( 'main_node_id' ) ) ; $ insertedNode -> setAttribute ( 'contentobject_version' , $ node -> attribute ( 'contentobject_version' ) ) ; $ insertedNode -> updateSubTreePath ( ) ; $ insertedNode -> sync ( ) ; $ locationAdded = true ; } } } if ( $ locationAdded ) { eZSearch :: addNodeAssignment ( $ nodeID , $ objectID , $ selectedNodeIDArray ) ; if ( in_array ( $ object -> attribute ( 'contentclass_id' ) , $ userClassIDArray ) ) { eZUser :: purgeUserCacheByUserId ( $ object -> attribute ( 'id' ) ) ; } } $ db -> commit ( ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; if ( ! eZSearch :: getEngine ( ) instanceof eZSearchEngine ) { eZContentOperationCollection :: registerSearchObject ( $ objectID ) ; } return array ( 'status' => true ) ; } | Adds a new nodeAssignment |
40,214 | static public function deleteObject ( $ deleteIDArray , $ moveToTrash = false ) { $ ini = eZINI :: instance ( ) ; $ aNodes = eZContentObjectTreeNode :: fetch ( $ deleteIDArray ) ; if ( ! is_array ( $ aNodes ) ) { $ aNodes = array ( $ aNodes ) ; } $ delayedIndexingValue = $ ini -> variable ( 'SearchSettings' , 'DelayedIndexing' ) ; if ( $ delayedIndexingValue === 'enabled' || $ delayedIndexingValue === 'classbased' ) { $ pendingActionsToDelete = array ( ) ; $ classList = $ ini -> variable ( 'SearchSettings' , 'DelayedIndexingClassList' ) ; $ assignedNodesByObject = array ( ) ; $ nodesToDeleteByObject = array ( ) ; foreach ( $ aNodes as $ node ) { $ object = $ node -> object ( ) ; $ objectID = $ object -> attribute ( 'id' ) ; $ assignedNodes = $ object -> attribute ( 'assigned_nodes' ) ; if ( count ( $ assignedNodes ) > 1 ) { if ( ! isset ( $ assignedNodesByObject [ $ objectID ] ) ) { $ assignedNodesByObject [ $ objectID ] = array ( ) ; foreach ( $ assignedNodes as $ assignedNode ) { $ assignedNodesByObject [ $ objectID ] [ ] = $ assignedNode -> attribute ( 'node_id' ) ; } } $ nodesToDeleteByObject [ $ objectID ] [ ] = $ node -> attribute ( 'node_id' ) ; $ diff = array_diff ( $ assignedNodesByObject [ $ objectID ] , $ nodesToDeleteByObject [ $ objectID ] ) ; if ( ! empty ( $ diff ) ) { continue ; } } if ( $ delayedIndexingValue !== 'classbased' || ( is_array ( $ classList ) && in_array ( $ object -> attribute ( 'class_identifier' ) , $ classList ) ) ) { $ pendingActionsToDelete [ ] = $ objectID ; } } if ( ! empty ( $ pendingActionsToDelete ) ) { $ filterConds = array ( 'param' => array ( $ pendingActionsToDelete ) ) ; eZPendingActions :: removeByAction ( 'index_object' , $ filterConds ) ; } } foreach ( $ aNodes as $ node ) { eZContentCacheManager :: addAdditionalNodeIDPerObject ( $ node -> attribute ( 'contentobject_id' ) , $ node -> attribute ( 'node_id' ) ) ; } eZContentObjectTreeNode :: removeSubtrees ( $ deleteIDArray , $ moveToTrash ) ; return array ( 'status' => true ) ; } | Deletes a content object or a list of content objects |
40,215 | static public function changeHideStatus ( $ nodeID ) { $ action = 'hide' ; $ curNode = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; if ( is_object ( $ curNode ) ) { if ( $ curNode -> attribute ( 'is_hidden' ) ) { eZContentObjectTreeNode :: unhideSubTree ( $ curNode ) ; $ action = 'show' ; } else { eZContentObjectTreeNode :: hideSubTree ( $ curNode ) ; } ezpEvent :: getInstance ( ) -> notify ( 'content/cache' , [ [ ( int ) $ nodeID ] , [ ( int ) $ curNode -> attribute ( 'contentobject_id' ) ] ] ) ; } eZSearch :: updateNodeVisibility ( $ nodeID , $ action ) ; return array ( 'status' => true ) ; } | Changes an contentobject s status |
40,216 | static public function updateSection ( $ nodeID , $ selectedSectionID , $ updateSearchIndexes = true ) { eZContentObjectTreeNode :: assignSectionToSubTree ( $ nodeID , $ selectedSectionID , false , $ updateSearchIndexes ) ; } | Assigns a node to a section |
40,217 | static public function changeTranslationAvailableStatus ( $ objectID , $ status = false ) { $ object = eZContentObject :: fetch ( $ objectID ) ; if ( ! $ object -> canEdit ( ) ) { return array ( 'status' => false ) ; } if ( $ object -> isAlwaysAvailable ( ) & $ status == false ) { $ object -> setAlwaysAvailableLanguageID ( false ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; } else if ( ! $ object -> isAlwaysAvailable ( ) & $ status == true ) { $ object -> setAlwaysAvailableLanguageID ( $ object -> attribute ( 'initial_language_id' ) ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; } return array ( 'status' => true ) ; } | Changes the status of a translation |
40,218 | static public function changeSortOrder ( $ nodeID , $ sortingField , $ sortingOrder = false ) { $ curNode = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; if ( is_object ( $ curNode ) ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ curNode -> setAttribute ( 'sort_field' , $ sortingField ) ; $ curNode -> setAttribute ( 'sort_order' , $ sortingOrder ) ; $ curNode -> store ( ) ; $ db -> commit ( ) ; $ object = $ curNode -> object ( ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ object -> attribute ( 'id' ) ) ; } return array ( 'status' => true ) ; } | Changes the sort order for a node |
40,219 | static public function updatePriority ( $ parentNodeID , $ priorityArray = array ( ) , $ priorityIDArray = array ( ) ) { $ curNode = eZContentObjectTreeNode :: fetch ( $ parentNodeID ) ; if ( $ curNode instanceof eZContentObjectTreeNode ) { $ objectIDs = array ( ) ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; for ( $ i = 0 , $ l = count ( $ priorityArray ) ; $ i < $ l ; $ i ++ ) { $ priority = ( int ) $ priorityArray [ $ i ] ; $ nodeID = ( int ) $ priorityIDArray [ $ i ] ; $ node = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; if ( ! $ node instanceof eZContentObjectTreeNode ) { continue ; } $ objectIDs [ ] = $ node -> attribute ( 'contentobject_id' ) ; $ db -> query ( "UPDATE ezcontentobject_tree SET priority={$priority} WHERE node_id={$nodeID} AND parent_node_id={$parentNodeID}" ) ; } $ curNode -> updateAndStoreModified ( ) ; $ db -> commit ( ) ; if ( ! eZSearch :: getEngine ( ) instanceof eZSearchEngine ) { eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectIDs ) ; foreach ( $ objectIDs as $ objectID ) { eZContentOperationCollection :: registerSearchObject ( $ objectID ) ; } } } return array ( 'status' => true ) ; } | Updates the priority of a node |
40,220 | static public function updateMainAssignment ( $ mainAssignmentID , $ objectID , $ mainAssignmentParentID ) { eZContentObjectTreeNode :: updateMainNodeID ( $ mainAssignmentID , $ objectID , false , $ mainAssignmentParentID ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; if ( ! eZSearch :: getEngine ( ) instanceof eZSearchEngine ) { eZContentOperationCollection :: registerSearchObject ( $ objectID ) ; } return array ( 'status' => true ) ; } | Update a node s main assignment |
40,221 | static public function updateInitialLanguage ( $ objectID , $ newInitialLanguageID ) { $ object = eZContentObject :: fetch ( $ objectID ) ; $ language = eZContentLanguage :: fetch ( $ newInitialLanguageID ) ; if ( $ language and ! $ language -> attribute ( 'disabled' ) ) { $ object -> setAttribute ( 'initial_language_id' , $ newInitialLanguageID ) ; $ objectName = $ object -> name ( false , $ language -> attribute ( 'locale' ) ) ; $ object -> setAttribute ( 'name' , $ objectName ) ; $ object -> store ( ) ; if ( $ object -> isAlwaysAvailable ( ) ) { $ object -> setAlwaysAvailableLanguageID ( $ newInitialLanguageID ) ; } $ nodes = $ object -> assignedNodes ( ) ; foreach ( $ nodes as $ node ) { $ node -> updateSubTreePath ( ) ; } } eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; return array ( 'status' => true ) ; } | Updates an contentobject s initial language |
40,222 | static public function updateAlwaysAvailable ( $ objectID , $ newAlwaysAvailable ) { $ object = eZContentObject :: fetch ( $ objectID ) ; $ change = false ; if ( $ object -> isAlwaysAvailable ( ) & $ newAlwaysAvailable == false ) { $ object -> setAlwaysAvailableLanguageID ( false ) ; $ change = true ; } else if ( ! $ object -> isAlwaysAvailable ( ) & $ newAlwaysAvailable == true ) { $ object -> setAlwaysAvailableLanguageID ( $ object -> attribute ( 'initial_language_id' ) ) ; $ change = true ; } if ( $ change ) { eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; if ( ! eZSearch :: getEngine ( ) instanceof eZSearchEngine ) { eZContentOperationCollection :: registerSearchObject ( $ objectID ) ; } } return array ( 'status' => true ) ; } | Set the always available flag for a content object |
40,223 | static public function removeTranslation ( $ objectID , $ languageIDArray ) { $ object = eZContentObject :: fetch ( $ objectID ) ; foreach ( $ languageIDArray as $ languageID ) { if ( ! $ object -> removeTranslation ( $ languageID ) ) { eZDebug :: writeError ( "Object with id $objectID: cannot remove the translation with language id $languageID!" , __METHOD__ ) ; } } eZContentOperationCollection :: registerSearchObject ( $ objectID ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; return array ( 'status' => true ) ; } | Removes a translation for a contentobject |
40,224 | static public function updateObjectState ( $ objectID , $ selectedStateIDList ) { $ object = eZContentObject :: fetch ( $ objectID ) ; $ currentStateIDArray = $ object -> attribute ( 'state_id_array' ) ; $ selectedStateIDList = array_diff ( $ selectedStateIDList , $ currentStateIDArray ) ; $ canAssignStateIDList = $ object -> attribute ( 'allowed_assign_state_id_list' ) ; $ selectedStateIDList = array_intersect ( $ selectedStateIDList , $ canAssignStateIDList ) ; foreach ( $ selectedStateIDList as $ selectedStateID ) { $ state = eZContentObjectState :: fetchById ( $ selectedStateID ) ; $ object -> assignState ( $ state ) ; } eZAudit :: writeAudit ( 'state-assign' , array ( 'Content object ID' => $ object -> attribute ( 'id' ) , 'Content object name' => $ object -> attribute ( 'name' ) , 'Selected State ID Array' => implode ( ', ' , $ selectedStateIDList ) , 'Comment' => 'Updated states of the current object: eZContentOperationCollection::updateObjectState()' ) ) ; eZSearch :: updateObjectState ( $ objectID , $ selectedStateIDList ) ; ezpEvent :: getInstance ( ) -> notify ( 'content/state/assign' , array ( $ objectID , $ selectedStateIDList ) ) ; eZContentCacheManager :: clearContentCacheIfNeeded ( $ objectID ) ; return array ( 'status' => true ) ; } | Update a contentobject s state |
40,225 | function copy ( ) { $ collection = clone $ this ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ collection -> store ( ) ; $ oldItems = $ this -> itemList ( ) ; foreach ( $ oldItems as $ oldItem ) { $ item = $ oldItem -> copy ( $ collection -> attribute ( 'id' ) ) ; } $ db -> commit ( ) ; return $ collection ; } | Copies the collection object the collection items and options . |
40,226 | static function fetch ( $ productCollectionID , $ asObject = true ) { return eZPersistentObject :: fetchObject ( eZProductCollection :: definition ( ) , null , array ( 'id' => $ productCollectionID ) , $ asObject ) ; } | Fetches an eZProductCollection based on its ID |
40,227 | function itemList ( $ asObject = true ) { return eZPersistentObject :: fetchObjectList ( eZProductCollectionItem :: definition ( ) , null , array ( "productcollection_id" => $ this -> ID ) , null , null , $ asObject ) ; } | Returns all production collection items as an array . |
40,228 | static function cleanupList ( $ productCollectionIDList ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; foreach ( $ productCollectionIDList as $ productCollectionID ) eZShippingManager :: purgeShippingInfo ( $ productCollectionID ) ; eZProductCollectionItem :: cleanupList ( $ productCollectionIDList ) ; $ where = $ db -> generateSQLINStatement ( $ productCollectionIDList , 'id' , false , false , 'int' ) ; $ db -> query ( "DELETE FROM ezproductcollection WHERE {$where}" ) ; $ db -> commit ( ) ; } | Removes all product collections based on a product collection ID list Will also remove the product collection items . |
40,229 | public static function instance ( ) { if ( ! self :: $ instance instanceof ezpContentPublishingQueueProcessor ) { self :: $ instance = new ezpContentPublishingQueueProcessor ( ) ; self :: $ instance -> registerSignalHandler ( ) ; } return self :: $ instance ; } | Singleton class loader |
40,230 | private function cleanupDeadProcesses ( ) { $ processes = ezpContentPublishingProcess :: fetchProcesses ( ezpContentPublishingProcess :: STATUS_WORKING ) ; foreach ( $ processes as $ process ) { if ( ! $ process -> isAlive ( ) ) { $ process -> reset ( ) ; } } } | Checks WORKING processes and removes from the queue those who are dead |
40,231 | public function childSignalHandler ( $ signo , $ pid = null , $ status = null ) { if ( $ pid === null ) { $ pid = pcntl_waitpid ( - 1 , $ status , WNOHANG ) ; } while ( $ pid > 0 ) { if ( $ pid && isset ( $ this -> currentJobs [ $ pid ] ) ) { $ exitCode = pcntl_wexitstatus ( $ status ) ; if ( $ exitCode != 0 ) { $ this -> out -> write ( "Process #{$pid} of object version #" . $ this -> currentJobs [ $ pid ] -> attribute ( 'ezcontentobject_version_id' ) . " exited with status {$exitCode}" ) ; eZDB :: setInstance ( eZDB :: instance ( false , false , true ) ) ; $ this -> currentJobs [ $ pid ] -> reset ( ) ; eZDB :: instance ( ) -> close ( ) ; eZDB :: setInstance ( null ) ; } unset ( $ this -> currentJobs [ $ pid ] ) ; } elseif ( $ pid ) { $ this -> signalQueue [ $ pid ] = $ status ; } $ pid = pcntl_waitpid ( - 1 , $ status , WNOHANG ) ; } return true ; } | Child process signal handler |
40,232 | function fileStore ( $ filePath , $ scope = false , $ delete = false , $ datatype = false ) { eZDebugSetting :: writeDebug ( 'kernel-clustering' , "fs::fileStore( '$filePath' )" , __METHOD__ ) ; } | Store file . |
40,233 | function fileStoreContents ( $ filePath , $ contents , $ scope = false , $ datatype = false ) { eZDebugSetting :: writeDebug ( 'kernel-clustering' , "fs::fileStoreContents( '$filePath' )" , __METHOD__ ) ; eZDebug :: accumulatorStart ( 'dbfile' , false , 'dbfile' ) ; eZFile :: create ( basename ( $ filePath ) , dirname ( $ filePath ) , $ contents , true ) ; $ perm = eZINI :: instance ( ) -> variable ( 'FileSettings' , 'StorageFilePermissions' ) ; chmod ( $ filePath , octdec ( $ perm ) ) ; eZDebug :: accumulatorStop ( 'dbfile' ) ; } | Store file contents . |
40,234 | function fileDeleteByWildcard ( $ wildcard ) { eZDebugSetting :: writeDebug ( 'kernel-clustering' , "fs::fileDeleteByWildcard( '$wildcard' )" , __METHOD__ ) ; eZDebug :: accumulatorStart ( 'dbfile' , false , 'dbfile' ) ; $ unlinkArray = eZSys :: globBrace ( $ wildcard ) ; if ( $ unlinkArray !== false and ( count ( $ unlinkArray ) > 0 ) ) { array_map ( 'unlink' , $ unlinkArray ) ; } eZDebug :: accumulatorStop ( 'dbfile' ) ; } | Delete files matching given wildcard . |
40,235 | function fileDeleteByDirList ( $ dirList , $ commonPath , $ commonSuffix ) { eZDebugSetting :: writeDebug ( 'kernel-clustering' , "fs::fileDeleteByDirList( '" . implode ( "," , $ dirList ) . "', '$commonPath', '$commonSuffix' )" , __METHOD__ ) ; eZDebug :: accumulatorStart ( 'dbfile' , false , 'dbfile' ) ; foreach ( $ dirList as $ dir ) { $ unlinkArray = eZSys :: globBrace ( "$commonPath/$dir/$commonSuffix*" ) ; if ( $ unlinkArray !== false ) { array_map ( 'unlink' , $ unlinkArray ) ; } } eZDebug :: accumulatorStop ( 'dbfile' ) ; } | Delete files located in a directories from dirList with common prefix specified by commonPath and common suffix with added wildcard at the end |
40,236 | static function fetchList ( $ limit = null ) { return eZPersistentObject :: fetchObjectList ( eZNotificationEvent :: definition ( ) , null , null , null , $ limit , true ) ; } | Fetches notification events as objects and returns them in an array . |
40,237 | static function fetchUnhandledList ( $ limit = null ) { return eZPersistentObject :: fetchObjectList ( eZNotificationEvent :: definition ( ) , null , array ( 'status' => self :: STATUS_CREATED ) , null , $ limit , true ) ; } | Fetches unhandled notification events as objects and returns them in an array . |
40,238 | public static function getInstance ( $ arguments , $ requireIniGroupe = true , $ checkFunctionExistence = false ) { if ( ! is_array ( $ arguments ) || ! isset ( $ arguments [ 1 ] ) ) { return null ; } $ className = $ callClassName = array_shift ( $ arguments ) ; $ functionName = array_shift ( $ arguments ) ; $ isTemplateFunction = false ; $ permissionFunctions = false ; $ permissionPrFunction = false ; $ ezjscoreIni = eZINI :: instance ( 'ezjscore.ini' ) ; if ( $ ezjscoreIni -> hasGroup ( 'ezjscServer_' . $ callClassName ) ) { if ( $ ezjscoreIni -> hasVariable ( 'ezjscServer_' . $ callClassName , 'File' ) ) include_once ( $ ezjscoreIni -> variable ( 'ezjscServer_' . $ callClassName , 'File' ) ) ; if ( $ ezjscoreIni -> hasVariable ( 'ezjscServer_' . $ callClassName , 'TemplateFunction' ) ) $ isTemplateFunction = $ ezjscoreIni -> variable ( 'ezjscServer_' . $ callClassName , 'TemplateFunction' ) === 'true' ; if ( $ ezjscoreIni -> hasVariable ( 'ezjscServer_' . $ callClassName , 'Functions' ) ) $ permissionFunctions = $ ezjscoreIni -> variable ( 'ezjscServer_' . $ callClassName , 'Functions' ) ; if ( $ ezjscoreIni -> hasVariable ( 'ezjscServer_' . $ callClassName , 'PermissionPrFunction' ) ) $ permissionPrFunction = $ ezjscoreIni -> variable ( 'ezjscServer_' . $ callClassName , 'PermissionPrFunction' ) === 'enabled' ; if ( $ ezjscoreIni -> hasVariable ( 'ezjscServer_' . $ callClassName , 'Class' ) ) $ className = $ ezjscoreIni -> variable ( 'ezjscServer_' . $ callClassName , 'Class' ) ; } else if ( $ requireIniGroupe ) { return null ; } if ( $ checkFunctionExistence && ! self :: staticHasFunction ( $ className , $ functionName , $ isTemplateFunction ) ) { return null ; } if ( $ permissionFunctions !== false ) { if ( ! self :: hasAccess ( $ permissionFunctions , ( $ permissionPrFunction ? $ functionName : null ) ) ) { return null ; } } return new ezjscServerRouter ( $ className , $ functionName , $ arguments , $ isTemplateFunction ) ; } | Gets instance of ezjscServerRouter IF arguments validates and user has access |
40,239 | public static function staticHasFunction ( $ className , $ functionName , $ isTemplateFunction = false ) { if ( $ isTemplateFunction ) { return true ; } else { return is_callable ( array ( $ className , $ functionName ) ) ; } } | Checks if function actually exits on the requested ezjscServerFunctions |
40,240 | public function call ( & $ environmentArguments = array ( ) , $ isPackeStage = false ) { if ( $ this -> isTemplateFunction ) { $ tpl = eZTemplate :: factory ( ) ; $ tpl -> setVariable ( 'arguments' , $ this -> functionArguments ) ; $ tpl -> setVariable ( 'environment' , $ environmentArguments ) ; return $ tpl -> fetch ( 'design:' . $ this -> className . '/' . $ this -> functionName . '.tpl' ) ; } else { return call_user_func_array ( array ( $ this -> className , $ this -> functionName ) , array ( $ this -> functionArguments , & $ environmentArguments , $ isPackeStage ) ) ; } } | Call the defined function on requested ezjscServerFunctions class |
40,241 | function processLoginRequired ( ezcMvcResult $ res , $ reasons , $ errorMap = null ) { $ reasonText = array ( ) ; if ( $ errorMap === null ) { $ errorMap = array ( 'ezpOauthFilter' => array ( ezpOauthFilter :: STATUS_TOKEN_INVALID => 'Token has expired.' , ezpOauthFilter :: STATUS_TOKEN_EXPIRED => 'Token has expired, please refresh it.' , ezpOauthFilter :: STATUS_TOKEN_INSUFFICIENT_SCOPE => 'You do have do have sufficient scope to access this resource.' , ) , ) ; } foreach ( $ reasons as $ line ) { $ reasonText [ ] = $ errorMap [ key ( $ line ) ] [ current ( $ line ) ] ; } $ res -> variables [ 'ezcAuth_reasons' ] = $ reasonText ; } | Method extracted from MvcAuthenticationTiein |
40,242 | public static function build ( ) { if ( ! isset ( self :: $ instance ) ) { self :: $ instance = self :: buildHandler ( eZINI :: instance ( 'file.ini' ) -> variable ( 'eZDFSClusteringSettings' , 'DFSBackend' ) ) ; } return self :: $ instance ; } | Builds the configured DFSBackend handler |
40,243 | protected function createErrorString ( ) { $ str = '' ; if ( $ this -> errorType !== null ) { $ str .= ", error='{$this->errorType}'" ; } if ( $ this -> errorMessage !== null ) { $ str .= ", error_description='{$this->errorMessage}'" ; } return $ str ; } | Creates for use in authentcation challenge header |
40,244 | public function doHandleRequest ( ) { $ initialRequiredParams = array ( 'grant_type' , 'client_id' , 'client_secret' ) ; $ codeRequiredParams = array ( 'code' , 'redirect_uri' ) ; $ refreshRequiredParams = array ( 'refresh_token' ) ; $ this -> checkParams ( $ initialRequiredParams ) ; $ grant_type = $ this -> request -> post [ 'grant_type' ] ; $ client_id = $ this -> request -> post [ 'client_id' ] ; $ client_secret = $ this -> request -> post [ 'client_secret' ] ; $ tokenTTL = ( int ) eZINI :: instance ( 'rest.ini' ) -> variable ( 'OAuthSettings' , 'TokenTTL' ) ; if ( ! $ this -> validateGrantType ( $ grant_type ) ) { throw new ezpOauthInvalidRequestException ( ezpOauthTokenEndpointErrorType :: UNSUPPORTED_GRANT_TYPE ) ; } $ result = new ezcMvcResult ( ) ; $ newToken = null ; switch ( $ grant_type ) { case 'authorization_code' : $ this -> checkParams ( $ codeRequiredParams ) ; $ newToken = ezpOauthUtility :: doRefreshTokenWithAuthorizationCode ( $ client_id , $ client_secret , $ this -> request -> post [ 'code' ] , $ this -> request -> post [ 'redirect_uri' ] ) ; break ; case 'refresh_token' : $ this -> checkParams ( $ refreshRequiredParams ) ; $ newToken = ezpOauthUtility :: doRefreshToken ( $ client_id , $ client_secret , $ this -> request -> post [ 'refresh_token' ] ) ; break ; } if ( ! $ newToken instanceof ezpRestToken ) { throw new ezpOauthInvalidTokenException ( ezpOauthTokenEndpointErrorType :: INVALID_REQUEST ) ; } $ result -> variables [ 'access_token' ] = $ newToken -> id ; $ result -> variables [ 'refresh_token' ] = $ newToken -> refresh_token ; $ result -> variables [ 'expires_in' ] = $ tokenTTL ; return $ result ; } | Handles the POST request which is sent to obtain token data . |
40,245 | static function generateNodeView ( $ tpl , $ node , $ object , $ languageCode , $ viewMode , $ offset , $ cacheDir , $ cachePath , $ viewCacheEnabled , $ viewParameters = array ( 'offset' => 0 , 'year' => false , 'month' => false , 'day' => false ) , $ collectionAttributes = false , $ validation = false ) { $ cacheFile = eZClusterFileHandler :: instance ( $ cachePath ) ; $ args = compact ( "tpl" , "node" , "object" , "languageCode" , "viewMode" , "offset" , "viewCacheEnabled" , "viewParameters" , "collectionAttributes" , "validation" ) ; $ Result = $ cacheFile -> processCache ( null , array ( 'eZNodeviewfunctions' , 'generateCallback' ) , null , null , $ args ) ; return $ Result ; } | Deprecated function for generating the view cache |
40,246 | static function generateCallback ( $ file , $ args ) { extract ( $ args ) ; $ res = eZNodeViewFunctions :: generateNodeViewData ( $ tpl , $ node , $ object , $ languageCode , $ viewMode , $ offset , $ viewParameters , $ collectionAttributes , $ validation ) ; $ store = $ res [ 'cache_ttl' ] != 0 ; if ( ! $ viewCacheEnabled ) $ store = false ; $ retval = array ( 'content' => $ res , 'scope' => 'viewcache' , 'store' => $ store ) ; if ( $ store ) $ retval [ 'binarydata' ] = serialize ( $ res ) ; return $ retval ; } | back to eZClusterFileHandler for processing . |
40,247 | static public function contentViewGenerate ( $ file , $ args ) { extract ( $ args ) ; $ node = eZContentObjectTreeNode :: fetch ( $ NodeID ) ; if ( ! $ node instanceof eZContentObjectTreeNode ) { if ( ! eZDB :: instance ( ) -> isConnected ( ) ) { return self :: contentViewGenerateError ( $ Module , eZError :: KERNEL_NO_DB_CONNECTION , false ) ; } return self :: contentViewGenerateError ( $ Module , eZError :: KERNEL_NOT_AVAILABLE ) ; } $ object = $ node -> attribute ( 'object' ) ; if ( ! $ object instanceof eZContentObject ) { return self :: contentViewGenerateError ( $ Module , eZError :: KERNEL_NOT_AVAILABLE ) ; } if ( $ node -> attribute ( 'is_invisible' ) && ! eZContentObjectTreeNode :: showInvisibleNodes ( ) ) { return self :: contentViewGenerateError ( $ Module , eZError :: KERNEL_ACCESS_DENIED ) ; } if ( ! $ node -> canRead ( ) ) { return self :: contentViewGenerateError ( $ Module , eZError :: KERNEL_ACCESS_DENIED , true , array ( 'AccessList' => $ node -> checkAccess ( 'read' , false , false , true ) ) ) ; } $ result = self :: generateNodeViewData ( $ tpl , $ node , $ object , $ LanguageCode , $ ViewMode , $ Offset , $ viewParameters , $ collectionAttributes , $ validation ) ; $ retval = array ( 'content' => $ result , 'scope' => 'viewcache' , 'store' => ! ( isset ( $ noCache ) and $ noCache ) ) ; if ( $ file !== false && $ retval [ 'store' ] ) $ retval [ 'binarydata' ] = serialize ( $ result ) ; return $ retval ; } | Generate convent view data |
40,248 | protected function getType ( $ item ) { $ type = gettype ( $ item ) ; if ( is_object ( $ item ) ) $ type .= "[" . get_class ( $ item ) . "]" ; return $ type ; } | Returns type for given item |
40,249 | protected function getValue ( $ item ) { if ( is_bool ( $ item ) ) $ value = $ item ? "true" : "false" ; else if ( is_array ( $ item ) ) $ value = 'Array(' . count ( $ item ) . ')' ; else if ( is_numeric ( $ item ) ) $ value = $ item ; else if ( is_string ( $ item ) ) $ value = "'" . $ item . "'" ; else if ( is_object ( $ item ) ) $ value = method_exists ( $ item , '__toString' ) ? ( string ) $ item : 'Object' ; else $ value = $ item ; return $ value ; } | Returns value for given item |
40,250 | public function getReport ( ) { $ report = array ( ) ; $ report [ 'restDebug' ] = $ this -> debug -> generateOutput ( ) ; $ reportEZDebug = $ this -> eZDebug -> printReportInternal ( false ) ; $ report [ 'eZDebug' ] = explode ( "\n" , $ reportEZDebug ) ; return $ report ; } | Returns debug report |
40,251 | static function addLanguage ( $ locale , $ name = null ) { $ localeObject = eZLocale :: instance ( $ locale ) ; if ( ! $ localeObject ) { eZDebug :: writeError ( "No such locale $locale!" , __METHOD__ ) ; return false ; } if ( $ name === null ) { $ name = $ localeObject -> attribute ( 'intl_language_name' ) ; } $ db = eZDB :: instance ( ) ; $ languages = eZContentLanguage :: fetchList ( true ) ; if ( ( $ existingLanguage = eZContentLanguage :: fetchByLocale ( $ locale ) ) ) { eZDebug :: writeWarning ( "Language '$locale' already exists!" , __METHOD__ ) ; return $ existingLanguage ; } if ( count ( $ languages ) >= self :: maxCount ( ) ) { eZDebug :: writeError ( 'Too many languages, cannot add more!' , __METHOD__ ) ; return false ; } $ db -> lock ( 'ezcontent_language' ) ; $ idSum = 0 ; foreach ( $ languages as $ language ) { $ idSum += $ language -> attribute ( 'id' ) ; } $ candidateId = 2 ; while ( $ idSum & $ candidateId ) { $ candidateId *= 2 ; } $ newLanguage = new eZContentLanguage ( array ( 'id' => $ candidateId , 'locale' => $ locale , 'name' => $ name , 'disabled' => 0 ) ) ; $ newLanguage -> store ( ) ; $ db -> unlock ( ) ; eZContentLanguage :: fetchList ( true ) ; eZContentCacheManager :: clearAllContentCache ( ) ; return $ newLanguage ; } | Adds new language to the site . |
40,252 | static function removeLanguage ( $ id ) { $ language = eZContentLanguage :: fetch ( $ id ) ; if ( $ language ) { return $ language -> removeThis ( ) ; } else { return false ; } } | Removes the language specified by ID . |
40,253 | function removeThis ( ) { if ( ( $ this -> objectCount ( ) > 0 ) or ( $ this -> classCount ( ) > 0 ) ) { return false ; } $ this -> remove ( ) ; eZContentCacheManager :: clearAllContentCache ( ) ; eZContentLanguage :: fetchList ( true ) ; return true ; } | Removes the language if there is no object having translation in it . |
40,254 | static function fetchList ( $ forceReloading = false ) { if ( isset ( $ GLOBALS [ 'eZContentLanguageList' ] ) && $ forceReloading === false ) return $ GLOBALS [ 'eZContentLanguageList' ] ; $ cachePath = eZSys :: cacheDirectory ( ) . '/ezcontentlanguage_cache.php' ; $ clusterFileHandler = eZClusterFileHandler :: instance ( $ cachePath ) ; if ( $ forceReloading || ! $ clusterFileHandler -> fileExists ( $ cachePath ) ) { $ languages = eZPersistentObject :: fetchObjectList ( eZContentLanguage :: definition ( ) ) ; $ clusterFileHandler -> fileStoreContents ( $ cachePath , serialize ( $ languages ) , 'content' , 'php' ) ; } else { $ languages = unserialize ( $ clusterFileHandler -> fetchContents ( ) ) ; if ( $ languages === false ) { eZDebug :: writeError ( "An error occurred while reading content language cache file $cachePath. File is being re-generated" , __METHOD__ ) ; return self :: fetchList ( true ) ; } } unset ( $ GLOBALS [ 'eZContentLanguageList' ] ) ; unset ( $ GLOBALS [ 'eZContentLanguageMask' ] ) ; $ GLOBALS [ 'eZContentLanguageList' ] = array ( ) ; $ mask = 1 ; foreach ( $ languages as $ language ) { $ GLOBALS [ 'eZContentLanguageList' ] [ $ language -> attribute ( 'id' ) ] = $ language ; $ mask += $ language -> attribute ( 'id' ) ; } $ GLOBALS [ 'eZContentLanguageMask' ] = $ mask ; return $ GLOBALS [ 'eZContentLanguageList' ] ; } | Fetches the list of the languages used on the site . |
40,255 | static function fetchLimitationList ( $ forceReloading = false ) { $ languages = array ( ) ; foreach ( eZContentLanguage :: fetchList ( $ forceReloading ) as $ language ) { $ languages [ ] = array ( 'name' => $ language -> attribute ( 'name' ) , 'id' => $ language -> attribute ( 'locale' ) ) ; } return $ languages ; } | Fetches the array with names and IDs of the languages used on the site . This method is used by the permission system . |
40,256 | static function fetchLocaleList ( ) { $ languages = eZContentLanguage :: fetchList ( ) ; $ localeList = array ( ) ; foreach ( $ languages as $ language ) { $ localeList [ ] = $ language -> attribute ( 'locale' ) ; } return $ localeList ; } | Fetches the array of locale codes of the languages used on the site . |
40,257 | static function fetch ( $ id ) { $ languages = eZContentLanguage :: fetchList ( ) ; return isset ( $ languages [ $ id ] ) ? $ languages [ $ id ] : false ; } | Fetches the language identified by ID . |
40,258 | static function fetchByLocale ( $ locale , $ createIfNotExist = false ) { $ languages = eZContentLanguage :: fetchList ( ) ; foreach ( $ languages as $ language ) { if ( $ language -> attribute ( 'locale' ) == $ locale ) { return $ language ; } } $ language = false ; if ( $ createIfNotExist ) { $ language = eZContentLanguage :: addLanguage ( $ locale ) ; } return $ language ; } | Fetches the language identified by locale code . |
40,259 | static function languagesByMask ( $ mask ) { $ result = array ( ) ; $ languages = eZContentLanguage :: fetchList ( ) ; foreach ( $ languages as $ key => $ language ) { if ( ( int ) $ key & ( int ) $ mask ) { $ result [ $ language -> attribute ( 'locale' ) ] = $ language ; } } return $ result ; } | Returns array of languages which have set the corresponding bit in the mask . |
40,260 | static function prioritizedLanguagesByMask ( $ mask ) { $ result = array ( ) ; $ languages = eZContentLanguage :: prioritizedLanguages ( ) ; foreach ( $ languages as $ language ) { if ( ( ( int ) $ language -> attribute ( 'id' ) & ( int ) $ mask ) > 0 ) { $ result [ $ language -> attribute ( 'locale' ) ] = $ language ; } } return $ result ; } | Returns array of prioritized languages which have set the corresponding bit in the mask . |
40,261 | static function topPriorityLanguageByMask ( $ mask ) { $ languages = eZContentLanguage :: prioritizedLanguages ( ) ; foreach ( $ languages as $ language ) { if ( ( ( int ) $ language -> attribute ( 'id' ) & ( int ) $ mask ) > 0 ) { return $ language ; } } return false ; } | Returns the most prioritized language which has set the corresponding bit in the mask . |
40,262 | static function maskByLocale ( $ locales , $ setZerothBit = false ) { if ( ! $ locales ) { return 0 ; } if ( ! is_array ( $ locales ) ) { $ locales = array ( $ locales ) ; } $ mask = 0 ; if ( $ setZerothBit ) { $ mask = 1 ; } foreach ( $ locales as $ locale ) { $ language = eZContentLanguage :: fetchByLocale ( $ locale ) ; if ( $ language ) { $ mask |= $ language -> attribute ( 'id' ) ; } } return ( int ) $ mask ; } | Returns bitmap mask for the specified languages . |
40,263 | static function idByLocale ( $ locale ) { $ language = eZContentLanguage :: fetchByLocale ( $ locale ) ; if ( $ language ) { return ( int ) $ language -> attribute ( 'id' ) ; } else { return false ; } } | \ static Returns id of the language specified . |
40,264 | function objectCount ( ) { $ db = eZDB :: instance ( ) ; $ languageID = $ this -> ID ; if ( $ db -> databaseName ( ) == 'oracle' ) { $ whereSQL = "bitand( language_mask, $languageID ) > 0" ; } else { $ whereSQL = "language_mask & $languageID > 0" ; } $ count = $ db -> arrayQuery ( "SELECT COUNT(*) AS count FROM ezcontentobject WHERE $whereSQL" ) ; return $ count [ 0 ] [ 'count' ] ; } | \ return The count of objects containing the translation in this language . |
40,265 | static function jsArrayByMask ( $ mask ) { $ localList = array ( ) ; $ languages = eZContentLanguage :: prioritizedLanguagesByMask ( $ mask ) ; foreach ( $ languages as $ key => $ language ) { $ localList [ ] = array ( 'locale' => $ language -> attribute ( 'locale' ) , 'name' => $ language -> attribute ( 'name' ) ) ; } if ( $ localList ) { return json_encode ( $ localList ) ; } else { return false ; } } | Returns the Javascript array with locale codes and names of the languages which have set the corresponding bit in specified mask . |
40,266 | static function expireCache ( $ expireCluster = true ) { unset ( $ GLOBALS [ 'eZContentLanguageList' ] , $ GLOBALS [ 'eZContentLanguagePrioritizedLanguages' ] , $ GLOBALS [ 'eZContentLanguageMask' ] , $ GLOBALS [ 'eZContentLanguageCronjobMode' ] ) ; if ( $ expireCluster ) { $ cachePath = eZSys :: cacheDirectory ( ) . '/ezcontentlanguage_cache.php' ; eZClusterFileHandler :: instance ( ) -> fileDelete ( $ cachePath ) ; } } | Removes all caches forcing it to read from database again for next method calls . |
40,267 | static function fetchImageAttributesByFilepath ( $ filepath , $ contentObjectAttributeID ) { $ db = eZDB :: instance ( ) ; $ contentObjectAttributeID = ( int ) $ contentObjectAttributeID ; $ cond = array ( 'id' => $ contentObjectAttributeID ) ; $ fields = array ( 'contentobject_id' , 'contentclassattribute_id' ) ; $ limit = array ( 'offset' => 0 , 'length' => 1 ) ; $ rows = eZPersistentObject :: fetchObjectList ( eZContentObjectAttribute :: definition ( ) , $ fields , $ cond , null , $ limit , false ) ; if ( count ( $ rows ) != 1 ) return array ( ) ; $ contentObjectID = ( int ) ( $ rows [ 0 ] [ 'contentobject_id' ] ) ; $ contentClassAttributeID = ( int ) ( $ rows [ 0 ] [ 'contentclassattribute_id' ] ) ; $ filepath = $ db -> escapeString ( htmlspecialchars ( $ filepath , version_compare ( PHP_VERSION , '5.4.0' , '>=' ) ? ENT_COMPAT | ENT_HTML401 : ENT_COMPAT , 'UTF-8' ) ) ; $ filepath = addcslashes ( $ filepath , "_" ) ; $ query = "SELECT id, version, language_code FROM ezcontentobject_attribute WHERE contentobject_id = $contentObjectID AND contentclassattribute_id = $contentClassAttributeID AND data_text LIKE '%url=\"$filepath\"%'" ; if ( $ db -> databaseName ( ) == 'oracle' ) { $ query .= " ESCAPE '\'" ; } $ rows = $ db -> arrayQuery ( $ query ) ; return $ rows ; } | Looks up ezcontentobjectattribute entries matching an image filepath and a contentobjectattribute ID |
40,268 | function hasConflicts ( $ editLanguage = false ) { $ object = $ this -> contentObject ( ) ; if ( ! $ editLanguage ) $ editLanguage = $ this -> initialLanguageCode ( ) ; $ versions = $ object -> versions ( true , array ( 'conditions' => array ( 'status' => array ( array ( eZContentObjectVersion :: STATUS_PUBLISHED , eZContentObjectVersion :: STATUS_ARCHIVED ) ) , 'language_code' => $ editLanguage ) ) ) ; $ conflictVersions = array ( ) ; foreach ( array_keys ( $ versions ) as $ key ) { $ version = & $ versions [ $ key ] ; if ( $ version -> attribute ( 'modified' ) > $ this -> attribute ( 'created' ) ) { $ conflictVersions [ ] = $ version ; } } if ( ! count ( $ conflictVersions ) ) { return false ; } return $ conflictVersions ; } | \ return array of version objects that caused conflict or false . |
40,269 | static function exportByNode ( $ nodeID ) { if ( ! $ nodeID ) return array ( 'error' => array ( 'error_type' => 'kernel' , 'error_code' => eZError :: KERNEL_NOT_FOUND ) ) ; $ rssExport = eZPersistentObject :: fetchObject ( eZRSSExport :: definition ( ) , null , array ( 'node_id' => $ nodeID , 'status' => eZRSSExport :: STATUS_VALID ) , true ) ; return array ( 'result' => $ rssExport ) ; } | Return valid eZRSSExport object for a specific node if it exists . |
40,270 | public static function getCacheTime ( $ functionName ) { static $ mtime = null ; if ( $ mtime === null ) { $ mtime = filemtime ( __FILE__ ) ; } return $ mtime ; } | getCacheTime Expiry time for code generators registirated on this class . Needs to be increased to current time when changes are done to returned translations . |
40,271 | function VATPercent ( $ object = false , $ country = false ) { $ VATType = $ this -> VATType ( ) ; if ( $ object === false ) { if ( $ this -> ContentObject === null ) return $ VATType -> attribute ( 'percentage' ) ; $ object = $ this -> ContentObject ; } return $ VATType -> getPercentage ( $ object , $ country ) ; } | Can return dynamic percentage depending on product and country the user is from . |
40,272 | static function clearAll ( $ cacheList = false ) { if ( ! $ cacheList ) $ cacheList = eZCache :: fetchList ( ) ; foreach ( $ cacheList as $ cacheItem ) { eZCache :: clearItem ( $ cacheItem ) ; } return true ; } | Clears all cache items . |
40,273 | static function clearImageAlias ( $ cacheItem ) { $ expiryHandler = eZExpiryHandler :: instance ( ) ; $ expiryHandler -> setTimestamp ( 'image-manager-alias' , time ( ) ) ; $ expiryHandler -> store ( ) ; ezpEvent :: getInstance ( ) -> notify ( 'image/invalidateAliases' ) ; } | Sets the image alias timestamp to the current timestamp this causes all image aliases to be recreated on viewing . |
40,274 | static function purgeImageAlias ( $ cacheItem ) { $ imageContentClassAttributes = eZContentClassAttribute :: fetchList ( true , array ( 'data_type' => 'ezimage' , 'version' => eZContentClass :: VERSION_STATUS_DEFINED ) ) ; $ classIds = array ( ) ; $ attributeIdentifiersByClass = array ( ) ; foreach ( $ imageContentClassAttributes as $ ccAttr ) { $ identifier = $ ccAttr -> attribute ( 'identifier' ) ; $ ccId = $ ccAttr -> attribute ( 'contentclass_id' ) ; if ( ! isset ( $ attributeIdentifiersByClass [ $ ccId ] ) ) { $ attributeIdentifiersByClass [ $ ccId ] = array ( ) ; } $ attributeIdentifiersByClass [ $ ccId ] [ ] = $ identifier ; $ classIds [ ] = $ ccId ; } $ subTreeParams = array ( 'ClassFilterType' => 'include' , 'ClassFilterArray' => $ classIds , 'MainNodeOnly' => true , 'IgnoreVisibility' => true , 'LoadDataMap' => false , 'Limit' => 100 , 'Offset' => 0 ) ; $ count = 0 ; while ( true ) { $ nodes = eZContentObjectTreeNode :: subTreeByNodeID ( $ subTreeParams , 1 ) ; if ( empty ( $ nodes ) ) { break ; } foreach ( $ nodes as $ node ) { call_user_func ( $ cacheItem [ 'reporter' ] , '' , $ count ) ; $ object = $ node -> attribute ( 'object' ) ; self :: purgeImageAliasForObject ( $ cacheItem , $ object , $ attributeIdentifiersByClass [ $ object -> attribute ( 'contentclass_id' ) ] ) ; $ count ++ ; } eZContentObject :: clearCache ( ) ; $ subTreeParams [ 'Offset' ] += $ subTreeParams [ 'Limit' ] ; } self :: clearImageAlias ( $ cacheItem ) ; } | Purges the image aliases of all ezimage attribute . The original image is kept . |
40,275 | private static function purgeImageAliasForObject ( array $ cacheItem , eZContentObject $ object , array $ imageIdentifiers ) { $ versions = $ object -> attribute ( 'versions' ) ; foreach ( $ versions as $ version ) { $ dataMap = $ version -> attribute ( 'data_map' ) ; foreach ( $ imageIdentifiers as $ identifier ) { $ attr = $ dataMap [ $ identifier ] ; if ( ! $ attr instanceof eZContentObjectAttribute ) { eZDebug :: writeError ( "Missing attribute $identifier in object " . $ object -> attribute ( 'id' ) . ", version " . $ version -> attribute ( 'version' ) . ". This indicates data corruption." , __METHOD__ ) ; } elseif ( $ attr -> attribute ( 'has_content' ) ) { $ attr -> attribute ( 'content' ) -> purgeAllAliases ( ) ; } } } } | The purge the image aliases in all versions of the content object . |
40,276 | static function clearTemplateBlockCache ( $ cacheItem ) { $ expiryHandler = eZExpiryHandler :: instance ( ) ; $ expiryHandler -> setTimestamp ( 'global-template-block-cache' , time ( ) ) ; $ expiryHandler -> store ( ) ; } | Removes all template block cache files and subtree entries . |
40,277 | static function clearTemplateOverrideCache ( $ cacheItem ) { $ cachePath = eZSys :: cacheDirectory ( ) . '/' . $ cacheItem [ 'path' ] ; eZDir :: recursiveDelete ( $ cachePath ) ; eZTemplateDesignResource :: clearInMemoryOverrideArray ( ) ; } | Removes all template override cache files subtree entries and clears in memory override cache . |
40,278 | static function clearStateLimitations ( $ cacheItem ) { $ cachePath = eZSys :: cacheDirectory ( ) ; $ fileHandler = eZClusterFileHandler :: instance ( ) ; $ fileHandler -> fileDelete ( $ cachePath , 'statelimitations_' ) ; ezpEvent :: getInstance ( ) -> notify ( 'content/state/cache/all' ) ; } | Clears all state limitation cache files . |
40,279 | static function clearActiveExtensions ( $ cacheItem ) { $ handler = eZExpiryHandler :: instance ( ) ; $ handler -> setTimestamp ( $ cacheItem [ 'expiry-key' ] , time ( ) ) ; $ handler -> store ( ) ; eZExtension :: clearActiveExtensionsCache ( ) ; eZExtension :: clearActiveExtensionsMemoryCache ( ) ; } | Clears active extensions list cache |
40,280 | static function fetchByContentObjectID ( $ contentObjectID , $ languageCode = null , $ asObject = true ) { $ condition = array ( ) ; $ condition [ 'contentobject_id' ] = $ contentObjectID ; $ condition [ 'data_type_string' ] = 'ezmedia' ; if ( $ languageCode != null ) { $ condition [ 'language_code' ] = $ languageCode ; } $ custom = array ( array ( 'operation' => 'DISTINCT id' , 'name' => 'id' ) ) ; $ ids = eZPersistentObject :: fetchObjectList ( eZContentObjectAttribute :: definition ( ) , array ( ) , $ condition , null , null , false , false , $ custom ) ; $ mediaFiles = array ( ) ; foreach ( $ ids as $ id ) { $ mediaFileObjectAttribute = eZMedia :: fetch ( $ id [ 'id' ] , null , $ asObject ) ; $ mediaFiles = array_merge ( $ mediaFiles , $ mediaFileObjectAttribute ) ; } return $ mediaFiles ; } | Fetch media objects by content object id |
40,281 | static function initialize ( $ context , $ locale , $ filename , $ useCache = true ) { $ instance = false ; $ file = $ locale . '/' . $ filename ; if ( ! empty ( $ GLOBALS [ 'eZTSTranslationTables' ] [ $ file ] ) ) { $ instance = $ GLOBALS [ 'eZTSTranslationTables' ] [ $ file ] ; if ( $ instance -> hasInitializedContext ( $ context ) ) { return $ instance ; } } eZDebug :: createAccumulatorGroup ( 'tstranslator' , 'TS translator' ) ; eZDebug :: accumulatorStart ( 'tstranslator_init' , 'tstranslator' , 'TS init' ) ; if ( ! $ instance ) { $ instance = new eZTSTranslator ( $ locale , $ filename , $ useCache ) ; $ GLOBALS [ 'eZTSTranslationTables' ] [ $ file ] = $ instance ; $ manager = eZTranslatorManager :: instance ( ) ; $ manager -> registerHandler ( $ instance ) ; } $ instance -> load ( $ context ) ; eZDebug :: accumulatorStop ( 'tstranslator_init' ) ; return $ instance ; } | Initialize the ts translator and context if this is not already done |
40,282 | function handleContextNode ( $ context ) { $ contextName = null ; $ messages = array ( ) ; $ context_children = $ context -> childNodes ; for ( $ i = 0 ; $ i < $ context_children -> length ; $ i ++ ) { $ context_child = $ context_children -> item ( $ i ) ; if ( $ context_child -> nodeType == XML_ELEMENT_NODE ) { if ( $ context_child -> tagName == "name" ) { $ name_el = $ context_child -> firstChild ; if ( $ name_el ) { $ contextName = $ name_el -> nodeValue ; } } break ; } } if ( ! $ contextName ) { eZDebug :: writeError ( "No context name found, skipping context" , __METHOD__ ) ; return false ; } foreach ( $ context_children as $ context_child ) { if ( $ context_child -> nodeType == XML_ELEMENT_NODE ) { $ childName = $ context_child -> tagName ; if ( $ childName == "message" ) { $ this -> handleMessageNode ( $ contextName , $ context_child ) ; } else if ( $ childName == "name" ) { } else { eZDebug :: writeError ( "Unknown element name: $childName" , __METHOD__ ) ; } } } if ( $ contextName === null ) { eZDebug :: writeError ( "No context name found, skipping context" , __METHOD__ ) ; return false ; } if ( ! isset ( $ this -> CachedMessages [ $ contextName ] ) ) $ this -> CachedMessages [ $ contextName ] = array ( ) ; return true ; } | Handles a DOM Context node and the messages it contains |
40,283 | function handleMessageNode ( $ contextName , $ message ) { $ source = null ; $ translation = null ; $ comment = null ; $ message_children = $ message -> childNodes ; for ( $ i = 0 ; $ i < $ message_children -> length ; $ i ++ ) { $ message_child = $ message_children -> item ( $ i ) ; if ( $ message_child -> nodeType == XML_ELEMENT_NODE ) { $ childName = $ message_child -> tagName ; if ( $ childName == "source" ) { if ( $ message_child -> childNodes -> length > 0 ) { $ source = '' ; foreach ( $ message_child -> childNodes as $ textEl ) { if ( $ textEl instanceof DOMText ) { $ source .= $ textEl -> nodeValue ; } else if ( $ textEl instanceof DOMElement && $ textEl -> tagName == 'byte' ) { $ source .= chr ( intval ( '0' . $ textEl -> getAttribute ( 'value' ) ) ) ; } } } } else if ( $ childName == "translation" ) { if ( $ message_child -> childNodes -> length > 0 ) { $ translation = '' ; foreach ( $ message_child -> childNodes as $ textEl ) { if ( $ textEl instanceof DOMText ) { $ translation .= $ textEl -> nodeValue ; } else if ( $ textEl instanceof DOMElement && $ textEl -> tagName == 'byte' ) { $ translation .= chr ( intval ( '0' . $ textEl -> getAttribute ( 'value' ) ) ) ; } } } } else if ( $ childName == "comment" ) { $ comment_el = $ message_child -> firstChild ; $ comment = $ comment_el -> nodeValue ; } else if ( $ childName == "translatorcomment" ) { } else if ( $ childName == "location" ) { } else eZDebug :: writeError ( "Unknown element name: " . $ childName , __METHOD__ ) ; } } if ( $ source === null ) { eZDebug :: writeError ( "No source name found, skipping message in context '{$contextName}'" , __METHOD__ ) ; return false ; } if ( $ translation === null ) { $ translation = $ source ; } if ( $ message instanceof DOMElement ) { $ codec = eZTextCodec :: instance ( "utf8" ) ; $ source = $ codec -> convertString ( $ source ) ; $ translation = $ codec -> convertString ( $ translation ) ; $ comment = $ codec -> convertString ( $ comment ) ; } $ this -> insert ( $ contextName , $ source , $ translation , $ comment ) ; return true ; } | Handles a translation message DOM node |
40,284 | function findKey ( $ key ) { $ msg = null ; if ( isset ( $ this -> Messages [ $ key ] ) ) { $ msg = $ this -> Messages [ $ key ] ; } return $ msg ; } | Returns the message that matches a translation md5 key |
40,285 | function keyTranslate ( $ key ) { $ msg = $ this -> findKey ( $ key ) ; if ( $ msg !== null ) return $ msg [ "translation" ] ; else { return null ; } } | Returns the translation for a translation md5 key |
40,286 | function translate ( $ context , $ source , $ comment = null ) { $ msg = $ this -> findMessage ( $ context , $ source , $ comment ) ; if ( $ msg !== null ) { return $ msg [ "translation" ] ; } return null ; } | Translates a context + source + comment |
40,287 | static function fetchList ( $ localeList = array ( ) ) { $ ini = eZINI :: instance ( ) ; $ dir = $ ini -> variable ( 'RegionalSettings' , 'TranslationRepository' ) ; $ fileInfoList = array ( ) ; $ translationList = array ( ) ; $ locale = '' ; if ( count ( $ localeList ) == 0 ) { $ localeList = eZDir :: findSubdirs ( $ dir ) ; } foreach ( $ localeList as $ locale ) { if ( $ locale != 'untranslated' ) { $ translationFiles = eZDir :: findSubitems ( $ dir . '/' . $ locale , 'f' ) ; foreach ( $ translationFiles as $ translationFile ) { if ( eZFile :: suffix ( $ translationFile ) == 'ts' ) { $ translationList [ ] = new eZTSTranslator ( $ locale , $ translationFile ) ; } } } } return $ translationList ; } | Fetches the list of available translations as an eZTSTranslator for each translation . |
40,288 | public static function expireCache ( $ timestamp = false , $ locale = null ) { if ( $ timestamp === false ) $ timestamp = time ( ) ; $ handler = eZExpiryHandler :: instance ( ) ; if ( $ locale ) $ handler -> setTimestamp ( self :: EXPIRY_KEY . '-' . $ locale , $ timestamp ) ; else $ handler -> setTimestamp ( self :: EXPIRY_KEY , $ timestamp ) ; $ handler -> store ( ) ; self :: resetGlobals ( ) ; } | Expires the translation cache |
40,289 | static function fetchChildCountByVersionStatus ( $ parentNodeIDList , $ status = eZContentObjectVersion :: STATUS_PENDING ) { $ db = eZDB :: instance ( ) ; $ parentIDStatement = $ db -> generateSQLINStatement ( $ parentNodeIDList ) ; $ sql = "SELECT COUNT( DISTINCT eznode_assignment.id ) AS cnt FROM ezcontentobject_version, eznode_assignment WHERE ezcontentobject_version.contentobject_id = eznode_assignment.contentobject_id AND ezcontentobject_version.version = eznode_assignment.contentobject_version AND ezcontentobject_version.status = $status AND eznode_assignment.parent_node $parentIDStatement " ; $ countResult = $ db -> arrayQuery ( $ sql ) ; return ( int ) $ countResult [ 0 ] [ 'cnt' ] ; } | Fetch node assignment count by version status giving parent node id list . |
40,290 | static function fetchChildListByVersionStatus ( $ parentNodeIDList , $ status = eZContentObjectVersion :: STATUS_PENDING , $ asObject = true ) { $ db = eZDB :: instance ( ) ; $ parentIDStatement = $ db -> generateSQLINStatement ( $ parentNodeIDList ) ; $ sql = "SELECT DISTINCT eznode_assignment.* FROM ezcontentobject_version, eznode_assignment WHERE ezcontentobject_version.contentobject_id = eznode_assignment.contentobject_id AND ezcontentobject_version.version = eznode_assignment.contentobject_version AND ezcontentobject_version.status = $status AND eznode_assignment.parent_node $parentIDStatement ORDER BY eznode_assignment.contentobject_id" ; $ nodeAssignmentArray = $ db -> arrayQuery ( $ sql ) ; if ( $ asObject ) { $ result = array ( ) ; foreach ( $ nodeAssignmentArray as $ nodeAssignment ) { $ result [ ] = new eZNodeAssignment ( $ nodeAssignment ) ; } return $ result ; } else { return $ nodeAssignmentArray ; } } | Fetch node assignment list by version status giving parent node id list . |
40,291 | public static function fromContentObject ( eZContentObject $ contentObject ) { $ set = new ezpContentFieldSet ( ) ; $ languages = $ contentObject -> availableLanguages ( ) ; foreach ( $ languages as $ language ) { $ set -> childrenFieldSets [ $ language ] = ezpContentFieldSet :: fromDataMap ( $ contentObject -> fetchDataMap ( false , $ language ) ) ; } reset ( $ languages ) ; $ set -> setActiveLanguage ( current ( $ languages ) ) ; return $ set ; } | Initializes a level one ezpContentFieldSet from an eZContentObject |
40,292 | public static function fromDataMap ( $ dataMap ) { $ set = new ezpContentFieldSet ( ) ; foreach ( $ dataMap as $ attribute ) { $ identifier = $ attribute -> attribute ( 'contentclass_attribute_identifier' ) ; $ set -> fields [ $ identifier ] = ezpContentField :: fromContentObjectAttribute ( $ attribute ) ; } $ set -> initIterator ( ) ; return $ set ; } | Initializes a level two ezpContentFieldSet from a content object data map |
40,293 | public function offsetGet ( $ offset ) { if ( ! isset ( $ this -> childrenFieldSets [ $ offset ] ) ) { throw new Exception ( "Language $offset could not be found on this ezpContent" ) ; } return $ this -> childrenFieldSets [ $ offset ] ; } | Array get handler . Will return the requested language s ezpFieldSet |
40,294 | public function setSaveHandler ( ) { session_module_name ( 'user' ) ; session_set_save_handler ( array ( $ this , 'open' ) , array ( $ this , 'close' ) , array ( $ this , 'read' ) , array ( $ this , 'write' ) , array ( $ this , 'destroy' ) , array ( $ this , 'gc' ) ) ; return true ; } | Set it self as save handler |
40,295 | function prepareSqlQuery ( & $ fd , & $ buffer ) { $ sqlQueryArray = array ( ) ; while ( count ( $ sqlQueryArray ) == 0 && ! feof ( $ fd ) ) { $ buffer .= fread ( $ fd , 4096 ) ; if ( $ buffer ) { $ sqlQuery = preg_replace ( array ( "/^#.*\n" . "/m" , "#^/\*.*\*/\n" . "#m" , "/^--.*\n" . "/m" , "/\n|\r\n|\r/m" ) , array ( "" , "" , "" , "\n" ) , $ buffer ) ; $ sqlQueryArray = preg_split ( "/;\n/m" , $ sqlQuery ) ; if ( preg_match ( '/;\n/m' , $ sqlQueryArray [ count ( $ sqlQueryArray ) - 1 ] ) ) { $ buffer = '' ; } else { $ buffer = $ sqlQueryArray [ count ( $ sqlQueryArray ) - 1 ] ; array_splice ( $ sqlQueryArray , count ( $ sqlQueryArray ) - 1 , 1 ) ; } } else { return $ sqlQueryArray ; } } return $ sqlQueryArray ; } | Prepare the sql file so we can create the database . |
40,296 | function reportQuery ( $ class , $ sql , $ numRows , $ timeTaken , $ asDebug = false ) { $ rowText = '' ; if ( $ numRows !== false ) $ rowText = "$numRows rows, " ; $ backgroundClass = ( $ this -> TransactionCounter > 0 ? "debugtransaction transactionlevel-$this->TransactionCounter" : '' ) ; if ( $ asDebug ) eZDebug :: writeDebug ( "$sql" , "$class::query($rowText" . number_format ( $ timeTaken , 3 ) . ' ms) query number per page:' . $ this -> NumQueries ++ , $ backgroundClass ) ; else eZDebug :: writeNotice ( "$sql" , "$class::query($rowText" . number_format ( $ timeTaken , 3 ) . ' ms) query number per page:' . $ this -> NumQueries ++ , $ backgroundClass ) ; } | Writes a debug notice with query information . |
40,297 | function endTimer ( ) { $ this -> EndTime = microtime ( true ) ; $ this -> TimeTaken = $ this -> EndTime - $ this -> StartTime ; $ this -> TimeTaken *= 1000.0 ; } | Stops the current timer and calculates the time taken . |
40,298 | function begin ( ) { $ ini = eZINI :: instance ( ) ; if ( $ ini -> variable ( "DatabaseSettings" , "Transactions" ) == "enabled" ) { if ( $ this -> TransactionCounter > 0 ) { if ( is_array ( $ this -> TransactionStackTree ) ) { $ bt = debug_backtrace ( ) ; $ subLevels = & $ this -> TransactionStackTree [ 'sub_levels' ] ; for ( $ i = 1 ; $ i < $ this -> TransactionCounter ; ++ $ i ) { $ subLevels = & $ subLevels [ count ( $ subLevels ) - 1 ] [ 'sub_levels' ] ; } $ subLevels [ count ( $ subLevels ) ] = array ( 'level' => $ this -> TransactionCounter , 'trace' => $ bt , 'sub_levels' => array ( ) ) ; } ++ $ this -> TransactionCounter ; return false ; } else { if ( is_array ( $ this -> TransactionStackTree ) ) { $ bt = debug_backtrace ( ) ; $ this -> TransactionStackTree = array ( 'level' => $ this -> TransactionCounter , 'trace' => $ bt , 'sub_levels' => array ( ) ) ; } } $ this -> TransactionIsValid = true ; if ( $ this -> isConnected ( ) ) { $ oldRecordError = $ this -> RecordError ; $ this -> RecordError = false ; $ this -> beginQuery ( ) ; $ this -> RecordError = $ oldRecordError ; ++ $ this -> TransactionCounter ; } } return true ; } | Begin a new transaction . |
40,299 | function commit ( ) { $ ini = eZINI :: instance ( ) ; if ( $ ini -> variable ( "DatabaseSettings" , "Transactions" ) == "enabled" ) { if ( $ this -> TransactionCounter <= 0 ) { eZDebug :: writeError ( 'No transaction in progress, cannot commit' , __METHOD__ ) ; return false ; } -- $ this -> TransactionCounter ; if ( $ this -> TransactionCounter == 0 ) { if ( is_array ( $ this -> TransactionStackTree ) ) { $ this -> TransactionStackTree = array ( ) ; } if ( $ this -> isConnected ( ) ) { if ( ! $ this -> TransactionIsValid ) { $ oldRecordError = $ this -> RecordError ; $ this -> RecordError = false ; $ this -> rollbackQuery ( ) ; $ this -> RecordError = $ oldRecordError ; return false ; } else { $ oldRecordError = $ this -> RecordError ; $ this -> RecordError = false ; $ this -> commitQuery ( ) ; $ this -> RecordError = $ oldRecordError ; } } } else { if ( is_array ( $ this -> TransactionStackTree ) ) { $ bt = debug_backtrace ( ) ; $ subLevels = & $ this -> TransactionStackTree [ 'sub_levels' ] ; for ( $ i = 1 ; $ i < $ this -> TransactionCounter ; ++ $ i ) { $ subLevels = & $ subLevels [ count ( $ subLevels ) - 1 ] [ 'sub_levels' ] ; } $ subLevels [ count ( $ subLevels ) - 1 ] [ 'commit_trace' ] = $ bt ; } } } return true ; } | Commits the current transaction . If this is not the outermost it will not commit to the database immediately but instead decrease the transaction counter . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.