Exemplo n.º 1
0
 /**
  * @param FactoryInterface $factory
  * @param array $items
  * @param null $event
  * @return \Knp\Menu\ItemInterface
  */
 private function generateMenu(FactoryInterface $factory, $items = [], $event = null)
 {
     /**
      * @var Journal $journal
      * @var AuthorizationChecker $checker
      */
     $dispatcher = $this->container->get('event_dispatcher');
     $menu = $factory->createItem('root')->setChildrenAttribute('class', 'list-unstyled');
     foreach ($items as $item) {
         $label = $item[0];
         $path = $item[1];
         $icon = $item[2];
         $unreadFeedbackCount = 0;
         if (isset($item[3])) {
             $unreadFeedbackCount = $item[3];
         }
         $menu->addChild($label, ['route' => $path, 'extras' => ['icon' => $icon, 'unreadFeedbackCount' => $unreadFeedbackCount]]);
     }
     $menuEvent = new MenuEvent();
     $menuEvent->setMenuItem($menu);
     if (!is_null($event)) {
         $dispatcher->dispatch($event, $menuEvent);
     }
     return $menuEvent->getMenuItem();
 }
Exemplo n.º 2
0
 public function leftMenu(FactoryInterface $factory)
 {
     /**
      * @var Journal $journal
      * @var AuthorizationChecker $checker
      */
     $dispatcher = $this->container->get('event_dispatcher');
     $checker = $this->container->get('security.authorization_checker');
     $journal = $this->container->get('ojs.journal_service')->getSelectedJournal();
     $journalId = $journal->getId();
     $menu = $factory->createItem('root')->setChildrenAttribute('class', 'nav nav-sidebar');
     if ($checker->isGranted('EDIT', $journal)) {
         $menu->addChild('settings', ['route' => 'ojs_journal_settings_index', 'routeParameters' => ['journalId' => $journalId]]);
     }
     $items = [['submissionSettings', 'title.journal_settings_submission', 'ojs_journal_settings_submission', 'paper-plane'], ['mailSettings', 'title.journal_settings_mail', 'ojs_journal_settings_mail', 'envelope'], ['checklist', 'title.submission_checklists', 'ojs_journal_checklist_index', 'list'], ['file', 'title.submission_files', 'ojs_journal_file_index', 'file'], ['userRole', 'title.users', 'ojs_journal_user_index', 'key'], ['index', 'title.journal_indexes', 'ojs_journal_index_index', 'sitemap'], ['issues', 'title.issues', 'ojs_journal_issue_index', 'newspaper-o'], ['sections', 'title.sections', 'ojs_journal_section_index', 'folder'], ['articles', 'title.articles', 'ojs_journal_article_index', 'file-text'], ['contacts', 'title.contacts', 'ojs_journal_journal_contact_index', 'users'], ['mailTemplates', 'title.title.mail_templates', 'ojs_journal_mail_template_index', 'envelope'], ['design', 'title.designs', 'ojs_journal_design_index', 'bars'], ['theme', 'title.themes', 'ojs_journal_theme_index', 'paint-brush'], ['boards', 'title.boards', 'ojs_journal_board_index', 'object-group'], ['announcements', 'title.announcements', 'ojs_journal_announcement_index', 'bullhorn'], ['pages', 'title.pages', 'ojs_journal_page_index', 'file'], ['posts', 'title.posts', 'ojs_journal_post_index', 'file-o']];
     foreach ($items as $item) {
         $field = $item[0];
         $label = $item[1];
         $path = $item[2];
         $icon = $item[3];
         if (empty($field) || $checker->isGranted('VIEW', $journal, $field)) {
             $menu->addChild($label, ['route' => $path, 'routeParameters' => ['journalId' => $journalId], 'extras' => ['icon' => $icon]]);
         }
     }
     $menuEvent = new MenuEvent();
     $menuEvent->setMenuItem($menu);
     $dispatcher->dispatch(JournalEvents::LEFT_MENU_INITIALIZED, $menuEvent);
     return $menuEvent->getMenuItem();
 }
Exemplo n.º 3
0
 public function fabMenu(FactoryInterface $factory)
 {
     /**
      * @var Journal $journal
      * @var AuthorizationChecker $checker
      */
     $dispatcher = $this->container->get('event_dispatcher');
     $checker = $this->container->get('security.authorization_checker');
     $menu = $factory->createItem('root')->setChildrenAttribute('class', 'dropdown-menu dropdown-menu-right');
     $menu->addChild('dashboard', ['route' => 'dashboard', 'attributes' => array('data-toggle' => 'tooltip', 'data-placement' => 'left'), 'extras' => ['icon' => 'dashboard']]);
     $journal = $this->container->get('ojs.journal_service')->getSelectedJournal();
     if ($journal) {
         $journalId = $journal->getId();
         if ($checker->isGranted('CREATE', $journal, 'articles')) {
             $menu->addChild('article.submit', ['route' => 'ojs_journal_submission_new', 'routeParameters' => ['journalId' => $journalId], 'attributes' => array('data-toggle' => 'tooltip', 'data-placement' => 'left'), 'extras' => ['icon' => 'file-text']]);
         }
         if ($checker->isGranted('EDIT', $journal, 'userRole')) {
             $menu->addChild('title.users', ['route' => 'ojs_journal_user_index', 'routeParameters' => ['journalId' => $journalId], 'attributes' => array('data-toggle' => 'tooltip', 'data-placement' => 'left'), 'extras' => ['icon' => 'key']]);
         }
         if ($checker->isGranted('EDIT', $journal, 'issues')) {
             $menu->addChild('title.issues', ['route' => 'ojs_journal_issue_index', 'routeParameters' => ['journalId' => $journalId], 'attributes' => array('data-toggle' => 'tooltip', 'data-placement' => 'left'), 'extras' => ['icon' => 'plug']]);
         }
         if ($checker->isGranted('VIEW', $journal, 'articles')) {
             $menu->addChild('articles', ['route' => 'ojs_journal_submission_me', 'routeParameters' => ['journalId' => $journalId], 'attributes' => array('data-toggle' => 'tooltip', 'data-placement' => 'left'), 'extras' => ['icon' => 'file-o']]);
         }
     }
     $menuEvent = new MenuEvent();
     $menuEvent->setMenuItem($menu);
     $dispatcher->dispatch(MenuEvents::FAB_MENU_INITIALIZED, $menuEvent);
     return $menuEvent->getMenuItem();
 }