コード例 #1
0
ファイル: Cache.php プロジェクト: acp3/module-menus
 /**
  * Saves the menu items to the cache
  *
  * @return boolean
  */
 public function saveMenusCache()
 {
     $menuItems = $this->menuItemRepository->getAllMenuItems();
     $cMenuItems = count($menuItems);
     if ($cMenuItems > 0) {
         $menus = $this->menuRepository->getAllMenus();
         $cMenus = count($menus);
         for ($i = 0; $i < $cMenus; ++$i) {
             $this->saveVisibleMenuItemsCache($menus[$i]['index_name']);
         }
         for ($i = 0; $i < $cMenuItems; ++$i) {
             for ($j = 0; $j < $cMenus; ++$j) {
                 if ($menuItems[$i]['block_id'] == $menus[$j]['id']) {
                     $menuItems[$i]['block_title'] = $menus[$j]['title'];
                     $menuItems[$i]['block_name'] = $menus[$j]['index_name'];
                 }
             }
         }
         $modeSearch = ['1', '2', '3', '4'];
         $modeReplace = [$this->translator->t('menus', 'module'), $this->translator->t('menus', 'dynamic_page'), $this->translator->t('menus', 'hyperlink'), $this->translator->t('menus', 'article')];
         for ($i = 0; $i < $cMenuItems; ++$i) {
             $menuItems[$i]['mode_formatted'] = str_replace($modeSearch, $modeReplace, $menuItems[$i]['mode']);
             $menuItems[$i]['first'] = $this->isFirstItemInSet($i, $menuItems);
             $menuItems[$i]['last'] = $this->isLastItemInSet($i, $menuItems);
         }
     }
     return $this->cache->save(self::CACHE_ID, $menuItems);
 }
コード例 #2
0
ファイル: Index.php プロジェクト: acp3/module-menus
 public function execute()
 {
     $menus = $this->menuRepository->getAllMenus();
     $cMenus = count($menus);
     if ($cMenus > 0) {
         $canDeleteItem = $this->acl->hasPermission('admin/menus/items/delete');
         $canEditItem = $this->acl->hasPermission('admin/menus/items/edit');
         $canSortItem = $this->acl->hasPermission('admin/menus/items/order');
         $this->view->assign('can_delete_item', $canDeleteItem);
         $this->view->assign('can_edit_item', $canEditItem);
         $this->view->assign('can_order_item', $canSortItem);
         $this->view->assign('can_delete', $this->acl->hasPermission('admin/menus/index/delete'));
         $this->view->assign('can_edit', $this->acl->hasPermission('admin/menus/index/edit'));
         $colspan = 4;
         if ($canDeleteItem || $canEditItem) {
             $colspan += 1;
         }
         if ($canSortItem) {
             $colspan += 1;
         }
         $this->view->assign('colspan', $colspan);
         $menuItems = $this->menusHelpers->menuItemsList();
         for ($i = 0; $i < $cMenus; ++$i) {
             if (isset($menuItems[$menus[$i]['index_name']]) === false) {
                 $menuItems[$menus[$i]['index_name']]['title'] = $menus[$i]['title'];
                 $menuItems[$menus[$i]['index_name']]['menu_id'] = $menus[$i]['id'];
                 $menuItems[$menus[$i]['index_name']]['items'] = [];
             }
         }
         $this->view->assign('pages_list', $menuItems);
     }
 }
コード例 #3
0
 /**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && array_key_exists($field, $data)) {
         return $this->isValid($data[$field], $field, $extra);
     }
     $menuId = isset($extra['menu_id']) ? $extra['menu_id'] : 0;
     return $this->menuRepository->menuExistsByName($data, $menuId) === false;
 }
コード例 #4
0
 /**
  * Gibt alle Menüleisten zur Benutzung in einem Dropdown-Menü aus
  *
  * @param integer $selected
  *
  * @return array
  */
 protected function menusDropDown($selected = 0)
 {
     $menus = $this->menusModel->getAllMenus();
     $cMenus = count($menus);
     for ($i = 0; $i < $cMenus; ++$i) {
         $menus[$i]['selected'] = $this->formsHelper->selectEntry('block_id', (int) $menus[$i]['id'], (int) $selected);
     }
     return $menus;
 }
コード例 #5
0
 /**
  * @param ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     if (!$event->isDeleteStatement()) {
         return;
     }
     foreach ($event->getEntryId() as $item) {
         if (!empty($item) && $this->menuRepository->menuExists($item) === true) {
             // Delete the assigned menu items and update the nested set tree
             $menuItems = $this->menuItemRepository->getAllItemsByBlockId($item);
             foreach ($menuItems as $menuItem) {
                 $this->menuItemsModel->delete($menuItem['id']);
             }
             $menuName = $this->menuRepository->getMenuNameById($item);
             $this->cache->getCacheDriver()->delete(Cache::CACHE_ID_VISIBLE . $menuName);
         }
     }
 }