<commit_before><?php

namespace Ojs\SiteBundle\Controller;

use Doctrine\ORM\EntityManager;
use Ojs\Common\Controller\OjsController as Controller;
use Ojs\JournalBundle\Entity\Journal;
use Ojs\JournalBundle\Entity\JournalRepository;
use Ojs\JournalBundle\Entity\SubjectRepository;
use Ojs\JournalBundle\Entity\Issue;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class SiteController extends Controller {

    /**
     * Global index page
     * @return Response
     */
    public function indexAction()
    {
        $data['page'] = 'index';
        $em = $this->getDoctrine()->getManager();
        $data["journals"] = $em->getRepository('OjsJournalBundle:Journal')->findBy(array('status' => 3), array(), 12);
        $data['institutions'] = $em->getRepository('OjsJournalBundle:Institution')->findBy(array(), array(), 6);
        $repo = $this->getDoctrine()->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_journals_index', ['filter' => ['subject' => $node['id']]]) . '">'
                        . $node['subject'] . ' (' . $node['totalJournalCount'] . ')</a>';
            }];
                $data['subjects'] = $repo->childrenHierarchy(null, false, $options);
                $data['page'] = 'index';
                $sumRepo = $em->getRepository('OjsJournalBundle:Sums');
                $data['stats'] = [
                    'journal' => $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Journal'])->getSum(),
                    'article' => $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Article'])->getSum(),
                    'subject' => $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Subject'])->getSum(),
                    'institution' => $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Institution'])->getSum(),
                    'user' => $sumRepo->findOneBy(['entity' => 'OjsUserBundle:User'])->getSum(),
                ];
                // anything else is anonym main page
                return $this->render('OjsSiteBundle::Site/home.html.twig', $data);
            }

            public function browseIndexAction()
            {
                $data['page'] = 'browse';
                return $this->render('OjsSiteBundle::Site/browse_index.html.twig', $data);
            }

            public function categoriesIndexAction()
            {
                $data['page'] = 'categories';
                return $this->render('OjsSiteBundle::Site/categories_index.html.twig', $data);
            }

            public function topicsIndexAction()<commit_msg>bugfix.<commit_after><?php

namespace Ojs\SiteBundle\Controller;

use Doctrine\ORM\EntityManager;
use Ojs\Common\Controller\OjsController as Controller;
use Ojs\JournalBundle\Entity\Journal;
use Ojs\JournalBundle\Entity\JournalRepository;
use Ojs\JournalBundle\Entity\SubjectRepository;
use Ojs\JournalBundle\Entity\Issue;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class SiteController extends Controller {

    /**
     * Global index page
     * @return Response
     */
    public function indexAction()
    {
        $data['page'] = 'index';
        $em = $this->getDoctrine()->getManager();
        $data["journals"] = $em->getRepository('OjsJournalBundle:Journal')->findBy(array('status' => 3), array(), 12);
        $data['institutions'] = $em->getRepository('OjsJournalBundle:Institution')->findBy(array(), array(), 6);
        $repo = $this->getDoctrine()->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_journals_index', ['filter' => ['subject' => $node['id']]]) . '">'
                        . $node['subject'] . ' (' . $node['totalJournalCount'] . ')</a>';
            }];
                $data['subjects'] = $repo->childrenHierarchy(null, false, $options);
                $data['page'] = 'index';
                $sumRepo = $em->getRepository('OjsJournalBundle:Sums');
                $journalSum = $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Journal']);
                $articleSum = $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Article']);
                $subjectSum = $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Subject']);
                $institutionSum = $sumRepo->findOneBy(['entity' => 'OjsJournalBundle:Institution']);
                $userSum = $sumRepo->findOneBy(['entity' => 'OjsUserBundle:User']);
                $data['stats'] = [
                    'journal' => $journalSum?$journalSum->getSum():0,
                    'article' => $articleSum?$articleSum->getSum():0,
                    'subject' => $subjectSum?$subjectSum->getSum():0,
                    'institution' => $institutionSum?$institutionSum->getSum():0,
                    'user' => $userSum?$userSum->getSum():0,
                ];
                // anything else is anonym main page
                return $this->render('OjsSiteBundle::Site/home.html.twig', $data);
            }

            public function browseIndexAction()
            {
                $data['page'] = 'browse';
                return $this->render('OjsSiteBundle::Site/browse_index.html.twig', $data);
            }

            public function categoriesIndexAction()
            {
                $data['page'] = 'categories';
                return $this->render('OjsSiteBundle::Site/categories_index.html.twig', $data);
            }

            public function topicsIndexAction()
{'fraction_non_alphanumeric': 0.17040951122853368, 'fraction_numerical': 0.0021466314398943197, 'mean_word_length': 2.3932773109243697, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '407912', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1669, 'n_words': 261}