function pathWithNames($regenerateCurrent = false) { // Only set name if current node is not the content root $ini = eZINI::instance('content.ini'); $contentRootID = $ini->variable('NodeSettings', 'RootNode'); if ($this->attribute('node_id') != $contentRootID) { $pathArray = $this->pathArray(); // Get rid of node with ID 1 (a special node) array_shift($pathArray); if ($regenerateCurrent) { // Get rid of current node, path element for this will be calculated array_pop($pathArray); } if (count($pathArray) == 0) { $path = ''; } else { $path = eZURLAliasML::fetchPathByActionList("eznode", $pathArray, $this->CurrentLanguage); } // Fallback in case fetchPathByActionList() fails, // then we ask for the path from the parent and generate the current // entry ourselves. if ($path === null) { if ($this->attribute('depth') == 0) { return ''; } eZDebug::writeError(__METHOD__ . "() failed to fetch path of node " . $this->attribute('node_id') . ", falling back to generated url entries. Run updateniceurls.php to fix the problem."); // Return a perma-link when the path lookup failed, this link will always work $path = 'content/view/full/' . $this->attribute('node_id'); return $path; } if ($regenerateCurrent) { $nodeName = $this->attribute('name'); $nodeName = eZURLAliasML::convertToAlias($nodeName, 'node_' . $this->attribute('node_id')); if ($path != '') { $path .= '/' . $nodeName; } else { $path = $nodeName; } } } else { $path = ''; } if ($regenerateCurrent) { $path = $this->checkPath($path); } return $path; }
/** * Ensures that eZURLAliasML::fetchPathByActionList() always uses prioritized languages, * even if a locale is enforced (3rd param) and always available flag is false. * * @see http://issues.ez.no/19055 * @group issue19055 * @covers eZURLAliasML::fetchPathByActionList */ public function testFetchPathByActionListWithFallback() { $frenchLocale = $this->frenchLanguage->attribute('locale'); ezpINIHelper::setINISettings(array(array('site.ini', 'RegionalSettings', 'ContentObjectLocale', $frenchLocale), array('site.ini', 'RegionalSettings', 'Locale', $frenchLocale), array('site.ini', 'RegionalSettings', 'SiteLanguageList', array($frenchLocale, 'eng-GB')), array('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled'))); eZContentOperationCollection::updateAlwaysAvailable(1, false); /* * - Create a content object in Norsk * - Remove AlwaysAvailable flag * - Add a translation in english * - Try to fetch path for this content in French (fallback is eng-GB as configured above) */ $folder = new ezpObject('folder', 2, 14, 1, $this->norskLanguage->attribute('locale')); $folder->name = 'norsk folder'; $folder->publish(); eZContentOperationCollection::updateAlwaysAvailable($folder->object->attribute('id'), false); $folder->refresh(); $folder->addTranslation('eng-GB', array('name' => 'english translation')); $folder->publish(); $generatedPath = eZURLAliasML::fetchPathByActionList('eznode', array($folder->mainNode->node_id), $frenchLocale); self::assertNotNull($generatedPath); self::assertEquals('english-translation', $generatedPath); eZContentOperationCollection::updateAlwaysAvailable(1, true); ezpINIHelper::restoreINISettings(); $folder->remove(); }