Beispiel #1
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_block_scripts($params, $content, &$smarty, &$repeat)
{
    if ($repeat == true) {
        Registry::set('runtime.inside_scripts', 1);
        return;
    }
    if (Registry::get('config.tweaks.dev_js')) {
        $content .= smarty_helper_inline_scripts($params, $content, $smarty, $repeat);
        return $content;
    }
    $scripts = array();
    $external_scripts = array();
    $dir_root = Registry::get('config.dir.root');
    $return = '';
    $current_location = Registry::get('config.current_location');
    if (preg_match_all('/\\<script(.*?)\\>(.*?)\\<\\/script\\>/s', $content, $m)) {
        $contents = '';
        foreach ($m[1] as $src) {
            if (!empty($src) && preg_match('/src ?= ?"([^"]+)"/', $src, $_m)) {
                if (strpos($_m[1], $current_location) !== false) {
                    $scripts[] = str_replace($current_location, '', preg_replace('/\\?.*?$/', '', $_m[1]));
                } else {
                    $external_scripts[] = $_m[1];
                }
            }
        }
        // Check file changes in dev mode
        $names = $scripts;
        if (Development::isEnabled('compile_check')) {
            foreach ($names as $index => $name) {
                if (is_file($dir_root . '/' . $name)) {
                    $names[$index] .= filemtime($dir_root . '/' . $name);
                }
            }
        }
        $filename = 'js/tygh/scripts-' . md5(implode(',', $names)) . fn_get_storage_data('cache_id') . '.js';
        if (!Storage::instance('statics')->isExist($filename)) {
            foreach ($scripts as $src) {
                $contents .= fn_get_contents(Registry::get('config.dir.root') . $src);
            }
            $contents = str_replace('[files]', implode("\n", $scripts), Registry::get('config.js_css_cache_msg')) . $contents;
            $contents = Minifier::minify($contents, array('flaggedComments' => false));
            Storage::instance('statics')->put($filename, array('contents' => $contents, 'compress' => false, 'caching' => true));
        }
        $return = '<script type="text/javascript" src="' . Storage::instance('statics')->getUrl($filename) . '?ver=' . PRODUCT_VERSION . '"></script>' . "\n";
        if (!empty($external_scripts)) {
            foreach ($external_scripts as $sc) {
                $return .= '<script type="text/javascript" src="' . $sc . '"></script>' . "\n";
            }
        }
        foreach ($m[2] as $sc) {
            if (!empty($sc)) {
                $return .= '<script type="text/javascript">' . $sc . '</script>' . "\n";
            }
        }
        $return .= smarty_helper_inline_scripts($params, $content, $smarty, $repeat);
    }
    return $return;
}
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_block_scripts($params, $content, &$smarty, &$repeat)
{
    if ($repeat == true) {
        return;
    }
    if (Registry::get('config.tweaks.dev_js')) {
        return $content;
    }
    $scripts = array();
    $dir_root = Registry::get('config.dir.root');
    $return = '';
    if (preg_match_all('/\\<script(.*?)\\>(.*?)\\<\\/script\\>/s', $content, $m)) {
        $contents = '';
        foreach ($m[1] as $src) {
            if (!empty($src) && preg_match('/src ?= ?"([^"]+)"/', $src, $_m)) {
                $scripts[] = str_replace(Registry::get('config.current_location'), '', preg_replace('/\\?.*?$/', '', $_m[1]));
            }
        }
        // Check file changes in dev mode
        $names = $scripts;
        if (Development::isEnabled('compile_check')) {
            foreach ($names as $index => $name) {
                if (is_file($dir_root . '/' . $name)) {
                    $names[$index] .= filemtime($dir_root . '/' . $name);
                }
            }
        }
        $gz_suffix = Registry::get('config.tweaks.gzip_css_js') ? '.gz' : '';
        $filename = 'js/tygh/scripts-' . md5(implode(',', $names)) . fn_get_storage_data('cache_id') . '.js';
        if (!Storage::instance('statics')->isExist($filename . $gz_suffix)) {
            foreach ($scripts as $src) {
                $contents .= fn_get_contents(Registry::get('config.dir.root') . $src);
            }
            $contents = str_replace('[files]', implode("\n", $scripts), Registry::get('config.js_css_cache_msg')) . $contents;
            Storage::instance('statics')->put($filename . $gz_suffix, array('contents' => $contents, 'compress' => Registry::get('config.tweaks.gzip_css_js'), 'caching' => true));
        }
        $return = '<script type="text/javascript" src="' . Storage::instance('statics')->getUrl($filename) . '?ver=' . PRODUCT_VERSION . '"></script>';
        foreach ($m[2] as $sc) {
            if (!empty($sc)) {
                $return .= '<script type="text/javascript">' . $sc . '</script>' . "\n";
            }
        }
    }
    return $return;
}
Beispiel #3
0
 /**
  * Outputs exception information
  * @return type
  */
 public function output()
 {
     if (!defined('AJAX_REQUEST') && Ajax::validateRequest($_REQUEST)) {
         // Return valid JS in ajax requests if the 'fail' status was thrown before ajax initialization
         header('Content-type: application/json');
         $message = json_encode(array('error' => $this->message));
         if (!empty($_REQUEST['callback'])) {
             $message = $_REQUEST['callback'] . "(" . $message . ");";
         }
         echo $message;
         exit;
     } elseif (defined('CONSOLE') || Debugger::isActive() || defined('DEVELOPMENT') && DEVELOPMENT) {
         echo $this->printDebug(defined('CONSOLE'));
     } else {
         $debug = "<!--\n" . $this->printDebug(true) . "\n-->";
         Development::showStub(array('[title]' => 'Service unavailable', '[banner]' => 'Service<br/> unavailable', '[message]' => 'Sorry, service is temporarily unavailable.'), $debug);
     }
 }
Beispiel #4
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Development;
use Tygh\Registry;
use Tygh\Settings;
use Tygh\UpgradeCenter\App as UpgradeCenter;
use Tygh\UpgradeCenter\Log;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if (in_array($mode, array('upgrade', 'revert'))) {
    // temporary set development mode, for full error displaying
    Development::enable('compile_check');
}
$app = UpgradeCenter::instance();
$custom_theme_files = array();
$skip_files = array('manifest.json');
$backend_files = array('admin_index' => 'admin.php', 'vendor_index' => 'vendor.php');
$uc_settings = Settings::instance()->getValues('Upgrade_center');
// If we're performing the update, check if upgrade center override controller is exist in the package
if (!empty($_SESSION['uc_package']) && file_exists(Registry::get('config.dir.upgrade') . $_SESSION['uc_package'] . '/uc_override.php')) {
    return include Registry::get('config.dir.upgrade') . $_SESSION['uc_package'] . '/uc_override.php';
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'update_settings') {
        if (!empty($_REQUEST['settings_data'])) {
            foreach ($_REQUEST['settings_data'] as $setting_name => $setting_value) {
                Settings::instance()->updateValue($setting_name, $setting_value, 'Upgrade_center');
Beispiel #5
0
 /**
  * Returns true if cache used for blocks
  *
  * @static
  * @return bool true if we may use cahce, false otherwise
  */
 public static function allowCache()
 {
     $use_cache = true;
     if (Registry::ifGet('config.tweaks.disable_block_cache', false) || Registry::get('runtime.customizaton_mode.design') || Registry::get('runtime.customizaton_mode.translation') || Development::isEnabled('compile_check')) {
         $use_cache = false;
     }
     return $use_cache;
 }
Beispiel #6
0
 // Set system notifications
 if (Registry::get('config.demo_mode') != true && AREA == 'A') {
     // If username equals to the password
     if (!fn_is_development() && fn_compare_login_password($user_data, $password)) {
         $lang_var = 'warning_insecure_password_email';
         fn_set_notification('E', __('warning'), __($lang_var, array('[link]' => fn_url('profiles.update'))), 'S', 'insecure_password');
     }
     if (empty($user_data['company_id']) && !empty($user_data['user_id'])) {
         // Insecure admin script
         if (!fn_is_development() && Registry::get('config.admin_index') == 'admin.php') {
             fn_set_notification('E', __('warning'), __('warning_insecure_admin_script', array('[href]' => Registry::get('config.resources.admin_protection_url'))), 'S');
         }
         if (!fn_is_development() && is_file(Registry::get('config.dir.root') . '/install/index.php')) {
             fn_set_notification('W', __('warning'), __('delete_install_folder'), 'S');
         }
         if (Development::isEnabled('compile_check')) {
             fn_set_notification('W', __('warning'), __('warning_store_optimization_dev', array('[link]' => fn_url("themes.manage"))));
         }
         fn_set_hook('set_admin_notification', $user_data);
     }
 }
 if (!empty($_REQUEST['remember_me'])) {
     fn_set_session_data(AREA . '_user_id', $user_data['user_id'], COOKIE_ALIVE_TIME);
     fn_set_session_data(AREA . '_password', $user_data['password'], COOKIE_ALIVE_TIME);
 }
 if (!empty($_REQUEST['return_url'])) {
     $redirect_url = $_REQUEST['return_url'];
 }
 unset($_REQUEST['redirect_url']);
 if (AREA == 'C') {
     fn_set_notification('N', __('notice'), __('successful_login'));
Beispiel #7
0
    return;
}
//
// Check if store is closed
//
if (Registry::get('settings.General.store_mode') == 'Y') {
    if (!empty($_REQUEST['store_access_key'])) {
        Tygh::$app['session']['store_access_key'] = $_GET['store_access_key'];
    }
    if (!fn_check_permissions(Registry::get('runtime.controller'), Registry::get('runtime.mode'), 'trusted_controllers')) {
        if (empty(Tygh::$app['session']['store_access_key']) || Tygh::$app['session']['store_access_key'] != Registry::get('settings.General.store_access_key')) {
            if (defined('AJAX_REQUEST')) {
                fn_set_notification('E', __('notice'), __('text_store_closed'));
                exit;
            }
            Development::showStub();
        }
    }
}
if (empty($_REQUEST['product_id']) && empty($_REQUEST['category_id'])) {
    unset(Tygh::$app['session']['current_category_id']);
}
$dispatch = $_REQUEST['dispatch'];
$dynamic_object = array();
if (!empty($_REQUEST['dynamic_object'])) {
    $dynamic_object = $_REQUEST['dynamic_object'];
}
$dynamic_object_scheme = SchemesManager::getDynamicObject($dispatch, AREA, $_REQUEST);
if (!empty($dynamic_object_scheme)) {
    $dispatch = $dynamic_object_scheme['customer_dispatch'];
}
Beispiel #8
0
/**
 * Merges css and less files
 *
 * @param array $files Array with style files
 * @param string $styles Style code
 * @param string $prepend_prefix Prepend prefix
 * @param array $params additional params
 */
function fn_merge_styles($files, $styles = '', $prepend_prefix = '', $params = array(), $area = AREA)
{
    $prefix = !empty($prepend_prefix) ? 'embedded' : 'standalone';
    $make_rtl = false;
    if (fn_is_rtl_language()) {
        $prefix .= '-rtl';
        $make_rtl = true;
    }
    $output = '';
    $less_output = '';
    $less_reflection = array();
    $compiled_less = '';
    $compiled_css = '';
    $relative_path = fn_get_theme_path('[relative]/[theme]/css', $area);
    $hashes = array();
    $names = array_map(function ($v) {
        return !empty($v['relative']) ? $v['relative'] : false;
    }, $files);
    // Check file changes
    if (Development::isEnabled('compile_check') || Debugger::isActive()) {
        $dir_root = Registry::get('config.dir.root');
        foreach ($names as $index => $name) {
            if (file_exists($dir_root . '/' . $name)) {
                $hashes[] = $name . filemtime($dir_root . '/' . $name);
            }
        }
    }
    $hashes[] = md5(implode('|', $names));
    $hashes[] = md5($styles);
    if ($area == 'C') {
        $hashes[] = Registry::get('runtime.layout.layout_id');
        $hashes[] = Registry::get('runtime.layout.style_id');
    }
    arsort($hashes);
    $hash = md5(implode(',', $hashes) . PRODUCT_VERSION) . fn_get_storage_data('cache_id');
    $filename = $prefix . '.' . $hash . '.css';
    $theme_manifest = Themes::factory(fn_get_theme_path('[theme]', 'C'))->getManifest();
    if (!Storage::instance('assets')->isExist($relative_path . '/' . $filename)) {
        Debugger::checkpoint('Before styles compilation');
        foreach ($files as $src) {
            $m_prefix = '';
            $m_suffix = '';
            if (!empty($src['media'])) {
                $m_prefix = "\n@media " . $src['media'] . " {\n";
                $m_suffix = "\n}\n";
            }
            if (strpos($src['file'], '.css') !== false) {
                $output .= "\n" . $m_prefix . fn_get_contents($src['file']) . $m_suffix;
            } elseif ($area != 'C' || empty($theme_manifest['converted_to_css'])) {
                $less_output_chunk = '';
                if (file_exists($src['file'])) {
                    if ($area == 'C' && (empty($theme_manifest['parent_theme']) || $theme_manifest['parent_theme'] == 'basic')) {
                        $less_output_chunk = "\n" . $m_prefix . fn_get_contents($src['file']) . $m_suffix;
                    } else {
                        $less_output_chunk = "\n" . $m_prefix . '@import "' . str_replace($relative_path . '/', '', $src['relative']) . '";' . $m_suffix;
                    }
                }
                if (!empty($params['reflect_less'])) {
                    if (preg_match('{/addons/([^/]+)/}is', $src['relative'], $m)) {
                        $less_reflection['output']['addons'][$m[1]] .= $less_output_chunk;
                    } else {
                        $less_reflection['output']['main'] .= $less_output_chunk;
                    }
                }
                $less_output .= $less_output_chunk;
            }
        }
        $header = str_replace('[files]', implode("\n", $names), Registry::get('config.js_css_cache_msg'));
        if (!empty($styles)) {
            $less_output .= $styles;
        }
        // Prepend all styles with prefix
        if (!empty($prepend_prefix)) {
            $less_output = $output . "\n" . $less_output;
            $output = '';
        }
        if (!empty($output)) {
            $compiled_css = Less::parseUrls($output, Storage::instance('assets')->getAbsolutePath($relative_path), fn_get_theme_path('[themes]/[theme]/media', $area));
        }
        if (!empty($theme_manifest['converted_to_css']) && $area == 'C') {
            $theme_css_path = fn_get_theme_path('[themes]/[theme]', $area) . '/css';
            $pcl_filepath = $theme_css_path . '/' . Themes::$compiled_less_filename;
            if (file_exists($pcl_filepath)) {
                $compiled_css .= fn_get_contents($pcl_filepath);
            }
            list($installed_addons) = fn_get_addons(array('type' => 'active'));
            foreach ($installed_addons as $addon) {
                $addon_pcl_filpath = $theme_css_path . "/addons/{$addon['addon']}/" . Themes::$compiled_less_filename;
                if (file_exists($pcl_filepath)) {
                    $compiled_css .= fn_get_contents($addon_pcl_filpath);
                }
            }
        }
        if (!empty($less_output)) {
            $less = new Less();
            if (!empty($params['compressed'])) {
                $less->setFormatter('compressed');
            }
            $less->setImportDir($relative_path);
            try {
                $compiled_less = $less->customCompile($less_output, Storage::instance('assets')->getAbsolutePath($relative_path), array(), $prepend_prefix, $area);
            } catch (Exception $e) {
                $skip_save = true;
                $shift = 4;
                $message = '<div style="border: 2px solid red; padding: 5px;">LESS ' . $e->getMessage();
                if (preg_match("/line: (\\d+)/", $message, $m)) {
                    $lo = explode("\n", $less_output);
                    $message .= '<br /><br /><pre>' . implode("\n", array_splice($lo, intval($m[1]) - $shift, $shift * 2)) . '</pre>';
                }
                $message .= '</div>';
                fn_set_notification('E', __('error'), $message);
            }
        }
        if (empty($skip_save)) {
            $compiled_content = $compiled_css . "\n" . $compiled_less;
            // Move all @import links to the Top of the file.
            if (preg_match_all('/@import url.*?;/', $compiled_content, $imports)) {
                $compiled_content = preg_replace('/@import url.*?;/', '', $compiled_content);
                foreach ($imports[0] as $import_link) {
                    $compiled_content = $import_link . "\n" . $compiled_content;
                }
            }
            if ($make_rtl) {
                $compiled_content = \CSSJanus::transform($compiled_content);
                $compiled_content = "body {\ndirection: rtl;\n}\n" . $compiled_content;
            }
            Storage::instance('assets')->put($relative_path . '/' . $filename, array('contents' => $header . $compiled_content, 'compress' => false, 'caching' => true));
            if (!empty($params['use_scheme'])) {
                fn_put_contents(fn_get_cache_path(false) . 'theme_editor/' . $filename, $output . '#LESS#' . $less_output);
            }
            if (!empty($params['reflect_less'])) {
                $less_reflection['import_dirs'] = array($relative_path);
                fn_put_contents(fn_get_cache_path(false) . 'less_reflection.json', json_encode($less_reflection));
            }
        }
        Debugger::checkpoint('After styles compilation');
    }
    $url = Storage::instance('assets')->getUrl($relative_path . '/' . $filename);
    return $url;
}
Beispiel #9
0
        }
        exit;
    }
    return array(CONTROLLER_STATUS_OK, 'themes.manage');
}
if ($mode == 'manage') {
    if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) {
        return array(CONTROLLER_STATUS_OK);
    }
    $available_themes = fn_get_available_themes(Registry::get('settings.theme_name'));
    if (!empty($available_themes['repo']) && !empty($available_themes['installed'])) {
        $available_themes['repo'] = array_diff_key($available_themes['repo'], $available_themes['installed']);
    }
    Tygh::$app['view']->assign('themes_prefix', fn_get_theme_path('[relative]', 'C'));
    Tygh::$app['view']->assign('repo_prefix', fn_get_theme_path('[repo]', 'C'));
    Registry::set('navigation.tabs', array('installed_themes' => array('title' => __('installed_themes'), 'js' => true), 'browse_all_available_themes' => array('title' => __('browse_all_available_themes'), 'js' => true)));
    $theme_name = fn_get_theme_path('[theme]', 'C');
    $layout = Layout::instance()->getDefault($theme_name);
    $style = Styles::factory($theme_name)->get($layout['style_id']);
    $layout['style_name'] = empty($style['name']) ? '' : $style['name'];
    Tygh::$app['view']->assign('layout', $layout);
    foreach ($available_themes['installed'] as $theme_id => $theme) {
        $layouts_params = array('theme_name' => $theme_id);
        $available_themes['installed'][$theme_id]['layouts'] = Layout::instance()->getList($layouts_params);
        if ($theme_id == $theme_name) {
            $available_themes['current']['layouts'] = $available_themes['installed'][$theme_id]['layouts'];
        }
    }
    Tygh::$app['view']->assign('available_themes', $available_themes);
    Tygh::$app['view']->assign('dev_modes', Development::get());
}
Beispiel #10
0
/**
 * @deprecated since 4.3.6
 */
function fn_companies_change_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
    Development::deprecated("The function fn_companies_change_status() is deprecated. Use fn_change_company_status() instead.");
    return fn_change_company_status($company_id, $status_to, $reason, $status_from, $skip_query, $notify);
}
Beispiel #11
0
/**
 * 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);
}
Beispiel #12
0
/**
 * 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);
}
Beispiel #13
0
} elseif ($mode == 'styles') {
    if ($action == 'update_status') {
        $theme = Themes::factory(fn_get_theme_path('[theme]', 'C'));
        $theme_manifest = $theme->getManifest();
        if (empty($theme_manifest['converted_to_css'])) {
            Styles::factory(fn_get_theme_path('[theme]', 'C'))->setStyle($_REQUEST['id'], $_REQUEST['status']);
            // Delete compiled CSS file
            fn_clear_cache('statics');
        } else {
            $layout = Layout::instance(Registry::get('runtime.company_id'))->getDefault();
            fn_set_notification('E', __('error'), __('theme_editor.error_theme_converted_to_css', array('[url]' => fn_url("customization.update_mode?type=theme_editor&status=enable&s_layout={$layout['layout_id']}"))));
        }
    }
    return array(CONTROLLER_STATUS_OK, 'themes.manage');
} elseif ($mode == 'update_dev_mode') {
    if (!empty($_REQUEST['dev_mode'])) {
        if (!empty($_REQUEST['state'])) {
            Development::enable($_REQUEST['dev_mode']);
        } else {
            Development::disable($_REQUEST['dev_mode']);
        }
        if ($_REQUEST['dev_mode'] == 'compile_check') {
            if (!empty($_REQUEST['state'])) {
                fn_set_notification('W', __('warning'), __('warning_store_optimization_dev', array('[link]' => fn_url('themes.manage'))));
            } else {
                fn_set_notification('W', __('warning'), __('warning_store_optimization_dev_disabled', array('[link]' => fn_url('themes.manage?ctpl'))));
            }
        }
    }
    exit;
}
Beispiel #14
0
        }
        exit;
    }
    return array(CONTROLLER_STATUS_OK, 'themes.manage');
}
if ($mode == 'manage') {
    if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) {
        return array(CONTROLLER_STATUS_OK);
    }
    $available_themes = fn_get_available_themes(Registry::get('settings.theme_name'));
    if (!empty($available_themes['repo']) && !empty($available_themes['installed'])) {
        $available_themes['repo'] = array_diff_key($available_themes['repo'], $available_themes['installed']);
    }
    Registry::get('view')->assign('themes_prefix', fn_get_theme_path('[relative]', 'C'));
    Registry::get('view')->assign('repo_prefix', fn_get_theme_path('[repo]', 'C'));
    Registry::set('navigation.tabs', array('installed_themes' => array('title' => __('installed_themes'), 'js' => true), 'browse_all_available_themes' => array('title' => __('browse_all_available_themes'), 'js' => true)));
    $theme_name = fn_get_theme_path('[theme]', 'C');
    $layout = Layout::instance()->getDefault($theme_name);
    $style = Styles::factory($theme_name)->get($layout['style_id']);
    $layout['style_name'] = empty($style['name']) ? '' : $style['name'];
    Registry::get('view')->assign('layout', $layout);
    foreach ($available_themes['installed'] as $theme_id => $theme) {
        $layouts_params = array('theme_name' => $theme_id);
        $available_themes['installed'][$theme_id]['layouts'] = Layout::instance()->getList($layouts_params);
        if ($theme_id == $theme_name) {
            $available_themes['current']['layouts'] = $available_themes['installed'][$theme_id]['layouts'];
        }
    }
    Registry::get('view')->assign('available_themes', $available_themes);
    Registry::get('view')->assign('dev_modes', Development::get());
}