<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of categories
 *
 * @author Alex
 */
class Categories extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->load->model('categories_model');
        $this->output->set_header('Content-Type: text/html; charset=utf-8');
        $topcategories = $this->categories_model->get_categories();
        $index = 1;
        $item = 1 ;
        echo '<ul id="menu-group-1" class="nav menu">';
        foreach ($topcategories as $topcategorie) {

            $subcategories = $this->categories_model->get_sub_categories($topcategorie->CATEGORIES_ID);

            echo '<li class="item-1 deeper parent">';
            echo '<a href="' . base_url() . 'products/cat/' . $topcategorie->CATEGORIES_ID . '">';
            if ($subcategories != NULL) {
                echo '<span data-toggle="collapse" data-parent="#menu-group-1" href="#sub-item-1" class="sign"><i class="icon-plus icon-white"></i></span>';
            }
            echo '<span class="lbl">' . $topcategorie->CATEGORIES_LABEL . '</span>';
            echo '</a>';


            if ($subcategories != NULL) {
                echo '<ul class="children nav-child unstyled small collapse" id="sub-item-1">';
                
                foreach ($subcategories as $subcategorie) {

                    $subsubcategories = $this->categories_model->get_sub_categories($subcategorie->CATEGORIES_ID);

                    echo '<li class="item-2 deeper parent">';
                    echo '<a href="' . base_url() . 'products/cat/' . $subcategorie->CATEGORIES_ID . '">';
                    if ($subsubcategories != NULL) {
                        echo '<span data-toggle="collapse" data-parent="#menu-group-1" href="#sub-item-'.$index.'" class="sign"><i class="icon-plus icon-white"></i></span>';
                    }
                    echo '<span class="lbl">' . $subcategorie->CATEGORIES_LABEL . '</span> ';
                    echo '</a>';



                    if ($subsubcategories != NULL) {
                        echo '<ul class="children nav-child unstyled small collapse" id="sub-item-'.$index.'">';
                        foreach ($subsubcategories as $subsubcategorie) {
                            echo '<li class="item-'.$item.'">';
                            echo '<a href="' . base_url() . 'products/cat/' . $subsubcategorie->CATEGORIES_ID . '">';
                            echo '<span class="blacked"><i class="icon-play"></i></span>';
                            echo '<span class="lbl">' . $subsubcategorie->CATEGORIES_LABEL . '</span>';
                            echo'</a>';
                            echo'</li>';
                            $index++;
                        }
                        echo '</ul>';
                    }
                    echo '</li>';
                    $index++;
                }
                echo '</ul>';
            }
            echo '</li>';
        }
        echo '</ul>';

        //$this->load->view('layouts/json_view', $data);
    }

    //put your code here
}<commit_msg>Catégories OK !<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of categories
 *
 * @author Alex
 */
class Categories extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->load->model('categories_model');
        $this->output->set_header('Content-Type: text/html; charset=utf-8');
        $topcategories = $this->categories_model->get_categories();
        $index = 1;
        $item = 1;
        echo '<ul id="menu-group-1" class="nav menu">';
        foreach ($topcategories as $topcategorie) {

            $subcategories = $this->categories_model->get_sub_categories($topcategorie->CATEGORIES_ID);

            echo '<li class="item-1 deeper parent">';
            $item++;
            echo '<a href="' . base_url() . 'products/cat/' . $topcategorie->CATEGORIES_ID . '">';
            if ($subcategories != NULL) {
                echo '<span data-toggle="collapse" data-parent="#menu-group-1" href="#sub-item-' . $item . '" class="sign"><i class="icon-plus icon-white"></i></span>';
            }
            echo '<span class="lbl">' . $topcategorie->CATEGORIES_LABEL . '</span>';
            echo '</a>';


            if ($subcategories != NULL) {
                echo '<ul class="children nav-child unstyled small collapse" id="sub-item-' . $item . '">';
                $item++;
                foreach ($subcategories as $subcategorie) {

                    $subsubcategories = $this->categories_model->get_sub_categories($subcategorie->CATEGORIES_ID);

                    echo '<li class="item-2 deeper parent">';
                    echo '<a href="' . base_url() . 'products/cat/' . $subcategorie->CATEGORIES_ID . '">';
                    if ($subsubcategories != NULL) {
                        echo '<span data-toggle="collapse" data-parent="#menu-group-1" href="#sub-item-' . $item . '" class="sign"><i class="icon-plus icon-white"></i></span>';
                    }
                    echo '<span class="lbl">' . $this->trunk($subcategorie->CATEGORIES_LABEL) . '</span> ';
                    echo '</a>';

                    if ($subsubcategories != NULL) {
                        echo '<ul class="children nav-child unstyled small collapse" id="sub-item-' . $item . '">';
                        foreach ($subsubcategories as $subsubcategorie) {
                            echo '<li class="item-' . $item . '">';
                            echo '<a href="' . base_url() . 'products/cat/' . $subsubcategorie->CATEGORIES_ID . '">';
                            echo '<span class="blacked"><i class="icon-play"></i></span>';
                            echo '<span class="lbl">' . $this->trunk($subsubcategorie->CATEGORIES_LABEL) . '</span>';
                            echo'</a>';
                            echo'</li>';
                            $item++;
                        }
                        echo '</ul>';
                    }
                    echo '</li>';
                    $index++;
                }
                echo '</ul>';
            }
            echo '</li>';
        }
        echo '</ul>';

        //$this->load->view('layouts/json_view', $data);
    }

    public function trunk($description) {
        //nombre de caractères à afficher
        $max_caracteres = 30;
        // Test si la longueur du texte dépasse la limite
        if (strlen($description) > $max_caracteres) {
            // Séléction du maximum de caractères
            $description = substr($description, 0, $max_caracteres);
            // Récupération de la position du dernier espace (afin déviter de tronquer un mot)
            $position_espace = strrpos($description, " ");
            $description = substr($description, 0, $position_espace);
            // Ajout des "..."
            $description = $description . "...";
        }
        return $description;
    }

    //put your code here
}
{'fraction_non_alphanumeric': 0.15796555435952636, 'fraction_numerical': 0.002960172228202368, 'mean_word_length': 1.6853323699421965, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 118, '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': '234785', 'n_tokens_mistral': 2073, 'n_tokens_neox': 2005, 'n_words': 449}