예제 #1
0
 /**
  * Delete the given menu item.
  *
  * @param MenuItem $menuItem
  */
 public function deleteItem($menuItem)
 {
     $this->db()->delete('menu_items')->where(array('id' => $menuItem->getId()))->execute();
 }
예제 #2
0
 /**
  * Gets the menu items as html-string.
  *
  * @param \Modules\Admin\Models\MenuItem $item
  * @param array $options
  * @return string
  */
 protected function recGetItems($item, $locale, $options = array())
 {
     $menuMapper = new \Modules\Admin\Mappers\Menu();
     $pageMapper = new \Modules\Page\Mappers\Page();
     $subItems = $menuMapper->getMenuItemsByParent($item->getMenuId(), $item->getId());
     $html = '';
     if (in_array($item->getType(), array(1, 2, 3))) {
         $html = '<li>';
     }
     if ($item->getType() == 1) {
         $html .= '<a href="' . $item->getHref() . '">' . $item->getTitle() . '</a>';
     } elseif ($item->getType() == 2) {
         $page = $pageMapper->getPageByIdLocale($item->getSiteId(), $locale);
         $html .= '<a href="' . $this->layout->getUrl($page->getPerma()) . '">' . $item->getTitle() . '</a>';
     } elseif ($item->getType() == 3) {
         $html .= '<a href="' . $this->layout->getUrl(array('module' => $item->getModuleKey(), 'action' => 'index', 'controller' => 'index')) . '">' . $item->getTitle() . '</a>';
     }
     if (!empty($subItems)) {
         if (isset($options['class_ul'])) {
             $html .= '<ul class="' . $options['class_ul'] . '">';
         } else {
             $html .= '<ul class="list-unstyled ilch_menu_ul">';
         }
         foreach ($subItems as $subItem) {
             $html .= $this->recGetItems($subItem, $locale, $options);
         }
         $html .= '</ul>';
     }
     if (in_array($item->getType(), array(1, 2, 3))) {
         $html .= '</li>';
     }
     return $html;
 }