示例#1
0
 public function init()
 {
     parent::init();
     global $smarty;
     require_once _PS_MODULE_DIR_ . 'belvg_staticblocks/classes/BelvgStaticBlocks.php';
     smartyRegisterFunction($smarty, 'function', 'getBelvgBlockContent', array('BelvgStaticBlocks', 'getBlockContent'));
 }
示例#2
0
 public function __construct()
 {
     parent::__construct();
     $this->context = Context::getContext();
     include_once $this->module->getLocalPath() . 'LoyaltyModule.php';
     include_once $this->module->getLocalPath() . 'LoyaltyStateModule.php';
     // Declare smarty function to render pagination link
     smartyRegisterFunction($this->context->smarty, 'function', 'summarypaginationlink', array('LoyaltyDefaultModuleFrontController', 'getSummaryPaginationLink'));
 }
 public function init()
 {
     require_once _PS_MODULE_DIR_ . 'belvg_staticblocks/classes/BelvgStaticBlocks.php';
     if (!self::$initialized) {
         global $smarty;
         smartyRegisterFunction($smarty, 'function', 'getBelvgBlockContent', array('BelvgStaticBlocks', 'getBlockContent'));
         smartyRegisterFunction($smarty, 'function', 'getBelvgBlockTitle', array('BelvgStaticBlocks', 'getBlockTitle'));
     }
     parent::init();
 }
示例#4
0
 /**
  *	module hook Home
  *
  */
 public function hookdisplayHome($params)
 {
     $callback = array(&$this, 'smarty_function_get_month_traduction');
     $callback2 = array(&$this, 'smarty_function_get_day_traduction');
     $callback3 = array(&$this, 'smarty_function_get_img');
     smartyRegisterFunction($this->context->smarty, 'function', 'smarty_function_get_month_traduction', $callback);
     smartyRegisterFunction($this->context->smarty, 'function', 'smarty_function_get_day_traduction', $callback2);
     smartyRegisterFunction($this->context->smarty, 'function', 'smarty_function_get_img', $callback3);
     $weather = json_decode(file_get_contents('http://www.myweather2.com/developer/weather.ashx?' . Configuration::get('RW_RESORT_CONFIG_VALUE') . '&output=json'));
     $this->context->smarty->assign('stat', $weather);
     return $this->display(__FILE__, 'resortweather.tpl');
 }
示例#5
0
 public function getContent()
 {
     $this->context->controller->addJQueryUI('ui.datepicker');
     $this->context->controller->addJQueryUI('ui.slider');
     $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/timepicker/jquery-ui-timepicker-addon.js');
     $this->context->controller->addCSS(_PS_JS_DIR_ . 'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css');
     smartyRegisterFunction($this->context->smarty, 'function', 'displayUSPhoneNumber', array('Zingaya', 'displayUSPhoneNumberSmarty'));
     smartyRegisterFunction($this->context->smarty, 'function', 'displayUSHour', array('Zingaya', 'displayUSHoursSmarty'));
     $this->_processPost();
     $this->context->smarty->assign($this->_retrieveInformation());
     $this->context->smarty->assign(array('zingaya_errors' => $this->_zingayaErrors, 'zingaya_warning' => $this->_zingayaWarning, 'zingaya_confirmation' => $this->_confirmation, 'zingaya_username' => Configuration::get('ZINGAYA_USERNAME'), 'zingaya_user_id' => Configuration::get('ZINGAYA_USER_ID'), 'zingaya_api_password' => Configuration::get('ZINGAYA_PASSWORD'), 'zingaya_token' => Configuration::get('ZINGAYA_TOKEN'), 'zingaya_base_link' => 'index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'zingaya_tracking' => 'http://www.prestashop.com/modules/zingaya.png?url_site=' . Tools::safeOutput($_SERVER['SERVER_NAME']) . '&id_lang=' . (int) $this->context->cookie->id_lang));
     return $this->display(__FILE__, 'zingaya-admin.tpl');
 }
示例#6
0
文件: PDF.php 项目: M03G/PrestaShop
 /**
  * @param $objects
  * @param $template
  * @param $smarty
  * @param string $orientation
  */
 public function __construct($objects, $template, $smarty, $orientation = 'P')
 {
     $this->pdf_renderer = new PDFGenerator((bool) Configuration::get('PS_PDF_USE_CACHE'), $orientation);
     $this->template = $template;
     /*
      * We need a Smarty instance that does NOT escape HTML.
      * Since in BO Smarty does not autoescape
      * and in FO Smarty does autoescape, we use
      * a new Smarty of which we're sure it does not escape
      * the HTML.
      */
     $this->smarty = clone $smarty;
     $this->smarty->escape_html = false;
     /* For PDF we restore some functions from Smarty
      * they've been removed in PrestaShop 1.7 so
      * new themes don't use them. Although PDF haven't been
      * reworked so every PDF controller must extend this class.
      */
     smartyRegisterFunction($this->smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
     smartyRegisterFunction($this->smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
     smartyRegisterFunction($this->smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
     smartyRegisterFunction($this->smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
     smartyRegisterFunction($this->smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
     smartyRegisterFunction($this->smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
     // used twice
     smartyRegisterFunction($this->smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
     smartyRegisterFunction($this->smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
     smartyRegisterFunction($this->smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
     $this->objects = $objects;
     if (!$objects instanceof Iterator && !is_array($objects)) {
         $this->objects = array($objects);
     }
     if (count($this->objects) > 1) {
         // when bulk mode only
         $this->send_bulk_flag = true;
     }
 }
$smarty->unregisterPlugin('function', 'convertPrice');
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('PP', 'smartyConvertPrice'));
$smarty->unregisterPlugin('function', 'convertPriceWithCurrency');
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('PP', 'smartyConvertPrice'));
smartyRegisterFunction($smarty, 'function', 'ppAssign', array('PP', 'smartyPPAssign'));
smartyRegisterFunction($smarty, 'function', 'formatQty', array('PP', 'smartyFormatQty'));
smartyRegisterFunction($smarty, 'function', 'convertQty', array('PP', 'smartyConvertQty'));
smartyRegisterFunction($smarty, 'function', 'displayQty', array('PP', 'smartyDisplayQty'));
$smarty->unregisterPlugin('function', 'displayPrice');
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('PP', 'smartyDisplayPrice'));
/* $smarty->unregisterPlugin('function', 'displayWtPrice'); */
/* smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('PP', 'smartyDisplayPrice')); */
$smarty->unregisterPlugin('function', 'displayWtPriceWithCurrency');
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('PP', 'smartyDisplayPrice'));
smartyRegisterFunction($smarty, 'function', 'displayProductName', array('PP', 'smartyDisplayProductName'));
smartyRegisterFunction($smarty, 'function', 'smartpriceText', 'smartyFunctionSmartpriceText');
function smartyModifierIcp($product, $id = false, $mode = 'css')
{
    $icp = 'icp-' . ($id === false ? (int) $product : (int) $product[$id]);
    if ($mode == 'css' && ($css = smartyModifierPP($product, 'css', 'left'))) {
        $icp .= $css;
    }
    return $icp;
}
function smartyModifierPPSafeoutput($string, $type = null)
{
    if ($type === null) {
        $type = 'html';
    }
    switch ($type) {
        case 'html':
smartyRegisterFunction($smarty, 'modifier', 'json_decode', array('Tools', 'jsonDecode'));
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
// used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
smartyRegisterFunction($smarty, 'function', 'addJsDef', array('Media', 'addJsDef'));
smartyRegisterFunction($smarty, 'block', 'addJsDefL', array('Media', 'addJsDefL'));
smartyRegisterFunction($smarty, 'modifier', 'boolval', array('Tools', 'boolval'));
function smartyDieObject($params, &$smarty)
{
    return Tools::d($params['var']);
}
function smartyShowObject($params, &$smarty)
{
    return Tools::p($params['var']);
}
function smartyMaxWords($params, &$smarty)
{
    Tools::displayAsDeprecated();
    $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8'));
    $words = explode(' ', $params['s']);
    foreach ($words as &$word) {
        if (Tools::strlen($word) > $params['n']) {
// unused
smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject');
// unused
smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate');
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'productPrice', array('Product', 'productPrice'));
// unused
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithoutDisplay', array('Product', 'productPriceWithoutDisplay'));
// unused
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'convertAndShow', array('Product', 'convertAndShow'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
// used twice
function smartyTranslate($params, &$smarty)
{
    /*
     * Warning in Smarty-v2 : 2 lines have been added to the Smarty class.
     * "public $currentTemplate = null;" into the class itself
     * "$this->currentTemplate = Tools::substr(basename($resource_name), 0, -4);" into the "fetch" method
     * Notice : before 1.4.2.5, this modification was in the display method
     *
     * In Smarty-v3 : No modifications, using the existing var $this->smarty->_current_file instead
     */
    global $_LANG, $_MODULES, $cookie, $_MODULE;
    if (!isset($params['js'])) {
        $params['js'] = 0;
    }
示例#10
0
// Debug only
smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject');
// Debug only
smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false);
smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook');
smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
// used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
function smartyDieObject($params, &$smarty)
{
    return Tools::d($params['var']);
}
function smartyShowObject($params, &$smarty)
{
    return Tools::p($params['var']);
}
function smartyMaxWords($params, &$smarty)
{
    Tools::displayAsDeprecated();
    $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8'));
    $words = explode(' ', $params['s']);
    foreach ($words as &$word) {
        if (Tools::strlen($word) > $params['n']) {
smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook');
smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');
smartyRegisterFunction($smarty, 'modifier', 'json_encode', array('Tools', 'jsonEncode'));
smartyRegisterFunction($smarty, 'modifier', 'json_decode', array('Tools', 'jsonDecode'));
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
// used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
function smartyDieObject($params, &$smarty)
{
    return Tools::d($params['var']);
}
function smartyShowObject($params, &$smarty)
{
    return Tools::p($params['var']);
}
function smartyMaxWords($params, &$smarty)
{
    Tools::displayAsDeprecated();
    $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8'));
    $words = explode(' ', $params['s']);
    foreach ($words as &$word) {
        if (Tools::strlen($word) > $params['n']) {
示例#12
0
 */
global $smarty;
$smarty->setTemplateDir(array(_PS_THEME_DIR_ . 'templates'));
$smarty->addPluginsDir(array(_PS_THEME_DIR_ . 'plugins'));
$smarty->registerResource('module', new SmartyResourceModule(array('theme' => _PS_THEME_DIR_ . 'modules/', 'modules' => _PS_MODULE_DIR_)));
if (Configuration::get('PS_HTML_THEME_COMPRESSION')) {
    $smarty->registerFilter('output', 'smartyMinifyHTML');
}
if (Configuration::get('PS_JS_HTML_THEME_COMPRESSION')) {
    $smarty->registerFilter('output', 'smartyPackJSinHTML');
}
$smarty->escape_html = true;
smartyRegisterFunction($smarty, 'function', 'widget', 'smartyWidget');
smartyRegisterFunction($smarty, 'function', 'render', 'smartyRender');
smartyRegisterFunction($smarty, 'function', 'form_field', 'smartyFormField');
smartyRegisterFunction($smarty, 'block', 'widget_block', 'smartyWidgetBlock');
function withWidget($params, callable $cb)
{
    if (!isset($params['name'])) {
        throw new Exception('Smarty helper `render_widget` expects at least the `name` parameter.');
    }
    $moduleName = $params['name'];
    unset($params['name']);
    $moduleInstance = Module::getInstanceByName($moduleName);
    if (!$moduleInstance instanceof PrestaShop\PrestaShop\Core\Module\WidgetInterface) {
        throw new Exception(sprintf('Module `%1$s` is not a WidgetInterface.', $moduleName));
    }
    return $cb($moduleInstance, $params);
}
function smartyWidget($params, &$smarty)
{
示例#13
0
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
// used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
smartyRegisterFunction($smarty, 'function', 'addJsDef', array('Media', 'addJsDef'));
smartyRegisterFunction($smarty, 'block', 'addJsDefL', array('Media', 'addJsDefL'));
smartyRegisterFunction($smarty, 'modifier', 'boolval', array('Tools', 'boolval'));
smartyRegisterFunction($smarty, 'modifier', 'cleanHtml', 'smartyCleanHtml');
function smartyDieObject($params, &$smarty)
{
    return Tools::d($params['var']);
}
function smartyShowObject($params, &$smarty)
{
    return Tools::p($params['var']);
}
function smartyMaxWords($params, &$smarty)
{
    Tools::displayAsDeprecated();
    $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8'));
    $words = explode(' ', $params['s']);
    foreach ($words as &$word) {
        if (Tools::strlen($word) > $params['n']) {
示例#14
0
if (Configuration::get('PS_JS_HTML_THEME_COMPRESSION'))
	$smarty->registerFilter('output', 'smartyPackJSinHTML');
*/
smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate');
smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer'));
smartyRegisterFunction($smarty, 'function', 't', 'smartyTruncate');
// unused
smartyRegisterFunction($smarty, 'function', 'm', 'smartyMaxWords');
// unused
smartyRegisterFunction($smarty, 'function', 'p', 'smartyShowObject');
// Debug only
smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject');
// Debug only
smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate');
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', 'displayPriceSmarty');
//smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice')); // used twice
function smartyTranslate($params, &$smarty)
{
    global $_LANG, $cookie;
    $string = str_replace('\'', '\\\'', $params['s']);
    $key = '';
    $filename = (!isset($smarty->compiler_object) or !is_object($smarty->compiler_object->template)) ? $smarty->template_filepath : $smarty->compiler_object->template->getTemplateFilepath();
    $pref_key = Tools::substr(basename($filename), 0, -4) . '_' . $string;
    $key = $string;
    $lang_array = $_LANG;
    if (is_array($lang_array) and key_exists($pref_key, $lang_array)) {
        $msg = $lang_array[$pref_key];
    } else {
        if (is_array($lang_array) and key_exists($key, $lang_array)) {
            $msg = $lang_array[$key];
 public static function preInit(&$metadata = array())
 {
     Configuration::set('PS_CANONICAL_REDIRECT', 0);
     // language
     if (isset($metadata['X-LANGUAGE'])) {
         $_GET['isolang'] = $metadata['X-LANGUAGE'];
     }
     // currency
     if (isset($metadata['X-CURRENCY'])) {
         $_POST['SubmitCurrency'] = 1;
         $_POST['id_currency'] = Currency::getIdByIsoCode($metadata['X-CURRENCY']);
     }
     // register a new translation smarty function
     global $smarty;
     if (function_exists('smartyRegisterFunction')) {
         smartyRegisterFunction($smarty, 'function', 'l2', 'smartyTranslate2');
     } else {
         $smarty->register_function('l2', 'smartyTranslate2');
     }
     // call the override function if found
     if (method_exists('CartAPI_Handlers_Override_Helpers', 'preInit')) {
         CartAPI_Handlers_Override_Helpers::preInit($metadata);
     }
 }
<?php

smartyRegisterFunction(Context::getContext()->smarty, 'modifier', 'text', 'smartyText');
smartyRegisterFunction(Context::getContext()->smarty, 'modifier', 'sanitize', 'smartySanitize');
function smartyText($data)
{
    // Prevent xss injection.
    if (Validate::isCleanHtml($data)) {
        return stripslashes(preg_replace('/\\v+|\\\\[rn]/', '<br/>', $data));
    }
    return '';
}
function smartySanitize($data)
{
    return htmlentities($data);
}
function smartyRegisterFunction($smarty, $type, $function, $params, $lazy = true)
{
    if (!in_array($type, array('function', 'modifier', 'block'))) {
        return false;
    }
    // lazy is better if the function is not called on every page
    if ($lazy) {
        $lazy_register = SmartyLazyRegister::getInstance();
        $lazy_register->register($params);
        if (is_array($params)) {
            $params = $params[1];
        }
        // SmartyLazyRegister allows to only load external class when they are needed
        $smarty->registerPlugin($type, $function, array($lazy_register, $params));
    } else {
示例#17
0
<?php

define('_TM_SMARTY_DIR_', _TM_TOOLS_DIR . 'smarty/');
require_once _TM_SMARTY_DIR_ . 'Smarty.class.php';
global $smarty;
$smarty = new Smarty();
$smarty->template_dir = _TM_THEMES_DIR;
$smarty->compile_dir = _TM_SMARTY_DIR_ . 'compile';
$smarty->cache_dir = _TM_SMARTY_DIR_ . 'cache';
$smarty->caching = false;
$smarty->compile_check = true;
$smarty->debugging = false;
spl_autoload_register("__autoload");
$link = new Link();
$smarty->assign($_tmconfig);
$smarty->assign(array('link' => $link, 'logged' => $cookie->logged, 'shop_name' => Configuration::get('TM_SHOP_NAME')));
if ($cookie->logged) {
    $smarty->assign(array('user_email' => $cookie->email, 'exit' => $link->getPage('LoginView', false, array('mylogout' => 'true')), 'logged' => $cookie->logged));
}
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'function', 'hookBlock', array('Module', 'hookBlock'));
function smartyRegisterFunction($smarty, $type, $function, $params)
{
    if (!in_array($type, array('function', 'modifier'))) {
        return false;
    }
    $smarty->registerPlugin($type, $function, $params);
}
示例#18
0
    }
}
smartyRegisterFunction($smarty, 'modifier', 'escape', 'smartyEscape');
smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate');
smartyRegisterFunction($smarty, 'function', 'dump', 'smartyDump');
// Debug only
smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false);
smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook');
smartyRegisterFunction($smarty, 'modifier', 'json_encode', array('Tools', 'jsonEncode'));
smartyRegisterFunction($smarty, 'modifier', 'json_decode', array('Tools', 'jsonDecode'));
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'modifier', 'boolval', array('Tools', 'boolval'));
smartyRegisterFunction($smarty, 'modifier', 'cleanHtml', 'smartyCleanHtml');
smartyRegisterFunction($smarty, 'modifier', 'classname', 'smartyClassname');
smartyRegisterFunction($smarty, 'modifier', 'classnames', 'smartyClassnames');
smartyRegisterFunction($smarty, 'function', 'url', array('Link', 'getUrlSmarty'));
function smartyDump($params, &$smarty)
{
    return Tools::dump($params['var']);
}
function smarty_modifier_htmlentitiesUTF8($string)
{
    return Tools::htmlentitiesUTF8($string);
}
function smartyMinifyHTML($tpl_output, &$smarty)
{
    $context = Context::getContext();
    if (isset($context->controller) && in_array($context->controller->php_self, array('pdf-invoice', 'pdf-order-return', 'pdf-order-slip'))) {
        return $tpl_output;
    }
    $tpl_output = Media::minifyHTML($tpl_output);
/* unused */
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'productPrice', array('Product', 'productPrice'));
/* unused */
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithoutDisplay', array('Product', 'productPriceWithoutDisplay'));
/* unused */
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
/* used twice */
if (_PS_MODE_DEV_) {
    smartyRegisterFunction($smarty, 'function', 'p', 'smartyShowObject');
    smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject');
}
function smartyTranslate($params, &$smarty)
{
    /*
     * Warning in Smarty-v2 : 2 lines have been added to the Smarty class.
     * "public $currentTemplate = null;" into the class itself
     * "$this->currentTemplate = Tools::substr(basename($resource_name), 0, -4);" into the "fetch" method
     * Notice : before 1.4.2.5, this modification was in the display method
     *
     * In Smarty-v3 : No modifications, using the existing var $smarty->template_resource instead
     */
    global $_LANG;
    if (!isset($params['js'])) {
        $params['js'] = 0;
    }
示例#20
0
$smarty->compile_check = true;
smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice'));
// used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
smartyRegisterFunction($smarty, 'function', 'addJsDef', array('Media', 'addJsDef'));
smartyRegisterFunction($smarty, 'block', 'addJsDefL', array('Media', 'addJsDefL'));
smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer'));
function toolsConvertPrice($params, &$smarty)
{
    return Tools::convertPrice($params['price'], Context::getContext()->currency);
}
function smartyTranslate($params, &$smarty)
{
    $htmlentities = !isset($params['js']);
    $pdf = isset($params['pdf']);
    $addslashes = isset($params['slashes']) || isset($params['js']);
    $sprintf = isset($params['sprintf']) ? $params['sprintf'] : array();
    if (!empty($params['d'])) {
        if (isset($params['tags'])) {
            $backTrace = debug_backtrace();
            $errorMessage = sprintf('Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().', $params['s'], $backTrace[0]['args'][1]->template_resource);
            if (_PS_MODE_DEV_) {