本文整理汇总了PHP中eZURLAliasML::convertPathToAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURLAliasML::convertPathToAlias方法的具体用法?PHP eZURLAliasML::convertPathToAlias怎么用?PHP eZURLAliasML::convertPathToAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURLAliasML
的用法示例。
在下文中一共展示了eZURLAliasML::convertPathToAlias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: fetchParentNodeByTranslation
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];
$this->appendLogEntry( "NodeID: $nodeID", 'CS:fetchParentNodeByTranslation' );
}
else
{
$this->appendLogEntry( "Root node", 'CS:fetchParentNodeByTranslation' );
$nodeID = 2;
}
// Attempt to fetch the node.
$node = eZContentObjectTreeNode::fetch( $nodeID );
// Return the node.
return $node;
}