private function _setActiveNodes($nodes)
{
$path = craft()->request->getPath();
$segments = craft()->request->getSegments();
$segmentCount = count($segments) > 0 ? count($segments) : 1;
// Set empty array for specific navigation
$this->_activeNodeIds[$this->_navigation->handle] = array();
$this->_activeNodeIdsForLevel[$this->_navigation->handle] = array();
foreach ($nodes as $node) {
$url = !empty($node['elementId']) ? $node['elementUrl'] : $node['url'];
$url = str_replace('{siteUrl}', '', $url);
$url = str_replace('__home__', '', $url);
if (substr($url, 0, 1) == '/') {
$url = substr($url, 1);
// Fix for relative URLs
}
if ($url == $path) {
$this->_activeNodeIds[$this->_navigation->handle][] = $node['id'];
$this->_activeNodeIdsForLevel[$this->_navigation->handle][$segmentCount] = $node['id'];
}
if (count($segments)) {
$found = false;
$count = 1;
// Start at second
$segmentString = $segments[0];
// Add first
while ($count < count($segments)) {
if ($url == $segmentString) {
$found = true;
break;
}
$segmentString .= '/' . $segments[$count];
$count++;
}
if ($found) {
$this->_activeNodeIds[$this->_navigation->handle][] = $node['id'];
$this->_activeNodeIdsForLevel[$this->_navigation->handle][$count] = $node['id'];
}
}
}
}