function fn_blocks_get_vendor_info() { $company_id = isset($_REQUEST['company_id']) ? $_REQUEST['company_id'] : null; $company_data = fn_get_company_data($company_id); $company_data['logos'] = fn_get_logos($company_id); return $company_data; }
function fn_get_company_logo_url($data) { $logos = fn_get_logos(); $image = fn_image_to_display($logos['theme']['image'], 144); //max width = 144, height = 400 according to rss specification $image = array('url' => $image['image_path'], 'title' => $data['title'], 'link' => $data['link'], 'width' => $image['width'], 'height' => $image['height']); return $image; }
function fn_get_company_logo_url($data) { $logos = fn_get_logos(); $image = fn_image_to_display($logos['theme']['image'], 144); //max width = 144, height = 400 according to rss specification if (!empty($image)) { $image = array('url' => !empty($image['image_path']) ? $image['image_path'] : Registry::get('config.http_location') . '/images/no_image.png', 'title' => $data['title'], 'link' => $data['link'], 'width' => $image['width'], 'height' => $image['height']); } return $image; }
fn_add_breadcrumb(__('all_vendors'), 'companies.catalog'); fn_add_breadcrumb($company_data['company']); $company_data['total_products'] = count(db_get_fields(fn_get_products(array('get_query' => true, 'company_id' => $_REQUEST['company_id'])))); $company_data['logos'] = fn_get_logos($company_data['company_id']); Registry::set('navigation.tabs', array('description' => array('title' => __('description'), 'js' => true))); $params = array('company_id' => $_REQUEST['company_id']); Tygh::$app['view']->assign('company_data', $company_data); } elseif ($mode == 'catalog') { fn_add_breadcrumb(__('all_vendors')); $params = $_REQUEST; $params['status'] = 'A'; $params['get_description'] = 'Y'; $vendors_per_page = Registry::get('settings.Vendors.vendors_per_page'); list($companies, $search) = fn_get_companies($params, $auth, $vendors_per_page); foreach ($companies as &$company) { $company['logos'] = fn_get_logos($company['company_id']); } Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search); } elseif ($mode == 'apply_for_vendor') { if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') { return array(CONTROLLER_STATUS_NO_PAGE); } $restored_company_data = fn_restore_post_data('company_data'); if ($restored_company_data) { Tygh::$app['view']->assign('company_data', $restored_company_data); } $restored_user_data = fn_restore_post_data('user_data'); if ($restored_user_data) { Tygh::$app['view']->assign('user_data', $restored_user_data); }
$post_data['postal_code'] = $order_info['b_zipcode']; $post_data['city'] = $order_info['b_city']; $post_data['state'] = fn_get_state_name($order_info['b_state'], $order_info['b_country']); if (empty($post_data['state'])) { $post_data['state'] = $order_info['b_state']; } if (fn_strlen($post_data['state']) > 50) { $post_data['state'] = fn_substr($post_data['state'], 0, 47) . '...'; } $post_data['country'] = db_get_field('SELECT code_A3 FROM ?:countries WHERE code=?s', $order_info['b_country']); $post_data['phone_number'] = $order_info['phone']; if ($processor_data['processor_params']['quick_checkout'] == 'Y') { $post_data['payment_methods'] = !empty($processor_data['processor_params']['payment_methods']) ? '' : 'ACC'; $post_data['hide_login'] = '******'; } else { $post_data['payment_methods'] = 'WLT'; $post_data['hide_login'] = !empty($suffix) ? '1' : '0'; } // split_gateway if (!empty($processor_data['processor_params']['payment_methods'])) { $post_data['payment_methods'] .= (!empty($post_data['payment_methods']) ? ',' : '') . $processor_data['processor_params']['payment_methods']; } // /split_gateway // logo if (!(!empty($processor_data['processor_params']['do_not_pass_logo']) && $processor_data['processor_params']['do_not_pass_logo'] == 'Y')) { $logos = fn_get_logos(); $post_data['logo_url'] = $logos['theme']['image']['image_path']; } fn_create_payment_form($url, $post_data, 'Skrill'); exit; }
function fn_theme_editor($params, $lang_code = CART_LANGUAGE) { $view = Tygh::$app['view']; $theme_name = Registry::get('runtime.layout.theme_name'); $layout_id = Registry::get('runtime.layout.layout_id'); if (!Registry::get('runtime.layout.style_id')) { $default_style_id = Styles::factory($theme_name)->getDefault(); db_query('UPDATE ?:bm_layouts SET style_id = ?s WHERE layout_id = ?i', $default_style_id, $layout_id); Registry::set('runtime.layout.style_id', $default_style_id); } $style_id = Registry::get('runtime.layout.style_id'); // Backward presets compatibility Registry::set('runtime.layout.preset_id', $style_id); // get current style $current_style = Styles::factory($theme_name)->get($style_id, array('parse' => true)); // get all styles $styles_list = Styles::factory($theme_name)->getList(); $schema = Styles::factory($theme_name)->getSchema(); $sections = array('te_general' => 'theme_editor.general', 'te_logos' => 'theme_editor.logos', 'te_colors' => 'theme_editor.colors', 'te_fonts' => 'theme_editor.fonts', 'te_backgrounds' => 'theme_editor.backgrounds', 'te_css' => 'theme_editor.css'); foreach ($sections as $section_id => $section) { if ($section_id == 'te_logos') { // Logos is hardcoded section, no need to define it in schema continue; } $section_id = str_replace('te_', '', $section_id); if (!isset($schema[$section_id])) { unset($sections['te_' . $section_id]); } } if (empty($params['selected_section']) || !isset($sections[$params['selected_section']])) { reset($sections); $params['selected_section'] = key($sections); } $theme = Themes::factory($theme_name); $theme_manifest = $theme->getManifest(); if (!empty($theme_manifest['converted_to_css'])) { if (empty($params['selected_css_file'])) { $params['selected_css_file'] = Themes::$compiled_less_filename; } $view->assign('selected_css_file', $params['selected_css_file']); $view->assign('css_files_list', $theme->getCssFilesList()); $view->assign('css_content', $theme->getCssContents($params['selected_css_file'])); } $view->assign('cse_logo_types', fn_get_logo_types()); $view->assign('cse_logos', fn_get_logos(Registry::get('runtime.company_id'))); $view->assign('selected_section', $params['selected_section']); $view->assign('te_sections', $sections); $view->assign('current_style', $current_style); $view->assign('props_schema', $schema); $view->assign('theme_patterns', Patterns::instance()->get($style_id)); $view->assign('styles_list', $styles_list); // FIXME: Backward compatibility $view->assign('presets_list', $styles_list); $view->assign('current_preset', $current_style); $view->assign('manifest', Styles::factory($theme_name)->getManifest()); $view->assign('theme_manifest', $theme_manifest); $view->assign('layouts', Layout::instance()->getList(array('theme_name' => $theme_name))); $view->assign('layout_data', Layout::instance()->get($layout_id)); $view->assign('theme_url', fn_url(empty($params['theme_url']) ? '' : $params['theme_url'])); }
Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); } elseif ($mode == 'update' || $mode == 'add') { if ($mode == 'add' && fn_allowed_for('ULTIMATE:FREE')) { return array(CONTROLLER_STATUS_DENIED); } $company_id = !empty($_REQUEST['company_id']) ? $_REQUEST['company_id'] : 0; $company_data = !empty($company_id) ? fn_get_company_data($company_id) : array(); if ($mode == 'update' && empty($company_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } if (fn_allowed_for('MULTIVENDOR')) { 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);
function fn_facebook_prepare_meta_data($provider_data, $params) { $addon_settings = Settings::instance()->getValues('social_buttons', 'ADDON'); if (fn_allowed_for('ULTIMATE')) { $company_id = Registry::ifGet('runtime.company_id', fn_get_default_company_id()); $site_name = fn_get_company_name($company_id); } if ($params['object'] == 'products') { $product = Registry::get('view')->getTemplateVars('product'); $return = array('type' => !empty($product['facebook_product_type']) ? $product['facebook_product_type'] : '', 'title' => fn_sb_format_page_title(), 'url' => fn_url('products.view?product_id=' . $params['object_id']), 'image' => !empty($product['main_pair']['detailed']['http_image_path']) ? $product['main_pair']['detailed']['http_image_path'] : '', 'site_name' => !empty($site_name) ? $site_name : Registry::get('settings.Company.company_name'), 'app_id' => !empty($addon_settings['facebook']['facebook_app_id']) ? $addon_settings['facebook']['facebook_app_id'] : ''); } elseif ($params['object'] == 'pages') { $page = Registry::get('view')->getTemplateVars('page'); $logos = fn_get_logos(); if (fn_allowed_for('ULTIMATE')) { $logos = fn_get_logos($company_id); } $return = array('type' => !empty($page['facebook_obj_type']) ? $page['facebook_obj_type'] : '', 'title' => $page['page'], 'url' => !empty($page['link']) ? $page['link'] : fn_url('pages.view?product_id=' . $params['object_id']), 'image' => $logos['theme']['image']['http_image_path'], 'site_name' => !empty($site_name) ? $site_name : Registry::get('settings.Company.company_name'), 'app_id' => !empty($addon_settings['facebook']['facebook_app_id']) ? $addon_settings['facebook']['facebook_app_id'] : ''); } return $return; }
function fn_facebook_prepare_meta_data($provider_data, $params) { $addon_settings = Settings::instance()->getValues('social_buttons', 'ADDON'); if ($params['object'] == 'products') { $product = Tygh::$app['view']->getTemplateVars('product'); $return = array('type' => !empty($product['facebook_obj_type']) ? $product['facebook_obj_type'] : '', 'app_id' => !empty($addon_settings['facebook']['facebook_app_id']) ? $addon_settings['facebook']['facebook_app_id'] : ''); } elseif ($params['object'] == 'pages') { $page = Tygh::$app['view']->getTemplateVars('page'); $logos = fn_get_logos(); $return = array('type' => !empty($page['facebook_obj_type']) ? $page['facebook_obj_type'] : '', 'app_id' => !empty($addon_settings['facebook']['facebook_app_id']) ? $addon_settings['facebook']['facebook_app_id'] : ''); } return $return; }
/** * 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); 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); if (!empty($layout_data['from_layout_id'])) { $original_logos = fn_get_logos($company_id, $layout_data['from_layout_id']); } // Create logos $types = fn_get_logo_types(); foreach ($types as $type => $data) { if (!empty($data['for_layout'])) { $logo = array('type' => $type, 'layout_id' => $layout_id, 'style_id' => $layout_data['style_id']); if (!empty($original_logos[$type]['image']['absolute_path'])) { $logo['image_path'] = $original_logos[$type]['image']['absolute_path']; } $object_ids[$type] = fn_update_logo($logo, $company_id); } } } 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; }
if (!empty($layout['is_default'])) { // Re-init layout data fn_init_layout(array('s_layout' => $dst_layout_id)); } } // Update manifest if (file_exists($theme_path . '/' . THEME_MANIFEST)) { $manifest_content = fn_get_contents($theme_path . '/' . THEME_MANIFEST); $manifest = json_decode($manifest_content, true); } else { $manifest = parse_ini_file($theme_path . '/' . THEME_MANIFEST_INI); } $manifest['title'] = $_REQUEST['theme_data']['title']; $manifest['description'] = $_REQUEST['theme_data']['description']; // Put logos of current layout to manifest $logos = fn_get_logos(Registry::get('runtime.company_id')); foreach ($logos as $type => $logo) { if (!empty($logo['image'])) { $filename = fn_basename($logo['image']['relative_path']); Storage::instance('images')->export($logo['image']['relative_path'], $theme_path . '/media/images/' . $filename); $manifest[$type] = 'media/images/' . $filename; } } fn_put_contents($theme_path . '/' . THEME_MANIFEST, json_encode($manifest)); fn_install_theme($theme_dest, Registry::get('runtime.company_id'), false); } } else { fn_set_notification('W', __('warning'), __('warning_theme_clone_dir_exists')); } } elseif ($mode == 'upload') { $theme_pack = fn_filter_uploaded_data('theme_pack', Registry::get('config.allowed_pack_exts'));
/** * 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)); }
/** * Creates logos of missing logo types for given layout and style. * * @param int $layout_id Layout ID * @param string $style_id Style ID */ public function createMissedLogoTypesForLayout($layout_id, $style_id) { if ((fn_allowed_for('ULTIMATE') && !empty($this->company_id) || fn_allowed_for('MULTIVENDOR')) && !empty($layout_id) && !empty($style_id) && !empty($this->theme_name)) { $logos = fn_get_logos($this->company_id, $layout_id, $style_id); $logo_types = fn_get_logo_types(false); $missed_logo_types = array_diff_key($logo_types, $logos); if (!empty($missed_logo_types)) { fn_create_theme_logos_by_layout_id($this->theme_name, $layout_id, $this->company_id, false, $style_id, array_keys($missed_logo_types)); } } }
function fn_clone_layouts($data, $from, $to) { // We need to clone logos, not attached to any layout too $logos = fn_get_logos($from, 0); if (!empty($logos)) { Registry::set('runtime.allow_upload_external_paths', true); foreach ($logos as $type => $logo) { fn_create_logo(array('type' => $logo['type'], 'layout_id' => $logo['layout_id'], 'image_path' => !empty($logo['image']['absolute_path']) ? $logo['image']['absolute_path'] : ''), $to); } Registry::set('runtime.allow_upload_external_paths', false); } return Layout::instance($from)->copy($to); }
/** * Get default logo's url for twigmo */ public static final function getDefaultLogoUrl($company_id = null) { $company_id = !empty($company_id) ? $company_id : fn_twg_get_current_company_id(); $logos = fn_get_logos($company_id, fn_twg_get_default_layout_id()); return !empty($logos['theme']['image']['image_path']) ? $logos['theme']['image']['image_path'] : ''; }
/** * Change style id for specified layout * * @param int $layout_id Layout ID * @param string $style_id Style name (Like: "satori", "ocean", etc) * @return true if updated */ public function setStyle($layout_id, $style_id) { $result = db_query('UPDATE ?:bm_layouts SET style_id = ?s WHERE layout_id = ?i AND theme_name = ?s', $style_id, $layout_id, $this->theme_name); if ((fn_allowed_for('ULTIMATE') && !empty($this->company_id) || fn_allowed_for('MULTIVENDOR')) && !empty($layout_id) && !empty($style_id) && !empty($this->theme_name)) { $logos = fn_get_logos($this->company_id, $layout_id, $style_id); $logo_types = fn_get_logo_types(false); $have_missed = array_diff_key($logo_types, $logos); if (!empty($have_missed)) { fn_create_theme_logos_by_layout_id($this->theme_name, $layout_id, $this->company_id, false, $style_id); } } return $result; }
/** * Creates a clone of the theme. * * @param string $clone_name Name of the new theme * @param array $clone_data Array with "title" and "description" fields for the new theme * @param int $company_id ID of the owner company for the new theme * * @return bool Whether cloning has succeed */ public function cloneAs($clone_name, $clone_data = array(), $company_id = 0) { $cloned = new self($clone_name); if (file_exists($cloned->getThemePath())) { fn_set_notification('W', __('warning'), __('warning_theme_clone_dir_exists')); return false; } if (!fn_install_theme_files($this->getThemeName(), $cloned->getThemeName(), false)) { return false; } // Layouts that belong to the theme $layouts = Layout::instance()->getList(array('theme_name' => $this->getThemeName())); // Clone layouts one by one foreach ($layouts as $layout) { $src_layout_id = $layout['layout_id']; unset($layout['layout_id']); $layout['theme_name'] = $cloned->getThemeName(); $layout['from_layout_id'] = $src_layout_id; $dst_layout_id = Layout::instance()->update($layout); if (!empty($layout['is_default'])) { // Re-init layout data fn_init_layout(array('s_layout' => $dst_layout_id)); } } $manifest = $cloned->getManifest(); if (isset($clone_data['title'])) { $manifest['title'] = $clone_data['title']; } if (isset($clone_data['description'])) { $manifest['description'] = $clone_data['description']; } // Put logos of current layout to manifest $logos = fn_get_logos(Registry::get('runtime.company_id')); foreach ($logos as $type => $logo) { if (!empty($logo['image'])) { $filename = fn_basename($logo['image']['relative_path']); Storage::instance('images')->export($logo['image']['relative_path'], $cloned->getThemePath() . '/media/images/' . $filename); $manifest[$type] = 'media/images/' . $filename; } } $cloned->setManifest($manifest); $cloned->saveManifest(); fn_install_theme($cloned->getThemeName(), $company_id, false); $cloned->overrideSettings(null, $company_id); }