<commit_before><?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 24.08.2015
 * Time: 11:28
 */

namespace common\classes;


class PrintMenu
{
    public $html = '';
    public $menuModel;
    public $menus = array();
    public $i,$j =0;

    public function generateHtml($model){
        foreach($model as $tab){
            $this->menus[$tab->parent_id][] = $tab;
        }

        //Debag::prn($this->menus);
        $this->html = '<nav class="mainmenu">
            <ul>';

        $this->outTree(0, 0);

        $this->html .= '</ul>
        </nav>';

        //Debag::prn($this->html);
        return $this->html;
    }

    public function outTree($parent_id, $level) {
        if (isset($this->menus[$parent_id])) { //    parent_id 
            foreach ($this->menus[$parent_id] as $value) { //
                //$this->html .= '<li style="margin-left:'. $level*25 .'px;"><a href="'.$value["url"].'">'.$value["name"].'</a>';

                $level = $level + 1; //  
                $this->html .= '<li style="margin-left:'. $level*25 .'px;">';

                //    ,    $parent_id  $level
                //

                if ($level == 1) {
                    $this->html .= '<a href="'.$value["url"].'">'.$value["name"].'</a><nav><ul>';
                } elseif ($level == 2) {
                    $this->html .= '<a href="'.$value["url"].'">'.$value["name"].'</a><ul>';
                } elseif($level == 3){
                    $this->html .= '<a href="'.$value["url"].'"><img src="'.$value["icon"].'" alt=""></a>
                    <a href="'.$value["url"].'">'.$value["name"].'</a>
                    <p>'.$value["descr"].'</p>';
                }

                $this->outTree($value["id"], $level);

                $level = $level - 1; //  
               // $this->html .= $level;
                if ($level == 0) {
                    $this->html .= '</ul></nav>';
                    //$this->i = 1;
                } elseif ($level == 1) {
                    $this->html .= '</ul>';
                    //$this->j = 1;
                }<commit_msg>Поправил стили в классе PrintMenu<commit_after><?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 24.08.2015
 * Time: 11:28
 */

namespace common\classes;


class PrintMenu
{
    public $html = '';
    public $menuModel;
    public $menus = array();
    public $i,$j =0;

    public function generateHtml($model){
        foreach($model as $tab){
            $this->menus[$tab->parent_id][] = $tab;
        }

        //Debag::prn($this->menus);
        $this->html = '<nav class="mainmenu">
            <ul>';

        $this->outTree(0, 0);

        $this->html .= '</ul>
        </nav>';

        //Debag::prn($this->html);
        return $this->html;
    }

    public function outTree($parent_id, $level) {
        if (isset($this->menus[$parent_id])) { //    parent_id 
            foreach ($this->menus[$parent_id] as $value) { //
                //$this->html .= '<li style="margin-left:'. $level*25 .'px;"><a href="'.$value["url"].'">'.$value["name"].'</a>';

                $level = $level + 1; //  
                $this->html .= '<li >';

                //    ,    $parent_id  $level
                //style="margin-left:'. $level*25 .'px;"

                if ($level == 1) {
                    $this->html .= '<a href="'.$value["url"].'">'.$value["name"].'</a><nav><ul>';
                } elseif ($level == 2) {
                    $this->html .= '<a href="'.$value["url"].'">'.$value["name"].'</a><ul>';
                } elseif($level == 3){
                    $this->html .= '<a href="'.$value["url"].'"><img src="'.$value["icon"].'" alt=""></a>
                    <a href="'.$value["url"].'" class="title">'.$value["name"].'</a>
                    <p>'.$value["descr"].'</p>';
                }

                $this->outTree($value["id"], $level);

                $level = $level - 1; //  
               // $this->html .= $level;
                if ($level == 0) {
                    $this->html .= '</ul></nav>';
                    //$this->i = 1;
                } elseif ($level == 1) {
                    $this->html .= '</ul>';
                    //$this->j = 1;
                }
{'fraction_non_alphanumeric': 0.23801613668723304, 'fraction_numerical': 0.013289036544850499, 'mean_word_length': 1.4279953917050692, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 95, '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': '4376347', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1294, 'n_words': 235}