public function __construct($theme_name) { $this->theme_name = $theme_name; $this->theme_path = fn_get_theme_path('[themes]/' . $theme_name, 'C'); $this->relative_path = fn_get_theme_path('[relative]/' . $theme_name, 'C'); $this->repo_path = fn_get_theme_path('[repo]/' . $theme_name, 'C'); }
function fn_settings_variants_addons_hybrid_auth_icons_pack() { $available_icons_packs = array(); $theme_name = Settings::instance()->getValue('theme_name', ''); $icons_dir = fn_get_theme_path('[themes]/', 'C') . $theme_name . '/media/images/addons/hybrid_auth/icons/'; $icons_packs = fn_get_dir_contents($icons_dir); foreach ($icons_packs as $id => $icons_packs_name) { $available_icons_packs[$icons_packs_name] = $icons_packs_name; } return $available_icons_packs; }
/** * Smarty plugin * @package Smarty * @subpackage plugins */ function smarty_function_style($params, &$smarty) { list($_area) = Tygh::$app['view']->getArea(); $params['src'] = !empty($params['src']) ? $params['src'] : ''; $location = Registry::get('config.current_location') . (strpos($params['src'], '/') === 0 ? '' : '/' . fn_get_theme_path('[relative]/[theme]', $_area) . '/css'); $url = $location . '/' . $params['src']; if (!empty($params['content'])) { return '<style type="text/css"' . (!empty($params['media']) ? ' media="' . $params['media'] . '"' : '') . '>' . $params['content'] . '</style>'; } return '<link type="text/css" rel="stylesheet"' . (!empty($params['media']) ? ' media="' . $params['media'] . '"' : '') . ' href="' . $url . '" />'; }
/** * Gets patterns absolute path * @param string $style_id style ID * @return string patterns absolute path */ public function getPath($style_id) { $path = fn_get_theme_path('[themes]/[theme]/media/images/patterns/', 'C'); /** * Modifies path to patterns * * @param object $this Patterns object * @param string $path current path * @param string $style_id style to get path for */ fn_set_hook('patterns_get_path', $this, $path, $style_id); return $path . fn_basename($style_id); }
/** * Compile LESS to CSS, appending data from styles and parsing urls * @param string $less_output LESS code * @param string $dirname absolute path where compiled file will be saved (to parse URLs correctly) * @param array $data style data * @param string $prepend_prefix prefix to prepend all selectors (for widget mode) * @param string $area Area (C/A) to get setting for * @return string CSS code */ public function customCompile($less_output, $dirname, $data = array(), $prepend_prefix = '', $area = AREA) { // Apply all Custom styles styles $less_output .= Styles::factory(fn_get_theme_path('[theme]', $area))->getLess($data); // Inject Bootstrap fluid variables $less_output .= self::getLayoutStyleVariables(); if (!empty($prepend_prefix)) { $less_output = $prepend_prefix . " {\n" . $less_output . "\n}"; } $output = $this->parse($less_output); // Remove "body" definition if (!empty($prepend_prefix)) { $output = str_replace($prepend_prefix . ' body', $prepend_prefix, $output); } return Less::parseUrls($output, $dirname, fn_get_theme_path('[themes]/[theme]/media')); }
function fn_mp_get_setting_templates() { $templates = array(); $skin_path = fn_get_theme_path('[themes]/[theme]', 'A'); $relative_directory_path = 'addons/maps_provider/settings/'; $template_path = $skin_path . '/templates/' . $relative_directory_path; $_templates = fn_get_dir_contents($template_path, false, true, '.tpl'); if (!empty($_templates)) { $needles = array('settings_', '.tpl'); $replacements = array('', ''); foreach ($_templates as $template) { if (preg_match('/^settings_/', $template, $m)) { $_template = str_replace($needles, $replacements, $template); // Get the provider name $templates[$_template] = $relative_directory_path . $template; } } } return $templates; }
private static function setBackupFrontend($company_id) { foreach (self::$file_areas as $key => $file_area) { foreach (self::$installed_themes as $theme) { self::$dirs['backup_files'][$key . '_frontend'][$company_id][$theme] = self::$dirs['backup_root'] . self::$backup_files_path . fn_get_theme_path('[relative]/' . $theme . '/', 'C', $company_id) . $file_area . '/' . self::$full_addon_path; } } }
$full_path = fn_get_theme_path('[themes]/[theme]', 'C') . '/templates/' . $_REQUEST['file']; if (fn_check_path($full_path)) { $c_name = fn_normalize_path($full_path); $r_name = fn_normalize_path(Registry::get('config.dir.themes_repository') . Registry::get('config.base_theme') . '/templates/' . $_REQUEST['file']); if (is_file($r_name)) { $copied = fn_copy($r_name, $c_name); } if ($copied) { fn_set_notification('N', __('notice'), __('text_file_restored', array('[file]' => fn_basename($_REQUEST['file'])))); } else { fn_set_notification('E', __('error'), __('text_cannot_restore_file', array('[file]' => fn_basename($_REQUEST['file'])))); } if ($copied) { if (defined('AJAX_REQUEST')) { Registry::get('ajax')->assign('force_redirection', fn_url($_REQUEST['current_url'])); Registry::get('ajax')->assign('non_ajax_notifications', true); } return array(CONTROLLER_STATUS_OK, $_REQUEST['current_url']); } } exit; } } if ($mode == 'get_content') { $ext = fn_strtolower(fn_get_file_ext($_REQUEST['file'])); if ($ext == 'tpl') { $theme_path = fn_get_theme_path('[themes]/[theme]/templates/', 'C'); Registry::get('ajax')->assign('content', fn_get_contents($_REQUEST['file'], $theme_path)); } exit; }
function fn_get_default_layouts_sources($theme_name = '', $themes_path = '') { $layouts_sources = array(); if (empty($themes_path)) { $themes_path = fn_get_theme_path('[themes]', 'C'); } if (empty($theme_name)) { $installed_themes = fn_get_dir_contents($themes_path, true); foreach ($installed_themes as $theme_name) { $layouts_sources = array_merge($layouts_sources, fn_get_default_layouts_sources($theme_name, $themes_path)); } } else { $layouts_path = $themes_path . '/' . $theme_name . '/layouts/'; $layouts = fn_get_dir_contents($layouts_path, false, true, '.xml'); foreach ($layouts as $layout_name) { $layout_path = fn_normalize_path($layouts_path . $layout_name); if (file_exists($layout_path)) { $layout_data = Exim::instance(Registry::get('runtime.company_id'), 0, $theme_name)->getLayoutData($layout_path, false); if (!empty($layout_data)) { $layout_data['theme_name'] = $theme_name; $layout_data['filename'] = $layout_name; $layouts_sources[] = $layout_data; } } } } return $layouts_sources; }
function fn_gift_certificates_logo_types(&$types, $for_company) { if ($for_company == true && fn_allowed_for('MULTIVENDOR')) { return false; } $types['gift_cert'] = array('text' => 'text_gift_certificate_logo', 'image' => fn_get_theme_path('[themes]/[theme]/mail/media/', 'C') . 'images/gift_cert_logo.png', 'single_logo' => true); return true; }
/** * Gets patterns absolute path * @param string $style_id style ID * @return string patterns absolute path */ public static function getPath($style_id) { $path = fn_get_theme_path('[themes]/[theme]/media/images/patterns/', 'C'); fn_set_hook('patterns_get_path', $path, $style_id); return $path . fn_basename($style_id); }
function fn_theme_editor_save_style($style_id, $style) { $theme_name = fn_get_theme_path('[theme]', 'C'); if (empty($style_id) && !empty($style['name'])) { $style_id = $style['name']; Styles::factory($theme_name)->copy(Registry::get('runtime.layout.style_id'), $style_id); } if (empty($style) || empty($style['data']) || empty($style_id)) { return false; } // Attach patterns $uploaded_data = fn_filter_uploaded_data('backgrounds'); if (!empty($uploaded_data)) { $style = Patterns::instance()->save($style_id, $style, $uploaded_data); } // Save style data if (!Styles::factory($theme_name)->update($style_id, $style)) { //FIXME: Presets backward compability $path = fn_get_theme_path('[relative]/[theme]/styles'); if (!is_dir($path)) { $path = fn_get_theme_path('[relative]/[theme]/presets'); } fn_set_notification('E', __('error'), __('theme_editor.style_data_cannot_be_saved', array('[theme_dir]' => $path))); return false; } fn_theme_editor_set_style($style_id); return $style_id; }
/** * Returns customer theme path * @static * @return string Path to customer theme folder */ public static function getCustomerThemePath() { return fn_get_theme_path('[themes]/[theme]/templates/', 'C'); }
/** * Removes addon's templates from theme folder * * @param string $addon Addon name to remove templates for * @return bool Always true */ function fn_uninstall_addon_templates($addon) { if (defined('DEVELOPMENT')) { return false; } $installed_themes = fn_get_installed_themes(); $design_dir = fn_get_theme_path('[themes]/', 'C'); foreach ($installed_themes as $theme_name) { $paths = array($design_dir . $theme_name . '/templates/addons/' . $addon, $design_dir . $theme_name . '/css/addons/' . $addon, $design_dir . $theme_name . '/media/images/addons/' . $addon, $design_dir . $theme_name . '/mail/templates/addons/' . $addon, $design_dir . $theme_name . '/mail/media/images/addons/' . $addon, $design_dir . $theme_name . '/mail/css/addons/' . $addon); foreach ($paths as $path) { if (is_dir($path)) { fn_rm($path); } } } return true; }
} if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'update_storage') { if (!empty($_REQUEST['storage_data'])) { if (Registry::get('runtime.storage.storage') != $_REQUEST['storage_data']['storage']) { $test = Storage::instance('statics', $_REQUEST['storage_data'])->testSettings($_REQUEST['storage_data']); $themes = array(); if ($test === true) { $total = 0; if (fn_allowed_for('ULTIMATE')) { foreach (fn_get_all_companies_ids() as $company_id) { $themes[$company_id] = fn_get_dir_contents(fn_get_theme_path('[themes]', 'C', $company_id)); $total += sizeof($themes[$company_id]); } } else { $themes[0] = fn_get_dir_contents(fn_get_theme_path('[themes]', 'C')); $total += sizeof($themes[0]); } $storage = Registry::get('config.storage'); unset($storage['statics']); // Do not transfer auto-generated data $total += sizeof($storage); fn_set_progress('parts', $total); // transfer storages foreach ($storage as $type => $options) { $from = Storage::instance($type, Registry::get('runtime.storage')); $to = Storage::instance($type, $_REQUEST['storage_data']); $to->putList($from->getList(''), $from->getAbsolutePath(''), array('overwrite' => true)); } Settings::instance()->updateValue('storage', serialize($_REQUEST['storage_data'])); fn_clear_cache();
/** * Updates or creates layout * @param array $layout_data layout data * @param int $layout_id layout ID to update, zero to create * @return int ID of updated/created layout */ public function update($layout_data, $layout_id = 0) { $create = empty($layout_id); if (fn_allowed_for('ULTIMATE')) { if (empty($layout_data['company_id'])) { $layout_data['company_id'] = $this->_company_id; } } $theme_name = empty($layout_data['theme_name']) ? fn_get_theme_path('[theme]', 'C', $this->_company_id, false) : $layout_data['theme_name']; $available_styles = Styles::factory($theme_name)->getList(array('short_info' => true)); /** * Performs actions before updating layout * * @param object $this Layout object * @param integer $layout_id layout ID * @param array $layout_data layout data * @param boolean $create create/update flag */ fn_set_hook('layout_update_pre', $this, $layout_id, $layout_data, $create); // Create layout if (empty($layout_id)) { $company_id = !empty($layout_data['company_id']) ? $layout_data['company_id'] : 0; if (!empty($layout_data['from_layout_id'])) { $layout_data['style_id'] = Styles::factory($theme_name)->getStyle($layout_data['from_layout_id']); } if (!empty($layout_data['style_id']) && !isset($available_styles[$layout_data['style_id']])) { unset($layout_data['style_id']); } if (empty($layout_data['style_id'])) { $layout_data['style_id'] = Styles::factory($theme_name)->getDefault(); } $layout_id = db_query("INSERT INTO ?:bm_layouts ?e", $layout_data); } else { if (isset($layout_data['style_id']) && !isset($available_styles[$layout_data['style_id']])) { $layout_data['style_id'] = Styles::factory($theme_name)->getDefault(); } $old_layout_data = $this->get($layout_id); if ($old_layout_data['is_default'] == 1 && empty($layout_data['is_default'])) { $layout_data['is_default'] = 1; } db_query('UPDATE ?:bm_layouts SET ?u WHERE layout_id = ?i', $layout_data, $layout_id); } if (!empty($layout_data['is_default'])) { $this->setDefault($layout_id); } if (!empty($layout_data['from_layout_id'])) { $this->copyById($layout_data['from_layout_id'], $layout_id); } return $layout_id; }
/** * Sets area to display templates from * @param string $area area name (C,A) * @param string $area_type area type (can be mail of empty) * @param integer $company_id company ID */ public function setArea($area, $area_type = '', $company_id = null) { if (fn_allowed_for('MULTIVENDOR') && is_null($company_id) && !Registry::get('runtime.company_id')) { $company_id = 0; } if ($area_type == 'mail') { $path = fn_get_theme_path('[themes]/[theme]/mail', $area, $company_id); $path_rel = fn_get_theme_path('[relative]/[theme]/mail', $area, $company_id); if ($area == 'A') { $c_prefix = 'backend/mail'; } else { $c_prefix = fn_get_theme_path('[theme]/mail', $area, $company_id); } } else { $path = fn_get_theme_path('[themes]/[theme]', $area, $company_id); $path_rel = fn_get_theme_path('[relative]/[theme]', $area, $company_id); if ($area == 'A') { $c_prefix = 'backend'; } else { $c_prefix = fn_get_theme_path('[theme]', $area, $company_id); } } $suffix = '/templates'; $this->template_area = $area . (!empty($area_type) ? '_' . $area_type : ''); $this->setTemplateDir($path . $suffix); $this->setConfigDir($path . $suffix); $this->_area = $area; $this->_area_type = $area_type; $compile_dir = Registry::get('config.dir.cache_templates') . $c_prefix; if (!is_dir($compile_dir)) { if (fn_mkdir($compile_dir) == false) { throw new PermissionsException("Can't create templates cache directory: <b>" . $compile_dir . '</b>.<br>Please check if it exists, and has writable permissions.'); } } $this->setCompileDir($compile_dir); $this->setCacheDir($compile_dir); $this->assign('images_dir', Registry::get('config.current_location') . '/' . $path_rel . '/media/images'); $this->assign('logos', fn_get_logos($company_id)); }
function fn_get_customer_layout_theme_path() { $company_id = null; if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) { $company_id = db_get_field("SELECT MIN(company_id) FROM ?:companies"); } $theme_name = fn_get_theme_path('[theme]', 'C', $company_id); $theme_path = fn_get_theme_path('[themes]/[theme]', 'C', $company_id); return array($theme_path, $theme_name); }
if (!empty($company_id)) { $company_data['logos'] = fn_get_logos($company_id); } Tygh::$app['view']->assign('logo_types', fn_get_logo_types(true)); } $restored_company_data = fn_restore_post_data('company_data'); if (!empty($restored_company_data) && $mode == 'add') { if (!empty($restored_company_data['shippings'])) { $restored_company_data['shippings'] = implode(',', $restored_company_data['shippings']); } $company_data = fn_array_merge($company_data, $restored_company_data); } if (fn_allowed_for('ULTIMATE')) { if ($mode == 'update') { $available_themes = fn_get_available_themes(fn_get_theme_path('[theme]', 'C', $company_id)); $theme_name = fn_get_theme_path('[theme]', 'C', $company_id); $layout = Layout::instance($company_id)->getDefault($theme_name); $style = Styles::factory($theme_name)->get($layout['style_id']); Tygh::$app['view']->assign('current_style', $style); Tygh::$app['view']->assign('theme_info', $available_themes['current']); } $countries_list = fn_get_simple_countries(); if (!empty($company_data['countries_list'])) { if (!is_array($company_data['countries_list'])) { $company_countries = explode(',', $company_data['countries_list']); } else { $company_countries = $company_data['countries_list']; } $_countries = array(); foreach ($company_countries as $code) { if (isset($countries_list[$code])) {
} 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()); }
/** * Updates or creates layout * @param array $layout_data layout data * @param int $layout_id layout ID to update, zero to create * @return int ID of updated/created layout */ public function update($layout_data, $layout_id = 0) { if (fn_allowed_for('ULTIMATE')) { if (empty($layout_data['company_id'])) { $layout_data['company_id'] = $this->_company_id; } } $theme_name = empty($layout_data['theme_name']) ? fn_get_theme_path('[theme]', 'C', $this->_company_id, false) : $layout_data['theme_name']; $available_styles = Styles::factory($theme_name)->getList(array('short_info' => true)); if (empty($layout_id)) { if (!empty($layout_data['from_layout_id'])) { $layout_data['style_id'] = Styles::factory($theme_name)->getStyle($layout_data['from_layout_id']); } if (!empty($layout_data['style_id']) && !isset($available_styles[$layout_data['style_id']])) { unset($layout_data['style_id']); } if (empty($layout_data['style_id'])) { $layout_data['style_id'] = Styles::factory($theme_name)->getDefault(); } $layout_id = db_query("INSERT INTO ?:bm_layouts ?e", $layout_data); // Create logos $types = fn_get_logo_types(); foreach ($types as $type => $data) { if (!empty($data['for_layout'])) { $object_ids[$type] = fn_create_logo(array('type' => $type, 'layout_id' => $layout_id), !empty($layout_data['company_id']) ? $layout_data['company_id'] : 0); } } } else { if (isset($layout_data['style_id']) && !isset($available_styles[$layout_data['style_id']])) { $layout_data['style_id'] = Styles::factory($theme_name)->getDefault(); } db_query("UPDATE ?:bm_layouts SET ?u WHERE layout_id = ?i", $layout_data, $layout_id); } if (!empty($layout_data['is_default'])) { $this->setDefault($layout_id); } if (!empty($layout_data['from_layout_id'])) { $this->copyById($layout_data['from_layout_id'], $layout_id); } return $layout_id; }
/** * Get customer images path */ public static final function getImagesPath() { $theme_path = fn_get_theme_path('[relative]/[theme]', 'C', fn_twg_get_current_company_id()); $path = $theme_path . '/media/images/addons/twigmo/images/'; return $path; }
function fn_update_company($company_data, $company_id = 0, $lang_code = CART_LANGUAGE) { $can_update = true; /** * Update company data (running before fn_update_company() function) * * @param array $company_data Company data * @param int $company_id Company identifier * @param string $lang_code Two-letter language code (e.g. 'en', 'ru', etc.) * @param boolean $can_update Flag, allows addon to forbid to create/update company */ fn_set_hook('update_company_pre', $company_data, $company_id, $lang_code, $can_update); if ($can_update == false) { return false; } if (fn_allowed_for('MULTIVENDOR') && Registry::get('runtime.company_id')) { unset($company_data['comission'], $company_data['comission_type'], $company_data['categories'], $company_data['shippings']); } elseif (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { unset($company_data['storefront'], $company_data['secure_storefront']); } if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) { if (isset($company_data['storefront'])) { if (empty($company_data['storefront'])) { fn_set_notification('E', __('error'), __('storefront_url_not_defined')); return false; } else { if (empty($company_data['secure_storefront'])) { $company_data['secure_storefront'] = $company_data['storefront']; } $company_data['storefront'] = Url::clean($company_data['storefront']); $company_data['secure_storefront'] = Url::clean($company_data['secure_storefront']); } } } unset($company_data['company_id']); $_data = $company_data; if (fn_allowed_for('MULTIVENDOR')) { // Check if company with same email already exists $is_exist = db_get_field("SELECT email FROM ?:companies WHERE company_id != ?i AND email = ?s", $company_id, $_data['email']); if (!empty($is_exist)) { $_text = 'error_vendor_exists'; fn_set_notification('E', __('error'), __($_text)); return false; } } if (fn_allowed_for('ULTIMATE') && !empty($company_data['storefront'])) { // Check if company with the same Storefront URL already exists $http_exist = db_get_row('SELECT company_id, storefront FROM ?:companies WHERE storefront = ?s', $company_data['storefront']); $https_exist = db_get_row('SELECT company_id, secure_storefront FROM ?:companies WHERE secure_storefront = ?s', $company_data['secure_storefront']); if (!empty($http_exist) || !empty($https_exist)) { if (empty($company_id)) { if (!empty($http_exist)) { fn_set_notification('E', __('error'), __('storefront_url_already_exists')); } else { fn_set_notification('E', __('error'), __('secure_storefront_url_already_exists')); } return false; } elseif (!empty($http_exist) && $company_id != $http_exist['company_id'] || !empty($https_exist) && $company_id != $https_exist['company_id']) { if (!empty($http_exist) && $company_id != $http_exist['company_id']) { fn_set_notification('E', __('error'), __('storefront_url_already_exists')); unset($_data['storefront']); } else { fn_set_notification('E', __('error'), __('secure_storefront_url_already_exists')); unset($_data['secure_storefront']); } return false; } } } if (isset($company_data['shippings'])) { $_data['shippings'] = empty($company_data['shippings']) ? '' : fn_create_set($company_data['shippings']); } if (!empty($_data['countries_list'])) { $_data['countries_list'] = implode(',', $_data['countries_list']); } else { $_data['countries_list'] = ''; } // add new company if (empty($company_id)) { // company title can't be empty if (empty($company_data['company'])) { fn_set_notification('E', __('error'), __('error_empty_company_name')); return false; } $_data['timestamp'] = TIME; $company_id = db_query("INSERT INTO ?:companies ?e", $_data); if (empty($company_id)) { return false; } $_data['company_id'] = $company_id; foreach (fn_get_translation_languages() as $_data['lang_code'] => $_v) { db_query("INSERT INTO ?:company_descriptions ?e", $_data); } $action = 'add'; // update company information } else { if (isset($company_data['company']) && empty($company_data['company'])) { unset($company_data['company']); } if (!empty($_data['status'])) { $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id); } db_query("UPDATE ?:companies SET ?u WHERE company_id = ?i", $_data, $company_id); if (isset($status_from) && $status_from != $_data['status']) { fn_companies_change_status($company_id, $_data['status'], '', $status_from, true); } // unset data lang code as it determines company main language not description language unset($_data['lang_code']); db_query("UPDATE ?:company_descriptions SET ?u WHERE company_id = ?i AND lang_code = ?s", $_data, $company_id, $lang_code); $action = 'update'; } /** * Update company data (running after fn_update_company() function) * * @param array $company_data Company data * @param int $company_id Company integer identifier * @param string $lang_code Two-letter language code (e.g. 'en', 'ru', etc.) * @param string $action Flag determines if company was created (add) or just updated (update). */ fn_set_hook('update_company', $company_data, $company_id, $lang_code, $action); $logo_ids = array(); if ($action == 'add') { $theme_name = !empty($company_data['theme_name']) ? $company_data['theme_name'] : Registry::get('config.base_theme'); if (fn_allowed_for('ULTIMATE')) { $clone_from = !empty($company_data['clone_from']) && $company_data['clone_from'] != 'all' ? $company_data['clone_from'] : null; if (!is_null($clone_from)) { $theme_name = fn_get_theme_path('[theme]', 'C', $clone_from); } } if (fn_allowed_for('ULTIMATE')) { $logo_ids = fn_install_theme($theme_name, $company_id, false); } else { $logo_ids = fn_create_theme_logos_by_layout_id($theme_name, 0, $company_id, true); } } fn_attach_image_pairs('logotypes', 'logos', 0, $lang_code, $logo_ids); return $company_id; }
public static function copyPresetImages() { $theme_name = Registry::get('config.base_theme'); $presets_path = fn_get_theme_path('[themes]/' . $theme_name . '/presets/data', 'C'); $preset_images_path = fn_get_theme_path('[themes]/' . $theme_name . '/media/images/patterns', 'C'); $files = fn_get_dir_contents($presets_path, false, true); foreach ($files as $file) { $content = fn_get_contents($presets_path . '/' . $file); if (preg_match('/@general_bg_image\\: url\\(["]?(.*?)["]?\\)/', $content, $m)) { $image_name = fn_basename($m[1]); if (strpos($image_name, '?') !== false) { list($image_name) = explode('?', $image_name); } if (file_exists($preset_images_path . '/' . $image_name)) { $preset_dir = str_replace('.less', '', $file); $new_path = $preset_images_path . '/' . $preset_dir; fn_mkdir($new_path); fn_copy($preset_images_path . '/' . $image_name, $new_path); $content = str_replace($image_name, $preset_dir . '/' . $image_name, $content); fn_put_contents($presets_path . '/' . $file, $content); } } } return true; }
$order_info['path_stamp'] = fn_get_image_pairs($order_info['payment_id'], 'stamp', 'M', true, true, DESCR_SL); $order_info['text_invoice_payment'] = __("addons.rus_payments.text_invoice_payment", array('[number_account]' => $order_info['order_id'], '[invoice_data]' => $invoice_date)); $view = Tygh::$app['view']; //fn_set_notification('I','view>',print_r($view)); $view->assign('total_print', $total_print); $view->assign('order_info', $order_info); $view->assign('fonts_path', fn_get_theme_path('[relative]/[theme]/media/fonts')); if ($order_info['shipping_cost'] != 0) { $view->assign('shipping_cost', true); } if ($mode == "send_account_payment") { if (!empty($order_info['email'])) { fn_disable_live_editor_mode(); $html = array($view->displayMail('addons/rus_payments/print_invoice_payment.tpl', false, 'C')); Pdf::render($html, fn_get_files_dir_path() . 'account_payment.pdf', 'save'); $data = array('order_info' => $order_info, 'total_print' => $total_print, 'fonts_path' => fn_get_theme_path('[relative]/[theme]/media/fonts')); Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'default_company_orders_department', 'data' => $data, 'attachments' => array(fn_get_files_dir_path() . 'account_payment.pdf'), 'tpl' => 'addons/rus_payments/print_invoice_payment.tpl', 'is_html' => true), 'A'); fn_set_notification('N', __('notice'), __('text_email_sent')); } } else { $view->assign('show_print_button', true); $view->displayMail('addons/rus_payments/print_invoice_payment.tpl', true, 'C'); } exit; } elseif ($mode == 'get_stamp') { Header("Content-Type: image/png"); Header("Content-Type: image/jpg"); Header("Content-Type: image/jpeg"); Header("Content-Type: image/gif"); $path_stamp = fn_get_image_pairs($_REQUEST['payment_id'], 'stamp', 'M', true, true, DESCR_SL); $image = fn_get_contents($path_stamp['icon']['absolute_path']);
/** * 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; }
/** * Gets root directory * @param string $type path type: full - full path, rel - relative path from root directory, repo - repository path * @return string path */ function fn_te_get_root($type) { if (fn_allowed_for('MULTIVENDOR') || Registry::get('runtime.company_id')) { $extra_path = '[theme]/'; } else { $extra_path = ''; } if ($type == 'full') { $path = fn_get_theme_path('[themes]/' . $extra_path, 'C'); } elseif ($type == 'rel') { $path = fn_get_theme_path('/[relative]/' . $extra_path, 'C'); } elseif ($type == 'repo') { $path = fn_get_theme_path('[repo]/' . $extra_path, 'C'); } fn_set_hook('te_get_root', $type, $path); return $path; }
$image_path = 'sess_data/' . fn_basename($_REQUEST['image']); if (Storage::instance('custom_files')->isExist($image_path)) { $real_path = Storage::instance('custom_files')->getAbsolutePath($image_path); list(, , $image_type, $tmp_path) = fn_get_image_size($real_path); if ($type == 'T') { $thumb_path = $image_path . '_thumb'; if (!Storage::instance('custom_files')->isExist($thumb_path)) { // Output a thumbnail image list($cont, $format) = fn_resize_image($tmp_path, Registry::get('settings.Thumbnails.product_lists_thumbnail_width'), Registry::get('settings.Thumbnails.product_lists_thumbnail_height'), Registry::get('settings.Thumbnails.thumbnail_background_color')); if (!empty($cont)) { Storage::instance('custom_files')->put($thumb_path, array('contents' => $cont)); } } $real_path = Storage::instance('custom_files')->getAbsolutePath($thumb_path); } header('Content-type: ' . $image_type); fn_echo(fn_get_contents($real_path)); exit; } // Not image file. Display spacer instead. header('Content-type: image/gif'); readfile(fn_get_theme_path('[themes]/[theme]') . '/media/images/spacer.gif'); exit; } elseif ($mode == 'thumbnail') { $img = fn_generate_thumbnail($_REQUEST['image_path'], $_REQUEST['w'], $_REQUEST['h']); if (!empty($img)) { header('Content-type: ' . fn_get_file_type($img)); fn_echo(fn_get_contents($img)); } exit; }
/** * Converts CSS property ( url("../a.png") ) to URL (http://e.com/a.png) * @param array $style_data style data * @return array modified parsed style data vars */ private function cssToUrl($style_data) { $url = Registry::get('config.current_location') . '/' . fn_get_theme_path('[relative]/[theme]/'); $parsed = array(); if (!empty($this->schema['backgrounds']['fields'])) { foreach ($this->schema['backgrounds']['fields'] as $field) { if (!empty($field['properties']['pattern'])) { $var_name = $field['properties']['pattern']; if (!empty($style_data[$var_name]) && strpos($style_data[$var_name], 'url(') !== false) { $parsed[$var_name] = fn_normalize_path(preg_replace('/url\\([\'"]?\\.\\.\\/(.*?)[\'"]?\\)/', $url . '$1', $style_data[$var_name])); if (strpos($parsed[$var_name], '?') === false) { $parsed[$var_name] .= '?' . TIME; } } } } } return $parsed; }
/** * Parse LESS markup and generate CSS with native nodejs parser * @param string $less_output LESS markup * @param string $area current working area * @return string generated CSS */ private static function parseWithNodeJs($less_output, $area = AREA) { $output = ''; $cmd = 'lessc -'; $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array('pipe', 'w')); chdir(fn_get_theme_path('[themes]/[theme]/css', $area)); $process = proc_open($cmd, $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $less_output); // file_get_contents('php://stdin') fclose($pipes[0]); $output = stream_get_contents($pipes[1]); $errors = stream_get_contents($pipes[2]); if (!empty($errors)) { fn_print_die($errors); } fclose($pipes[1]); $return_value = proc_close($process); } return $output; }