<commit_before><?php
App::uses('AppController', 'Controller');

class TaxonomiesController extends AppController
{
    public $components = array('Session', 'RequestHandler');

    public $paginate = array(
            'limit' => 60,
            'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user van view/page.
            'contain' => array(
                'TaxonomyPredicate' => array(
                    'fields' => array('TaxonomyPredicate.id'),
                    'TaxonomyEntry' => array('fields' => array('TaxonomyEntry.id'))
                )
            ),
            'order' => array(
                    'Taxonomy.id' => 'DESC'
            ),
    );

    public function index()
    {
        $this->paginate['recursive'] = -1;
        $taxonomies = $this->paginate();
        $this->loadModel('Tag');
        foreach ($taxonomies as $key => $taxonomy) {
            $total = 0;
            foreach ($taxonomy['TaxonomyPredicate'] as $predicate) {
                $total += empty($predicate['TaxonomyEntry']) ? 1 : count($predicate['TaxonomyEntry']);
            }
            $taxonomies[$key]['total_count'] = $total;
            $taxonomies[$key]['current_count'] = $this->Tag->find('count', array('conditions' => array('lower(Tag.name) LIKE ' => strtolower($taxonomy['Taxonomy']['namespace']) . ':%', 'hide_tag' => 0)));
            unset($taxonomies[$key]['TaxonomyPredicate']);
        }
        if ($this->_isRest()) {
            return $this->RestResponse->viewData($taxonomies, $this->response->type());
        } else {
            $this->set('taxonomies', $taxonomies);
        }
    }

    public function view($id)
    {
        if (isset($this->passedArgs['pages'])) {
            $currentPage = $this->passedArgs['pages'];
        } else {
            $currentPage = 1;
        }
        $this->set('page', $currentPage);
        $urlparams = '';
        $passedArgs = array();
        App::uses('CustomPaginationTool', 'Tools');
        $filter = isset($this->passedArgs['filter']) ? $this->passedArgs['filter'] : false;
        $taxonomy = $this->Taxonomy->getTaxonomy($id, array('full' => true, 'filter' => $filter));
        if (empty($taxonomy)) {
            throw new NotFoundException(__('Taxonomy not found.'));
        }
        $this->loadModel('EventTag');
        $this->loadModel('AttributeTag');
        foreach ($taxonomy['entries'] as $key => $value) {
            $count = 0;
            if (!empty($value['existing_tag'])) {
                foreach ($value['existing_tag'] as $et) {
                    $count = $this->EventTag->find('count', array(<commit_msg>fix: [taxonomies] non initialised variable throwing notices fixed<commit_after><?php
App::uses('AppController', 'Controller');

class TaxonomiesController extends AppController
{
    public $components = array('Session', 'RequestHandler');

    public $paginate = array(
            'limit' => 60,
            'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user van view/page.
            'contain' => array(
                'TaxonomyPredicate' => array(
                    'fields' => array('TaxonomyPredicate.id'),
                    'TaxonomyEntry' => array('fields' => array('TaxonomyEntry.id'))
                )
            ),
            'order' => array(
                    'Taxonomy.id' => 'DESC'
            ),
    );

    public function index()
    {
        $this->paginate['recursive'] = -1;
        $taxonomies = $this->paginate();
        $this->loadModel('Tag');
        foreach ($taxonomies as $key => $taxonomy) {
            $total = 0;
            foreach ($taxonomy['TaxonomyPredicate'] as $predicate) {
                $total += empty($predicate['TaxonomyEntry']) ? 1 : count($predicate['TaxonomyEntry']);
            }
            $taxonomies[$key]['total_count'] = $total;
            $taxonomies[$key]['current_count'] = $this->Tag->find('count', array('conditions' => array('lower(Tag.name) LIKE ' => strtolower($taxonomy['Taxonomy']['namespace']) . ':%', 'hide_tag' => 0)));
            unset($taxonomies[$key]['TaxonomyPredicate']);
        }
        if ($this->_isRest()) {
            return $this->RestResponse->viewData($taxonomies, $this->response->type());
        } else {
            $this->set('taxonomies', $taxonomies);
        }
    }

    public function view($id)
    {
        if (isset($this->passedArgs['pages'])) {
            $currentPage = $this->passedArgs['pages'];
        } else {
            $currentPage = 1;
        }
        $this->set('page', $currentPage);
        $urlparams = '';
        $passedArgs = array();
        App::uses('CustomPaginationTool', 'Tools');
        $filter = isset($this->passedArgs['filter']) ? $this->passedArgs['filter'] : false;
        $taxonomy = $this->Taxonomy->getTaxonomy($id, array('full' => true, 'filter' => $filter));
        if (empty($taxonomy)) {
            throw new NotFoundException(__('Taxonomy not found.'));
        }
        $this->loadModel('EventTag');
        $this->loadModel('AttributeTag');
        foreach ($taxonomy['entries'] as $key => $value) {
            $count = 0;
            $count_a = 0;
            if (!empty($value['existing_tag'])) {
                foreach ($value['existing_tag'] as $et) {
                    $count = $this->EventTag->find('count', array(
{'fraction_non_alphanumeric': 0.17446964155084127, 'fraction_numerical': 0.006035113386978786, 'mean_word_length': 2.2303603071470763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 79, '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': '3210193', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1519, 'n_words': 310}