Файл: core/Base.php
Строк: 117
<?php
include_once(DIR.'/core/Core.php'); 
include_once(DIR.'/model/startup.php');
include_once(DIR.'/model/M_Users.php');
startup(); // Инициализация настроек к БД и т.д
abstract class Base extends Core 
{
    protected function _before() {    // Аналог __construct()
        parent::_before();
        Cur::$set['version'] = 1; // Версия системы
        Cur::$set['lang'] = 0; // Язык 
        Cur::$set['langVer'] = 0; // Версия языка. 
        Cur::$set['title'] = null; // Основной title для html
        Cur::$set['id'] = 0; // id пользователя. 
        Cur::$set['ajxCode'] = 0; // код ошибки ajax-а
        Cur::$set['pageParams'] = array( // Парметры для генерации страницы. 
            "id" => Cur::$set['id'],
            "pads" => 1,
            "leftblocks" => "",
            "leftads" => "asdasd",
            "ads_can_show" => 0,
            "ads_showed" => 0,
            "ads_section" => "profile",
            "level" => 2,
            "loc" => Cur::get('loc'),
            "wrap_page" => 0,
            "width" => 791,
            "width_dec" => 160,
            "width_dec_footer" => 130,
            "counters" => "-1,-1,-1,-1,-1,0,-1,1,0,0,0,1,1",
            "pvbig" => 1,
            "pvdark" => 1
        );
    }
    protected function init() {
        Request::utf8($this->_al, $this->al); // Определение conetnt type
        $this->mUser = M_Users::Instance(); // Инициализация модели пользоваителей
        
        // Очистка старых сессий.
        $this->mUser->ClearSessions();
        // Текущий пользователь.
        $this->user = $this->mUser->Get();
        // Проверка активности пользователя.
        if($this->user != null) 
            $this->mUser->checkOpenSession($this->user['id_user']);
        // Запрет на показ страницы
        if ($this->need_login && $this->user == null)
            Request::redirect('/');
        // Инициализация основных параметров.  
        Cur::$set['lang'] = $this->user['lang'];
        Cur::$set['id'] = (int) $this->user['id_user'];
        Cur::$set['pageParams']['id'] = (int) $this->user['id_user'];
        // Вывод нужного вида в блок с меню. 
        $toMain['sideBar'] = (!$this->user) ? 
                                            $this->view('widget/sideBar/v_login.php') : 
                                            $this->view('widget/sideBar/v_nav.php', array(
                                                'user' => $this->user
                                            ));
        
        $toMain['headerLink'] = (!$this->user) ? 
                                            $this->view('widget/header/v_header_noLogin.php') : 
                                            $this->view('widget/header/v_header.php');
        // Установка переменных для шаблона. 
        $this->setVarsMainTempl($toMain, true);
    }
    // Генерация основного вывода. 
    protected function _after() {
        parent::_after();
        
        // Генерация javascript кода на каждую страницу. 
        Cur::$set['js'] = $this->view('main/js/js_main.js', array(
            'pageParams' => json_encode(Cur::get('pageParams')),
            'user' => $this->user
        )).Cur::get('js');
        
        $endTime = $this->getTime(); // Debug time
        $this->endTime = bcsub($endTime, $this->startTime, 6); // Debug time
        
        if($this->out == null) {
            $this->toTemplate['cur'] = Cur::getAll(); 
            if($this->al == 1) { // При запросе страницы с al=1
                $content = (!$this->_al) ? $this->view('main/v_main.php', $this->toTemplate) : $this->toTemplate['content'];
                $static = (!$this->_al) ? implode(',', Cur::get('static')) : $this->toTemplate['static'];
                $js = (!$this->_al) ? Cur::get('js') : $this->toTemplate['js'];
                $type = Cur::get('contType');
                // Temporarily, next to make through $this->view.
                $this->out = //'<!--'.
                                Cur::get('version').'<!>'.
                                $static.'<!>'.
                                Cur::get('lang').'<!>'.
                                Cur::get('langVer').'<!>'.
                                Cur::get('ajxCode').'<!>'.
                                Cur::get('title').'<!>'.
                                $content.'<!'.$type.'>'.
                                $js;//.'<!>'.
                                //'-->';
                //$out = $this->view('v_main_ajax.php', $this->toTemplate);
            } else if($this->al == -1) { // При запросе страницы с al=-1
                $this->addFrame(true);
            } else {  // При обычном запросе страницы
                $varsScrollFix = array_merge($this->toTemplate, array(
                    'content' => $this->view('main/v_main.php', $this->toTemplate),
                    'debugLog' => Debug::get(),
                    'timeLoad' => $this->endTime
                ));
                $varsFull =    array_merge($this->toTemplate, array(
                    'scrollFix' => $this->view('main/v_main_scrollFix.php', $varsScrollFix),
                    'al' => $this->al,
                ));
                $this->out = $this->view('main/v_main_full.php', $varsFull);
            }
        }
        echo $this->out; // Основной вывод. 
    }
    protected function addFrame($end = null) {
        parent::addFrame();
        // Если метод был вызван первый раз. 
        if($this->_forFrameCount < 1) { // генерация первоначального вывода _framedone. 
            $static = implode(',', Cur::get('static'));
            $refLogin = $this->_ref == 'login';
            if($refLogin === true) {
                $varsScrollFix =    array_merge($this->toTemplate, array(
                    'content' => $this->view('main/v_main.php', $this->toTemplate),
                ));
                $content = $this->view('main/v_main_scrollFix.php', $varsScrollFix);
                Cur::$set['pageParams']['fullPage'] = 1;
            } else {
                $content = $this->view('main/v_main.php', $this->toTemplate);
            }
        }
        echo $this->view('main/v_main_frame.php', array(
            'content' => $content,
            'static' => $static,
            'end' => $end,
            '_forFrameCount' => $this->_forFrameCount,
            '_forFrame' => $this->_forFrame,
            'cur' => Cur::getAll(),
            'debugLog' => Debug::get(),
            'timeLoad' => $this->endTime,
            'refLogin' => $refLogin
        ),true);
        $this->_forFrame = null;
        $this->_forFrameCount++;
    }
}