/**
* 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);
}