/** * Init template engine * * @return boolean always true */ function fn_init_templater() { if (defined('TEMPLATER_STARTED')) { return true; } require_once DIR_CORE . 'class.templater.php'; // // Template objects for processing html templates // $view = new Templater(); $view_mail = new Templater(); fn_set_hook('init_templater', $view, $view_mail); $view->register_prefilter(array(&$view, 'prefilter_hook')); $view_mail->register_prefilter(array(&$view_mail, 'prefilter_hook')); if (AREA == 'A' && !empty($_SESSION['auth']['user_id'])) { $view->register_prefilter(array(&$view, 'prefilter_form_tooltip')); } if (Registry::get('settings.customization_mode') == 'Y' && AREA == 'C') { $view->register_prefilter(array(&$view, 'prefilter_template_wrapper')); $view->register_outputfilter(array(&$view, 'outputfilter_template_ids')); $view->customization = true; } else { // Inline prefilter if (Registry::get('config.tweaks.inline_compilation') == true) { $view->register_prefilter(array(&$view, 'prefilter_inline')); } } if (Registry::get('config.tweaks.anti_csfr') == true) { $view->register_prefilter(array(&$view, 'prefilter_security_hash')); } // Output bufferring postfilter $view->register_prefilter(array(&$view, 'prefilter_output_buffering')); // Translation postfilter $view->register_postfilter(array(&$view, 'postfilter_translation')); if (Registry::get('settings.translation_mode') == 'Y') { $view->register_outputfilter(array(&$view, 'outputfilter_translate_wrapper')); } // // Store all compiled templates to the single directory // $view->use_sub_dirs = false; $view->compile_check = Registry::get('config.tweaks.check_templates'); if (Registry::get('settings.General.debugging_console') == 'Y') { if (empty($_SESSION['debugging_console']) && !empty($_SESSION['auth']['user_id'])) { $user_type = db_get_field("SELECT user_type FROM ?:users WHERE user_id = ?i", $_SESSION['auth']['user_id']); if ($user_type == 'A') { $_SESSION['debugging_console'] = true; } } if (isset($_SESSION['debugging_console']) && $_SESSION['debugging_console'] == true) { error_reporting(0); $view->debugging = true; } } $skin_name = Registry::get('config.skin_name'); $view->template_dir = DIR_SKINS . $skin_name . '/' . AREA_NAME; $view->config_dir = DIR_SKINS . $skin_name . '/' . AREA_NAME; $view->secure_dir = DIR_SKINS . $skin_name . '/' . AREA_NAME; $view->assign('images_dir', Registry::get('config.current_path') . "/skins/{$skin_name}/" . AREA_NAME . "/images"); $view->compile_dir = DIR_COMPILED . AREA_NAME . (defined('SKINS_PANEL') ? $skin_name : ''); $view->cache_dir = DIR_CACHE; $view->assign('skin_area', AREA_NAME); // Get manifest $manifest = fn_get_manifest(AREA_NAME); $view->assign('manifest', $manifest); // Mail templates should be taken from the customer skin if (AREA != 'C') { $manifest = fn_get_manifest('customer'); } $view_mail->assign('manifest', $manifest); $view_mail->template_dir = DIR_SKINS . Registry::get('settings.skin_name_customer') . '/mail'; $view_mail->config_dir = DIR_SKINS . Registry::get('settings.skin_name_customer') . '/mail'; $view_mail->secure_dir = DIR_SKINS . Registry::get('settings.skin_name_customer') . '/mail'; $view_mail->assign('images_dir', Registry::get('config.current_path') . '/skins/' . Registry::get('settings.skin_name_customer') . '/mail/images'); $view_mail->compile_dir = DIR_COMPILED . 'mail'; $view_mail->assign('skin_area', 'mail'); if (!is_dir($view->compile_dir)) { fn_mkdir($view->compile_dir); } if (!is_dir($view->cache_dir)) { fn_mkdir($view->cache_dir); } if (!is_dir($view_mail->compile_dir)) { fn_mkdir($view_mail->compile_dir); } if (!is_writable($view->compile_dir) || !is_dir($view->compile_dir)) { fn_error(debug_backtrace(), "Can't write template cache in the directory: <b>" . $view->compile_dir . '</b>.<br>Please check if it exists, and has writable permissions.', false); } $view->assign('ldelim', '{'); $view->assign('rdelim', '}'); $avail_languages = array(); foreach (Registry::get('languages') as $k => $v) { if ($v['status'] == 'D') { continue; } $avail_languages[$k] = $v; } $view->assign('languages', $avail_languages); $view->setLanguage(CART_LANGUAGE); $view_mail->setLanguage(CART_LANGUAGE); $view->assign('localizations', fn_get_localizations(CART_LANGUAGE, true)); if (defined('CART_LOCALIZATION')) { $view->assign('localization', fn_get_localization_data(CART_LOCALIZATION)); } $view->assign('currencies', Registry::get('currencies'), false); $view->assign('primary_currency', CART_PRIMARY_CURRENCY, false); $view->assign('secondary_currency', CART_SECONDARY_CURRENCY, false); $view_mail->assign('currencies', Registry::get('currencies'), false); $view_mail->assign('primary_currency', CART_PRIMARY_CURRENCY, false); $view_mail->assign('secondary_currency', CART_SECONDARY_CURRENCY, false); $view->assign('s_companies', Registry::get('s_companies'), false); $view->assign('s_company', defined('COMPANY_ID') ? COMPANY_ID : 'all', false); $view_mail->assign('s_companies', Registry::get('s_companies'), false); $view_mail->assign('s_company', defined('COMPANY_ID') ? COMPANY_ID : 'all', false); Registry::set('view', $view); Registry::set('view_mail', $view_mail); define('TEMPLATER_STARTED', true); return true; }
return array(CONTROLLER_STATUS_NO_PAGE); } Tygh::$app['view']->assign('localization', $localizaton); Tygh::$app['view']->assign('localization_countries', array_diff(fn_get_simple_countries(), $localizaton['countries'])); Tygh::$app['view']->assign('localization_currencies', array_diff(fn_get_simple_currencies(), $localizaton['currencies'])); Tygh::$app['view']->assign('localization_languages', array_diff(fn_get_simple_languages(true), $localizaton['languages'])); Tygh::$app['view']->assign('default_localization', fn_get_default_localization(DESCR_SL)); Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true), 'details' => array('title' => __('items_title'), 'js' => true))); } elseif ($mode == 'add') { Tygh::$app['view']->assign('localization_countries', fn_get_simple_countries()); Tygh::$app['view']->assign('localization_currencies', fn_get_simple_currencies()); Tygh::$app['view']->assign('localization_languages', fn_get_simple_languages(true)); Tygh::$app['view']->assign('default_localization', fn_get_default_localization(DESCR_SL)); Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true), 'details' => array('title' => __('items_title'), 'js' => true))); } elseif ($mode == 'manage') { Tygh::$app['view']->assign('localizations', fn_get_localizations(DESCR_SL)); } function fn_delete_localization($localization_ids) { $loc_objects = fn_get_localization_objects(); fn_set_progress('parts', sizeof($localization_ids) * sizeof($loc_objects)); foreach ($localization_ids as $loc_id) { foreach ($loc_objects as $table) { fn_set_progress('echo', __('converting_data_in_table', array('[table]' => $table))); db_query("UPDATE ?:{$table} SET localization = ?p", fn_remove_from_set('localization', $loc_id)); } db_query("DELETE FROM ?:localizations WHERE localization_id = ?i", $loc_id); db_query("DELETE FROM ?:localization_descriptions WHERE localization_id = ?i", $loc_id); db_query("DELETE FROM ?:localization_elements WHERE localization_id = ?i", $loc_id); } fn_set_notification('N', __('notice'), __('done'));
return array(CONTROLLER_STATUS_NO_PAGE); } Registry::get('view')->assign('localization', $localizaton); Registry::get('view')->assign('localization_countries', array_diff(fn_get_simple_countries(), $localizaton['countries'])); Registry::get('view')->assign('localization_currencies', array_diff(fn_get_simple_currencies(), $localizaton['currencies'])); Registry::get('view')->assign('localization_languages', array_diff(fn_get_simple_languages(true), $localizaton['languages'])); Registry::get('view')->assign('default_localization', fn_get_default_localization(DESCR_SL)); Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true), 'details' => array('title' => __('items_title'), 'js' => true))); } elseif ($mode == 'add') { Registry::get('view')->assign('localization_countries', fn_get_simple_countries()); Registry::get('view')->assign('localization_currencies', fn_get_simple_currencies()); Registry::get('view')->assign('localization_languages', fn_get_simple_languages(true)); Registry::get('view')->assign('default_localization', fn_get_default_localization(DESCR_SL)); Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true), 'details' => array('title' => __('items_title'), 'js' => true))); } elseif ($mode == 'manage') { Registry::get('view')->assign('localizations', fn_get_localizations(DESCR_SL)); } elseif ($mode == 'delete') { if (!empty($_REQUEST['localization_id'])) { fn_delete_localization((array) $_REQUEST['localization_id']); } return array(CONTROLLER_STATUS_OK, "localizations.manage"); } function fn_delete_localization($localization_ids) { $loc_objects = fn_get_localization_objects(); fn_set_progress('parts', sizeof($localization_ids) * sizeof($loc_objects)); foreach ($localization_ids as $loc_id) { foreach ($loc_objects as $table) { fn_set_progress('echo', __('converting_data_in_table', array('[table]' => $table))); db_query("UPDATE ?:{$table} SET localization = ?p", fn_remove_from_set('localization', $loc_id)); }
/** * Init template engine * * @return boolean always true */ function fn_init_templater($area = AREA) { $auth = Tygh::$app['session']['auth']; $view = new SmartyCore(); \SmartyException::$escape = false; /** * Change templater pre-init parameters * * @param object $view Templater object */ fn_set_hook('init_templater', $view); $view->_dir_perms = DEFAULT_DIR_PERMISSIONS; $view->_file_perms = DEFAULT_FILE_PERMISSIONS; $view->registerResource('tygh', new Tygh\SmartyEngine\FileResource()); // resource for shared templates loaded from backend $view->registerResource('backend', new Tygh\SmartyEngine\BackendResource()); if ($area == 'A') { if (!empty($auth['user_id'])) { // Auto-tooltips for admin panel $view->registerFilter('pre', array('Tygh\\SmartyEngine\\Filters', 'preFormTooltip')); if (fn_allowed_for('ULTIMATE')) { // Enable sharing for objects $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputSharing')); } } $view->registerFilter('pre', array('Tygh\\SmartyEngine\\Filters', 'preScript')); } if ($area == 'C') { $view->registerFilter('pre', array('Tygh\\SmartyEngine\\Filters', 'preTemplateWrapper')); if (Registry::get('runtime.customization_mode.design')) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputTemplateIds')); } if (Registry::get('runtime.customization_mode.live_editor')) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputLiveEditorWrapper')); } $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputScript')); } if (Embedded::isEnabled()) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputEmbeddedUrl')); } // CSRF form protection if (fn_is_csrf_protection_enabled($auth)) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputSecurityHash')); } // Language variable retrieval optimization $view->registerFilter('post', array('Tygh\\SmartyEngine\\Filters', 'postTranslation')); $smarty_plugins_dir = $view->getPluginsDir(); $view->setPluginsDir(Registry::get('config.dir.functions') . 'smarty_plugins'); $view->addPluginsDir($smarty_plugins_dir); $view->error_reporting = E_ALL & ~E_NOTICE; $view->registerDefaultPluginHandler(array('Tygh\\SmartyEngine\\Filters', 'smartyDefaultHandler')); $view->setArea($area); $view->use_sub_dirs = false; $view->compile_check = Development::isEnabled('compile_check') || Debugger::isActive() || fn_is_development() ? true : false; $view->setLanguage(CART_LANGUAGE); $view->assign('ldelim', '{'); $view->assign('rdelim', '}'); $view->assign('currencies', Registry::get('currencies'), false); $view->assign('primary_currency', CART_PRIMARY_CURRENCY, false); $view->assign('secondary_currency', CART_SECONDARY_CURRENCY, false); $view->assign('languages', Registry::get('languages')); if ($area == 'A') { $view->assign('addon_permissions_text', fn_get_addon_permissions_text()); } if (!fn_allowed_for('ULTIMATE:FREE')) { $view->assign('localizations', fn_get_localizations(CART_LANGUAGE, true)); if (defined('CART_LOCALIZATION')) { $view->assign('localization', fn_get_localization_data(CART_LOCALIZATION)); } } if (defined('THEMES_PANEL')) { if (fn_allowed_for('ULTIMATE')) { $storefronts = db_get_array('SELECT storefront, company, company_id FROM ?:companies'); Registry::set('demo_theme.storefronts', $storefronts); } $view->assign('demo_theme', Registry::get('demo_theme')); } Tygh::$app['view'] = $view; /** * Change templater parameters * * @param object $view Templater object */ fn_set_hook('init_templater_post', $view); return array(INIT_STATUS_OK); }
/** * Init template engine * * @return boolean always true */ function fn_init_templater($area = AREA) { $view = new SmartyCore(); \SmartyException::$escape = false; /** * Change templater pre-init parameters * * @param object $view Templater object */ fn_set_hook('init_templater', $view); $view->registerResource('tygh', new Tygh\SmartyEngine\FileResource()); if ($area == 'A' && !empty($_SESSION['auth']['user_id'])) { // Auto-tooltips for admin panel $view->registerFilter('pre', array('Tygh\\SmartyEngine\\Filters', 'preFormTooltip')); } // Customization mode if ($area == 'C') { $view->registerFilter('pre', array('Tygh\\SmartyEngine\\Filters', 'preTemplateWrapper')); if (Registry::get('runtime.customization_mode.design')) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputTemplateIds')); } } if (Registry::get('config.tweaks.anti_csrf') == true) { // CSRF form protection $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputSecurityHash')); } if (Embedded::isEnabled()) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputEmbeddedUrl')); } if (fn_allowed_for('ULTIMATE')) { // Enable sharing for objects $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputSharing')); } // Language variable retrieval optimization $view->registerFilter('post', array('Tygh\\SmartyEngine\\Filters', 'postTranslation')); // Translation mode if (Registry::get('runtime.customization_mode.translation')) { $view->registerFilter('output', array('Tygh\\SmartyEngine\\Filters', 'outputTranslateWrapper')); } if (Registry::get('settings.General.debugging_console') == 'Y') { if (empty($_SESSION['debugging_console']) && !empty($_SESSION['auth']['user_id'])) { $user_type = db_get_field("SELECT user_type FROM ?:users WHERE user_id = ?i", $_SESSION['auth']['user_id']); if ($user_type == 'A') { $_SESSION['debugging_console'] = true; } } if (isset($_SESSION['debugging_console']) && $_SESSION['debugging_console'] == true) { error_reporting(0); $view->debugging = true; } } $smarty_plugins_dir = $view->getPluginsDir(); $view->setPluginsDir(Registry::get('config.dir.functions') . 'smarty_plugins'); $view->addPluginsDir($smarty_plugins_dir); $view->error_reporting = E_ALL & ~E_NOTICE; $view->registerDefaultPluginHandler(array('Tygh\\SmartyEngine\\Filters', 'smartyDefaultHandler')); $view->setArea($area); $view->use_sub_dirs = false; $view->compile_check = Development::isEnabled('compile_check') || Debugger::isActive() || defined('DEVELOPMENT') ? true : false; $view->setLanguage(CART_LANGUAGE); $view->assign('ldelim', '{'); $view->assign('rdelim', '}'); $view->assign('currencies', Registry::get('currencies'), false); $view->assign('primary_currency', CART_PRIMARY_CURRENCY, false); $view->assign('secondary_currency', CART_SECONDARY_CURRENCY, false); $view->assign('languages', Registry::get('languages')); if ($area == 'A') { $view->assign('addon_permissions_text', fn_get_addon_permissions_text()); } if (!fn_allowed_for('ULTIMATE:FREE')) { $view->assign('localizations', fn_get_localizations(CART_LANGUAGE, true)); if (defined('CART_LOCALIZATION')) { $view->assign('localization', fn_get_localization_data(CART_LOCALIZATION)); } } if (defined('THEMES_PANEL')) { if (fn_allowed_for('ULTIMATE')) { $storefronts = db_get_array('SELECT storefront, company, company_id FROM ?:companies'); Registry::set('demo_theme.storefronts', $storefronts); } $view->assign('demo_theme', Registry::get('demo_theme')); } Registry::set('view', $view); /** * Change templater parameters * * @param object $view Templater object */ fn_set_hook('init_templater_post', $view); return array(INIT_STATUS_OK); }
} $view->assign('localization', $localizaton); $view->assign('localization_countries', array_diff(fn_get_simple_countries(), $localizaton['countries'])); $view->assign('localization_currencies', array_diff(fn_get_simple_currencies(), $localizaton['currencies'])); $view->assign('localization_languages', array_diff(fn_get_simple_languages(), $localizaton['languages'])); $view->assign('default_localization', fn_get_default_localization(DESCR_SL)); Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'details' => array('title' => fn_get_lang_var('items_title'), 'js' => true))); } elseif ($mode == 'add') { fn_add_breadcrumb(fn_get_lang_var('localizations'), "localizations.manage"); $view->assign('localization_countries', fn_get_simple_countries()); $view->assign('localization_currencies', fn_get_simple_currencies()); $view->assign('localization_languages', fn_get_simple_languages()); $view->assign('default_localization', fn_get_default_localization(DESCR_SL)); Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'details' => array('title' => fn_get_lang_var('items_title'), 'js' => true))); } elseif ($mode == 'manage') { $view->assign('localizations', fn_get_localizations(DESCR_SL)); } elseif ($mode == 'delete') { if (!empty($_REQUEST['localization_id'])) { fn_delete_localization((array) $_REQUEST['localization_id']); } return array(CONTROLLER_STATUS_REDIRECT, "localizations.manage"); } function fn_delete_localization($localization_ids) { fn_start_scroller(); foreach ($localization_ids as $loc_id) { foreach (fn_get_localization_objects() as $table) { fn_echo('<br />' . str_replace('[table]', $table, fn_get_lang_var('converting_data_in_table')) . '...' . '<br />'); db_query("UPDATE ?:{$table} SET localization = ?p", fn_remove_from_set('localization', $loc_id)); } fn_stop_scroller();