Skip to content

Commit

Permalink
add more robust check for node id
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Apr 5, 2012
1 parent 596ed4a commit 31c6296
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion classes/sitelink.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function __construct($operatorValue, $parameters){
$this->urlComponents['host']=parse_url(eZRSSExport::fetchByName(substr($operatorValue,strrpos($operatorValue,'/')+1))->URL,PHP_URL_HOST);
}
if($this->normalize()){
$this->nodeID=$this->urlComponents['path']?eZURLAliasML::fetchNodeIDByPath($this->urlComponents['path']):false;
$this->nodeID=$this->findNodeID();
}
}

Expand Down Expand Up @@ -72,6 +72,20 @@ function debug($message, $label, $level=eZDebug::LEVEL_DEBUG){
return false;
}

function findNodeID(){
if($this->urlComponents['path'] && $NodeID=eZURLAliasML::fetchNodeIDByPath($this->urlComponents['path'])){
return $NodeID;
}
if($this->pathPrefix && strpos($this->urlComponents['path'], $this->pathPrefix)!==false){
$Path=str_replace("$this->pathPrefix/", '', $this->urlComponents['path']);
if($NodeID=eZURLAliasML::fetchNodeIDByPath($Path)){
$this->urlComponents['path']=$Path;
return $NodeID;
}
}
return false;
}

function findObjectNode($object){
if(get_class($object)=='eZContentObject'){
$assigned_nodes = $object->assignedNodes();
Expand Down

0 comments on commit 31c6296

Please sign in to comment.