/** * Global index page * @return Response */ public function indexAction() { $data['page'] = 'index'; $em = $this->getDoctrine()->getManager(); $data['journals'] = $em->getRepository('OjsJournalBundle:Journal')->getHomePageList(); $switcher = $this->createForm(new QuickSwitchType(), null, array())->createView(); /** @var SubjectRepository $repo */ $repo = $em->getRepository('OjsJournalBundle:Subject'); $options = ['decorate' => true, 'rootOpen' => '<ul>', 'rootClose' => '</ul>', 'childOpen' => '<li>', 'childClose' => '</li>', 'idField' => true, 'nodeDecorator' => function ($node) { return '<a href="' . $this->generateUrl('ojs_site_explore_index', ['filter' => ['subject' => $node['id']]]) . '">@todo_this_will_fixed' . ' (' . $node['totalJournalCount'] . ')</a>'; }]; $data['subjects'] = TreeHelper::createSubjectTreeView(TreeHelper::SUBJECT_SEARCH, $this->get('router'), $repo->findAll()); $data['page'] = 'index'; $data['stats'] = ['journal' => 0, 'article' => 0, 'subject' => 0, 'publisher' => 0, 'user' => 0]; $journalApplications = $this->getDoctrine()->getRepository('OjsAdminBundle:SystemSetting')->findOneBy(['name' => 'journal_application']); $publisherApplications = $this->getDoctrine()->getRepository('OjsAdminBundle:SystemSetting')->findOneBy(['name' => 'publisher_application']); $data['journalApplicationAllowance'] = $journalApplications ? $journalApplications->getValue() : true; $data['publisherApplicationAllowance'] = $publisherApplications ? $publisherApplications->getValue() : true; $data['stats']['journal'] = $this->get('fos_elastica.index.search.journal')->count(new MatchAll()); $data['stats']['article'] = $this->get('fos_elastica.index.search.articles')->count(new MatchAll()); $data['stats']['subject'] = $this->get('fos_elastica.index.search.subject')->count(new MatchAll()); $data['stats']['publisher'] = $this->get('fos_elastica.index.search.publisher')->count(new MatchAll()); $data['stats']['user'] = $this->get('fos_elastica.index.search.user')->count(new MatchAll()); $data['announcements'] = $em->getRepository('OjsAdminBundle:AdminAnnouncement')->findAll(); $data['announcement_count'] = count($data['announcements']); $data['posts'] = $em->getRepository('OjsAdminBundle:AdminPost')->findAll(); $data['switcher'] = $switcher; // anything else is anonym main page return $this->render('OjsSiteBundle::Site/home.html.twig', $data); }
/** * @param $type * @param Router $router * @param ArrayCollection|Subject[] $subjects * @param int|null $parentId * @return string */ public static function createSubjectTreeView($type, $router, $subjects, $parentId = null) { $tree = '<ul>%s</ul>'; $item = '<li>%s</li>'; $link = '<a href="%s">%s</a>'; $items = ""; /** * @var Subject $subject * @var ArrayCollection $children */ foreach ($subjects as $subject) { if ($subject->getParent() === null || $subject->getParent()->getId() === $parentId) { if ($type == TreeHelper::SUBJECT_ADMIN) { $path = $router->generate('ojs_admin_subject_show', ['id' => $subject->getId()]); } else { $path = $router->generate('ojs_search_index', ['subject_filters' => $subject->getSubject()]); } $content = sprintf($link, $path, $subject->getSubject()); $children = $subject->getChildren(); if ($children->count() > 0) { $content = $content . TreeHelper::createSubjectTreeView($type, $router, $children, $subject->getId()); } $items = $items . sprintf($item, $content); } } return sprintf($tree, $items); }
/** * Global index page * @return Response */ public function indexAction() { $data['page'] = 'index'; $em = $this->getDoctrine()->getManager(); $data['journals'] = $em->getRepository('OjsJournalBundle:Journal')->getHomePageList($this->get('file_cache')); shuffle($data['journals']); /** @var SubjectRepository $repo */ $repo = $em->getRepository('OjsJournalBundle:Subject'); $allSubjects = $repo->findAll(); usort($allSubjects, function ($a, $b) { return $b->getRgt() > $a->getRgt(); }); $data['subjects'] = TreeHelper::createSubjectTreeView(TreeHelper::SUBJECT_SEARCH, $this->get('router'), $allSubjects); $data['page'] = 'index'; $data['stats'] = ['journal' => 0, 'article' => 0, 'subject' => 0, 'publisher' => 0, 'user' => 0]; $data['stats']['journal'] = $this->get('fos_elastica.index.search.journal')->count(new MatchAll()); $data['stats']['article'] = $this->get('fos_elastica.index.search.articles')->count(new MatchAll()); $data['stats']['subject'] = $this->get('fos_elastica.index.search.subject')->count(new MatchAll()); $data['stats']['publisher'] = $this->get('fos_elastica.index.search.publisher')->count(new MatchAll()); $data['stats']['user'] = $this->get('fos_elastica.index.search.user')->count(new MatchAll()); $data['announcements'] = $em->getRepository('OjsAdminBundle:AdminAnnouncement')->findAll(); $data['announcement_count'] = count($data['announcements']); $data['posts'] = $em->getRepository('OjsAdminBundle:AdminPost')->findAll(); // anything else is anonym main page return $this->render('OjsSiteBundle::Site/home.html.twig', $data); }
/** * Lists all Subject entities. * * @param Request $request * @return Response */ public function indexAction(Request $request) { if (!$this->isGranted('VIEW', new Subject())) { throw new AccessDeniedException("You are not authorized for this page!"); } $source = new Entity("OjsJournalBundle:Subject"); $source->manipulateRow(function (Row $row) use($request) { /* @var Subject $entity */ $entity = $row->getEntity(); $entity->setDefaultLocale($request->getDefaultLocale()); if (!is_null($entity)) { $row->setField('subject', $entity->getSubject()); $row->setField('description', $entity->getDescription()); } return $row; }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->showAction('ojs_admin_subject_show', 'id'); $rowAction[] = $gridAction->editAction('ojs_admin_subject_edit', 'id'); $rowAction[] = $gridAction->deleteAction('ojs_admin_subject_delete', 'id'); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); /** @var ArrayCollection|Subject[] $all */ $all = $this->getDoctrine()->getRepository('OjsJournalBundle:Subject')->findAll(); $data = ['grid' => $grid, 'tree' => TreeHelper::createSubjectTreeView(TreeHelper::SUBJECT_ADMIN, $this->get('router'), $all)]; return $grid->getGridResponse('OjsAdminBundle:AdminSubject:index.html.twig', $data); }
/** * Global index page * @return Response */ public function indexAction() { $data['page'] = 'index'; $em = $this->getDoctrine()->getManager(); $data['journals'] = $em->getRepository('OjsJournalBundle:Journal')->getHomePageList(); /** @var SubjectRepository $repo */ $repo = $em->getRepository('OjsJournalBundle:Subject'); $data['subjects'] = TreeHelper::createSubjectTreeView(TreeHelper::SUBJECT_SEARCH, $this->get('router'), $repo->findAll()); $data['page'] = 'index'; $data['stats'] = ['journal' => 0, 'article' => 0, 'subject' => 0, 'publisher' => 0, 'user' => 0]; $journalApplications = $this->getDoctrine()->getRepository('OjsAdminBundle:SystemSetting')->findOneBy(['name' => 'journal_application']); $publisherApplications = $this->getDoctrine()->getRepository('OjsAdminBundle:SystemSetting')->findOneBy(['name' => 'publisher_application']); $data['journalApplicationAllowance'] = $journalApplications ? $journalApplications->getValue() : true; $data['publisherApplicationAllowance'] = $publisherApplications ? $publisherApplications->getValue() : true; $data['stats']['journal'] = $this->get('fos_elastica.index.search.journal')->count(new MatchAll()); $data['stats']['article'] = $this->get('fos_elastica.index.search.articles')->count(new MatchAll()); $data['stats']['subject'] = $this->get('fos_elastica.index.search.subject')->count(new MatchAll()); $data['stats']['publisher'] = $this->get('fos_elastica.index.search.publisher')->count(new MatchAll()); $data['stats']['user'] = $this->get('fos_elastica.index.search.user')->count(new MatchAll()); $data['announcements'] = $em->getRepository('OjsAdminBundle:AdminAnnouncement')->findAll(); $data['announcement_count'] = count($data['announcements']); $data['posts'] = $em->getRepository('OjsAdminBundle:AdminPost')->findAll(); // anything else is anonym main page return $this->render('OjsSiteBundle::Site/home.html.twig', $data); }
/** * Lists all Subject entities. * * @param Request $request * @return Response */ public function indexAction(Request $request) { $source = new Entity("OjsJournalBundle:Subject"); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->showAction('ojs_admin_subject_show', 'id'); $rowAction[] = $gridAction->editAction('ojs_admin_subject_edit', 'id'); $rowAction[] = $gridAction->deleteAction('ojs_admin_subject_delete', 'id'); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); /** @var ArrayCollection|Subject[] $all */ $all = $this->getDoctrine()->getRepository('OjsJournalBundle:Subject')->findAll(); $data = ['grid' => $grid, 'tree' => TreeHelper::createSubjectTreeView(TreeHelper::SUBJECT_ADMIN, $this->get('router'), $all)]; return $grid->getGridResponse('OjsAdminBundle:AdminSubject:index.html.twig', $data); }