public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt)
 {
     if (isset($parameters['Source'])) {
         $nodeID = $parameters['Source'];
         $node = eZContentObjectTreeNode::fetch($nodeID, false, false);
         // not as an object
         if ($node && $node['modified_subnode'] <= $publishedAfter) {
             return array();
         }
     } else {
         $nodeID = 0;
     }
     $subTreeParameters = array();
     $subTreeParameters['AsObject'] = false;
     $subTreeParameters['SortBy'] = array('published', false);
     // first the latest
     $subTreeParameters['AttributeFilter'] = array('and', array('published', '>', $publishedAfter), array('published', '<=', $publishedBeforeOrAt), array('visibility', '=', true));
     if (isset($parameters['Class'])) {
         $subTreeParameters['ClassFilterType'] = 'include';
         $subTreeParameters['ClassFilterArray'] = explode(';', $parameters['Class']);
     }
     if (isset($parameters['Limit'])) {
         $subTreeParameters['Limit'] = (int) $parameters['Limit'];
     }
     $result = eZContentObjectTreeNode::subTreeByNodeID($subTreeParameters, $nodeID);
     if ($result === null) {
         return array();
     }
     $fetchResult = array();
     foreach ($result as $item) {
         $fetchResult[] = array('object_id' => $item['id'], 'node_id' => $item['node_id'], 'ts_publication' => $item['published']);
     }
     return $fetchResult;
 }
 private static function fetchIndexTargets($indexTarget, $classIdentifiers, $contentObjectAttribute)
 {
     if (!is_array($classIdentifiers)) {
         return array();
     }
     if ($indexTarget == 'parent_line') {
         $path = $contentObjectAttribute->object()->mainNode()->fetchPath();
         if (!empty($classIdentifiers)) {
             $targets = array();
             foreach ($path as $pathNode) {
                 if (in_array($pathNode->classIdentifier(), $classIdentifiers)) {
                     $targets[] = $pathNode;
                 }
             }
             return $targets;
         }
         return $path;
     } else {
         if ($indexTarget == 'parent') {
             $parentNode = $contentObjectAttribute->object()->mainNode()->fetchParent();
             if (empty($classIdentifiers) || in_array($parentNode->classIdentifier(), $classIdentifiers)) {
                 return array($parentNode);
             }
         } else {
             if ($indexTarget == 'children' || $indexTarget == 'subtree') {
                 $children = eZContentObjectTreeNode::subTreeByNodeID(array('ClassFilterType' => !empty($classIdentifiers) ? 'include' : false, 'ClassFilterArray' => !empty($classIdentifiers) ? $classIdentifiers : false, 'Depth' => $indexTarget == 'children' ? 1 : false), $contentObjectAttribute->object()->mainNode()->attribute('node_id'));
                 if (is_array($children)) {
                     return $children;
                 }
             }
         }
     }
     return array();
 }
 public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt)
 {
     if (isset($parameters['Source'])) {
         $nodeID = $parameters['Source'];
         $node = eZContentObjectTreeNode::fetch($nodeID, false, false);
         // not as an object
         if ($node && $node['modified_subnode'] <= $publishedAfter) {
             return array();
         }
     } else {
         $nodeID = 0;
     }
     $subTreeParameters = array();
     $subTreeParameters['AsObject'] = false;
     $subTreeParameters['SortBy'] = array('published', true);
     // first the oldest
     $subTreeParameters['AttributeFilter'] = array('and', array('published', '>', $publishedAfter), array('published', '<=', $publishedBeforeOrAt));
     if (isset($parameters['Classes'])) {
         $subTreeParameters['ClassFilterType'] = 'include';
         $subTreeParameters['ClassFilterArray'] = explode(',', $parameters['Classes']);
     }
     // Do not fetch hidden nodes even when ShowHiddenNodes=true
     $subTreeParameters['AttributeFilter'] = array('and', array('visibility', '=', true));
     $nodes = eZContentObjectTreeNode::subTreeByNodeID($subTreeParameters, $nodeID);
     if ($nodes === null) {
         return array();
     }
     $fetchResult = array();
     foreach ($nodes as $node) {
         $fetchResult[] = array('object_id' => $node['contentobject_id'], 'node_id' => $node['node_id'], 'ts_publication' => $node['published']);
     }
     return $fetchResult;
 }
Пример #4
0
 public function execute($process, $event)
 {
     $processParameters = $process->attribute('parameter_list');
     $object = eZContentObject::fetch($processParameters['object_id']);
     $targetClassIdentifier = $object->contentClass()->attribute('identifier');
     $iniGroups = eZINI::instance('ngindexer.ini')->groups();
     $targets = array();
     foreach ($iniGroups as $iniGroupName => $iniGroup) {
         $iniGroupNameArray = explode('/', $iniGroupName);
         if (is_array($iniGroupNameArray) && count($iniGroupNameArray) == 3) {
             $class = eZContentClass::fetchByIdentifier($iniGroupNameArray[0]);
             if ($class instanceof eZContentClass) {
                 $classAttribute = $class->fetchAttributeByIdentifier($iniGroupNameArray[1]);
                 if ($classAttribute instanceof eZContentClassAttribute) {
                     $indexTarget = isset($iniGroup['IndexTarget']) ? trim($iniGroup['IndexTarget']) : '';
                     $referencedClassIdentifiers = isset($iniGroup['ClassIdentifiers']) && is_array($iniGroup['ClassIdentifiers']) ? $iniGroup['ClassIdentifiers'] : null;
                     if ($referencedClassIdentifiers != null && (empty($referencedClassIdentifiers) || in_array($targetClassIdentifier, $referencedClassIdentifiers))) {
                         switch ($indexTarget) {
                             case 'parent':
                             case 'parent_line':
                                 $children = eZContentObjectTreeNode::subTreeByNodeID(array('ClassFilterType' => 'include', 'ClassFilterArray' => array($iniGroupNameArray[0]), 'Depth' => $indexTarget == 'parent' ? 1 : false), $object->mainNode()->attribute('node_id'));
                                 if (is_array($children)) {
                                     $targets = array_merge($targets, $children);
                                 }
                                 break;
                             case 'children':
                                 $parentNode = $object->mainNode()->fetchParent();
                                 if ($parentNode->classIdentifier() == $iniGroupNameArray[0]) {
                                     $targets[] = $parentNode;
                                 }
                                 break;
                             case 'subtree':
                                 $path = $object->mainNode()->fetchPath();
                                 foreach ($path as $pathNode) {
                                     if ($pathNode->classIdentifier() == $iniGroupNameArray[0]) {
                                         $targets[] = $parentNode;
                                     }
                                 }
                                 break;
                             default:
                                 continue;
                         }
                     }
                 }
             }
         }
     }
     $filteredTargets = array();
     foreach ($targets as $target) {
         $objectID = $target->attribute('contentobject_id');
         $version = $target->object()->attribute('current_version');
         if (!isset($filteredTargets[$objectID])) {
             $filteredTargets[$objectID] = $version;
             eZContentOperationCollection::registerSearchObject($objectID, $version);
         }
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
Пример #5
0
 /**
  * Runs a content repository query using a given set of criteria
  *
  * @param ezpContentCriteria $criteria
  * @return ezpContentList
  */
 public static function query(ezpContentCriteria $criteria)
 {
     $fetchParams = self::translateFetchParams($criteria);
     $nodes = eZContentObjectTreeNode::subTreeByNodeID($fetchParams->params, $fetchParams->rootNodeId);
     $return = array();
     foreach ($nodes as $node) {
         $return[] = ezpContent::fromNode($node);
     }
     return $return;
 }
 function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     $postVariableName = $base . "_data_object_relation_id_" . $contentObjectAttribute->attribute("id");
     $haveData = false;
     if ($http->hasPostVariable($postVariableName)) {
         $relatedObjectID = $http->postVariable($postVariableName);
         if ($relatedObjectID == '') {
             $relatedObjectID = null;
         }
         $contentObjectAttribute->setAttribute('data_int', $relatedObjectID);
         $haveData = true;
     }
     $fuzzyMatchVariableName = $base . "_data_object_relation_fuzzy_match_" . $contentObjectAttribute->attribute("id");
     if ($http->hasPostVariable($fuzzyMatchVariableName)) {
         $trans = eZCharTransform::instance();
         $fuzzyMatchText = trim($http->postVariable($fuzzyMatchVariableName));
         if ($fuzzyMatchText != '') {
             $fuzzyMatchText = $trans->transformByGroup($fuzzyMatchText, 'lowercase');
             $classAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
             if ($classAttribute) {
                 $classContent = $classAttribute->content();
                 if ($classContent['default_selection_node']) {
                     $nodeID = $classContent['default_selection_node'];
                     $nodeList = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1), $nodeID);
                     $lastDiff = false;
                     $matchObjectID = false;
                     foreach ($nodeList as $node) {
                         $name = $trans->transformByGroup(trim($node->attribute('name')), 'lowercase');
                         $diff = $this->fuzzyTextMatch($name, $fuzzyMatchText);
                         if ($diff === false) {
                             continue;
                         }
                         if ($diff == 0) {
                             $matchObjectID = $node->attribute('contentobject_id');
                             break;
                         }
                         if ($lastDiff === false or $diff < $lastDiff) {
                             $lastDiff = $diff;
                             $matchObjectID = $node->attribute('contentobject_id');
                         }
                     }
                     if ($matchObjectID !== false) {
                         $contentObjectAttribute->setAttribute('data_int', $matchObjectID);
                         $haveData = true;
                     }
                 }
             }
         }
     }
     return $haveData;
 }
Пример #7
0
if ($dryRun) {
    $cli->notice("Don't worry, --dry-run mode activated.");
}
foreach ($deleteIDArray as $nodeID) {
    /** @var eZContentObjectTreeNode $node */
    $node = eZContentObjectTreeNode::fetch($nodeID);
    if ($node === null) {
        $cli->error("\nSubtree remove Error!\nCannot find subtree with nodeID: '{$nodeID}'.");
        continue;
    }
    $count = (int) eZContentObjectTreeNode::subTreeCountByNodeID($params, $nodeID);
    $cli->notice("===== {$nodeID} : {$count} children to remove. " . $node->url());
    $i = 0;
    do {
        /** @var eZContentObjectTreeNode[] $children */
        $children = eZContentObjectTreeNode::subTreeByNodeID($params, $nodeID);
        foreach ($children as $child) {
            $i++;
            $child_node_id = $child->attribute('node_id');
            if ($verbose) {
                $t = time();
                $te = max($t - $start, 1);
                // temps écoulé. (1 min pour éviter les divisions par 0)
                $tm = $te / $i;
                // temps moyen. = temps déjà consomé divisé par le nombre de objet passé. FLoat.
                $r = $count - $i;
                $tr = (int) ($r * $tm);
                // temps restant = nombre d'objet restant multiplié par le temp moyen.
                $tf = $t + $tr;
                // temps final = temps actuel plus le temps restant
                $df = date('H:i.s', $tf);
Пример #8
0
/**
 * Returns publisher folders related to given cluster
 * @param string $clusterIdentifier
 * @throws Exception
 * @return array:
 */
function fetchPublisherFoldersForCluster( $clusterIdentifier )
{
	$remoteID      = 'country_' . $clusterIdentifier;
	$clusterObject = eZContentObject::fetchByRemoteId($remoteID);

	if ( !$clusterObject instanceof eZContentObject )
		throw new Exception( 'No node found for cluster ' . $clusterIdentifier );

	$clusterNodeID = $clusterObject->mainNode()->attribute('node_id');
	$class         = eZContentClass::fetchByIdentifier( CLASS_IDENTIFIER_PUBLISHER_FOLDER );
	$attributeID   = (int) $class->fetchAttributeByIdentifier( ATTRIBUTE_TARGET_CONTENT_SERVICE )->ID;
	$limit         = 200;
	$offset        = 0;
	$result        = array();

	while ( true )
	{
		$params = array(
				'Depth' => 1,
				'AsObject' => true,
				'ClassFilterType' => 'include',
				'ClassFilterArray' => array(
						CLASS_IDENTIFIER_APPLICATION_FOLDER
				),
				'Limit' => $limit,
				'Offset' => $offset,
		);

		$fetchedNodes = eZContentObjectTreeNode::subTreeByNodeID( $params, $clusterNodeID );

		if ( empty( $fetchedNodes ) )
			break;

		foreach ( $fetchedNodes as $node )
		{
			$object = $node->ContentObject;

			$publisherFolders = $object->relatedObjects( false, false, $attributeID, false, array(
					'AllRelations' => eZContentObject::RELATION_ATTRIBUTE
			), true );

			foreach ( $publisherFolders as $publisherFolder )
			{
				$result['objects'][] = $publisherFolder;
				$result['questions'][] = str_replace( 'publisher_folder-', '',  $publisherFolder->RemoteID );
			}
		}

		$offset += $limit;
	}
	return $result;
}
}
// check that solr is enabled and used
$eZSolr = eZSearch::getEngine();
if (!$eZSolr instanceof eZSolr) {
    $script->shutdown(1, 'The current search engine plugin is not eZSolr');
}
$limit = 50;
$entries = eZPendingActions::fetchByAction(eZSolr::PENDING_ACTION_INDEX_SUBTREE);
if (!empty($entries)) {
    $parentNodeIDList = array();
    foreach ($entries as $entry) {
        $parentNodeID = $entry->attribute('param');
        $parentNodeIDList[] = (int) $parentNodeID;
        $offset = 0;
        while (true) {
            $nodes = eZContentObjectTreeNode::subTreeByNodeID(array('IgnoreVisibility' => true, 'Offset' => $offset, 'Limit' => $limit, 'Limitation' => array()), $parentNodeID);
            if (!empty($nodes) && is_array($nodes)) {
                foreach ($nodes as $node) {
                    ++$offset;
                    $cli->output("\tIndexing object ID #{$node->attribute('contentobject_id')}");
                    // delay commits with passing false for $commit parameter
                    $eZSolr->addObject($node->attribute('object'), false);
                }
                // finish up with commit
                $eZSolr->commit();
                // clear object cache to conserver memory
                eZContentObject::clearCache();
            } else {
                break;
                // No valid nodes
            }
Пример #10
0
function copySubtree($srcNodeID, $dstNodeID, &$notifications, $allVersions, $keepCreator, $keepTime)
{
    // 1. Copy subtree and form the arrays of accordance of the old and new nodes and content objects.
    $sourceSubTreeMainNode = $srcNodeID ? eZContentObjectTreeNode::fetch($srcNodeID) : false;
    $destinationNode = $dstNodeID ? eZContentObjectTreeNode::fetch($dstNodeID) : false;
    if (!$sourceSubTreeMainNode) {
        eZDebug::writeError("Cannot get subtree main node (nodeID = {$srcNodeID}).", "Subtree copy Error!");
        $notifications['Errors'][] = ezpI18n::tr('kernel/content/copysubtree', "Fatal error: cannot get subtree main node (ID = %1).", null, array($srcNodeID));
        $notifications['Result'] = false;
        return $notifications;
    }
    if (!$destinationNode) {
        eZDebug::writeError("Cannot get destination node (nodeID = {$dstNodeID}).", "Subtree copy Error!");
        $notifications['Errors'][] = ezpI18n::tr('kernel/content/copysubtree', "Fatal error: cannot get destination node (ID = %1).", null, array($dstNodeID));
        $notifications['Result'] = false;
        return $notifications;
    }
    $sourceNodeList = array();
    $syncNodeIDListSrc = array();
    // arrays for synchronizing between source and new IDs of nodes
    $syncNodeIDListNew = array();
    $syncObjectIDListSrc = array();
    // arrays for synchronizing between source and new IDs of contentobjects
    $syncObjectIDListNew = array();
    $sourceSubTreeMainNodeID = $sourceSubTreeMainNode->attribute('node_id');
    $sourceNodeList[] = $sourceSubTreeMainNode;
    $syncNodeIDListSrc[] = $sourceSubTreeMainNode->attribute('parent_node_id');
    $syncNodeIDListNew[] = (int) $dstNodeID;
    $nodeIDBlackList = array();
    // array of nodes which are unable to copy
    $objectIDBlackList = array();
    // array of contentobjects which are unable to copy in any location inside new subtree
    $sourceNodeList = array_merge($sourceNodeList, eZContentObjectTreeNode::subTreeByNodeID(array('Limitation' => array()), $sourceSubTreeMainNodeID));
    $countNodeList = count($sourceNodeList);
    $notifications['Notifications'][] = ezpI18n::tr('kernel/content/copysubtree', "Number of nodes of source subtree - %1", null, array($countNodeList));
    // Prepare list of source node IDs. We will need it in the future
    // for checking node is inside or outside of the subtree being copied.
    $sourceNodeIDList = array();
    foreach ($sourceNodeList as $sourceNode) {
        $sourceNodeIDList[] = $sourceNode->attribute('node_id');
    }
    eZDebug::writeDebug("Source NodeID = {$srcNodeID}, destination NodeID = {$dstNodeID}", "Subtree copy: START!");
    // 1. copying and publishing source subtree
    $k = 0;
    while (count($sourceNodeList) > 0) {
        if ($k > $countNodeList) {
            eZDebug::writeError("Too many loops while copying nodes.", "Subtree Copy Error!");
            break;
        }
        for ($i = 0; $i < count($sourceNodeList); $i) {
            $sourceNodeID = $sourceNodeList[$i]->attribute('node_id');
            // if node was alreaty copied
            if (in_array($sourceNodeID, $syncNodeIDListSrc)) {
                array_splice($sourceNodeList, $i, 1);
                continue;
            }
            //////////// check permissions START
            // if node is already in black list, then skip current node:
            if (in_array($sourceNodeID, $nodeIDBlackList)) {
                array_splice($sourceNodeList, $i, 1);
                continue;
            }
            $sourceObject = $sourceNodeList[$i]->object();
            $srcSubtreeNodeIDlist = $sourceNodeID == $sourceSubTreeMainNodeID ? $syncNodeIDListSrc : $sourceNodeIDList;
            $copyResult = copyPublishContentObject($sourceObject, $srcSubtreeNodeIDlist, $syncNodeIDListSrc, $syncNodeIDListNew, $syncObjectIDListSrc, $syncObjectIDListNew, $objectIDBlackList, $nodeIDBlackList, $notifications, $allVersions, $keepCreator, $keepTime);
            if ($copyResult === 0) {
                // if copying successful then remove $sourceNode from $sourceNodeList
                array_splice($sourceNodeList, $i, 1);
            } else {
                $i++;
            }
        }
        $k++;
    }
    array_shift($syncNodeIDListSrc);
    array_shift($syncNodeIDListNew);
    $countNewNodes = count($syncNodeIDListNew);
    $countNewObjects = count($syncObjectIDListNew);
    $notifications['Notifications'][] = ezpI18n::tr('kernel/content/copysubtree', "Number of copied nodes - %1", null, array($countNewNodes));
    $notifications['Notifications'][] = ezpI18n::tr('kernel/content/copysubtree', "Number of copied contentobjects - %1", null, array($countNewObjects));
    eZDebug::writeDebug(count($syncNodeIDListNew), "Number of copied nodes: ");
    eZDebug::writeDebug(count($syncObjectIDListNew), "Number of copied contentobjects: ");
    eZDebug::writeDebug($objectIDBlackList, "Copy subtree: Not copied object IDs list:");
    eZDebug::writeDebug($nodeIDBlackList, "Copy subtree: Not copied node IDs list:");
    $key = array_search($sourceSubTreeMainNodeID, $syncNodeIDListSrc);
    if ($key === false) {
        eZDebug::writeDebug("Root node of given subtree was not copied.", "Subtree copy:");
        $notifications['Result'] = false;
        return $notifications;
    }
    // 2. fetch all new subtree
    $newSubTreeMainNodeID = $syncNodeIDListSrc[$key];
    $newSubTreeMainNode = eZContentObjectTreeNode::fetch($newSubTreeMainNodeID);
    $newNodeList[] = $newSubTreeMainNode;
    $newNodeList = $sourceNodeList = array_merge($newNodeList, eZContentObjectTreeNode::subTreeByNodeID(false, $newSubTreeMainNodeID));
    // 3. fix local links (in ezcontentobject_link)
    eZDebug::writeDebug("Fixing global and local links...", "Subtree copy:");
    $db = eZDB::instance();
    if (!$db) {
        eZDebug::writeError("Cannot create instance of eZDB for fixing local links (related objects).", "Subtree Copy Error!");
        $notifications['Errors'][] = ezpI18n::tr('kernel/content/copysubtree', "Cannot create instance of eZDB to fix local links (related objects).");
        return $notifications;
    }
    $idListINString = $db->generateSQLINStatement($syncObjectIDListNew, 'from_contentobject_id', false, false, 'int');
    $relatedRecordsList = $db->arrayQuery("SELECT * FROM ezcontentobject_link WHERE {$idListINString}");
    foreach ($relatedRecordsList as $relatedEntry) {
        $kindex = array_search($relatedEntry['to_contentobject_id'], $syncObjectIDListSrc);
        if ($kindex !== false) {
            $newToContentObjectID = (int) $syncObjectIDListNew[$kindex];
            $linkID = (int) $relatedEntry['id'];
            $db->query("UPDATE ezcontentobject_link SET  to_contentobject_id={$newToContentObjectID} WHERE id={$linkID}");
        }
    }
    // 4. duplicating of global links for new contentobjects (in ezurl_object_link) are automatic during copy of contentobject.
    //    it was fixed as bug patch.
    // 5. fixing node_ids and object_ids in ezxmltext attributes of copied objects
    $conditions = array('contentobject_id' => '', 'data_type_string' => 'ezxmltext');
    foreach ($syncObjectIDListNew as $contentObjectID) {
        $conditions['contentobject_id'] = $contentObjectID;
        $attributeList = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, $conditions);
        if (count($attributeList) == 0) {
            continue;
        }
        foreach ($attributeList as $xmlAttribute) {
            $xmlText = $xmlAttribute->attribute('data_text');
            $xmlTextLen = strlen($xmlText);
            $isTextModified = false;
            $curPos = 0;
            while ($curPos < $xmlTextLen) {
                $literalTagBeginPos = strpos($xmlText, "<literal", $curPos);
                if ($literalTagBeginPos) {
                    $literalTagEndPos = strpos($xmlText, "</literal>", $literalTagBeginPos);
                    if ($literalTagEndPos === false) {
                        break;
                    }
                    $curPos = $literalTagEndPos + 9;
                }
                if (($tagBeginPos = strpos($xmlText, "<link", $curPos)) !== false or ($tagBeginPos = strpos($xmlText, "<a", $curPos)) !== false or ($tagBeginPos = strpos($xmlText, "<embed", $curPos)) !== false) {
                    $tagEndPos = strpos($xmlText, ">", $tagBeginPos + 1);
                    if ($tagEndPos === false) {
                        break;
                    }
                    $tagText = substr($xmlText, $tagBeginPos, $tagEndPos - $tagBeginPos);
                    if (($nodeIDAttributePos = strpos($tagText, " node_id=\"")) !== false) {
                        $idNumberPos = $nodeIDAttributePos + 10;
                        $quoteEndPos = strpos($tagText, "\"", $idNumberPos);
                        if ($quoteEndPos !== false) {
                            $idNumber = substr($tagText, $idNumberPos, $quoteEndPos - $idNumberPos);
                            $key = array_search((int) $idNumber, $syncNodeIDListSrc);
                            if ($key !== false) {
                                $tagText = substr_replace($tagText, (string) $syncNodeIDListNew[$key], $idNumberPos, $quoteEndPos - $idNumberPos);
                                $xmlText = substr_replace($xmlText, $tagText, $tagBeginPos, $tagEndPos - $tagBeginPos);
                                $isTextModified = true;
                            }
                        }
                    } else {
                        if (($objectIDAttributePos = strpos($tagText, " object_id=\"")) !== false) {
                            $idNumberPos = $objectIDAttributePos + 12;
                            $quoteEndPos = strpos($tagText, "\"", $idNumberPos);
                            if ($quoteEndPos !== false) {
                                $idNumber = substr($tagText, $idNumberPos, $quoteEndPos - $idNumberPos);
                                $key = array_search((int) $idNumber, $syncObjectIDListSrc);
                                if ($key !== false) {
                                    $tagText = substr_replace($tagText, (string) $syncObjectIDListNew[$key], $idNumberPos, $quoteEndPos - $idNumberPos);
                                    $xmlText = substr_replace($xmlText, $tagText, $tagBeginPos, $tagEndPos - $tagBeginPos);
                                    $isTextModified = true;
                                }
                            }
                        }
                    }
                    $curPos = $tagEndPos;
                } else {
                    if (($tagBeginPos = strpos($xmlText, "<object", $curPos)) !== false) {
                        $tagEndPos = strpos($xmlText, ">", $tagBeginPos + 1);
                        if (!$tagEndPos) {
                            break;
                        }
                        $tagText = substr($xmlText, $tagBeginPos, $tagEndPos - $tagBeginPos);
                        if (($idAttributePos = strpos($tagText, " id=\"")) !== false) {
                            $idNumberPos = $idAttributePos + 5;
                            $quoteEndPos = strpos($tagText, "\"", $idNumberPos);
                            if ($quoteEndPos !== false) {
                                $idNumber = substr($tagText, $idNumberPos, $quoteEndPos - $idNumberPos);
                                $key = array_search((int) $idNumber, $syncObjectIDListSrc);
                                if ($key !== false) {
                                    $tagText = substr_replace($tagText, (string) $syncObjectIDListNew[$key], $idNumberPos, $quoteEndPos - $idNumberPos);
                                    $xmlText = substr_replace($xmlText, $tagText, $tagBeginPos, $tagEndPos - $tagBeginPos);
                                    $isTextModified = true;
                                }
                            }
                        }
                        $curPos = $tagEndPos;
                    } else {
                        break;
                    }
                }
            }
            // while END
            if ($isTextModified) {
                $xmlAttribute->setAttribute('data_text', $xmlText);
                $xmlAttribute->store();
            }
        }
        // foreach END
    }
    // 6. fixing datatype ezobjectrelationlist
    $conditions = array('contentobject_id' => '', 'data_type_string' => 'ezobjectrelationlist');
    foreach ($syncObjectIDListNew as $contentObjectID) {
        $conditions['contentobject_id'] = $contentObjectID;
        $attributeList = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, $conditions);
        if (count($attributeList) == 0) {
            continue;
        }
        foreach ($attributeList as $relationListAttribute) {
            $relationsXmlText = $relationListAttribute->attribute('data_text');
            $relationsDom = eZObjectRelationListType::parseXML($relationsXmlText);
            $relationItems = $relationsDom->getElementsByTagName('relation-item');
            $isRelationModified = false;
            foreach ($relationItems as $relationItem) {
                $originalObjectID = $relationItem->getAttribute('contentobject-id');
                $key = array_search($originalObjectID, $syncObjectIDListSrc);
                if ($key !== false) {
                    $newObjectID = $syncObjectIDListNew[$key];
                    $relationItem->setAttribute('contentobject-id', $newObjectID);
                    $isRelationModified = true;
                }
                $originalNodeID = $relationItem->getAttribute('node-id');
                if ($originalNodeID) {
                    $key = array_search($originalNodeID, $syncNodeIDListSrc);
                    if ($key !== false) {
                        $newNodeID = $syncNodeIDListNew[$key];
                        $relationItem->setAttribute('node-id', $newNodeID);
                        $newNode = eZContentObjectTreeNode::fetch($newNodeID);
                        $newParentNodeID = $newNode->attribute('parent_node_id');
                        $relationItem->setAttribute('parent-node-id', $newParentNodeID);
                        $isRelationModified = true;
                    }
                }
            }
            if ($isRelationModified) {
                $attributeID = $relationListAttribute->attribute('id');
                $attributeVersion = $relationListAttribute->attribute('version');
                $changedDomString = $db->escapeString(eZObjectRelationListType::domString($relationsDom));
                $db->query("UPDATE ezcontentobject_attribute SET data_text='{$changedDomString}'\n                             WHERE id={$attributeID} AND version={$attributeVersion}");
            }
        }
    }
    eZDebug::writeDebug("Successfuly DONE.", "Copy subtree:");
    $notifications['Result'] = true;
    return $notifications;
}
 public static function fetchObjectTree($parentNodeID, $sortBy, $onlyTranslated, $language, $offset, $limit, $depth, $depthOperator, $classID, $attribute_filter, $extended_attribute_filter, $class_filter_type, $class_filter_array, $groupBy, $mainNodeOnly, $ignoreVisibility, $limitation, $asObject, $objectNameFilter, $loadDataMap = null)
 {
     $treeParameters = array('Offset' => $offset, 'OnlyTranslated' => $onlyTranslated, 'Language' => $language, 'Limit' => $limit, 'Limitation' => $limitation, 'SortBy' => $sortBy, 'class_id' => $classID, 'AttributeFilter' => $attribute_filter, 'ExtendedAttributeFilter' => $extended_attribute_filter, 'ClassFilterType' => $class_filter_type, 'ClassFilterArray' => $class_filter_array, 'IgnoreVisibility' => $ignoreVisibility, 'ObjectNameFilter' => $objectNameFilter, 'MainNodeOnly' => $mainNodeOnly);
     if (is_array($groupBy)) {
         $groupByHash = array('field' => $groupBy[0], 'type' => false);
         if (isset($groupBy[1])) {
             $groupByHash['type'] = $groupBy[1];
         }
         $treeParameters['GroupBy'] = $groupByHash;
     }
     if ($asObject !== null) {
         $treeParameters['AsObject'] = $asObject;
     }
     if ($loadDataMap) {
         $treeParameters['LoadDataMap'] = true;
     } else {
         if ($loadDataMap === null) {
             $treeParameters['LoadDataMap'] = 15;
         }
     }
     if ($depth !== false) {
         $treeParameters['Depth'] = $depth;
         $treeParameters['DepthOperator'] = $depthOperator;
     }
     $children = null;
     if (is_numeric($parentNodeID) or is_array($parentNodeID)) {
         $children = eZContentObjectTreeNode::subTreeByNodeID($treeParameters, $parentNodeID);
     }
     if ($children === null) {
         return array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
     } else {
         return array('result' => $children);
     }
 }
$options = $script->getOptions('', '', false, false, array('siteaccess' => true, 'user' => true));
$siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false;
$script->setUseSiteAccess($siteAccess);
$script->initialize();
$cli->output("\nStart.");
$contentIni = eZINI::instance('content.ini');
$userRootNodeID = $contentIni->variable('NodeSettings', 'UserRootNode');
$siteIni = eZINI::instance('site.ini');
$anonymousUserID = $siteIni->variable('UserSettings', 'AnonymousUserID');
$anonymousUser = eZUser::fetch($anonymousUserID);
$anonymousUsers = array();
if (is_object($anonymousUser)) {
    $anonymousUsers = $anonymousUser->groups();
    $anonymousUsers[] = $anonymousUserID;
}
$topUserNodes = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1), $userRootNodeID);
if (count($topUserNodes) == 0) {
    $cli->warning("Unable to retrieve the user root node. Please make sure\n" . "you log in to the system with the administrator's user\n" . "acount by using the -l and -p command line options.");
    $script->shutdown(1);
}
$roleName = 'Tipafriend Role';
$role = eZRole::fetchByName($roleName);
if (is_object($role)) {
    $cli->warning("The 'Tipafriend Role' already exists in the system. This means that\n" . "the script was already run before or the same role was added manually.\n" . "The role will not be added. Check the role settings of the system.");
} else {
    $userInput = '';
    $usersToAssign = array();
    $stdin = fopen("php://stdin", "r+");
    foreach ($topUserNodes as $userNode) {
        if ($userInput != 'a') {
            $name = $userNode->getName();
Пример #13
0
    $k++;
}
array_shift($syncNodeIDListSrc);
array_shift($syncNodeIDListNew);
$cli->output("\nNumber of copied nodes: " . count($syncNodeIDListNew));
$cli->output("Number of copied contentobjects: " . count($syncObjectIDListNew));
// 2. fetch all new subtree
$key = array_search($sourceSubTreeMainNodeID, $syncNodeIDListSrc);
if ($key === false) {
    $cli->error("Subtree copy Error!\nCannot find subtree root node in array of IDs of copied nodes.");
    $script->shutdown(1);
}
$newSubTreeMainNodeID = $syncNodeIDListSrc[$key];
$newSubTreeMainNode = eZContentObjectTreeNode::fetch($newSubTreeMainNodeID);
$newNodeList[] = $newSubTreeMainNode;
$newNodeList = $sourceNodeList = array_merge($newNodeList, eZContentObjectTreeNode::subTreeByNodeID(false, $newSubTreeMainNodeID));
$cli->output("Fixing global and local links...");
// 3. fix local links (in ezcontentobject_link)
$db = eZDB::instance();
if (!$db) {
    $cli->error("Subtree Copy Error!\nCannot create instance of eZDB for fixing local links (related objects).");
    $script->shutdown(3);
}
$idListStr = implode(',', $syncObjectIDListNew);
$relatedRecordsList = $db->arrayQuery("SELECT * FROM ezcontentobject_link WHERE from_contentobject_id IN ({$idListStr})");
foreach ($relatedRecordsList as $relatedEntry) {
    $kindex = array_search($relatedEntry['to_contentobject_id'], $syncObjectIDListSrc);
    if ($kindex !== false) {
        $newToContentObjectID = $syncObjectIDListNew[$kindex];
        $linkID = $relatedEntry['id'];
        $db->query("UPDATE ezcontentobject_link SET  to_contentobject_id={$newToContentObjectID} WHERE id={$linkID}");
    $cli->error( "Subtree remove Error!\nCannot get subtree nodes. Please check nodes-id argument and try again." );
    $script->showHelp();
    $script->shutdown( 1 );
}
*/
$ini = eZINI::instance();
// Get user's ID who can remove subtrees. (Admin by default with userID = 14)
$userCreatorID = $ini->variable("UserSettings", "UserCreatorID");
$user = eZUser::fetch($userCreatorID);
if (!$user) {
    $cli->error("Subtree remove Error!\nCannot get user object by userID = '{$userCreatorID}'.\n(See site.ini[UserSettings].UserCreatorID)");
    $script->shutdown(1);
}
eZUser::setCurrentlyLoggedInUser($user, $userCreatorID);
$moveToTrash = false;
$deleteIDArray = eZContentObjectTreeNode::subTreeByNodeID(array('Limit' => 10000, 'Depth' => 4, 'ClassFilterType' => 'include', 'ClassFilterArray' => array('blog_post')), 2);
// print_r( count( $deleteIDArray ) );
$deleteIDArrayResult = array();
foreach ($deleteIDArray as $nodeID) {
    $node = eZContentObjectTreeNode::fetch($nodeID->attribute('node_id'));
    if ($node === null) {
        $cli->error("\nSubtree remove Error!\nCannot find subtree with nodeID: '{$nodeID}'.");
        continue;
    }
    $deleteIDArrayResult[] = $nodeID->attribute('node_id');
}
// Get subtree removal information
$info = eZContentObjectTreeNode::subtreeRemovalInformation($deleteIDArrayResult);
$deleteResult = $info['delete_list'];
if (count($deleteResult) == 0) {
    $cli->output("\nExit.");
Пример #15
0
 static function goAndPublishGroups(&$requiredParams, $curDN, &$groupsTree, &$stack, $depth, $isUser = false)
 {
     if (!isset($groupsTree[$curDN])) {
         eZDebug::writeError('Passed $curDN is not in result tree array.', __METHOD__);
         return false;
     }
     array_push($stack, $curDN);
     $current =& $groupsTree[$curDN];
     // check the name
     if ($isUser) {
         $currentName = $current['data'][$requiredParams['LDAPLoginAttribute']];
     } else {
         $currentName = $current['data'][$requiredParams['LDAPGroupNameAttribute']];
     }
     if (is_array($currentName) and isset($currentName['count']) and $currentName['count'] > 0) {
         $currentName = $currentName[0];
     }
     if (empty($currentName)) {
         eZDebug::writeWarning("Cannot create/use group with empty name (dn = {$curDN})", __METHOD__);
         return false;
     }
     // go through parents
     if (is_array($current['parents']) and count($current['parents']) > 0) {
         foreach (array_keys($current['parents']) as $key) {
             $parent =& $groupsTree[$key];
             if (in_array($parent['data']['dn'], $stack)) {
                 $groupsTree['_recursion_detected_'] = true;
                 eZDebug::writeError('Recursion is detected in the user-groups tree while getting parent groups for ' . $curDN, __METHOD__);
                 return false;
             }
             if (isset($parent['nodes']) and count($parent['nodes']) > 0) {
                 continue;
             }
             $ret = self::goAndPublishGroups($requiredParams, $parent['data']['dn'], $groupsTree, $stack, $depth - 1);
             if (isset($groupsTree['_recursion_detected_']) and $groupsTree['_recursion_detected_']) {
                 return false;
             }
         }
     } else {
         // We've reached a top node
         if (!isset($groupsTree['root'])) {
             $groupsTree['root'] = array('data' => null, 'parents' => null, 'children' => array(), 'nodes' => array($requiredParams['TopUserGroupNodeID']));
         }
         if (!isset($groupsTree['root']['children'][$curDN])) {
             $groupsTree['root']['children'][$curDN] =& $current;
         }
         if (!isset($current['parents']['root'])) {
             $current['parents']['root'] =& $groupsTree['root'];
         }
     }
     if (!isset($current['nodes'])) {
         $current['nodes'] = array();
     }
     $parentNodesForNew = array();
     foreach (array_keys($current['parents']) as $key) {
         $parent =& $groupsTree[$key];
         if (is_array($parent['nodes']) and count($parent['nodes']) > 0) {
             foreach ($parent['nodes'] as $parentNodeID) {
                 // fetch current parent node
                 $parentNode = eZContentObjectTreeNode::fetch($parentNodeID);
                 if (is_object($parentNode)) {
                     $params = array('AttributeFilter' => array(array('name', '=', $currentName)), 'Limitation' => array());
                     $nodes = eZContentObjectTreeNode::subTreeByNodeID($params, $parentNodeID);
                     if (is_array($nodes) and count($nodes) > 0 and !$isUser) {
                         // if group with given name already exist under $parentNode then get fetch
                         // group node and remember its ID
                         $node =& $nodes[0];
                         $nodeID = $node->attribute('node_id');
                         $current['nodes'][] = $nodeID;
                     } else {
                         // if not exist then remember $parentNodeID to publish a new one
                         $parentNodesForNew[] = $parentNodeID;
                     }
                 } else {
                     eZDebug::writeError('Cannot fetch parent node for creating new user group ' . $parentNodeID, __METHOD__);
                 }
             }
         } else {
             eZDebug::writeError("Cannot get any published parent group for group/user with name = '{$currentName}'" . " (dn = '" . $current['data']['dn'] . "')", __METHOD__);
         }
     }
     if (count($parentNodesForNew) > 0) {
         if ($isUser) {
             $current['new_parents'] = $parentNodesForNew;
             $newNodeIDs = array();
         } else {
             $newNodeIDs = eZLDAPUser::publishNewUserGroup($parentNodesForNew, array('name' => $currentName, 'description' => ''));
         }
         $current['nodes'] = array_merge($current['nodes'], $newNodeIDs);
     }
     array_pop($stack);
     return true;
 }
    $cli->warning("content.ini/[VersionManagement]/DefaultVersionHistoryLimit and content.ini/[VersionManagement]/VersionHistoryClass");
    $cli->warning();
    $cli->warning("You have 10 seconds to break the script (press Ctrl-C)");
    sleep(10);
    $cli->output();
}
$subTreeParams = array('Limitation' => array(), 'MainNodeOnly' => true, 'LoadDataMap' => false, 'IgnoreVisibility' => true);
$total = eZContentObjectTreeNode::subTreeCountByNodeID($subTreeParams, 1);
$cli->output("{$total} objects to check... (In the progess bar, 'R' means that at least a version was removed)");
$script->setIterationData('R', '.');
$script->resetIteration($total);
$subTreeParams['Offset'] = 0;
$subTreeParams['Limit'] = 100;
$db = eZDB::instance();
while (true) {
    $nodes = eZContentObjectTreeNode::subTreeByNodeID($subTreeParams, 1);
    if (empty($nodes)) {
        break;
    }
    foreach ($nodes as $node) {
        $object = $node->attribute('object');
        $versionCount = $object->getVersionCount();
        $versionLimit = eZContentClass::versionHistoryLimit($object->attribute('content_class'));
        if ($versionCount <= $versionLimit) {
            $script->iterate($cli, false, "Nothing to do on object #{$object->attribute('id')}");
            continue;
        }
        $versionToRemove = $versionCount - $versionLimit;
        $versions = $object->versions(true, array('conditions' => array('status' => eZContentObjectVersion::STATUS_ARCHIVED), 'sort' => array('modified' => 'asc'), 'limit' => array('limit' => $versionToRemove, 'offset' => 0)));
        $removedVersion = 0;
        $db->begin();
 public static function createMFSitemap()
 {
     eZDebug::writeDebug("Generating Standard Sitemap with images ...", __METHOD__);
     $cli = $GLOBALS['cli'];
     global $cli, $isQuiet;
     if (!$isQuiet) {
         $cli->output("Generating Sitemap for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
     }
     $ini = eZINI::instance('site.ini');
     $googlesitemapsINI = eZINI::instance('xrowsitemap.ini');
     // Get the Sitemap's root node
     $contentINI = eZINI::instance('content.ini');
     $rootNode = eZContentObjectTreeNode::fetch($contentINI->variable('NodeSettings', 'RootNode'));
     if (!$rootNode instanceof eZContentObjectTreeNode) {
         $cli->output("Invalid RootNode for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
         continue;
     }
     // Settings variables
     if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterType') and $googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterArray')) {
         $params2 = array('ClassFilterType' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterArray'));
     }
     $max = 49997;
     // max. amount of links in 1 sitemap
     $limit = 50;
     // Fetch the content tree
     $params = array('SortBy' => array(array('depth', true), array('published', false)));
     if (isset($params2)) {
         $params = array_merge($params, $params2);
     }
     $subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID);
     if ($subtreeCount == 1) {
         $cli->output("No Items found under node #" . $contentINI->variable('NodeSettings', 'RootNode') . ".");
     }
     if (!$isQuiet) {
         $amount = $subtreeCount + 1;
         // +1 is root node
         $cli->output("Adding {$amount} nodes to the sitemap.");
         $output = new ezcConsoleOutput();
         $bar = new ezcConsoleProgressbar($output, $amount);
     }
     $addPrio = false;
     if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'AddPriorityToSubtree') and $googlesitemapsINI->variable('MFSitemapSettings', 'AddPriorityToSubtree') == 'true') {
         $addPrio = true;
     }
     $sitemap = new xrowSitemap();
     // Generate Sitemap
     /** START Adding the root node **/
     $object = $rootNode->object();
     $meta = xrowMetaDataFunctions::fetchByObject($object);
     $extensions = array();
     $extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode'));
     $url = $rootNode->attribute('url_alias');
     eZURI::transformURI($url, true);
     if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') {
         $url = 'http://' . xrowSitemapTools::domain() . $url;
     } else {
         $url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url;
     }
     if ($meta and $meta->googlemap != '0') {
         $extensions[] = new xrowSitemapItemFrequency($meta->change);
         $extensions[] = new xrowSitemapItemPriority($meta->priority);
         $sitemap->add($url, $extensions);
     } elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
         if ($addPrio) {
             $extensions[] = new xrowSitemapItemPriority('1');
         }
         $sitemap->add($url, $extensions);
     }
     if (isset($bar)) {
         $bar->advance();
     }
     /** END Adding the root node **/
     $max = min($max, $subtreeCount);
     $params['Limit'] = min($max, $limit);
     $params['Offset'] = 0;
     while ($params['Offset'] < $max) {
         $nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID);
         foreach ($nodeArray as $subTreeNode) {
             eZContentLanguage::expireCache();
             $object = $subTreeNode->object();
             $images = array();
             $meta = xrowMetaDataFunctions::fetchByObject($object);
             $extensions = array();
             $extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode'));
             $url = $subTreeNode->attribute('url_alias');
             eZURI::transformURI($url, true);
             if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') {
                 $url = 'http://' . xrowSitemapTools::domain() . $url;
             } else {
                 $url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url;
             }
             if ($meta and $meta->googlemap != '0') {
                 $extensions[] = new xrowSitemapItemFrequency($meta->change);
                 $extensions[] = new xrowSitemapItemPriority($meta->priority);
             } elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
                 if ($addPrio) {
                     $rootDepth = $rootNode->attribute('depth');
                     $prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10;
                     if ($prio > 0) {
                         $extensions[] = new xrowSitemapItemPriority($prio);
                     }
                 }
             }
             $images = self::getSitemapImageItems($object);
             $sitemap->add($url, array_merge($extensions, $images));
             if (isset($bar)) {
                 $bar->advance();
             }
         }
         eZContentObject::clearCache();
         $params['Offset'] += $params['Limit'];
     }
     // write XML Sitemap to file
     $dir = eZSys::storageDirectory() . '/sitemap/' . xrowSitemapTools::domain();
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $filename = $dir . '/' . xrowSitemap::BASENAME . '_standard_' . $GLOBALS['eZCurrentAccess']['name'] . '.' . xrowSitemap::SUFFIX;
     $sitemap->save($filename);
     if (!$isQuiet) {
         $cli->output("\n");
         $cli->output("Sitemap {$filename} for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " has been generated.\n");
     }
 }
 function getExtractableNodes($limit = false, $offset = false)
 {
     $classList = eZContentObjectAkismet::getExtractableClassList();
     $params = array('ClassFilterType' => 'include', 'ClassFilterArray' => $classList, 'SortBy' => array(array('published', false)), 'Limit' => $limit, 'Offset' => $offset);
     $nodes = eZContentObjectTreeNode::subTreeByNodeID($params, 1);
     return $nodes;
 }
Пример #19
0
    function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters )
    {
        $level = 0;
        $done = false;
        $i = 0;
        $pathArray = array();
        $tmpModulePath = $namedParameters['path'];
        $classFilter = $namedParameters['class_filter'];
        $language = $namedParameters['language'];
        $loadDataMap = $namedParameters['load_data_map'];
        // node_id is not used anymore
        if ( !empty( $namedParameters['node_id'] ) )
        {
            eZDebug::writeNotice( 'Deprecated parameter "node_id" in treemenu template operator' );
        }

        if ( $classFilter === false )
        {
            $classFilter = array();
        }
        else if ( count( $classFilter ) == 0 )
        {
            $classFilter = array( 1 );
        }
        $classFilter = ( count( $classFilter ) == 1 and !isset( $classFilter[0] ) ) ? array( 1 ) : $classFilter;
        $tmpModulePathCount = count( $tmpModulePath );
        if ( !$tmpModulePath[ $tmpModulePathCount -1 ]['url'] and isset( $tmpModulePath[ $tmpModulePathCount -1 ]['node_id'] ) )
            $tmpModulePath[ $tmpModulePathCount -1 ]['url'] = '/content/view/full/' . $tmpModulePath[ $tmpModulePathCount -1 ]['node_id'];

        $depthSkip = $namedParameters['depth_skip'];
        $indentationLevel = $namedParameters['indentation_level'];

        $maxLevel = $namedParameters['max_level'];
        $isSelectedMethod = $namedParameters['is_selected_method'];
        if ( $maxLevel === false )
            $maxLevel = 2;

        while ( !$done && isset( $tmpModulePath[$i+$depthSkip] ) )
        {
            // get node id
            $elements = explode( '/', $tmpModulePath[$i+$depthSkip]['url'] );
            $nodeID = false;
            if ( isset( $elements[4] ) )
                $nodeID = $elements[4];

            $excludeNode = false;

            if ( isset( $elements[1] ) &&
                 isset( $elements[2] ) &&
                $elements[1] == 'content' &&
                $elements[2] == 'view' &&
                is_numeric( $nodeID ) &&
                $excludeNode == false &&
                $level < $maxLevel )
            {
                $node = eZContentObjectTreeNode::fetch( $nodeID );
                if ( !isset( $node ) ) { $operatorValue = $pathArray; return; }
                if ( isset( $tmpModulePath[$i+$depthSkip+1] ) )
                {
                    $nextElements = explode( '/', $tmpModulePath[$i+$depthSkip+1]['url'] );
                    if ( isset( $nextElements[4] ) )
                    {
                        $nextNodeID = $nextElements[4];
                    }
                    else
                    {
                        $nextNodeID = false;
                    }
                }
                else
                    $nextNodeID = false;

                $menuChildren = eZContentObjectTreeNode::subTreeByNodeID( array( 'Depth' => 1,
                                                                         'Offset' => 0,
                                                                         'SortBy' => $node->sortArray(),
                                                                         'Language' => $language,
                                                                         'ClassFilterType' => 'include',
                                                                         'ClassFilterArray' => $classFilter ),
                                                                  $nodeID );

                /// Fill objects with attributes, speed boost, only use if load_data_map is true
                // or if less then 16 nodes and param is not set (null)
                if ( $loadDataMap || (  $loadDataMap === null && count( $menuChildren ) <= 15 ) )
                    eZContentObject::fillNodeListAttributes( $menuChildren );

                $tmpPathArray = array();
                foreach ( $menuChildren as $child )
                {
                    $name = $child->attribute( 'name' );
                    $tmpNodeID = $child->attribute( 'node_id' );

                    $url = "/content/view/full/$tmpNodeID/";
                    $urlAlias = '/' . $child->attribute( 'url_alias' );
                    $hasChildren = $child->attribute( 'is_container' ) && $child->attribute( 'children_count' ) > 0;
                    $contentObject = $child->attribute( 'object' );

                    $indent = ($i - 1) * $indentationLevel;

                    $isSelected = false;
                    $nextNextElements = ( $isSelectedMethod == 'node' and isset( $tmpModulePath[$i+$depthSkip+2]['url'] ) ) ? explode( '/', $tmpModulePath[$i+$depthSkip+2]['url'] ) : null;
                    if ( $nextNodeID === $tmpNodeID and !isset( $nextNextElements[4] ) )
                    {
                        $isSelected = true;
                    }

                    $tmpPathArray[] = array( 'id' => $tmpNodeID,
                                             'level' => $i,
                                             'class_name' => $contentObject->classname(),
                                             'is_main_node' => $child->attribute( 'is_main' ),
                                             'has_children' => $hasChildren,
                                             'indent' => $indent,
                                             'url_alias' => $urlAlias,
                                             'url' => $url,
                                             'text' => $name,
                                             'is_selected' => $isSelected,
                                             'node' => $child );
                }

                // find insert pos
                $j = 0;
                $insertPos = 0;
                foreach ( $pathArray as $path )
                {
                    if ( $path['id'] == $nodeID )
                        $insertPos = $j;
                    $j++;
                }
                $restArray = array_splice( $pathArray, $insertPos + 1 );

                $pathArray = array_merge( $pathArray, $tmpPathArray );
                $pathArray = array_merge( $pathArray, $restArray );
            }
            else
            {
                if ( $level == 0 )
                {
                    $node = eZContentObjectTreeNode::fetch( 2 );
                    if ( !$node instanceof eZContentObjectTreeNode )
                    {
                        $operatorValue = $pathArray;
                        return;
                    }

                    $menuChildren = eZContentObjectTreeNode::subTreeByNodeID( array( 'Depth' => 1,
                                                                             'Offset' => 0,
                                                                             'SortBy' => $node->sortArray(),
                                                                             'Language' => $language,
                                                                             'ClassFilterType' => 'include',
                                                                             'ClassFilterArray' => $classFilter ),
                                                                      2 );

                    /// Fill objects with attributes, speed boost, only use if load_data_map is true
                    // or if less then 16 nodes and param is not set (null)
                    if ( $loadDataMap || (  $loadDataMap === null && count( $menuChildren ) < 16 ) )
                        eZContentObject::fillNodeListAttributes( $menuChildren );

                    $pathArray = array();
                    foreach ( $menuChildren as $child )
                    {
                        $name = $child->attribute( 'name' );
                        $tmpNodeID = $child->attribute( 'node_id' );

                        $url = "/content/view/full/$tmpNodeID/";
                        $urlAlias = '/' . $child->attribute( 'url_alias' );

                        $pathArray[] = array( 'id' => $tmpNodeID,
                                              'level' => $i,
                                              'is_main_node' => $child->attribute( 'is_main' ),
                                              'url_alias' => $urlAlias,
                                              'url' => $url,
                                              'text' => $name,
                                              'is_selected' => false,
                                              'node' => $child );
                    }
                }
                $done = true;
            }
            ++$level;
            ++$i;
        }

        $operatorValue = $pathArray;
    }
 /**
  * Get Menu children.
  *
  * @param Array getParameters.
  * @param Array getOptions.
  * @param Array postParameters.
  * @param Array postOptions.
  *
  * @return DOMElement DOMElement contating top node information.
  */
 public function ezodfGetMenuChildren($getParams, $getOptions, $postParams, $postOptions)
 {
     $nodeID = $getParams['nodeID'];
     $languageCode = $getOptions['languageCode'];
     $offset = $getOptions['offset'];
     $limit = $getOptions['limit'];
     $domDocument = new DOMDocument('1.0', 'utf-8');
     $childrenElement = $domDocument->createElement('MenuChildren');
     // Set attributes.
     $childrenElement->setAttribute('offset', $offset);
     if ($languageCode) {
         $childrenElement->setAttribute('languageCode', $languageCode);
     }
     $childrenElement->setAttribute('limit', $limit);
     // Get children, and add them to children list.
     $children = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1, 'DepthOperator' => 'eq', 'Limit' => $limit, 'Offset' => $offset, 'Language' => $languageCode, 'ClassFilterType' => 'include', 'ClassFilterArray' => eZINI::instance('contentstructuremenu.ini')->variable('TreeMenu', 'ShowClasses')), $nodeID);
     if ($children) {
         foreach ($children as $childNode) {
             $childrenElement->appendChild($this->createTreeNodeDOMElement($domDocument, $childNode));
         }
         $childrenElement->setAttribute('count', count($children));
     } else {
         $childrenElement->setAttribute('count', 0);
     }
     return $childrenElement;
 }
Пример #21
0
 /**
  * Purges the image aliases of all ezimage attribute. The original image is
  * kept.
  *
  * @param array $cacheItem
  * @access public
  */
 static function purgeImageAlias($cacheItem)
 {
     // 1. fetch ezcontentclass having an ezimage attribute
     // 2. fetch objects of these classes
     // 3. purge image alias for all version
     $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);
 }
Пример #22
0
 /**
  * Generate array of paex objects to update based on updatechildren status
  *
  * @param array $paex_to_update     Array of already updated paex objects
  * @return array of paex objects to update, with final values set.
  */
 function generateUpdateChildren($paexToUpdate = array())
 {
     eZDebug::writeDebug('Start', __METHOD__);
     if (!$this->attribute('updatechildren')) {
         eZDebug::writeDebug('UpdateChildren flag disabled. Nothing to do.', __METHOD__);
     } else {
         $newPasswordvalidationregexp = $this->attribute('passwordvalidationregexp');
         $newPasswordlifetime = $this->attribute('passwordlifetime');
         $newExpirationnotification = $this->attribute('expirationnotification');
         // Fetch the main node that belongs to the current paex
         $mainNodeID = eZContentObjectTreeNode::findMainNode($this->attribute('contentobject_id'));
         eZDebug::writeDebug('Going to update subtree starting at node ' . $mainNodeID . '.', __METHOD__);
         // Fetch the full subtree array to update
         $fullSubtree = eZContentObjectTreeNode::subTreeByNodeID(array("MainNodeOnly" => true, "AsObject" => false), $mainNodeID);
         foreach ($fullSubtree as $node) {
             // Fetch the paex for each node
             $addPaexToUpdate = eZPaEx::fetch($node["contentobject_id"]);
             // If the paex is not marked to updatechildren, update the paex object
             if ($addPaexToUpdate instanceof eZPaEx && $addPaexToUpdate->attribute('updatechildren') != 1) {
                 $addPaexToUpdate->setAttribute('passwordvalidationregexp', $newPasswordvalidationregexp);
                 $addPaexToUpdate->setAttribute('passwordlifetime', $newPasswordlifetime);
                 $addPaexToUpdate->setAttribute('expirationnotification', $newExpirationnotification);
                 $paexToUpdate[$node["contentobject_id"]] = $addPaexToUpdate;
             } else {
                 eZDebug::writeDebug('Skipping object ' . $add_paex_to_update->attribute('contentobject_id'), __METHOD__);
             }
         }
     }
     eZDebug::writeDebug('End', __METHOD__);
     return $paexToUpdate;
 }
 /**
  * @param array|bool $params
  * @return array|null
  */
 function subTree($params = false)
 {
     return eZContentObjectTreeNode::subTreeByNodeID($params, $this->attribute('node_id'));
 }
$siteURL = $siteINI->variable('SiteSettings', 'SiteURL');
$ClassFilterArray = $refINI->variable('SitemapSettings', 'ClassFilterArray');
$ClassFilterType = $refINI->variable('SitemapSettings', 'ClassFilterType');
print_r($ClassFilterType);
if ($ClassFilterType != 'include' && $ClassFilterType != 'exclude') {
    eZExecution::cleanExit();
}
$params = array('ClassFilterType' => $ClassFilterType, 'ClassFilterArray' => $ClassFilterArray);
$count = eZContentObjectTreeNode::subTreeCountByNodeID($params, 2);
/* Clean de la base SQL */
$sql_truncate = "TRUNCATE TABLE `do_sitemap` ";
$db->query($sql_truncate);
$params['Limit'] = $limit;
while ($offset < $count) {
    $params['Offset'] = $offset;
    $elements = eZContentObjectTreeNode::subTreeByNodeID($params, 2);
    foreach ($elements as $element) {
        $info = array();
        $info['dosm_loc'] = $siteURL . '/' . $element->url();
        $info['dosm_lastmod'] = date('Y-m-d', $element->object()->attribute('modified'));
        $info['dosm_changefreq'] = 'monthly';
        $info['dosm_priority'] = '1';
        $info['dosm_insertedDate'] = '';
        $info['dosm_updatedDate'] = date('Y-m-d', $element->object()->attribute('published'));
        $sql = doDBUtils::createInsertFromArray($info, 'do_sitemap');
        $db->query($sql);
    }
    eZContentObject::clearCache();
    $offset = $offset + $limit;
}
/*	Creation d'un sitemap index et fichier sitemap */
    function addNode( $nodeID, $isSubtree = true )
    {
        $this->RootNodeIDArray[] = $nodeID;
        $this->NodeIDArray[] = $nodeID;

        if ( $isSubtree )
        {
            $nodeArray = eZContentObjectTreeNode::subTreeByNodeID( array( 'AsObject' => false ), $nodeID );
            foreach( $nodeArray as $node )
            {
                $this->NodeIDArray[] = $node['node_id'];
            }
        }
    }
$userCreatorID = $ini->variable("UserSettings", "UserCreatorID");
$user = eZUser::fetch($userCreatorID);
// Test for valid user object
if (!$user) {
    $cli->error("Subtree remove Error!\nCannot get user object by userID = '{$userCreatorID}'.\n(See site.ini[UserSettings].UserCreatorID)");
    $script->shutdown(1);
}
// Login as user
eZUser::setCurrentlyLoggedInUser($user, $userCreatorID);
/**
 * Iterate over nodes in provided range, test to ensure nodeID in range exists.
 */
if (isset($start) && isset($end)) {
    foreach (range($start, $end) as $nodeID) {
        if ($argumentsRemoveChildren == true) {
            $childNodes = eZContentObjectTreeNode::subTreeByNodeID(array('AsObject' => false), $nodeID);
            /**
             * Test for valid results
             */
            if ($childNodes === null or !is_array($childNodes)) {
                $cli->error("\nSubtree remove Error!\nCannot find subtree with nodeID: '{$nodeID}'.");
                continue;
            }
            /**
             * Add first node in range to list of nodes to remove
             */
            $deleteIDArrayResult[] = $nodeID;
            /**
             * Add child nodes under the node subtree within the specified in range to list of nodes to remove
             */
            foreach ($childNodes as $iterationNode) {
Пример #27
0
$newsletter_ini = eZINI::instance('jaj_newsletter.ini');
$site_ini = eZINI::instance('site.ini');
$root_node_id = $newsletter_ini->variable('NewsletterSettings', 'RootFolderNodeId');
$batch_limit = $newsletter_ini->variable('NewsletterDelivery', 'BatchLimit');
$site_url = $site_ini->variable('SiteSettings', 'SiteURL');
$mail_transport = jajSmtpTransport::mailTransport();
$charset = jajSmtpTransport::charset();
$from_email = new ezcMailAddress($newsletter_ini->variable('NewsletterSettings', 'FromEmail'), $newsletter_ini->variable('NewsletterSettings', 'FromName'), $charset);
$reply_email = new ezcMailAddress($newsletter_ini->variable('NewsletterSettings', 'ReplyEmail'), '', $charset);
if (!$batch_limit) {
    $batch_limit = 1;
}
$time_limit = 60 * 10;
// 10 minutes, should be lover than cron job
$start_time = time();
$pendingNewsletters = eZContentObjectTreeNode::subTreeByNodeID(array('Limit' => 10, 'ClassFilterType' => 'include', 'ClassFilterArray' => array('jaj_newsletter'), 'AttributeFilter' => array(array('jaj_newsletter/status', '=', 'in progress'))), $root_node_id);
foreach ($pendingNewsletters as $newsletter) {
    $cli->output('Delivering newsletter: ' . $newsletter->getName() . ' (ContentObjectID: ' . $newsletter->ContentObjectID . ')');
    $cli->output('Batch limit left: ' . $batch_limit);
    $object_id = $newsletter->ContentObjectID;
    $url_alias = $newsletter->urlAlias();
    $url_newsletter = "http://" . $site_url . "/" . $url_alias . "/(generate)/nl/(uuid)/";
    $data_map = $newsletter->DataMap();
    $subject = $data_map['subject']->toString();
    $deliveries = jajNewsletterDelivery::fetchDeliveriesByContentobjectIDAndState($object_id, 'pending', $batch_limit, 0, true);
    foreach ($deliveries as $delivery) {
        $batch_limit--;
        $cli->output('Generating newsletter for: ' . $delivery->attribute('email'));
        // Sanity check
        if ($delivery->attribute('sent') || $delivery->attribute('state') != 'pending') {
            $cli->output('Looks like this has been sent before. Bailing...');
Пример #28
0
 /**
  * For each node in $nodeList finds its children nodes and adds its ids to
  * the $nodeIDList.
  *
  * @param array(eZContentObjectTreeNode) $nodeList
  * @param array(int) $nodeIDList
  */
 public static function appendChildrenNodeIDs(&$nodeList, &$nodeIDList)
 {
     $params = array('Depth' => 1, 'AsObject' => false);
     foreach ($nodeList as $node) {
         $childNodeList = eZContentObjectTreeNode::subTreeByNodeID($params, $node->attribute('node_id'));
         if (!empty($childNodeList)) {
             foreach ($childNodeList as $childNode) {
                 $nodeIDList[] = $childNode['node_id'];
             }
         }
     }
 }
    /**
     * Regression test for issue #16737
     * 1) Test executing the sql and verify that it doesn't have database error.
     * 2) Test the sorting in class_name, class_name with contentobject_id
     * The test should pass in mysql, postgresql and oracle
     */
    public function testIssue16737()
    {


        //test generated result of createSortingSQLStrings
        $sortList = array( array( 'class_name', true ) );
        $result = eZContentObjectTreeNode::createSortingSQLStrings( $sortList );
        $this->assertEquals( ', ezcontentclass_name.name as contentclass_name',
                            strtolower( $result['attributeTargetSQL'] ) );
        $this->assertEquals( 'contentclass_name asc', strtolower( $result['sortingFields'] ) );

        $sortListTwo = array( array( 'class_name', false ),
                              array( 'class_identifier', true ) );
        $result = eZContentObjectTreeNode::createSortingSQLStrings( $sortListTwo );
        $this->assertEquals( ', ezcontentclass_name.name as contentclass_name',
                            strtolower( $result['attributeTargetSQL'] ));
        $this->assertEquals( 'contentclass_name desc, ezcontentclass.identifier asc',
                            strtolower( $result['sortingFields'] ) );

        //test trash node with classname
        $sortBy = array( array( 'class_name', true ),
                         array( 'contentobject_id', true ) );
        $params = array( 'SortBy', $sortBy );
        $result = eZContentObjectTrashNode::trashList( $params );
        $this->assertEquals( array(), $result );
        $result = eZContentObjectTrashNode::trashList( $params, true );
        $this->assertEquals( 0, $result );  //if there is an error, there will be fatal error message

        //test subtreenode with classname
        $parent = new ezpObject( 'folder', 1 );
        $parent->publish();
        $parentNodeID = $parent->mainNode->node_id;

        $article = new ezpObject( 'article', $parentNodeID );
        $article->publish();

        $link = new ezpObject( 'link', $parentNodeID );
        $link->publish();

        $folder = new ezpObject( 'folder', $parentNodeID );
        $folder->publish();

        $folder2 = new ezpObject( 'folder', $parentNodeID );
        $folder2->publish();

        $sortBy = array( array( 'class_name', false ) );
        $params = array( 'SortBy' => $sortBy );
        $result = eZContentObjectTreeNode::subTreeByNodeID( $params, $parentNodeID );
        $this->assertEquals( $article->mainNode->node_id, $result[count( $result )-1]->attribute( 'node_id' ) );

        $sortBy = array( array( 'class_name', false ),
                         array( 'contentobject_id', false ) );
        $params = array( 'SortBy' => $sortBy );
        $result = eZContentObjectTreeNode::subTreeByNodeID( $params, $parentNodeID );
        $this->assertEquals( $folder2->mainNode->node_id, $result[1]->attribute( 'node_id' ) );
    }
    /**
     * @param string $path
     * @param MerckManualShowcase $app
     * @return bool|eZContentObjectTreeNode
     */
    public static function findNodeFromPath( $path, &$app )
    {
        /* We remove the publisher folder id at the beginning of the url as we already have it */
        $path                  = preg_replace('#^/\d+/#', '/', $path );

        $manualAppNode         = eZContentObjectTreeNode::fetch( self::rootNodeId() );
        $manualAppNodePathName = $manualAppNode->pathWithNames();
        $tabNodePath           = explode('/', substr($path, 1));
        $remoteId              = end($tabNodePath);

        if(preg_match('/^[a-f0-9]{32}$/', $remoteId))
        {
            $nodeRemote = eZContentObjectTreeNode::fetchByRemoteID($remoteId);

            if($nodeRemote instanceof eZContentObjectTreeNode)
            {
                $app->fullContext = 'topic';
                return $nodeRemote;
            }
        }

        $pathParts = explode('/', substr($path, 1));

        if ( $pathParts[0] == 'table' )
        {
            $app->fullContext = 'table';
            return eZContentObjectTreeNode::fetch($pathParts[1]);
        }

        // Url with topic
        list($sectionName, $chapterName, $topicName, $mediaType, $mediaName, $other) = $pathParts;

        // Url without topic
        $matches = array();

        if ( preg_match('/media-([a-z]+)/', $topicName, $matches) )
        {
            list($sectionName, $chapterName, $mediaType, $mediaName, $other) = $pathParts;
            $topicName = null;
        }

        // Full section
        if ( $sectionName != null && is_null( $chapterName ) && is_null( $topicName ) )
        {
            $app->fullContext = 'section';
            $app->section = MerckManualFunctionCollection::fetchSection('url', $sectionName);
            return eZContentObjectTreeNode::fetch(MerckManualShowcase::rootNodeId());
        }
        if ( $sectionName == 'about-us' )
        {
            list($chapterName, $topicName, $mediaType, $mediaName, $other) = $pathParts;
        }

        $path = $manualAppNodePathName;
        // Full of chapter
        if ( $chapterName )
        {
            $app->fullContext = 'chapter';
            $path .= '/' . $chapterName;
        }

        // Full of topic
        if ( $topicName )
        {
            $app->fullContext = 'topic';
            $path .= '/' . $topicName;
        }

        $nodeId = eZURLAliasML::fetchNodeIDByPath($path);

        if ( $nodeId )
        {
            if ( $mediaName )
            {
                $mediaType = str_replace('media-', '', $mediaType);

                // Get media node
                // Full of html table image
                // /topic_name/(media-image-file)/oscar2/filename
                if ( $mediaType == 'image-file' )
                {
                    $app->fullContext = $mediaType;
                    $app->oscarFolder = $mediaName;
                    $app->mediaName = $other;
                }

                // Full of inline audio, video, image
                elseif ( $mediaType )
                {
                    // Construct the remote_id of the media folder
                    /* @type $dataMap eZContentObjectAttribute[] */
                    $contentObject        = eZContentObject::fetchByNodeID($nodeId);
                    $dataMap              = $contentObject->dataMap();
                    $publisherAttrContent = $dataMap['publisher']->content();

                    if ( isset($publisherAttrContent['relation_list'][0]['contentobject_remote_id']) )
                    {
                        // Get media folder
                        $mediaFolderRemoteId = sprintf('%s_media_%s', $publisherAttrContent['relation_list'][0]['contentobject_remote_id'], $mediaType);
                        $mediaFolder = eZContentObject::fetchByRemoteID($mediaFolderRemoteId);

                        if ( $mediaFolder )
                        {
                            // Get media
                            $mediaFolderPathName = $mediaFolder->mainNode()->pathWithNames();
                            $nodeId = eZURLAliasML::fetchNodeIDByPath($mediaFolderPathName . '/' . $mediaName);
                            $app->fullContext = $mediaType;
                        }
                    }
                }
            }
        }

        if ( $nodeId )
        {
            // Full of chapter must not be accessible, show first topic
            if ( $app->fullContext == 'chapter' )
            {
                $params = array(
                    'Depth'         => 1,
                    'DepthOperator' => 'eq',
                    'SortBy'        => array(array('priority', 'asc')),
                    'Limit'         => 1
                );
                $children = eZContentObjectTreeNode::subTreeByNodeID($params, $nodeId);

                if ( isset($children[0]) && $children[0] instanceof eZContentObjectTreeNode )
                {
                    $node = $children[0];
                    $app->fullContext = 'topic';
                }
                else
                    $node = null;
            }
            else
            {
                $node = eZContentObjectTreeNode::fetch($nodeId);
            }

            return $node;
        }

        return false;
    }