Exemplo n.º 1
0
 /**
  * @param string|object $page The page where this navigation entry points to
  * @param string|object $highlightgroup If the page inherits from this class/object, the entry will be highlighted. Defaults to $page if not specified.
  * @param string $title The title for this entry. Defaults to classname of page if not found in annotations.
  */
 public function __construct($page, $page_parameter = NULL, $title = "", Loops $loops = NULL)
 {
     $prefix = "Pages\\";
     if (!$loops) {
         $loops = Loops::getLoops();
     }
     $core = $loops->getService("web_core");
     $this->pageclass = $pageclass = is_object($page) ? get_class($page) : $prefix . $page;
     if (!class_exists($pageclass)) {
         throw new Exception("Class '{$pageclass}' does not exist.");
     }
     $count = WebCore::getParameterCount($pageclass);
     if ($page_parameter === NULL) {
         $page_parameter = array_slice($core->page_parameter, 0, $count);
     }
     if (!$title) {
         if ($annotation = $loops->getService("annotations")->get($this->pageclass)->findFirst("Navigation\\Title")) {
             $title = $annotation->title;
         }
     }
     if (!$title) {
         if (is_object($page)) {
             $title = get_class($page);
             if (substr($title, 0, strlen($prefix)) == $prefix) {
                 $title = substr($title, strlen($prefix));
             }
         } else {
             $title = $page;
         }
     }
     $link = WebCore::getPagePathFromClassname($pageclass, $page_parameter);
     parent::__construct($link, $title, $loops);
     $this->highlight = is_a($core->page, $pageclass, TRUE) && implode("/", array_slice($core->page_parameter, 0, $count)) == implode("/", array_slice($page_parameter, 0, $count));
 }