Example #1
0
 /**
  * @param waSystem $system
  * @param array $options
  * @return waSmarty3View
  */
 public function __construct(waSystem $system, $options = array())
 {
     $this->smarty = new Smarty();
     parent::__construct($system, $options);
     if (isset($options['auto_literal'])) {
         $this->smarty->auto_literal = $options['auto_literal'];
     }
     if (isset($options['left_delimiter'])) {
         $this->smarty->left_delimiter = $options['left_delimiter'];
     }
     if (isset($options['right_delimiter'])) {
         $this->smarty->right_delimiter = $options['right_delimiter'];
     }
     $this->smarty->setTemplateDir(isset($options['template_dir']) ? $options['template_dir'] : $system->getAppPath());
     $this->smarty->setCompileDir(isset($options['compile_dir']) ? $options['compile_dir'] : $system->getAppCachePath('templates/compiled/'));
     $this->smarty->setCacheDir($system->getAppCachePath('templates/cache/'));
     if (ini_get('safe_mode')) {
         $this->smarty->use_sub_dirs = false;
     } else {
         $this->smarty->use_sub_dirs = true;
     }
     // not use
     //$this->smarty->setCompileCheck(wa()->getConfig()->isDebug()?true:false);
     $this->smarty->addPluginsDir($system->getConfig()->getPath('system') . '/vendors/smarty-plugins');
     $this->smarty->loadFilter('pre', 'translate');
 }
Example #2
0
 /**
  * Renders a page.
  */
 public function render()
 {
     if ($this->trimWhiteSpace) {
         $this->smarty->loadFilter('output', 'trimwhitespace');
     }
     $this->smarty->display($this->page_template);
 }
Example #3
0
 /**
  * Инициализация хуков и префильтра Smarty
  */
 protected function _initTplHooks()
 {
     if ($this->aTplHooks or Config::Get('plugin.aceadminpanel.smarty.options.mark_template')) {
         if (!class_exists('DomFrag')) {
             ACE::FileInclude('plugin:aceadminpanel:lib/DomFrag.class.php');
         }
         if (class_exists('DomFrag')) {
             // Подключаем Smarty-плагин
             $this->oSmarty->loadFilter('pre', 'tplhook');
             $this->Assign('aTplHooks', $this->aTplHooks);
         }
     }
 }
Example #4
0
 /**
  * @return Smarty
  */
 private function _getSmarty()
 {
     if (!isset(self::$_smarty)) {
         self::$_smarty = new Smarty();
         self::$_smarty->setTemplateDir(DIR_ROOT);
         self::$_smarty->setCompileDir(CM_Bootloader::getInstance()->getDirTmp() . 'smarty/');
         self::$_smarty->_file_perms = 0666;
         self::$_smarty->_dir_perms = 0777;
         self::$_smarty->compile_check = CM_Bootloader::getInstance()->isDebug();
         self::$_smarty->caching = false;
         self::$_smarty->error_reporting = error_reporting();
     }
     $pluginDirs = array(SMARTY_PLUGINS_DIR);
     foreach ($this->getSite()->getModules() as $moduleName) {
         $pluginDirs[] = CM_Util::getModulePath($moduleName) . 'library/' . $moduleName . '/SmartyPlugins';
     }
     self::$_smarty->setPluginsDir($pluginDirs);
     self::$_smarty->loadFilter('pre', 'translate');
     return self::$_smarty;
 }
Example #5
0
 /**
  * Follows a route and produces a web page from it.
  */
 public function route()
 {
     $view = null;
     $exception = null;
     /* construct template engine */
     $smarty = new Smarty();
     $smarty->caching = true;
     $smarty->cache_lifetime = 120;
     $smarty->setTemplateDir(__DIR__ . '/layouts');
     $smarty->setCompileDir(__DIR__ . '/../../smarty/compiled_templates');
     $smarty->setCacheDir(__DIR__ . '/../../smarty/cache');
     switch ($this->path) {
         case 'index':
             $view = new IndexView($smarty);
             break;
         case 'statuses':
             if (!$this->isLoggedIn()) {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to view the circuit board status list.');
                 break;
             }
             $view = new StatusesView($smarty);
             $model = new StatusesModel($view);
             $controller = new StatusesController($model);
             try {
                 $controller->fetchStatuses();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'updates':
             if (!$this->isLoggedIn() || $_SESSION['rank'] != 'ADMIN') {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to an administrator\'s account to poll the service for updates.');
                 break;
             }
             $view = new UpdatesView($smarty);
             $model = new UpdatesModel($view);
             $controller = new UpdatesController($model);
             try {
                 $controller->fetchUpdates();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'register':
             $view = new RegisterView($smarty);
             $model = new RegisterModel($view);
             $controller = new RegisterController($model);
             try {
                 $controller->checkValidRegistration();
                 $username = $model->getUsername();
                 if ($model->isRegistered()) {
                     $view = new RegisteredView($smarty);
                     $model = new RegisteredModel($view);
                     $model->setUsername($username);
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'login':
             $view = new LoginView($smarty);
             $model = new LoginModel($view);
             $controller = new LoginController($model);
             try {
                 $controller->checkValidLogin();
                 if ($model->isLoggedIn()) {
                     // successful login
                     $view = new LoggedInView($smarty);
                     $model = new LoggedInModel($view);
                     $model->setUsername($_SESSION['username']);
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'logout':
             $view = new LogoutView($smarty);
             $model = new LogoutModel($view, $this->isLoggedIn());
             $controller = new LogoutController($model);
             try {
                 $controller->logout();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'debug':
             if (!$this->isLoggedIn() || $_SESSION['rank'] != 'ADMIN') {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to an administrator\'s account view the debug page.');
                 break;
             }
             $view = new DebugView($smarty);
             break;
             /* any unhandled action return them to the welcome screen */
         /* any unhandled action return them to the welcome screen */
         default:
             $this->path = 'index';
             $view = new IndexView($smarty);
             break;
     }
     if ($exception !== null) {
         $view = new ErrorView($smarty);
         $model = new ErrorModel($view);
         $model->setMessage($exception->getMessage());
     }
     if (!DEBUG_MODE) {
         /* optimize the output by removing whitespace */
         $smarty->loadFilter("output", "trimwhitespace");
     }
     /* apply view specific information to the template engine */
     $view->applyTemplate($this->isLoggedIn());
     /* display generated template */
     $smarty->display($view->getId() . '.tpl');
 }
Example #6
0
 /**
  * Returns an instance of the Smarty Template Engine
  * 
  * @static 
  * @return Smarty
  */
 static function getInstance()
 {
     static $instance = null;
     if (null == $instance) {
         define('SMARTY_RESOURCE_CHAR_SET', LANG_CHARSET_CODE);
         require DEVBLOCKS_PATH . 'libs/smarty/Smarty.class.php';
         $instance = new Smarty();
         $instance->template_dir = APP_PATH . '/templates';
         $instance->compile_dir = APP_TEMP_PATH . '/templates_c';
         $instance->cache_dir = APP_TEMP_PATH . '/cache';
         $instance->use_sub_dirs = false;
         $instance->caching = 0;
         $instance->cache_lifetime = 0;
         $instance->compile_check = defined('DEVELOPMENT_MODE') && DEVELOPMENT_MODE ? true : false;
         // Auto-escape HTML output
         $instance->loadFilter('variable', 'htmlspecialchars');
         //$instance->register->variableFilter(array('_DevblocksTemplateManager','variable_filter_esc'));
         // Devblocks plugins
         $instance->register->block('devblocks_url', array('_DevblocksTemplateManager', 'block_devblocks_url'));
         $instance->register->modifier('devblocks_date', array('_DevblocksTemplateManager', 'modifier_devblocks_date'));
         $instance->register->modifier('devblocks_hyperlinks', array('_DevblocksTemplateManager', 'modifier_devblocks_hyperlinks'));
         $instance->register->modifier('devblocks_hideemailquotes', array('_DevblocksTemplateManager', 'modifier_devblocks_hide_email_quotes'));
         $instance->register->modifier('devblocks_prettytime', array('_DevblocksTemplateManager', 'modifier_devblocks_prettytime'));
         $instance->register->modifier('devblocks_prettybytes', array('_DevblocksTemplateManager', 'modifier_devblocks_prettybytes'));
         $instance->register->modifier('devblocks_translate', array('_DevblocksTemplateManager', 'modifier_devblocks_translate'));
         $instance->register->resource('devblocks', array(array('_DevblocksSmartyTemplateResource', 'get_template'), array('_DevblocksSmartyTemplateResource', 'get_timestamp'), array('_DevblocksSmartyTemplateResource', 'get_secure'), array('_DevblocksSmartyTemplateResource', 'get_trusted')));
     }
     return $instance;
 }
Example #7
0
    $token = $_SESSION['token'];
}
// initialize smarty
define('SMARTY_DIR', str_replace("\\", "/", getcwd()) . '/includes/Smarty-3.1.15/libs/');
require_once SMARTY_DIR . 'Smarty.class.php';
require_once SMARTY_DIR . 'SmartyPaginate.class.php';
function escFilter($content)
{
    return htmlspecialchars($content, ENT_QUOTES, 'cp1251');
}
$smarty = new Smarty();
$smarty->setCacheDir($global_temporary_directory . '/');
$smarty->setCompileDir($global_temporary_directory . '/');
$smarty->setTemplateDir('includes/templates/');
$smarty->registerFilter('variable', 'escFilter');
$smarty->loadFilter('output', 'trimwhitespace');
$smarty->caching = false;
$smarty->assign('show_help_to_users', $show_help_to_users);
$smarty->assign('show_http_to_users', $show_http_to_users);
$smarty->assign('show_logons_to_users', $show_logons_to_users);
$smarty->assign('show_other_to_users', $show_other_to_users);
$smarty->assign('enable_http_mode', $enable_http_mode);
$smarty->assign('disable_ip_logger', $disable_ip_logger);
$smarty->assign('enable_email_mode', $enable_email_mode);
$smarty->assign('show_email_to_users', $show_email_to_users);
$smarty->assign('show_domains', $show_domains);
$smarty->assign('show_domains_to_users', $show_domains_to_users);
$smarty->assign('token', $token);
// initialize common used variables
$self_file = $_SERVER['SCRIPT_NAME'];
$authentication_login = trim(assign($_REQUEST['login']));
            $site_trail->add($name['products_name'], xos_href_link(FILENAME_PRODUCT_INFO, 'm=' . $_GET['m'] . '&p=' . $_GET['p']));
        } else {
            $site_trail->add($name['products_name'], xos_href_link(FILENAME_PRODUCT_INFO, 'c=' . $cPath . '&p=' . $_GET['p']));
        }
    }
}
// initialize the message stack for output messages
require DIR_WS_CLASSES . 'message_stack.php';
$messageStack = new messageStack();
require DIR_WS_CLASSES . 'template_integration.php';
$templateIntegration = new templateIntegration();
$templateIntegration->buildBlocks();
// check for active product categories in Level 0
$check_is_shop_query = xos_db_query("select count(*) as count from " . TABLE_CATEGORIES_OR_PAGES . " where parent_id = '0' and is_page = 'false' and categories_or_pages_status = '1'");
$check_is_shop = xos_db_fetch_array($check_is_shop_query);
$is_shop = false;
if ($check_is_shop['count'] > 0) {
    $is_shop = true;
}
// set which precautions should be checked
define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
define('WARN_SESSION_AUTO_START', 'true');
define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');
$smarty->caching = 0;
$smarty->cache_lifetime = -1;
$smarty->compile_check = constant(COMPILE_CHECK);
$smarty->configLoad('languages/' . $_SESSION['language'] . '.conf', 'general');
$smarty->configLoad('templates/' . SELECTED_TPL . '/includes/configuration/config.conf');
$smarty->loadFilter('output', 'set_internal_link');
//  $smarty->loadFilter('output','trimwhitespace');
$smarty->assign(array('nl' => "\n", 'is_shop' => $is_shop, 'page_info' => $page_info, 'request_type' => $request_type, 'link_filename_popup_content_6' => STATUS_POPUP_CONTENT_6 == '1' ? xos_href_link(FILENAME_POPUP_CONTENT, 'co=6', $request_type) : '', 'end_tags' => DISPLAY_PAGE_PARSE_TIME == 'true' && STORE_PAGE_PARSE_TIME == 'true' ? $templateIntegration->getBlocks('footer_scripts') : $templateIntegration->getBlocks('footer_scripts') . "</body>\n</html>", 'date_format_long' => xos_date_format(DATE_FORMAT_LONG), 'languages_path' => DIR_WS_CATALOG . DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/' . $_SESSION['language'] . '/', 'buttons_path' => DIR_WS_CATALOG . DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/' . $_SESSION['language'] . '/buttons/', 'images_path' => DIR_WS_CATALOG . DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/'));