Esempio n. 1
0
 /**
  * @param Loops\Navigation $navigation The subnavigtaion menu
  * @param string|Loops\Navigation\Entry $title A displayable title for this entry OR an entry from which link, title and highlight will be inherited
  * @param string $link The link for this entry (may not be clickable depending on template implementation)
  */
 public function __construct(Navigation $navigation, $title, $link = "", Loops $loops = NULL)
 {
     $this->subnavigation = $navigation;
     if ($title instanceof Entry) {
         parent::__construct($title->link, $title->title, NULL, $loops);
         $this->entry = $title;
         $this->link =& $this->entry->link;
         $this->title =& $this->entry->title;
     } else {
         parent::__construct($link, $title, $loops);
     }
 }
Esempio n. 2
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));
 }
Esempio n. 3
0
 /**
  * @param string $link The external link as it should be shown in href
  * @param string $title A displayable title for this entry
  * @param bool $newtab Specifies if the link should be opened in a new tab
  */
 public function __construct($link, $title = "", $newtab = TRUE, Loops $loops = NULL)
 {
     $this->newtab = $newtab;
     parent::__construct($link, $title ?: $link, NULL, $context);
 }