Example #1
0
 /**
  *
  *
  * @param \FrenchFrogs\Ruler\Page\Page $page
  * @return string
  */
 public function page(Ruler\Page\Page $page)
 {
     // attribute initialization
     $indicator = $children = '';
     // label
     $html = '<span class="title">' . $page->getLabel() . '</span>';
     if ($current = $page->isCurrent()) {
         $indicator .= ' selected';
     }
     // Render child page
     if ($page->hasChildren()) {
         // add arrow icon
         $indicator .= ' arrow';
         foreach ($page->getChildren() as $p) {
             /**@var Ruler\Page\Page $p*/
             $class = '';
             if ($p->isCurrent()) {
                 $page->addClass('active');
                 // active for parent page
                 $class = 'class="active"';
             }
             if ($p->hasPermission() && !\ruler()->hasPermission($p->getPermission())) {
                 continue;
             }
             $children .= '<li ' . $class . '>' . html('a', ['href' => $p->getLink()], $p->getLabel()) . '</li>';
         }
         $children = '<ul class="sub-menu">' . $children . '</ul>';
         // overcharge link for javascript opening menu
         $page->setLink('javascript:;');
     }
     // render all
     $html .= '<span class="' . $indicator . '"></span>';
     $html = html('a', ['href' => $page->getLink()], $html);
     $html .= $children;
     return $html;
 }