<commit_before><?php

/**
 * Description of home
 *
 * @author juise_man
 */
class Controller_Home extends Controller_Application {

    protected static function get_main_page() {
        $langID = TCLocal::getCurrentLangID();
        if (is_null($langID)) {
            return Model_MainPage::query()->get_one();
        } else {
            return Model_MainPage::query()->where('language_id', '=', TCLocal::getCurrentLangID())->get_one();
        }
    }
            
    function before() {
        $this->template = TCCore\TCTheme::main_view();
        
        
        
        
        if (Model_Language::query()->count() > 0) {

            if ($lang = Fuel\Core\Request::active()->param('lang')) {
                TCLocal::setCurrentLang($lang);
            } else {

                $matched_langs = array();//Model_Language::find('all');
                $all_langs = array();

                foreach (Model_Language::find('all') as $model_lang) {
                    $matched_langs[$model_lang->code] = strtolower(explode(',', $model_lang->match));
                    $all_langs[] = $model_lang->code;
                }


                $lang = TCLocal::forge()->match('ru', $matched_langs);

                if (in_array($lang, array_keys($all_langs))) {
                    TCLocal::setCurrentLang($lang);
                }

                if (Fuel\Core\Request::active()->route->name == '_root_') {
                    Fuel\Core\Response::redirect(TCRouter::get('root', Fuel\Core\Request::active()->route->named_params));
                } else {
                    Fuel\Core\Response::redirect(TCRoute::get(Fuel\Core\Request::active()->route->name, Fuel\Core\Request::active()->route->named_params));
                }

            }

        }
        
        parent::before();
        $this->template->set_global('route_params', array('name' => Fuel\Core\Request::active()->route->name, 'named_params' => Fuel\Core\Request::active()->route->named_params));

        
        $model_mainpage = self::get_main_page();
        
        if(!is_null($model_mainpage)) {
            $this->template->set_global('main_page_model', $model_mainpage, false);
            $links = (Model_Language::query()->count() > 1) ? Model_Link::query()->where('language_id', '=', TCLocal::getCurrentLangID())->order_by('weight')->get() : Model_Link::query()->order_by('weight')->get();
            $this->template->set_global('links', $links);
        } else {
            throw new Fuel\Core\HttpNotFoundException();
        }

        self::$current_page = \Fuel\Core\Request::active()->uri->current();
    }

    function action_index() {
        self::$current_page = "Home";
        $main = self::get_main_page();
        if(!is_null($main)) {
            $this->template->set_global('title', $main->title);
            $this->template->set_global('meta_keywrd', $main->meta);
        }
        $this->template->content = TCCore\TCTheme::load_view('home/partials/home');
    }

}
<commit_msg>xvxdv<commit_after><?php

/**
 * Description of home
 *
 * @author juise_man
 */
class Controller_Home extends Controller_Application {

    protected static function get_main_page() {
        $langID = TCLocal::getCurrentLangID();
        if (is_null($langID)) {
            return Model_MainPage::query()->get_one();
        } else {
            return Model_MainPage::query()->where('language_id', '=', TCLocal::getCurrentLangID())->get_one();
        }
    }
            
    function before() {
        $this->template = TCCore\TCTheme::main_view();
        
        
        
        
        if (Model_Language::query()->count() > 0) {

            if ($lang = Fuel\Core\Request::active()->param('lang')) {
                TCLocal::setCurrentLang($lang);
            } else {

                $matched_langs = array();//Model_Language::find('all');
                $all_langs = array();

                foreach (Model_Language::find('all') as $model_lang) {
                    $matched_langs[$model_lang->code] = explode(',', $model_lang->match);
                    $all_langs[] = strtolower($model_lang->code);
                }


                $lang = TCLocal::forge()->match('ru', $matched_langs);

                if (in_array($lang, array_keys($all_langs))) {
                    TCLocal::setCurrentLang($lang);
                }

                if (Fuel\Core\Request::active()->route->name == '_root_') {
                    Fuel\Core\Response::redirect(TCRouter::get('root', Fuel\Core\Request::active()->route->named_params));
                } else {
                    Fuel\Core\Response::redirect(TCRoute::get(Fuel\Core\Request::active()->route->name, Fuel\Core\Request::active()->route->named_params));
                }

            }

        }
        
        parent::before();
        $this->template->set_global('route_params', array('name' => Fuel\Core\Request::active()->route->name, 'named_params' => Fuel\Core\Request::active()->route->named_params));

        
        $model_mainpage = self::get_main_page();
        
        if(!is_null($model_mainpage)) {
            $this->template->set_global('main_page_model', $model_mainpage, false);
            $links = (Model_Language::query()->count() > 1) ? Model_Link::query()->where('language_id', '=', TCLocal::getCurrentLangID())->order_by('weight')->get() : Model_Link::query()->order_by('weight')->get();
            $this->template->set_global('links', $links);
        } else {
            throw new Fuel\Core\HttpNotFoundException();
        }

        self::$current_page = \Fuel\Core\Request::active()->uri->current();
    }

    function action_index() {
        self::$current_page = "Home";
        $main = self::get_main_page();
        if(!is_null($main)) {
            $this->template->set_global('title', $main->title);
            $this->template->set_global('meta_keywrd', $main->meta);
        }
        $this->template->content = TCCore\TCTheme::load_view('home/partials/home');
    }

}

{'fraction_non_alphanumeric': 0.17617617617617617, 'fraction_numerical': 0.000667334000667334, 'mean_word_length': 2.2670299727520438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 99, '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': '1992410', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1717, 'n_words': 206}