function updateSubTreePath($updateParent = true, $nodeMove = false) { $changeCount = 0; $nodeID = $this->attribute('node_id'); $parentNodeID = $this->attribute('parent_node_id'); // Avoid recursion due to database inconsistencies if ($nodeID === $parentNodeID) { eZDebug::writeError("Parent node ID equals node ID for node: {$nodeID}. The node cannot be a parent of itself!", __METHOD__); return false; } // Only set name if current node is not the content root $ini = eZINI::instance('content.ini'); $contentRootID = $ini->variable('NodeSettings', 'RootNode'); $obj = $this->object(); $alwaysMask = $obj->attribute('language_mask') & 1; $languages = $obj->allLanguages(); $nameList = array(); $initialLanguageID = $obj->attribute('initial_language_id'); $pathIdentificationName = false; foreach ($languages as $language) { $nodeName = ''; if ($nodeID != $contentRootID) { $objClass = $obj->attribute('content_class'); $nodeName = $objClass->urlAliasName($obj, false, $language->attribute('locale')); $nodeName = eZURLAliasFilter::processFilters($nodeName, $language, $this); $nodeName = eZURLAliasML::convertToAlias($nodeName, 'node_' . $nodeID); $nodeName = $this->adjustPathElement($nodeName, $nodeMove); // Compatibility mode: // Store name for the 'path_identification_string' column. if ($initialLanguageID == $language->attribute('id')) { $pathIdentificationName = eZURLAliasML::convertToAliasCompat($nodeName, 'node_' . $nodeID); } } $nameList[] = array('text' => $nodeName, 'language' => $language); } $parentActionName = "eznode"; $parentActionValue = $parentNodeID; $parentElementID = false; $existingElements = eZURLAliasML::fetchByAction("eznode", $nodeID); $existingElementID = null; if (count($existingElements) > 0) { $existingElementID = $existingElements[0]->attribute('id'); $parentElementID = $existingElements[0]->attribute('parent'); } // If we have parent element it means the node is already published // and we have to see if it has been moved if ($parentNodeID != 1 and $updateParent) { $parents = eZURLAliasML::fetchByAction("eznode", $parentNodeID); if (count($parents) == 0) { $parentNode = $this->fetchParent(); if (!$parentNode) { return false; } $result = $parentNode->updateSubTreePath(); if (!$result) { return false; } $parents = eZURLAliasML::fetchByAction($parentActionName, $parentActionValue); if (count($parents) == 0) { return false; } $oldParentElementID = $parentElementID; foreach ($parents as $paren) { $parentElementID = 0; if ($paren->attribute('text') != '') { $parentElementID = (int) $paren->attribute('link'); break; } } } else { $oldParentElementID = $parentElementID; $parentElementID = 0; foreach ($parents as $paren) { if ($paren->attribute('text') != '') { $parentElementID = (int) $paren->attribute('link'); break; } } } } else { } $this->updatePathIdentificationString($pathIdentificationName); $languageID = $obj->attribute('initial_language_id'); $cleanup = false; foreach ($nameList as $nameEntry) { $text = $nameEntry['text']; $language = $nameEntry['language']; $result = eZURLAliasML::storePath($text, 'eznode:' . $nodeID, $language, false, $alwaysMask, $parentElementID, $cleanup); if ($result['status'] === true) { $changeCount++; } } return $changeCount; }