Author: XE Developers (developers@xpressengine.com)
Inheritance: extends Xpressengine\Category\Models\CategoryItem
 /**
  * Service Provider Boot
  *
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $pluginRegister = $this->app['xe.pluginRegister'];
     $pluginRegister->add(MenuType::class);
     $pluginRegister->add(MenuSelect::class);
     $pluginRegister->add(TypeSelect::class);
     $pluginRegister->add(DirectLink::class);
     foreach ($this->policies as $class => $policy) {
         $gate->policy($class, $policy);
     }
     // 메뉴아이템의 링크를 편하게 제공하기 위한 resolver 등록
     MenuItem::setLinkResolver(function (MenuItem $item) {
         $title = xe_trans($item->getAttributeValue('title'));
         if ($item->getRelationValue('basicImage')) {
             if ($item->isSelected()) {
                 $image = $item->getSelectedImage();
             } else {
                 $image = $item->basicImage;
             }
             $hoverImage = $item->getHoverImage();
             return sprintf('<img src="%s" class="__xe_menu_image" data-hover="%s" alt="%s"/>', $image, $hoverImage, $title);
         }
         return $title;
     });
 }
Esempio n. 2
0
 /**
  * Get setting page url by menu item
  *
  * @param MenuItem $item menu item instance
  * @return string|null
  */
 public function getInstanceSettingURI(MenuItem $item)
 {
     $menuType = $this->modules->getModuleObject($item->type);
     return $menuType::getInstanceSettingURI($item->getKey());
 }
Esempio n. 3
0
 /**
  * Delete menu item
  *
  * @param MenuItem $item menu item instance
  * @return bool
  */
 public function deleteItem(MenuItem $item)
 {
     $key = $this->getItemCacheKey($item->getKey());
     $this->cache->forget($key);
     return $this->repo->deleteItem($item);
 }
Esempio n. 4
0
 protected function registerItemImage(MenuItem $item, $name)
 {
     $columnKeyName = $name . 'Id';
     if ($uploadImg = Input::file($name)) {
         $image = XeMedia::make(XeStorage::upload($uploadImg, 'public/menu'));
         XeStorage::bind($item->getKey(), $image);
         if ($item->{$columnKeyName} !== null) {
             XeStorage::unBind($item->getKey(), $item->{$name});
         }
         $item->{$columnKeyName} = $image->getKey();
     } else {
         $key = 'remove' . ucfirst($name);
         if (Input::get($key) && $item->{$columnKeyName} !== null) {
             XeStorage::unBind($item->getKey(), $item->{$name});
             $item->{$columnKeyName} = null;
         }
     }
 }
Esempio n. 5
0
 /**
  * Delete menu item
  *
  * @param MenuItem $item menu item instance
  * @return bool
  */
 public function deleteItem(MenuItem $item)
 {
     unset($this->itemBag[$item->getKey()]);
     return $this->repo->deleteItem($item);
 }
 /**
  * Returns breadcrumbs for permission
  *
  * @param MenuItem  $item menu item instance
  * @param Menu|null $menu menu instance
  * @return array
  */
 private function getItemBreadcrumbs(MenuItem $item, Menu $menu = null)
 {
     $menu = $menu ?: $item->menu;
     return array_merge([$menu->getKey()], $item->getBreadcrumbs());
 }
Esempio n. 7
0
 /**
  * set board list
  *
  * @return void
  */
 protected function setBoardList()
 {
     $instanceConfig = InstanceConfig::instance();
     $instanceId = $instanceConfig->getInstanceId();
     $configHandler = app('xe.board.config');
     $boards = $configHandler->gets();
     $boardList = [];
     /** @var ConfigEntity $config */
     foreach ($boards as $config) {
         // 현재의 게시판은 리스트에서 제외
         if ($instanceId === $config->get('boardId')) {
             continue;
         }
         $boardName = $config->get('boardName');
         if ($boardName === null || $boardName === '') {
             $menuItem = MenuItem::find($config->get('boardId'));
             $boardName = $menuItem->title;
         }
         $boardList[] = ['value' => $config->get('boardId'), 'text' => $boardName];
     }
     $this->data['boardList'] = $boardList;
 }
 /**
  * Delete menu item
  *
  * @param MenuItem $item menu item instance
  * @return bool
  */
 public function deleteItem(MenuItem $item)
 {
     $item->menu->decrement($item->menu->getCountName());
     return $item->delete();
 }
 /**
  * Delete menu item
  *
  * @param MenuItem $item menu item instance
  * @return bool
  */
 public function deleteItem(MenuItem $item)
 {
     return $item->delete();
 }