本文整理汇总了PHP中eZURLAliasML类的典型用法代码示例。如果您正苦于以下问题:PHP eZURLAliasML类的具体用法?PHP eZURLAliasML怎么用?PHP eZURLAliasML使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZURLAliasML类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchContentNode
public static function fetchContentNode($nodeID, $nodePath, $languageCode, $remoteID = false)
{
$contentNode = null;
if ($nodeID) {
if (!isset($languageCode)) {
$languageCode = false;
}
$contentNode = eZContentObjectTreeNode::fetch($nodeID, $languageCode);
} else {
if ($nodePath) {
$nodeID = eZURLAliasML::fetchNodeIDByPath($nodePath);
if ($nodeID) {
$contentNode = eZContentObjectTreeNode::fetch($nodeID);
}
} else {
if ($remoteID) {
$contentNode = eZContentObjectTreeNode::fetchByRemoteID($remoteID);
}
}
}
if ($contentNode === null) {
$retVal = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
} else {
$retVal = array('result' => $contentNode);
}
return $retVal;
}
示例2: modify
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
{
switch ($operatorName) {
case 'ngurl':
if (empty($namedParameters['siteaccess'])) {
return;
}
$ini = eZSiteAccess::getIni($namedParameters['siteaccess'], 'site.ini');
$destinationLocale = $ini->variable('RegionalSettings', 'ContentObjectLocale');
$siteLanguageList = $ini->variable('RegionalSettings', 'SiteLanguageList');
$nodeID = eZURLAliasML::fetchNodeIDByPath($operatorValue);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeID, $destinationLocale, false);
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
if ($this->isModuleUrl($operatorValue) || $this->isCurrentLocaleAvailable($siteLanguageList)) {
$destinationUrl = $operatorValue;
} else {
$destinationUrl = '';
}
} else {
$destinationUrl = $destinationElement[0]->getPath($destinationLocale, $siteLanguageList);
}
$siteaccessUrlMapping = eZINI::instance('nglanguageswitcher.ini')->variable('LanguageSwitcher', 'SiteAccessUrlMapping');
$destinationUrl = eZURI::encodeURL($destinationUrl);
$operatorValue = rtrim($siteaccessUrlMapping[$namedParameters['siteaccess']], '/') . '/' . ltrim($destinationUrl, '/');
break;
}
}
示例3: fetchUrlAlias
public function fetchUrlAlias($nodeId = null, $path = null, $locale)
{
if (!$nodeId && !$path) {
return array('result' => false);
}
if (empty($locale) || !is_string($locale)) {
return array('result' => false);
}
if (is_numeric($nodeId)) {
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $locale, false);
} else {
if (is_string($path)) {
$nodeId = eZURLAliasML::fetchNodeIDByPath($path);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $locale, false);
}
}
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
// Either no translation exists for $locale or $path was not pointing to a node
return array('result' => false);
}
$currentLanguageCodes = eZContentLanguage::prioritizedLanguageCodes();
array_unshift($currentLanguageCodes, $locale);
$currentLanguageCodes = array_unique($currentLanguageCodes);
$urlAlias = $destinationElement[0]->getPath($locale, $currentLanguageCodes);
return array('result' => $urlAlias);
}
示例4: runOperation
function runOperation(&$node)
{
$target_parent_node_id = $this->target_id;
if (empty($target_parent_node_id)) {
if ($this->move_to_depth >= $node->attribute('depth')) {
return false;
}
// Find the correct target node for the specified depth
$path_array = $node->attribute('path_array');
$target_parent_node_id = $path_array[$this->move_to_depth - 1];
}
$assigned_nodes = $node->attribute('object')->attribute('assigned_nodes');
// Find the target node
foreach ($assigned_nodes as $target_node) {
if ($target_node->attribute('parent_node_id') == $target_parent_node_id) {
$target_node_id = $target_node->attribute('node_id');
// Make sure target node is not us
if ($node->attribute('node_id') == $target_node_id) {
return false;
}
$urlalias_list = eZURLAliasML::fetchByAction('eznode', $node->attribute('node_id'));
$target_node_urlalias_list = eZURLAliasML::fetchByAction('eznode', $target_node_id);
// Sanity check, this should never happen
if (!isset($target_node_urlalias_list[0])) {
eZDebug::writeError('Found no url alias records for node with id ' . $target_node_id, 'batchtool/nodemerge');
return false;
}
$target_node_urlalias_id = $target_node_urlalias_list[0]->attribute('id');
$target_parent_urlalias_id = $target_node_urlalias_list[0]->attribute('parent');
$db = eZDB::instance();
$db->begin();
// Make sure any children nodes are moved to the new node
foreach ($node->attribute('children') as $child) {
moveNode($child, $target_node_id);
}
// Make sure any bookmarks are moved to the new node
$bookmark_list = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('node_id' => $node->attribute('node_id')));
foreach ($bookmark_list as $bookmark) {
$bookmark->setAttribute('node_id', $target_node_id);
$bookmark->store();
}
// Remove the node in question
$node->removeNodeFromTree(true);
// Set up url alias redirects to the new node
foreach ($urlalias_list as $url_alias) {
$url_alias->setAttribute('action', 'eznode:' . $target_node_id);
$url_alias->setAttribute('action_type', 'eznode');
$url_alias->setAttribute('link', $target_node_urlalias_id);
$url_alias->setAttribute('is_original', 0);
$url_alias->store();
}
$db->commit();
return true;
}
}
return false;
}
示例5: destinationUrl
/**
* Returns URL alias for the specified <var>$locale</var>
*
* @param string $url
* @param string $locale
* @return void
*/
public function destinationUrl()
{
$nodeId = $this->origUrl;
$urlAlias = '';
if (!is_numeric($this->origUrl)) {
if (!$this->isUrlPointingToModule($this->origUrl)) {
$this->origUrl = self::addPathPrefixIfNeeded($this->origUrl);
}
$nodeId = eZURLAliasML::fetchNodeIDByPath($this->origUrl);
}
$siteLanguageList = $this->getSiteAccessIni()->variable('RegionalSettings', 'SiteLanguageList');
// set prioritized languages of destination SA, and fetch corresponding (prioritized) URL alias
eZContentLanguage::setPrioritizedLanguages($siteLanguageList);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, false, true);
eZContentLanguage::clearPrioritizedLanguages();
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
// If the return of fetchByAction is empty, it can mean a couple
// of different things:
// Either we are looking at a module, and we should pass the
// original URL on
//
// Or we are looking at URL which does not exist in the
// destination siteaccess, for instance an untranslated object. In
// which case we will point to the root of the site, unless it is
// available as a fallback.
if ($nodeId) {
$urlAlias = $this->origUrl;
// if applicable, remove destination PathPrefix from url
if (!self::removePathPrefixIfNeeded($this->getSiteAccessIni(), $urlAlias)) {
// If destination siteaccess has a PathPrefix but url is not matched,
// also check current SA's prefix, and remove if it matches.
self::removePathPrefixIfNeeded(eZINI::instance('site.ini'), $urlAlias);
}
} else {
if ($this->isUrlPointingToModule($this->origUrl)) {
$urlAlias = $this->origUrl;
}
}
} else {
// Translated object found, forwarding to new URL.
$urlAlias = $destinationElement[0]->getPath($this->destinationLocale, $siteLanguageList);
// if applicable, remove destination PathPrefix from url
self::removePathPrefixIfNeeded($this->getSiteAccessIni(), $urlAlias);
$urlAlias .= $this->userParamString;
}
$this->baseDestinationUrl = rtrim($this->baseDestinationUrl, '/');
$ini = eZINI::instance();
if ($GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI && !($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') === "enabled" && $ini->variable('SiteSettings', 'DefaultAccess') == $this->destinationSiteAccess)) {
$finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias;
} else {
$finalUrl = $this->baseDestinationUrl . '/' . $urlAlias;
}
if ($this->queryString != '') {
$finalUrl .= '?' . $this->queryString;
}
return $finalUrl;
}
示例6:
if (count($existingElements) > 0) {
$parentID = (int) $existingElements[0]->attribute('parent');
$linkID = (int) $existingElements[0]->attribute('id');
}
if ($parentIsRoot) {
$parentID = 0;
// Start from the top
}
$mask = $language->attribute('id');
$obj = $node->object();
$alwaysMask = $obj->attribute('language_mask') & 1;
$mask |= $alwaysMask;
$origAliasText = $aliasText;
$result = eZURLAliasML::storePath($aliasText, 'eznode:' . $node->attribute('node_id'), $language, $linkID, $alwaysMask, $parentID, true, false, false, $aliasRedirects);
if ($result['status'] === eZURLAliasML::LINK_ALREADY_TAKEN) {
$lastElements = eZURLAliasML::fetchByPath($result['path']);
if (count($lastElements) > 0) {
$lastElement = $lastElements[0];
$infoCode = "feedback-alias-exists";
$infoData['new_alias'] = $aliasText;
$infoData['url'] = $lastElement->attribute('path');
$infoData['action_url'] = $lastElement->actionURL();
$aliasText = $origAliasText;
}
} else {
if ($result['status'] === true) {
$aliasText = $result['path'];
if (strcmp($aliasText, $origAliasText) != 0) {
$infoCode = "feedback-alias-cleanup";
$infoData['orig_alias'] = $origAliasText;
$infoData['new_alias'] = $aliasText;
示例7: fclose
}
}
fclose($handle);
} else {
$cli->output("Warning: Cannot open apache log-file '{$logFilePath}' for reading, please check permissions and try again.");
}
} else {
$cli->output("Warning: apache log-file '{$logFilePath}' doesn't exist, please check your ini-settings and try again.");
}
// Process the content of $pathHashCounter to transform it into $nodeIDHashCounter
foreach ($pathHashCounter as $path => $count) {
$nodeID = eZURLAliasML::fetchNodeIDByPath($path);
// Support for PathPrefix
for ($pathPrefixIndex = 0; !$nodeID && $pathPrefixIndex < $pathPrefixesCount; ++$pathPrefixIndex) {
// Try prepending each of the existing pathPrefixes, to see if one of them matches an existing node
$nodeID = eZURLAliasML::fetchNodeIDByPath($pathPrefixes[$pathPrefixIndex] . $path);
}
if ($nodeID) {
if (!isset($nodeIDHashCounter[$nodeID])) {
$nodeIDHashCounter[$nodeID] = $count;
} else {
$nodeIDHashCounter[$nodeID] += $count;
}
}
}
foreach ($nodeIDHashCounter as $nodeID => $count) {
if (eZContentObjectTreeNode::fetch($nodeID) != null) {
$counter = eZViewCounter::fetch($nodeID);
if ($counter == null) {
$counter = eZViewCounter::create($nodeID);
$counter->setAttribute('count', $count);
示例8: destinationUrl
/**
* Returns URL alias for the specified <var>$locale</var>
*
* @param string $url
* @param string $locale
* @return void
*/
public function destinationUrl()
{
$nodeId = $this->origUrl;
if (!is_numeric($this->origUrl)) {
$nodeId = eZURLAliasML::fetchNodeIDByPath($this->origUrl);
}
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $this->destinationLocale, false);
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
// If the return of fetchByAction is empty, it can mean a couple
// of different things:
// Either we are looking at a module, and we should pass the
// original URL on
//
// Or we are looking at URL which does not exist in the
// destination siteaccess, for instance an untranslated object. In
// which case we will point to the root of the site, unless it is
// available as a fallback.
if ($this->isUrlPointingToModule($this->origUrl) || $this->isLocaleAvailableAsFallback()) {
// We have a module, we're keeping the orignal url.
$urlAlias = $this->origUrl;
} else {
// We probably have an untranslated object, which is not
// available with SiteLanguageList setting, we direct to root.
$urlAlias = '';
}
} else {
// Translated object found, forwarding to new URL.
$saIni = $this->getSiteAccessIni();
$siteLanguageList = $saIni->variable('RegionalSettings', 'SiteLanguageList');
$urlAlias = $destinationElement[0]->getPath($this->destinationLocale, $siteLanguageList);
$urlAlias .= $this->userParamString;
}
$this->baseDestinationUrl = rtrim($this->baseDestinationUrl, '/');
if ($GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI) {
$finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias;
} else {
$finalUrl = $this->baseDestinationUrl . '/' . $urlAlias;
}
return $finalUrl;
}
示例9: urlAlias
/**
* Returns the node's url alias
*
* @return string
*/
function urlAlias()
{
$useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias'];
$ini = eZINI::instance();
$cleanURL = '';
if (!isset($useURLAlias)) {
$useURLAlias = $ini->variable('URLTranslator', 'Translation') == 'enabled';
}
if ($useURLAlias) {
$path = $this->pathWithNames();
if ($ini->hasVariable('SiteAccessSettings', 'PathPrefix') && $ini->variable('SiteAccessSettings', 'PathPrefix') != '') {
$prepend = $ini->variable('SiteAccessSettings', 'PathPrefix');
$pathIdenStr = substr($prepend, strlen($prepend) - 1) == '/' ? $path . '/' : $path;
if (strncasecmp($pathIdenStr, $prepend, strlen($prepend)) == 0) {
$cleanURL = eZURLAliasML::cleanURL(substr($path, strlen($prepend)));
} else {
$cleanURL = eZURLAliasML::cleanURL($path);
}
} else {
$cleanURL = eZURLAliasML::cleanURL($path);
}
} else {
$cleanURL = eZURLAliasML::cleanURL('content/view/full/' . $this->NodeID);
}
return $cleanURL;
}
示例10: fetchParentNodeByTranslation
/**
* Attempts to fetch a possible node by translating the provided
* string/path to a node-number.
*
* The last section of the path is removed before the actual
* translation: hence, the PARENT node is returned.
*
* @param string $nodePathString Eg. 'Folder1/file1.txt'
* @return eZContentObject Eg. the node of 'Folder1'
*/
protected function fetchParentNodeByTranslation($nodePathString)
{
// Strip extensions. E.g. .jpg
$nodePathString = $this->fileBasename($nodePathString);
// Strip away last slash
if (strlen($nodePathString) > 0 and $nodePathString[strlen($nodePathString) - 1] === '/') {
$nodePathString = substr($nodePathString, 0, strlen($nodePathString) - 1);
}
$nodePathString = $this->splitLastPathElement($nodePathString, $element);
if (strlen($nodePathString) === 0) {
$nodePathString = '/';
}
$nodePathString = eZURLAliasML::convertPathToAlias($nodePathString);
// Attempt to translate the URL to something like "/content/view/full/84".
$translateResult = eZURLAliasML::translate($nodePathString);
// handle redirects
while ($nodePathString === 'error/301') {
$nodePathString = $translateResult;
$translateResult = eZURLAliasML::translate($nodePathString);
}
// Get the ID of the node (which is the last part of the translated path).
if (preg_match("#^content/view/full/([0-9]+)\$#", $nodePathString, $matches)) {
$nodeID = $matches[1];
} else {
$ini = eZINI::instance('webdav.ini');
if ($ini->hasVariable('GeneralSettings', 'StartNode')) {
$nodeID = $ini->variable('GeneralSettings', 'StartNode');
}
}
// Attempt to fetch the node.
$node = eZContentObjectTreeNode::fetch($nodeID);
// Return the node.
return $node;
}
示例11: getSSLZones
/**
* \static
* Load content SSL zones definitions.
* Substitute URIs with corresponding path strings
* (e.g. "/news" would be subsituted with "/1/2/50").
* The result is cached in memory to save time on multiple invocations.
* It is also saved in a cache file that is usually updated by eZContentCacheManager along with content cache.
*/
static function getSSLZones()
{
if (!isset($GLOBALS['eZSSLZonesCachedPathStrings'])) {
$cacheFileName = eZSSLZone::cacheFileName();
$cacheDirName = eZSys::cacheDirectory();
// if file cache does not exist then create it
if (!is_readable($cacheFileName)) {
$ini = eZINI::instance();
$sslSubtrees = $ini->variable('SSLZoneSettings', 'SSLSubtrees');
if (!isset($sslSubtrees) || !$sslSubtrees) {
return array();
}
// if there are some content SSL zones defined in the ini settings
// then let's calculate path strings for them
$pathStringsArray = array();
foreach ($sslSubtrees as $uri) {
$elements = eZURLAliasML::fetchByPath($uri);
if (count($elements) == 0) {
eZDebug::writeError("Cannot fetch URI '{$uri}'", __METHOD__);
continue;
}
$action = $elements[0]->attribute('action');
if (!preg_match("#^eznode:(.+)#", $action, $matches)) {
eZDebug::writeError("Cannot decode action '{$action}' for URI '{$uri}'", __METHOD__);
continue;
}
$nodeID = (int) $matches[1];
$node = eZContentObjectTreeNode::fetch($nodeID);
if (!$node instanceof eZContentObjectTreeNode) {
eZDebug::writeError("cannot fetch node by URI '{$uri}'", __METHOD__);
continue;
}
$pathStringsArray[$uri] = $node->attribute('path_string');
unset($node);
}
// write calculated path strings to the file
if (!file_exists($cacheDirName)) {
eZDir::mkdir($cacheDirName, false, true);
}
$fh = fopen($cacheFileName, 'w');
if ($fh) {
fwrite($fh, "<?php\n\$pathStringsArray = " . var_export($pathStringsArray, true) . ";\n?>");
fclose($fh);
$perm = eZINI::instance()->variable('FileSettings', 'StorageFilePermissions');
chmod($cacheFileName, octdec($perm));
}
return $GLOBALS['eZSSLZonesCachedPathStrings'] = $pathStringsArray;
} else {
// let's read its contents and return them
include_once $cacheFileName;
// stores array to $pathStringsArray
return $GLOBALS['eZSSLZonesCachedPathStrings'] = $pathStringsArray;
}
}
// else if in-memory cache already exists then return its contents
$pathStringsArray = $GLOBALS['eZSSLZonesCachedPathStrings'];
return $pathStringsArray;
}
示例12: foreach
if ($isValid) {
eZURL::setIsValid($linkID, false);
}
$cli->output($cli->stylize('warning', "invalid"));
} else {
if (!$isValid) {
eZURL::setIsValid($linkID, true);
}
$cli->output($cli->stylize('success', "valid"));
}
} else {
$cli->output("Couldn't check https protocol");
}
}
} else {
$translateResult = eZURLAliasML::translate($url);
if (!$translateResult) {
$isInternal = false;
// Check if it is a valid internal link.
foreach ($siteURLs as $siteURL) {
$siteURL = preg_replace("/\\/\$/e", "", $siteURL);
$fp = @fopen($siteURL . "/" . $url, "r");
if (!$fp) {
// do nothing
} else {
$isInternal = true;
fclose($fp);
}
}
$translateResult = $isInternal;
}
示例13: fetchSectionsInformations
/**
* @param bool $stats
* @return array
*/
public static function fetchSectionsInformations($stats = true)
{
$cluster = ClusterTool::clusterIdentifier();
if ( isset(self::$sectionsInformations[$cluster][(int) $stats]) )
{
return array('result' => self::$sectionsInformations[$cluster][(int) $stats]);
}
$trigramRemoteToName = FacetFilteringTool::getTaxonomyTranslation('trigram_section');
$sectionRemoteToName = FacetFilteringTool::getTaxonomyTranslation('section');
uasort( $sectionRemoteToName, function($a, $b) {
return strcmp( StringTool::CJK2Pinyin($a), StringTool::CJK2Pinyin($b) );
});
$informations = array();
foreach ( $sectionRemoteToName as $remote => $name )
{
$trigram = false;
if ( isset($trigramRemoteToName['trigram_' . $remote]) )
{
$trigram = $trigramRemoteToName['trigram_' . $remote];
}
$url = eZURLAliasML::convertToAlias($name);
if ( $url == '_1' )
{
$url = str_replace('section_v', '', $remote);
}
$informations[$remote] = array(
'remote' => $remote,
'url' => $url,
'name' => $name,
'trigram' => $trigram,
'topic_count' => 0,
'chapter_count' => 0
);
}
if ( $stats )
{
$rootNodeId = MerckManualShowcase::rootNodeId();
$fields = array('subattr_section___source_id____s', 'subattr_symptom___source_id____s');
$fq = array(
'meta_class_identifier_ms:"article"',
'meta_path_si:' . $rootNodeId,
);
$defaultsParams = array(
'q' => '',
'start' => 0,
'rows' => 0,
'fq' => implode(' AND ', $fq),
'fl' => implode(',', $fields),
'qt' => 'ezpublish',
'explainOther' => '',
'hl' => 'false',
'facet' => 'true',
'facet.field' => array('subattr_section___source_id____s'),
'facet.limit' => array(-1),
'facet.mincount' => array(1),
'facet.sort' => array('alpha')
);
// Count chapter
$params = $defaultsParams;
$params['fq'] .= ' AND attr_relative_depth_i:0';
$result = SolrTool::rawSearch($params);
foreach ( $result['facet_counts']['facet_fields']['subattr_section___source_id____s'] as $section => $count )
if ( isset($informations[$section]) )
$informations[$section]['chapter_count'] = $count;
// Count topic
$params = $defaultsParams;
$params['fq'] .= ' AND attr_relative_depth_i:1';
$result = self::rawSearch($params);
foreach ( $result['facet_counts']['facet_fields']['subattr_section___source_id____s'] as $section => $count )
if ( isset($informations[$section]) )
$informations[$section]['topic_count'] = $count;
}
if ( !isset(self::$sectionsInformations[$cluster]) )
self::$sectionsInformations[$cluster] = array();
self::$sectionsInformations[$cluster][(int) $stats] = $informations;
return array('result' => $informations);
}
示例14: testStorePathReparentAliasEntries
/**
* Test that store path does not reparent children of entries with same action
* if they are custom aliases
*/
public function testStorePathReparentAliasEntries()
{
// Create a real folder
$r = mt_rand();
$theRealFolder = new ezpObject("folder", 2);
$theRealFolder->name = __FUNCTION__ . $r;
$theRealFolder->publish();
// Create a real article in real folder
$myNode = new ezpObject("article", $theRealFolder->mainNode->node_id);
$myNode->title = "MyNode";
$myNode->publish();
// We fetch the url path element of our real folder entry,
// in order to create an alias to it
$realFolderUrl = eZURLAliasML::fetchByAction("eznode", $theRealFolder->mainNode->node_id);
$realFolderUrlId = $realFolderUrl[0]->attribute('id');
$myNodeUrl = eZURLAliasML::fetchByAction("eznode", $myNode->mainNode->node_id);
$myNodeUrlId = $myNodeUrl[0]->attribute('id');
// We create a custom url alias for the real folder under $realFolderAliasPath
// Note the first path element will be a virtual nop:
$realFolderAliasPath = "VirtualPath/AliasToTheRealFolder{$r}";
$action = "eznode:" . $theRealFolder->mainNode->node_id;
$realFolderAlias = eZURLAliasML::storePath($realFolderAliasPath, $action, false, $realFolderUrlId);
$realFolderAliasId = $realFolderAlias['element']->attribute('id');
/*
We create a custom url alias for MyNode, which is located underneath
the alias for real folder, in the url path
\
|-- TheRealFolder (node a)
| `-- MyNode (node b)
`-- VirtualPath (nop:)
`-- AliasToTheRealFolder (node a)
`-- AliasToMyNode (node b)
*/
// $myNodeAliasPath = "{$realFolderAliasPath}/AliasToMyNode{$r}";
$myNodeAliasPath = "AliasToMyNode{$r}";
$myNodeAction = "eznode:" . $myNode->mainNode->node_id;
$myNodeAlias = eZURLAliasML::storePath($myNodeAliasPath, $myNodeAction, false, $myNodeUrlId, false, $realFolderAliasId);
$myNodeAliasOriginalParent = $myNodeAlias['element']->attribute('parent');
// We republish the real folder, not strictly necessary to change the
// but it is more illustrative.
$theRealFolder->name = __FUNCTION__ . $r . "Renamed";
$theRealFolder->publish();
// Assert that our alias to MyNode was indeed placed underneath $realFolderAliasPath
self::assertEquals($realFolderAliasId, $myNodeAliasOriginalParent);
$db = eZDB::instance();
$q = self::buildSql(array($myNode->mainNode->node_id), false, array('is_alias' => 1, 'is_original' => 1));
$myNodeAliasPostChange = $db->arrayQuery($q);
$myNodeAliasPostChangeParent = $myNodeAliasPostChange[0]['parent'];
// Make sure the the alias to MyNode have not been moved in the url path
// after publishing the parent of the real node.
self::assertEquals($myNodeAliasOriginalParent, $myNodeAliasPostChangeParent, "Parent have custom url alias have been changed inadvertently.");
}
示例15: findNodeFromPath
/**
* @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();
//.........这里部分代码省略.........