Example #1
0
 /**
  * @param string $currentUri
  * @return boolean
  */
 public function findActivePageByUri($currentUri)
 {
     $found = FALSE;
     $adminDirName = \CMS::backendPath();
     foreach ($this->getPages() as $page) {
         $url = $page->getUrl();
         $len = strpos($url, $adminDirName);
         if ($len !== FALSE) {
             $len += strlen($adminDirName);
         }
         $url = substr($url, $len);
         $len = strpos($currentUri, $adminDirName);
         if ($len !== FALSE) {
             $len += strlen($adminDirName);
         }
         $uri = substr($currentUri, $len);
         if (!empty($url) and strpos($uri, $url) !== FALSE) {
             $page->setStatus(TRUE);
             Collection::setCurrentPage($page);
             $found = TRUE;
             break;
         }
     }
     if ($found === FALSE) {
         foreach ($this->getSections() as $section) {
             $found = $section->findActivePageByUri($currentUri);
             if ($found !== FALSE) {
                 return $found;
             }
         }
     }
     return $found;
 }