function fn_settings_variants_appearance_default_image_previewer() { $previewers_path = Registry::get('config.dir.root') . '/js/tygh/previewers'; $previewers = fn_get_dir_contents($previewers_path, false, true, 'js'); $return = array(); foreach ($previewers as $previewer) { $previewer_description = fn_get_file_description($previewers_path . '/' . $previewer, 'previewer-description'); $return[fn_basename($previewer, '.previewer.js')] = $previewer_description; } return $return; }
function fn_get_products_views($simple_mode = true, $active = false) { /** * Change params for getting product views * * @param boolean $simple_mode Flag that defines is product views should be returned in simple mode * @param boolean $active Flag that defines if only active views should be returned */ fn_set_hook('get_products_views_pre', $simple_mode, $active); $active_layouts = Registry::get('settings.Appearance.default_products_view_templates'); if (!is_array($active_layouts)) { parse_str($active_layouts, $active_layouts); } if (!array_key_exists(Registry::get('settings.Appearance.default_products_view'), $active_layouts)) { $active_layouts[Registry::get('settings.Appearance.default_products_view')] = 'Y'; } /*if (Registry::isExist('products_views') == true && AREA != 'A') { $products_views = Registry::get('products_views'); foreach ($products_views as &$view) { $view['title'] = __($view['title']); } if ($simple_mode) { $products_views = Registry::get('products_views'); foreach ($products_views as $key => $value) { $products_views[$key] = $value['title']; } } if ($active) { $products_views = array_intersect_key($products_views, $active_layouts); } return $products_views; }*/ $products_views = array(); list($theme_path, $theme_name) = fn_get_customer_layout_theme_path(); // Get all available product_list_templates dirs $templates_path[] = $theme_path . '/templates/blocks/product_list_templates'; foreach ((array) Registry::get('addons') as $addon_name => $data) { if ($data['status'] == 'A') { if (is_dir($theme_path . '/templates/addons/' . $addon_name . '/blocks/product_list_templates')) { $templates_path[] = $theme_path . '/templates/addons/' . $addon_name . '/blocks/product_list_templates'; } } } // Scan received directories and fill the "views" array foreach ($templates_path as &$path) { $view_templates = fn_get_dir_contents($path, false, true, 'tpl'); if (!empty($view_templates)) { foreach ($view_templates as &$file) { if ($file != '.' && $file != '..') { preg_match("/(.*" . fn_basename($theme_name) . "\\/templates\\/)(.*)/", $path, $matches); $_path = $matches[2] . '/' . $file; // Check if the template has inner description (like a "block manager") $tempalte_description = fn_get_file_description($path . '/' . $file, 'template-description', true); $_title = substr($file, 0, -4); $products_views[$_title] = array('template' => $_path, 'title' => empty($tempalte_description) ? $_title : $tempalte_description, 'active' => array_key_exists($_title, $active_layouts)); } } } } //Registry::set('products_views', $products_views); foreach ($products_views as &$view) { $view['title'] = __($view['title']); } if ($simple_mode) { foreach ($products_views as $key => $value) { $products_views[$key] = $value['title']; } } if ($active) { $products_views = array_intersect_key($products_views, $active_layouts); } /** * Change product views * * @param array $products_views Array of products views * @param boolean $simple_mode Flag that defines is product views should be returned in simple mode * @param boolean $active Flag that defines if only active views should be returned */ fn_set_hook('get_products_views_post', $products_views, $simple_mode, $active); return $products_views; }
/** * Create product tabs for addon * * @param string $addon Add-on name * @param string $tab_order Tab order prepend|append * @param string $lang_code 2 letter language code * @return bool */ public function createAddonTabs($addon, $tab_order = 'append', $lang_code = DESCR_SL) { $repo_path = fn_get_theme_path('[repo]/[theme]/templates/', 'C', $this->_company_id); $themes_path = fn_get_theme_path('[themes]/[theme]/templates/', 'C', $this->_company_id); $addon_path = 'addons/' . $addon . '/blocks/product_tabs'; $repo_tabs_blocks = fn_get_dir_contents($repo_path . $addon_path, false, true, '.tpl', $repo_path . $addon_path . '/'); $theme_tabs_blocks = fn_get_dir_contents($themes_path . $addon_path, false, true, '.tpl', $themes_path . $addon_path . '/'); $tabs_blocks = array_merge($repo_tabs_blocks, $theme_tabs_blocks); $created_tabs = array(); if (!empty($tabs_blocks)) { foreach ($tabs_blocks as $template) { $addon_template = $addon_path . '/' . fn_basename($template); if (!isset($created_tabs[$addon_template])) { $name = fn_get_file_description($template, 'block-description', true); $position = $this->getMaxPosition() + 1; if ($tab_order == 'prepend') { $position = 0; } $tab_data = array('name' => __($name), 'tab_type' => 'T', 'position' => $position, 'status' => 'D', 'addon' => $addon, 'template' => $addon_template, 'is_primary' => 'Y', 'lang_code' => $lang_code, 'company_id' => $this->_company_id); $tab_id = $this->update($tab_data); foreach (fn_get_translation_languages() as $lang_code => $v) { $this->_updateDescription($tab_id, array('lang_code' => $lang_code, 'name' => __($name, array(), $lang_code))); } $created_tabs[$addon_template] = 1; } } return true; } return false; }
/** * Generates template name from language value * from {*block-description: *} comment from template. * @static * @param string $path Path to template * @param string $theme_path Path to theme * @return string Name of template */ public static function generateTemplateName($path, $theme_path, $area = AREA) { $name = fn_get_file_description($theme_path . $path, 'block-description', true); if (empty($name)) { $name = fn_basename($path, '.tpl'); } if ($area == 'A') { $name = __($name); } return $name; }