Exemple #1
0
 public function __construct()
 {
     parent::__construct();
     $this->smarty->setTemplateDir(System_Settings::getSmarty_template());
     $this->smarty->setCompileDir(System_Settings::getSmarty_compile_dir());
     $this->smarty->setCacheDir(System_Settings::getSmarty_cached_dir());
     $this->smarty->debugging = System_Settings::getSmarty_debugging();
     $this->smarty->caching = System_Settings::getSmarty_caching();
     $this->smarty->cache_lifetime = System_Settings::getSmarty_cache_lifetime();
 }
Exemple #2
0
     error_reporting(E_ALL);
     ini_set('display_errors', true);
     ini_set('html_errors', true);
     ini_set('error_reporting', E_ALL); */
 // Определение префикса названий таблиц в БД
 PdoWrap::setEncoding(ENCODING);
 PdoWrap::setEncodingConnection(ENCODING_CONNECTION);
 PdoWrap::setPrefix($db_conf['db_table_prefix']);
 // Установка основных переменных класса
 Files::setDir(USERFILES);
 Files::setOrig(IMG_ORIGINAL);
 // Подключаем Smarty
 require_once DOC . 'vendors/smarty/Smarty.class.php';
 $smarty = new Smarty();
 System_Settings::setSmarty_template('.admin');
 $smarty->setTemplateDir(System_Settings::getSmarty_template());
 $smarty->setCompileDir(System_Settings::getSmarty_compile_dir());
 $smarty->setCacheDir(System_Settings::getSmarty_cached_dir());
 $smarty->debugging = System_Settings::getSmarty_debugging();
 $smarty->caching = false;
 $smarty->cache_lifetime = 0;
 //	Подключение функций.
 require_once DOC . 'functions/functions_list.php';
 // Подключение функций для щаблонов
 require_once DOC . 'functions/smarty.functions.php';
 $langs = array();
 $langs_array = array();
 //	Список языков.
 if (defined('MULTILANG') && MULTILANG == 1) {
     // Получаем список доступных языков
     $langs = get_langs();
Exemple #3
0
 function __construct(&$smarty, $preload_m = null, $conf = array(), $rights = array(), $localize = array())
 {
     self::setCurrentLang($conf['curlang']);
     self::setDefaultLang($conf['deflang']);
     self::setAString($conf['aStrings']);
     self::setLocalize($localize);
     if (is_array($conf) && count($conf) > 0) {
         foreach ($conf as $var => $value) {
             $this->setConf($var, $value);
         }
     }
     self::setFinalPath($this->getConf('final_path'));
     self::setLimit($this->getConf('limit'));
     //	Подключение данных для ремаппинга.
     $__remap = array();
     if (is_file(System_Settings::getPathRoot() . '/remap.php')) {
         require System_Settings::getPathRoot() . '/remap.php';
     }
     $show_page_text = 1;
     $current_lang = self::getCurrentLang();
     // Подключение файлов основного модуля
     include System_Settings::getPathRoot() . '/modules/pages/class.pages.php';
     include System_Settings::getPathRoot() . '/modules/pages/controller.php';
     // Выгрузка файла локализации
     $__lang = self::getLocalize();
     // Получаем информацию об корневой странице модуля
     $page = array();
     $bread_crumbs = array();
     $page_title = '';
     $tpl = 'index';
     self::setModuleAString(self::$aString);
     if (class_exists('Pages')) {
         // Объекст класса для работы с деревьями
         $base = new TreeTable(DOC, $current_lang, PREF);
         $pages = new Pages($base, $__lang);
         // Для показа статических страниц нужно разобрать URL
         $aStrings = self::getModuleAString();
         // Получение информации о корневой странице
         $page = $pages->showBasePage($aStrings);
         if (isset($page['type']) && $page['type'] == 1 && $page['tree_level'] > 0 && !preg_match('/\\.html$/i', $_SERVER['REDIRECT_URL'])) {
             $page = array();
         } elseif (isset($page['tree_level']) && $page['tree_level'] == 0 && count($aStrings) > 1) {
             $page = array();
         }
         if (isset($page['id'])) {
             // Получение хлебных крошек
             $bread_crumbs = $pages->getBreadCrumbsByID($page['id']);
             /*		Шаблон страницы.	*/
             $tpl = !isset($page['template']) || empty($page['template']) ? 'index' : is_file(System_Settings::getSmarty_template() . $page['template'] . '.tpl') ? $page['template'] : 'index2';
         }
     }
     if (count(self::$aString) > 1) {
         if (isset($__remap[self::$aString[1]])) {
             // Если Страница является модулем, то отьрасывыем остальную часть УРЛ
             // Разбор остальной части будет производиться в модуле
             $root_aString = array();
             $module_aString = array();
             $count_aString = count(self::$aString);
             for ($i = 0; $i < $count_aString; $i++) {
                 if ($i <= 1) {
                     $root_aString[] = self::$aString[$i];
                 } else {
                     $module_aString[] = self::$aString[$i];
                 }
             }
             if ($count_aString != count($root_aString)) {
                 $show_page_text = 0;
             }
             self::setAString($root_aString);
             self::setModuleAString($module_aString);
             $module_name = $__remap[self::$aString[1]]['module'];
         } elseif (isset($page['type']) && $page['type'] == 2) {
             $module_name = $page['alias'];
             // TODO: Проверить работу модулей
             // Проверяем является ли страница модулем
             if ($this->checkModule($module_name)) {
                 // Если Страница является модулем, то отьрасывыем остальную часть УРЛ
                 // Разбор остальной части будет производиться в модуле
                 $root_aString = array();
                 $module_aString = array();
                 $count_aString = count(self::$aString);
                 for ($i = 0; $i < $count_aString; $i++) {
                     if ($i <= 1) {
                         $root_aString[] = self::$aString[$i];
                     } else {
                         $module_aString[] = self::$aString[$i];
                     }
                 }
                 if ($count_aString != count($root_aString)) {
                     $show_page_text = 0;
                 }
                 self::setAString($root_aString);
                 self::setModuleAString($module_aString);
                 $module_name = self::$aString[1];
             } else {
                 $module_name = 'pages';
             }
         }
     }
     // Имя запрашиваемого пользователем модуля
     $modules = !empty($module_name) ? $module_name : 'pages';
     // Модули загружаемые до загрузки основного модуля
     if ($preload_m != null) {
         foreach ($preload_m as $key => $value) {
             $this->setRequestModule($key);
             $this->AddModule($key, $value);
         }
     }
     if ($modules != 'pages') {
         // Проверить существует ли запрошенный модуль
         if ($this->checkModule($modules)) {
             // Получение прав пользователей
             $query = 'CALL get_user_rights(:user_level)';
             $params = array(':user_level' => isset($_SESSION['siteuser']['group_id']) ? (int) $_SESSION['siteuser']['group_id'] : 0);
             $rights = PdoWrap::select($query, $params);
             $access = 1;
             foreach ($rights as $values) {
                 if ($modules == $values['folder'] && $values['read'] == 1) {
                     $access++;
                 }
             }
             $action = 'index';
             if ($access > 0) {
                 // Установить имя запрошенного модуля
                 $this->setRequestModule($modules);
                 // Проверить вызываемые дейтсвия для модуля
                 if ($this->checkAction($action)) {
                     // Установить имя запрошенного модуля
                     $this->setRequestAction($action);
                     if (isset($__remap[$this->getRequestModule()])) {
                         // Все параметры для вызова основного модуля готовы, вызываем модуль
                         $module = $__remap[$this->getRequestModule()]['module'];
                         if ($this->checkLang()) {
                             include System_Settings::getPathRoot() . '/modules/' . $module . '/langs/' . self::getCurrentLang() . '.lang.php';
                         }
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/class.' . $module . '.php';
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/controller.php';
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/index.action.php';
                     } else {
                         // Все параметры для вызова основного модуля готовы, вызываем модуль
                         if ($this->checkLang()) {
                             $__lang = '';
                             require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/langs/' . self::getCurrentLang() . '.lang.php';
                             self::setLocalize($__lang);
                         }
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/class.' . $this->getRequestModule() . '.php';
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/controller.php';
                         // и действие для данного модуля
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/' . self::getRequestAction() . '.action.php';
                         // Проверяем существование модульного шаблона
                         if (file_exists(System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/templates/' . $tpl . '.tpl')) {
                             $tpl = System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/templates/' . $tpl;
                         }
                     }
                     // В случае ошибки - вывести сообщение и остановить работу скрипта
                 } else {
                     require_once DOC . '/error404.php';
                 }
             } else {
                 echo 'access denied';
                 exit;
             }
         } else {
             require_once DOC . '/error404.php';
             exit;
         }
     } else {
         // Подключение управляющего файла модуля
         include System_Settings::getPathRoot() . '/modules/pages/index.action.php';
     }
     // Установка шаблона
     self::setTpl($tpl);
     // Получение заголовка
     $page_title = $pages->getPageTitle($page['head_title'], self::getPageNum(), $page['show_navigation']);
     // Выгрузка переменных в шаблон
     $smarty->assign(array('page' => $page, 'breadcrumbs' => $bread_crumbs, 'page_title' => $page_title, 'show_page_text' => $show_page_text));
 }
Exemple #4
0
        exit;
    }
} else {
    //  проверяем содержит ли страница компонент
    $component = components($page['text'], $page, $page['link'], $page_num);
    $page['text'] = $component['content'];
}
//	Получение информации о странице.
if (!is_array($page) or empty($page)) {
    //	Страница не найдена. Попытка ввода url вручную или поломались ключи у дерева (врятли).
    require_once DOC . 'error404.php';
    exit;
}
// получение родительской страницы
$parents = $pages->enumPath('pages', $page['id']);
$parent = $page;
for ($i = 0; $i < count($parents); $i++) {
    if ($parents[$i]['tree_level'] == 1) {
        $parent = $parents[$i];
    }
}
/*		Шаблон страницы.	*/
$tpl = !isset($page['template']) || empty($page['template']) ? 'index' : is_file(System_Settings::getSmarty_template() . $page['template'] . '.tpl') ? $page['template'] : 'index2';
// Выгрузка в AJAX JSON
if ((int) Text::get_get('AjaxShowPage') == 1) {
    $pages->getJsonWrap($page);
}
// Выгрузка переменных в шаблон
$smarty->assign(array('page' => $page, 'parent' => $parent, 'breadcrumbs' => $bread_crumbs, 'page_title' => $pages->getPageTitle($page['head_title'])));
// Шаблон для вывода статических страниц
self::setTpl($tpl);