Особенности перехода с Smarty 2 на Smarty 3 (mysmarty.class.php)

239
29 августа 2018, 23:00

Всем привет, меняю "движок" т.е. Smarty 2 на Smarty 3, в настройках скрипта(config.php) на PHP с использованием Smarty 2 есть:

require_once($config['basedir'].'/smarty/libs/Smarty.class.php');
require_once($config['basedir'].'/libraries/mysmarty.class.php');
...
STemplate::assign ...
STemplate::setCompileDir ...
STemplate::setTplDir ...

В index.php(главный в корне домена) есть:

STemplate::display('header.tpl');
STemplate::display('index.tpl');
STemplate::display('footer.tpl');

Smarty.class.php стандартный(все с комментариями), а в специальном файле(mysmarty.class.php) есть такое:

<?php
class STemplate {
   function STemplate() {
        global $Smarty;
        if (!isset($Smarty)) {
            $Smarty = new Smarty;
        }
    }
    function create() {
        global $Smarty;
        $Smarty = new Smarty();
        $Smarty->compile_check = true;
        $Smarty->debugging = false;
        $Smarty->template_dir = dirname(__FILE__) . "/../../themes";
        $Smarty->compile_dir  = dirname(__FILE__) . "/../../temporary";
        return true;
    }
    function setCompileDir($dir_name) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->compile_dir = $dir_name;
    }
    function setType($type) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->type = $type;
    }
    function assign($var, $value) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->assign($var, $value);
    }
    function setTplDir($dir_name = null) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        if (!$dir_name) {
            $Smarty->template_dir = dirname(__FILE__) . "/../../themes/default";
        } else {
            $Smarty->template_dir = $dir_name;
        }
    }
    function setModule($module) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->theme = $module;
        $Smarty->type  = "module";
    }
    function setTheme($theme) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->template_dir = dirname(__FILE__) . "/../../themes/" . $theme;
        $Smarty->compile_dir  = dirname(__FILE__) . "/../../temporary/" . $theme;
        $Smarty->theme        = $theme;
        $Smarty->type         = "theme";
    }
    function getTplDir() {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        return $Smarty->template_dir;
    }
    function display($filename) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->display($filename);
    }
    function fetch($filename) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        return $Smarty->fetch($filename);
    }
    function getVars() {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        return $Smarty->get_template_vars();
    }
}
?>

Вызов функций в файлах идет с STemplate:: ...

Вопрос, надо ли что-то менять в mysmarty.class.php при переходе с Smarty 2 на Smarty 3 (кроме файлов от разработчика)? P.S. foreach в файле шаблона проекта работает

READ ALSO
Symfony 4 Fos User Bundle

Symfony 4 Fos User Bundle

Сделал регистрацию на FosUserBundle Symfony 41 Создал отдельный контроллер и view, регистрация работает и доступна по ссылке site/register

245
Вывести php переменную в html которая в echo

Вывести php переменную в html которая в echo

Этот html код находиться в echo, как тут правильно вывеести переменную которая $result?

245
PHP REST API Авторизация для Android

PHP REST API Авторизация для Android

Какие есть подходы для реализации авторизации на стороне PHP из Android приложенияЯ не совсем понимаю серверную часть

230
Opencart 2.1 нету способа выбора доставки

Opencart 2.1 нету способа выбора доставки

Нужно добавить способы доставки в интернет магазине https://kalibritop/ при оформлении заказа

189