public function getImageLink($name, $ids, $type = null) { global $protocol_content; if (empty($protocol_content)) { $protocol_content = _PS_SSL_ENABLED_ ? 'https://' : 'http://'; } // legacy mode or default image if (Configuration::get('PS_LEGACY_IMAGES') && file_exists(_PS_PROD_IMG_DIR_ . $ids . ($type ? '-' . $type : '') . '.jpg') || strpos($ids, 'default') !== false) { // if ($this->allow == 1) // $uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg'; // else // $uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').'.jpg'; $uri_path = _THEME_PROD_DIR_ . $ids . ($type ? '-' . $type : '') . '.jpg'; } else { // if ids if of the form id_product-id_image, we want to extract the id_image part $split_ids = explode('-', $ids); $id_image = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]; // if ($this->allow == 1) // $uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').'/'.$name.'.jpg'; // else // $uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'.jpg'; $uri_path = _THEME_PROD_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . '.jpg'; } return $protocol_content . Tools::getMediaServer($uri_path) . $uri_path; }
public function getImageLink($name, $ids, $type = null) { $context = Context::getContext(); // check if WebP support is enabled. if ($context->cookie->exists() && $context->cookie->WebPSupport) { $extension = '.webp'; } else { $extension = '.jpg'; } $not_default = false; // Check if module is installed, enabled, customer is logged in and watermark logged option is on if (Configuration::get('WATERMARK_LOGGED') && (Module::isInstalled('watermark') && Module::isEnabled('watermark')) && isset(Context::getContext()->customer->id)) { $type .= '-' . Configuration::get('WATERMARK_HASH'); } // legacy mode or default image $theme = Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_ . $ids . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . $extension) ? '-' . Context::getContext()->shop->id_theme : ''; if (Configuration::get('PS_LEGACY_IMAGES') && file_exists(_PS_PROD_IMG_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . $extension) || ($not_default = strpos($ids, 'default') !== false)) { if ($this->allow == 1 && !$not_default) { $uri_path = __PS_BASE_URI__ . $ids . ($type ? '-' . $type : '') . $theme . '/' . $name . $extension; } else { $uri_path = _THEME_PROD_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . $extension; } } else { // if ids if of the form id_product-id_image, we want to extract the id_image part $split_ids = explode('-', $ids); $id_image = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]; $theme = Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . $extension) ? '-' . Context::getContext()->shop->id_theme : ''; if ($this->allow == 1) { $uri_path = __PS_BASE_URI__ . $id_image . ($type ? '-' . $type : '') . $theme . '/' . $name . $extension; } else { $uri_path = _THEME_PROD_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . $theme . $extension; } } return $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path; }
public function getImageLink($name, $ids, $type = null, $overimage = null) { $not_default = false; $theme = Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_ . $ids . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . '.jpg') ? '-' . Context::getContext()->shop->id_theme : ''; if (Configuration::get('PS_LEGACY_IMAGES') && file_exists(_PS_PROD_IMG_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . '.jpg') || ($not_default = strpos($ids, 'default') !== false)) { if ($this->allow == 1 && !$not_default) { $uri_path = __PS_BASE_URI__ . $ids . ($type ? '-' . $type : '') . $theme . '/' . $name . '.jpg'; } else { $uri_path = _THEME_PROD_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . '.jpg'; } } else { $split_ids = explode('-', $ids); $id_image = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]; $theme = Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . '.jpg') ? '-' . Context::getContext()->shop->id_theme : ''; if (isset($overimage)) { $sql = "SELECT id_image FROM `" . _DB_PREFIX_ . "image` WHERE `id_product` = '{$overimage}' AND position = 2"; $getoverimage = Db::getInstance()->getRow($sql); if ($getoverimage) { $id_image = array_shift($getoverimage); } else { return false; } } if ($this->allow == 1) { $uri_path = __PS_BASE_URI__ . $id_image . ($type ? '-' . $type : '') . $theme . '/' . $name . '.jpg'; } else { $uri_path = _THEME_PROD_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . $theme . '.jpg'; } } return $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path; }
public function init() { if (parent::$initialized) { return; } $ret = parent::init(); // This override is part of the cloudcache module, so the cloudcache.php file exists require_once dirname(__FILE__) . '/../../modules/cloudcache/cloudcache.php'; // As parent::init() set the parent::$initialized flag, all below will be done only once. $module = new CloudCache(); if (!$module->active || !Configuration::get('CLOUDCACHE_API_ACTIVE')) { return $ret; } // Use global because 1.4 only, 1.5 is in an other file global $smarty; $assignArray = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_); $httHost = Tools::getHttpHost(); $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') && Tools::usingSecureMode() ? true : false; $protocol_content = $useSSL ? 'https://' : 'http://'; foreach ($assignArray as $assignKey => $assignValue) { if (substr($assignValue, 0, 1) == '/' || $protocol_content == 'https://') { $smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue); } else { $smarty->assign($assignKey, $assignValue); } } return $ret; }
public function hookDisplayTop($params) { if (!$this->isCached('blockbanner.tpl', $this->getCacheId())) { $imgname = Configuration::get('BLOCKBANNER_IMG', $this->context->language->id); if ($imgname && file_exists(_PS_MODULE_DIR_ . $this->name . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . $imgname)) { $this->smarty->assign('banner_img', $this->context->link->protocol_content . Tools::getMediaServer($imgname) . $this->_path . 'img/' . $imgname); } $this->smarty->assign(array('banner_link' => Configuration::get('BLOCKBANNER_LINK', $this->context->language->id), 'banner_desc' => Configuration::get('BLOCKBANNER_DESC', $this->context->language->id))); } return $this->display(__FILE__, 'blockbanner.tpl', $this->getCacheId()); }
/** * Returns the template's HTML header * @return string HTML header */ public function getHeader() { $shop_name = Configuration::get('PS_SHOP_NAME'); $path_logo = $this->getLogo(); $width = 0; $height = 0; if (!empty($path_logo)) { list($width, $height) = getimagesize($path_logo); } $this->smarty->assign(array('logo_path' => $path_logo, 'img_ps_dir' => 'http://' . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_, 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'title' => $this->title, 'date' => $this->date, 'shop_name' => $shop_name, 'width_logo' => $width, 'height_logo' => $height)); return $this->smarty->fetch($this->getTemplate('header')); }
protected function initialize() { $this->adv_imgname = 'advertising'; if ((Shop::getContext() == Shop::CONTEXT_GROUP || Shop::getContext() == Shop::CONTEXT_SHOP) && file_exists(_PS_MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '-g' . $this->context->shop->getContextShopGroupID() . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'))) { $this->adv_imgname .= '-g' . $this->context->shop->getContextShopGroupID(); } if (Shop::getContext() == Shop::CONTEXT_SHOP && file_exists(_PS_MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '-s' . $this->context->shop->getContextShopID() . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'))) { $this->adv_imgname .= '-s' . $this->context->shop->getContextShopID(); } $this->adv_img = Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'); $this->adv_link = htmlentities(Configuration::get('BLOCKADVERT_LINK'), ENT_QUOTES, 'UTF-8'); $this->adv_title = htmlentities(Configuration::get('BLOCKADVERT_TITLE'), ENT_QUOTES, 'UTF-8'); }
public function getContent() { $output = $this->postProcess() . ' <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" enctype="multipart/form-data"> <fieldset> <legend>' . $this->l('Store block configuration') . '</legend>'; if (Configuration::get('BLOCKSTORE_IMG')) { $output .= '<div class="margin-form"><img src="' . Tools::getProtocol() . Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/' . Configuration::get('BLOCKSTORE_IMG') . '" alt="' . $this->l('Store image') . '" style="height:115px;margin-left: 100px;width:174px"/></div>'; } $output .= ' <label for="store_img">' . $this->l('Change image') . '</label> <div class="margin-form"> <input id="store_img" type="file" name="store_img" /> ( ' . $this->l('image will be displayed as 174x115') . ' ) </div> <p class="center"> <input class="button" type="submit" name="submitStoreConf" value="' . $this->l('Save') . '"/> </p> </fieldset> </form> '; return $output; }
public function init() { global $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files; if (self::$initialized) { return; } self::$initialized = true; $css_files = array(); $js_files = array(); if ($this->ssl and (empty($_SERVER['HTTPS']) or strtolower($_SERVER['HTTPS']) == 'off') and Configuration::get('PS_SSL_ENABLED')) { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']); exit; } ob_start(); /* Loading default country */ $defaultCountry = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); $cookie = new Cookie('ps'); $link = new Link(); if ($this->auth and !$cookie->isLogged($this->guestAllowed)) { Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : '')); } /* Theme is missing or maintenance */ if (!is_dir(_PS_THEME_DIR_)) { die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.')); } elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' and !(int) Configuration::get('PS_SHOP_ENABLE')) { $this->maintenance = true; } elseif (Configuration::get('PS_GEOLOCATION_ENABLED')) { if (!isset($cookie->iso_code_country)) { if ($cookie->logged) { $id_country = Customer::getCurrentCountry((int) $cookie->id_customer); $cookie->iso_code_country = Country::getIsoById($id_country); } else { $this->geolocationManagement(); } } if (!isset($cookie->iso_code_country)) { $current_country_id = Customer::getCurrentCountry((int) $cookie->id_customer); } else { $current_country_id = Country::getByIso($cookie->iso_code_country); } $current_country = new Country($current_country_id, 1); $cookie->id_country = $current_country->id; $smarty->assign('current_country', $current_country->name); $smarty->assign('current_country_id', $current_country->id); if ($cookie->id_country == 110 && !isset($cookie->id_currency)) { $cookie->id_currency = 4; } } //set imagesize if not set if (!isset($cookie->image_size)) { $cookie->image_size = IMAGE_SIZE_LARGE; $cookie->write(); } if (!isset($cookie->greetings) && !$cookie->logged) { $cookie->greetings = 1; $cookie->write(); $smarty->assign('show_greetings', 1); } //echo $cookie->image_size; if ($image_size = Tools::getValue("is")) { if ($image_size == "s" && $cookie->image_size == IMAGE_SIZE_LARGE) { $cookie->image_size = IMAGE_SIZE_SMALL; $cookie->write(); } else { if ($image_size == "l" && $cookie->image_size == IMAGE_SIZE_SMALL) { $cookie->image_size = IMAGE_SIZE_LARGE; $cookie->write(); } } } // Switch language if needed and init cookie language if ($iso = Tools::getValue('isolang') and Validate::isLanguageIsoCode($iso) and $id_lang = (int) Language::getIdByIso($iso)) { $_GET['id_lang'] = $id_lang; } Tools::switchLanguage(); Tools::setCookieLanguage(); /* attribute id_lang is often needed, so we create a constant for performance reasons */ if (!defined('_USER_ID_LANG_')) { define('_USER_ID_LANG_', (int) $cookie->id_lang); } if (isset($_GET['logout']) or $cookie->logged and Customer::isBanned((int) $cookie->id_customer)) { $cookie->logout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL); } elseif (isset($_GET['mylogout'])) { $this->logoutFacebook(); $cookie->mylogout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL); } if ($source = Tools::getValue('utm_source')) { $cookie->last_source = $source; $cookie->write(); } if ($ref_source = Tools::getValue('vbref')) { $cookie->last_ref_source = $ref_source; $cookie->write(); } /*else { if(!isset($cookie->last_ref_source)) { $cookie->last_ref_source = 0; $cookie->write(); } }*/ global $currency; $currency = Tools::setCurrency(); $_MODULES = array(); /* Cart already exists */ if ((int) $cookie->id_cart) { $cart = new Cart((int) $cookie->id_cart); if ($cart->OrderExists()) { unset($cookie->id_cart, $cart, $cookie->checkedTOS); } elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) and !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) and $cart->nbProducts() and intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 and !self::isInWhitelistForGeolocation()) { unset($cookie->id_cart, $cart); } elseif ($cookie->id_customer != $cart->id_customer or $cookie->id_lang != $cart->id_lang or $cookie->id_currency != $cart->id_currency) { if ($cookie->id_customer) { $cart->id_customer = (int) $cookie->id_customer; } $cart->id_lang = (int) $cookie->id_lang; $cart->id_currency = (int) $cookie->id_currency; $cart->update(); } /* Select an address if not set */ if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $cookie->id_customer) { $to_update = false; if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) { $to_update = true; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); } if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) { $to_update = true; $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer); } if ($to_update) { $cart->update(); } } } if (!isset($cart) or !$cart->id) { $this->checkIDS(); $cart = new Cart(); $cart->id_lang = (int) $cookie->id_lang; $cart->id_currency = (int) $cookie->id_currency; $cart->id_guest = (int) $cookie->id_guest; if ($cookie->id_customer) { $cart->id_customer = (int) $cookie->id_customer; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); $cart->id_address_invoice = $cart->id_address_delivery; } else { $cart->id_address_delivery = 0; $cart->id_address_invoice = 0; } } if (!$cart->nbProducts()) { $cart->id_carrier = NULL; } $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')) . '_' . strtoupper(Configuration::get('PS_LOCALE_COUNTRY') . '.UTF-8'); setlocale(LC_COLLATE, $locale); setlocale(LC_CTYPE, $locale); setlocale(LC_TIME, $locale); setlocale(LC_NUMERIC, 'en_US.UTF-8'); if (Validate::isLoadedObject($currency)) { $smarty->ps_currency = $currency; } if (Validate::isLoadedObject($ps_language = new Language((int) $cookie->id_lang))) { $smarty->ps_language = $ps_language; } /* get page name to display it in body id */ $pathinfo = pathinfo(__FILE__); $page_name = basename($_SERVER['PHP_SELF'], '.' . $pathinfo['extension']); $page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name; $smarty->assign(Tools::getMetaTags($cookie->id_lang, $page_name)); $smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); /* Breadcrumb */ $navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>'; $smarty->assign('navigationPipe', $navigationPipe); $protocol_link = (Configuration::get('PS_SSL_ENABLED') or !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://'; $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED') or !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://'; if (!defined('_PS_BASE_URL_')) { define('_PS_BASE_URL_', Tools::getShopDomain(true)); } if (!defined('_PS_BASE_URL_SSL_')) { define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true)); } $link->preloadPageLinks(); $this->canonicalRedirection(); Product::initPricesComputation(); $display_tax_label = $defaultCountry->display_tax_label; if ($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) { $infos = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $country = new Country((int) $infos['id_country']); if (Validate::isLoadedObject($country)) { $display_tax_label = $country->display_tax_label; } } global $isBetaUser, $conversion_rate_inr; $conversion_rate_inr = 55; if (!$cookie->isLogged()) { $this->initFacebook(); } else { $customer_groups = Customer::getGroupsStatic((int) $cookie->id_customer); if (in_array(2, $customer_groups)) { $smarty->assign('internal_vb_user', 1); } if (in_array(3, $customer_groups)) { $isBetaUser = true; } else { $isBetaUser = false; } /*$reward_points = VBRewards::getCustomerPoints($cookie->id_customer); $can_redeem = VBRewards::checkPointsValidity($cookie->id_customer, 0); if($can_redeem) $smarty->assign('can_redeem_points', 1); $smarty->assign('balance_points', $reward_points);*/ } $smarty->assign('img_version', IMG_VERSION); $this->setRecaptchaHTML(); if ($page_name === "index") { $sql = "select title,image_path,url from ps_banner where is_active = 1 order by display_order asc"; $home_banners = Db::getInstance()->ExecuteS($sql); $smarty->assign("home_banners", $home_banners); } $smarty->assign(array('lazy' => 1, 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $cookie, 'page_name' => $page_name, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getShopDomain() . __PS_BASE_URI__, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => Language::getLanguages(), 'priceDisplay' => Product::getTaxCalculationMethod(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE'), 'conversion_rate' => $conversion_rate_inr)); // Deprecated $smarty->assign(array('id_currency_cookie' => (int) $currency->id, 'logged' => $cookie->isLogged(), 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false)); // TODO for better performances (cache usage), remove these assign and use a smarty function to get the right media server in relation to the full ressource name $assignArray = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_); foreach ($assignArray as $assignKey => $assignValue) { if (substr($assignValue, 0, 1) == '/' or $protocol_content == 'https://') { $smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue); } else { $smarty->assign($assignKey, $assignValue); } } // setting properties from global var self::$cookie = $cookie; self::$cart = $cart; self::$smarty = $smarty; self::$link = $link; if ($this->maintenance) { $this->displayMaintenancePage(); } if ($this->restrictedCountry) { $this->displayRestrictedCountryPage(); } //live edit if (Tools::isSubmit('live_edit') and $ad = Tools::getValue('ad') and Tools::getValue('liveToken') == sha1(Tools::getValue('ad') . _COOKIE_KEY_)) { if (!is_dir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $ad)) { die(Tools::displayError()); } } $this->iso = $iso; $this->setMedia(); //For sokrati pixel self::$smarty->assign("new_customer_regd", false); if ((int) self::$cookie->new_reg === 1) { self::$smarty->assign("new_customer_regd", true); unset(self::$cookie->new_reg); } if (self::$cookie->id_customer) { self::$smarty->assign("balance_points", VBRewards::getCustomerPoints(self::$cookie->id_customer)); } }
public function getImageLink($name, $ids, $type = NULL) { global $protocol_content; // legacy mode or default image if (Configuration::get('PS_LEGACY_IMAGES') && file_exists(_PS_PROD_IMG_DIR_ . $ids . ($type ? '-' . $type : '') . '.jpg') || strpos($ids, 'default') !== false) { $uri_path = _THEME_PROD_DIR_ . $ids . ($type ? '-' . $type : '') . '.jpg'; } else { // if ids if of the form id_product-id_image, we want to extract the id_image part $split_ids = explode('-', $ids); $id_image = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]; $uri_path = _THEME_PROD_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . '.jpg'; } return $protocol_content . Tools::getMediaServer($uri_path) . $uri_path; }
/** * Combine Compress and Cache (ccc) JS calls */ public static function cccJS() { global $js_files, $protocol_link; //inits $compressed_js_files_not_found = array(); $js_files_infos = array(); $js_files_date = 0; $compressed_js_file_date = 0; $compressed_js_filename = ''; $js_external_files = array(); // get js files infos foreach ($js_files as $filename) { $expr = explode(':', $filename); if ($expr[0] == 'http') { $js_external_files[] = $filename; } else { $infos = array(); $infos['uri'] = $filename; $url_data = parse_url($filename); $infos['path'] = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']); $js_files_infos[] = $infos; $js_files_date = max(file_exists($infos['path']) ? filemtime($infos['path']) : 0, $js_files_date); $compressed_js_filename .= $filename; } } // get compressed js file infos $compressed_js_filename = md5($compressed_js_filename); $compressed_js_path = _PS_THEME_DIR_ . 'cache/' . $compressed_js_filename . '.js'; $compressed_js_file_date = file_exists($compressed_js_path) ? filemtime($compressed_js_path) : 0; // aggregate and compress js files content, write new caches files if ($js_files_date > $compressed_js_file_date) { $content = ''; foreach ($js_files_infos as $file_infos) { if (file_exists($file_infos['path'])) { $content .= file_get_contents($file_infos['path']) . ';'; } else { $compressed_js_files_not_found[] = $file_infos['path']; } } $content = Tools::packJS($content); if (!empty($compressed_js_files_not_found)) { $content = '/* WARNING ! file(s) not found : "' . implode(',', $compressed_js_files_not_found) . '" */' . "\n" . $content; } file_put_contents($compressed_js_path, $content); chmod($compressed_js_path, 0777); } // rebuild the original js_files array $url = str_replace(_PS_ROOT_DIR_ . '/', __PS_BASE_URI__, $compressed_js_path); $js_files = array_merge(array($protocol_link . Tools::getMediaServer($url) . $url), $js_external_files); }
public function getCatImageLink($name, $id_category, $type = null) { if ($this->allow == 1 && $type) { $uri_path = __PS_BASE_URI__ . 'c/' . $id_category . '-' . $type . '/' . $name . '.jpg'; } else { $uri_path = _THEME_CAT_DIR_ . $id_category . ($type ? '-' . $type : '') . '.jpg'; } return $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path; }
public static function replaceByAbsoluteURL($matches) { global $current_css_file; $protocol_link = Tools::getCurrentUrlProtocolPrefix(); if (array_key_exists(1, $matches) && array_key_exists(2, $matches)) { if (!preg_match('/^(?:https?:)?\\/\\//iUs', $matches[2])) { $tmp = dirname($current_css_file) . '/' . $matches[2]; return $matches[1] . $protocol_link . Tools::getMediaServer($tmp) . $tmp; } else { return $matches[0]; } } return false; }
/** * postProcess update configuration * @TODO adding alt and title attributes for <img> and <a> * @var string * @return void */ public function postProcess() { global $currentIndex; $errors = ''; if (Tools::isSubmit('submitDeleteImgConf')) { $this->_deleteCurrentImg(); } if (Tools::isSubmit('submitAdvConf')) { $file = false; if (isset($_FILES['adv_img']) and isset($_FILES['adv_img']['tmp_name']) and !empty($_FILES['adv_img']['tmp_name'])) { if ($error = checkImage($_FILES['adv_img'], Tools::convertBytes(ini_get('upload_max_filesize')))) { $errors .= $error; } elseif ($dot_pos = strrpos($_FILES['adv_img']['name'], '.')) { // as checkImage tell us it's a good image, we'll just copy the extension $this->_deleteCurrentImg(); $this->adv_imgname = 'advertising'; $ext = substr($_FILES['adv_img']['name'], $dot_pos + 1); $newname = 'advertising_custom'; if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], _PS_MODULE_DIR_ . $this->name . '/' . $newname . '.' . $ext)) { $errors .= $this->l('Error move uploaded file'); } else { $this->adv_imgname = $newname; } Configuration::updateValue('BLOCKADVERT_IMG_EXT', $ext); $this->adv_img = Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'); } } if ($link = Tools::getValue('adv_link')) { Configuration::updateValue('BLOCKADVERT_LINK', $link); $this->adv_link = htmlentities($link, ENT_QUOTES, 'UTF-8'); } if ($title = Tools::getValue('adv_title')) { Configuration::updateValue('BLOCKADVERT_TITLE', $title); $this->adv_title = htmlentities($title, ENT_QUOTES, 'UTF-8'); } } if ($errors) { echo $this->displayError($errors); } }
/** * @see HTMLTemplate::getHeader() */ public function getHeader() { $shop_name = Configuration::get('PS_SHOP_NAME'); $this->smarty->assign(array('logo_path' => $this->getLogo(), 'img_ps_dir' => 'http://' . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_, 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'title' => $this->title, 'reference' => $this->supply_order->reference, 'date' => $this->date, 'shop_name' => $shop_name)); return $this->smarty->fetch($this->getTemplate('supply-order-header')); }
public function getWidgetVariables($hookName, array $params) { $imgname = Configuration::get('BANNER_IMG', $this->context->language->id); if ($imgname && file_exists(_PS_MODULE_DIR_ . $this->name . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . $imgname)) { $this->smarty->assign('banner_img', $this->context->link->protocol_content . Tools::getMediaServer($imgname) . $this->_path . 'img/' . $imgname); } $banner_link = Configuration::get('BANNER_LINK', $this->context->language->id); if (!$banner_link) { $banner_link = $this->context->link->getPageLink('index'); } return array('banner_link' => $banner_link, 'banner_desc' => Configuration::get('BANNER_DESC', $this->context->language->id)); }
public function getMediaLink($filepath) { return Tools::getProtocol(Tools::usingSecureMode() && _PS_SSL_ENABLED_) . Tools::getMediaServer($filepath) . $filepath; }
/** * postProcess update configuration * @TODO adding alt and title attributes for <img> and <a> * @var string * @return void */ public function postProcess() { global $currentIndex; $errors = ''; if (Tools::isSubmit('submitDeleteImgConf')) { $this->_deleteCurrentImg(); } if (Tools::isSubmit('submitAdvConf')) { $file = false; if (isset($_FILES['adv_img']) and isset($_FILES['adv_img']['tmp_name']) and !empty($_FILES['adv_img']['tmp_name'])) { if ($error = checkImage($_FILES['adv_img'], 4000000)) { $errors .= $error; } elseif ($dot_pos = strrpos($_FILES['adv_img']['name'], '.')) { // __DIR__ exists since php 5.3 $current_dir = defined(__DIR__) ? __DIR__ : dirname(__FILE__); // as checkImage tell us it's a good image, we'll just copy the extension $ext = substr($_FILES['adv_img']['name'], $dot_pos + 1); $newname = $this->adv_imgname . '.' . $ext; $this->_deleteCurrentImg(); if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], $current_dir . '/' . $newname)) { $errors .= $this->l('Error move uploaded file'); } Configuration::updateValue('BLOCKADVERT_IMG_EXT', $ext); $this->adv_img = Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'); } } if ($link = Tools::getValue('adv_link')) { Configuration::updateValue('BLOCKADVERT_LINK', $link); $this->adv_link = htmlentities($link, ENT_QUOTES, 'UTF-8'); } } if ($errors) { echo $this->displayError($errors); } }
public function hookHome() { if (isset($this->context->cookie->id_unisender)) { $this->smarty->assign('message', 'Вы уже подписаны'); } $imgname = Configuration::get('BLOCKBANNER_IMG_NEWS', $this->context->language->id); if ($imgname && file_exists(_PS_MODULE_DIR_ . $this->name . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . $imgname)) { $this->smarty->assign('banner_img', $this->context->link->protocol_content . Tools::getMediaServer($imgname) . $this->_path . 'img/' . $imgname); } $this->smarty->assign(array('banner_img' => Configuration::get('BLOCKBANNER_IMG_NEWS', $this->context->language->id), 'banner_title' => Configuration::get('BLOCKBANNER_LINK', $this->context->language->id), 'banner_collection_name' => Configuration::get('BLOCKBANNER_DESC', $this->context->language->id), 'banner_text' => Configuration::get('BLOCKBANNER_TEXT', $this->context->language->id), 'banner_discount' => Configuration::get('BLOCKBANNER_DISCOUNT', $this->context->language->id), 'banner_count_items' => Configuration::get('BLOCKBANNER_COUNT_ITEMS', $this->context->language->id))); if (Tools::isSubmit('email_confirmation')) { $code = Tools::getValue('email_confirmation'); if ($row = Db::getInstance()->getRow("select * from `" . _DB_PREFIX_ . "newsletter_confirmation` where `code` = '{$code}'")) { $params = array('api_key' => '58priw95sdjt7umw17ixbnkkkudtoq5u7nmfcacy', 'list_ids' => '4734062', 'fields[email]' => $row['email'], 'request_ip' => $row['ip'], 'request_time' => $row['date'], 'confirm_ip' => empty($_SERVER['HTTP_CLIENT_IP']) ? empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['HTTP_CLIENT_IP'], 'confirm_time' => date('Y-m-d H:i:s'), 'double_optin' => '3'); $ch = curl_init('http://api.unisender.com/ru/api/subscribe?format=json'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $response = curl_exec($ch); if ($response) { $response = json_decode($response); if (empty($response->error) && $response->result->person_id) { $this->smarty->assign('message', $this->l('Вы успешно подписаны')); $this->context->cookie->id_unisender = $response->result->person_id; DB::getInstance()->execute("DELETE FROM `" . _DB_PREFIX_ . "newsletter_confirmation` WHERE `email` = '{$row['email']}'"); } else { $this->smarty->assign('error', $this->l('Подписка не удалась')); } } else { $this->smarty->assign('error', $this->l('Подписка не удалась')); } } else { $this->smarty->assign('error', $this->l('Код подтверждения устарел')); } } return $this->display(__FILE__, 'blocknewsletter-home.tpl'); }
public static function replaceByAbsoluteURL($matches) { global $current_css_file; $protocol_link = Tools::getCurrentUrlProtocolPrefix(); if (array_key_exists(1, $matches) && array_key_exists(2, $matches)) { if (!preg_match('/^(?:https?:)?\\/\\//iUs', $matches[2])) { $sep = '/'; $tmp = substr($matches[2], 0, 1) == $sep ? $matches[2] : dirname($current_css_file) . $sep . ltrim($matches[2], $sep); $server = Tools::getMediaServer($tmp); return $matches[1] . $protocol_link . $server . $tmp; } else { return $matches[0]; } } return false; }
public function getMediaLink($filepath) { return Tools::getProtocol() . Tools::getMediaServer($filepath) . $filepath; }
public function getTemplateVarUrls() { $http = Tools::getCurrentUrlProtocolPrefix(); $base_url = $this->context->shop->getBaseURL(true, true); $urls = array('base_url' => $base_url, 'current_url' => $this->context->shop->getBaseURL(true, false) . $_SERVER['REQUEST_URI'], 'shop_domain_url' => $this->context->shop->getBaseURL(true, false)); $assign_array = array('img_ps_url' => _PS_IMG_, 'img_cat_url' => _THEME_CAT_DIR_, 'img_lang_url' => _THEME_LANG_DIR_, 'img_prod_url' => _THEME_PROD_DIR_, 'img_manu_url' => _THEME_MANU_DIR_, 'img_sup_url' => _THEME_SUP_DIR_, 'img_ship_url' => _THEME_SHIP_DIR_, 'img_store_url' => _THEME_STORE_DIR_, 'img_col_url' => _THEME_COL_DIR_, 'img_url' => _THEME_IMG_DIR_, 'css_url' => _THEME_CSS_DIR_, 'js_url' => _THEME_JS_DIR_, 'pic_url' => _THEME_PROD_PIC_DIR_); foreach ($assign_array as $assign_key => $assign_value) { if (substr($assign_value, 0, 1) == '/' || $this->ssl) { $urls[$assign_key] = $http . Tools::getMediaServer($assign_value) . $assign_value; } else { $urls[$assign_key] = $assign_value; } } $pages = array(); $p = array('address', 'addresses', 'authentication', 'cart', 'category', 'cms', 'contact', 'discount', 'guest-tracking', 'history', 'identity', 'index', 'my-account', 'order-confirmation', 'order-detail', 'order-follow', 'order', 'order-return', 'order-slip', 'pagenotfound', 'password', 'pdf-invoice', 'pdf-order-return', 'pdf-order-slip', 'prices-drop', 'product', 'search', 'sitemap', 'stores', 'supplier'); foreach ($p as $page_name) { $index = str_replace('-', '_', $page_name); $pages[$index] = $this->context->link->getPageLink($page_name, true); } $pages['register'] = $this->context->link->getPageLink('authentication', true, null, array('create_account' => '1')); $pages['order_login'] = $this->context->link->getPageLink('order', true, null, array('login' => '1')); $urls['pages'] = $pages; $urls['theme_assets'] = __PS_BASE_URI__ . 'themes/' . $this->context->shop->theme->getName() . '/assets/'; $urls['actions'] = array('logout' => $this->context->link->getPageLink('index', true, null, 'mylogout')); return $urls; }
public static function replaceByAbsoluteURL($matches) { global $current_css_file; $protocol_link = Tools::getCurrentUrlProtocolPrefix(); if (array_key_exists(1, $matches)) { $tmp = dirname($current_css_file) . '/' . $matches[1]; return 'url(\'' . $protocol_link . Tools::getMediaServer($tmp) . $tmp . '\')'; } return false; }
public function init() { if (parent::$initialized) { return; } $ret = parent::init(); if (!self::_isActive()) { return $ret; } $assign_array = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_); /* // Add the images directory for mobile */ /* if ($this->context->getMobileDevice() != false) */ /* $assign_array['img_mobile_dir'] = _THEME_MOBILE_IMG_DIR_; */ /* // Add the CSS directory for mobile */ /* if ($this->context->getMobileDevice() != false) */ /* $assign_array['css_mobile_dir'] = _THEME_MOBILE_CSS_DIR_; */ $httHost = Tools::getHttpHost(); $protocol_content = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://'; foreach ($assign_array as $assignKey => $assignValue) { if (substr($assignValue, 0, 1) == '/' || $protocol_content == 'https://') { $this->context->smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue); } else { $this->context->smarty->assign($assignKey, $assignValue); } } return $ret; }
/** * @param array $link_sitemap contain all the links for the Google Sitemap file to be generated * @param string $lang language of link to add * @param int $index index of the current Google Sitemap file * @param int $i count of elements added to sitemap main array * @param int $id_supplier supplier object identifier * * @return bool */ private function _getSupplierLink(&$link_sitemap, $lang, &$index, &$i, $id_supplier = 0) { $link = new Link(); if (method_exists('ShopUrl', 'resetMainDomainCache')) { ShopUrl::resetMainDomainCache(); } $suppliers_id = Db::getInstance()->ExecuteS('SELECT s.`id_supplier` FROM `' . _DB_PREFIX_ . 'supplier` s INNER JOIN `' . _DB_PREFIX_ . 'supplier_lang` sl ON s.`id_supplier` = sl.`id_supplier` ' . ($this->tableColumnExists(_DB_PREFIX_ . 'supplier_shop') ? 'INNER JOIN `' . _DB_PREFIX_ . 'supplier_shop` ss ON s.`id_supplier` = ss.`id_supplier`' : '') . ' WHERE s.`active` = 1 AND s.`id_supplier` > ' . (int) $id_supplier . ($this->tableColumnExists(_DB_PREFIX_ . 'supplier_shop') ? ' AND ss.`id_shop` = ' . (int) $this->context->shop->id : '') . ' AND sl.`id_lang` = ' . (int) $lang['id_lang'] . ' ORDER BY s.`id_supplier` ASC'); foreach ($suppliers_id as $supplier_id) { $supplier = new Supplier((int) $supplier_id['id_supplier'], $lang['id_lang']); $url = $link->getSupplierLink($supplier, $supplier->link_rewrite, $lang['id_lang']); $image_link = 'http://' . Tools::getMediaServer(_THEME_SUP_DIR_) . _THEME_SUP_DIR_ . (!file_exists(_THEME_SUP_DIR_ . '/' . (int) $supplier->id . '-medium_default.jpg') ? $lang['iso_code'] . '-default' : (int) $supplier->id) . '-medium_default.jpg'; $image_link = !in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link)) ? str_replace(array('https', Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri), array('http', Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri . Context::getContext()->shop->virtual_uri), $image_link) : $image_link; $file_headers = Configuration::get('GSITEMAP_CHECK_IMAGE_FILE') ? @get_headers($image_link) : true; $supplier_image = array(); if ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true) { $supplier_image = array('title_img' => htmlspecialchars(strip_tags($supplier->name)), 'link' => 'http' . (Configuration::get('PS_SSL_ENABLED') ? 's' : '') . '://' . Tools::getMediaServer(_THEME_SUP_DIR_) . _THEME_SUP_DIR_ . (!file_exists(_THEME_SUP_DIR_ . '/' . (int) $supplier->id . '-medium_default.jpg') ? $lang['iso_code'] . '-default' : (int) $supplier->id) . '-medium_default.jpg'); } if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'supplier', 'page' => 'supplier', 'lastmod' => $supplier->date_upd, 'link' => $url, 'image' => $supplier_image), $lang['iso_code'], $index, $i, $supplier_id['id_supplier'])) { return false; } } return true; }
public function init() { global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files; if (self::$initialized) { return; } self::$initialized = true; // If current URL use SSL, set it true (used a lot for module redirect) if (Tools::usingSecureMode()) { $useSSL = $this->ssl = true; } $css_files = array(); $js_files = array(); if ($this->ssl && !Tools::usingSecureMode() && _PS_SSL_ENABLED_) { header('HTTP/1.1 301 Moved Permanently'); header('Cache-Control: no-cache'); header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']); exit; } elseif (_PS_SSL_ENABLED_ && Tools::usingSecureMode() && !$this->ssl) { header('HTTP/1.1 301 Moved Permanently'); header('Cache-Control: no-cache'); header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']); exit; } ob_start(); /* Loading default country */ $defaultCountry = new Country((int) _PS_COUNTRY_DEFAULT_, (int) _PS_LANG_DEFAULT_); $cookie = new Cookie('ps', '', time() + ((int) Configuration::get('PS_COOKIE_LIFETIME_FO') > 0 ? (int) Configuration::get('PS_COOKIE_LIFETIME_FO') : 1) * 3600); $link = new Link(); if ($this->auth && !$cookie->isLogged($this->guestAllowed)) { Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : '')); } /* Theme is missing or maintenance */ if (!file_exists(_PS_THEME_DIR_)) { die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.')); } elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' && !(int) Configuration::get('PS_SHOP_ENABLE')) { $this->maintenance = true; } elseif (_PS_GEOLOCATION_ENABLED_) { $this->geolocationManagement(); } // Switch language if needed and init cookie language $iso = Tools::getValue('isolang'); if ($iso && Validate::isLanguageIsoCode($iso)) { $id_lang = (int) Language::getIdByIso($iso); if ($id_lang) { $_GET['id_lang'] = $id_lang; } } Tools::switchLanguage(); Tools::setCookieLanguage(); /* attribute id_lang is often needed, so we create a constant for performance reasons */ if (!defined('_USER_ID_LANG_')) { define('_USER_ID_LANG_', (int) $cookie->id_lang); } if (isset($_GET['logout']) || $cookie->logged && Customer::isBanned((int) $cookie->id_customer)) { $cookie->logout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); } elseif (isset($_GET['mylogout'])) { $cookie->mylogout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); } global $currency; $currency = Tools::setCurrency(); /* Cart already exists */ if ((int) $cookie->id_cart) { $cart = new Cart((int) $cookie->id_cart); if ($cart->OrderExists()) { unset($cookie->id_cart, $cart, $cookie->checkedTOS); } elseif (_PS_GEOLOCATION_ENABLED_ && !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && (int) Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') != -1 && !self::isInWhitelistForGeolocation()) { unset($cookie->id_cart, $cart); } elseif ($cookie->id_customer != $cart->id_customer || $cookie->id_lang != $cart->id_lang || $cookie->id_currency != $cart->id_currency) { if ($cookie->id_customer) { $cart->id_customer = (int) $cookie->id_customer; } $cart->id_lang = (int) $cookie->id_lang; $cart->id_currency = (int) $cookie->id_currency; $cart->update(); } /* Select an address if not set */ if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $cookie->id_customer) { $to_update = false; if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) { $to_update = true; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); } if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) { $to_update = true; $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer); } if ($to_update) { $cart->update(); } } } if (!isset($cart) || !$cart->id) { $cart = new Cart(); $cart->id_lang = (int) $cookie->id_lang; $cart->id_currency = (int) $cookie->id_currency; $cart->id_guest = (int) $cookie->id_guest; if ($cookie->id_customer) { $cart->id_customer = (int) $cookie->id_customer; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); $cart->id_address_invoice = $cart->id_address_delivery; } else { $cart->id_address_delivery = 0; $cart->id_address_invoice = 0; } } if (!$cart->nbProducts()) { $cart->id_carrier = null; } $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')) . '_' . strtoupper(Configuration::get('PS_LOCALE_COUNTRY') . '.UTF-8'); setlocale(LC_COLLATE, $locale); setlocale(LC_CTYPE, $locale); setlocale(LC_TIME, $locale); setlocale(LC_NUMERIC, 'en_US.UTF-8'); if (Validate::isLoadedObject($currency)) { $smarty->ps_currency = $currency; } if (Validate::isLoadedObject($ps_language = new Language((int) $cookie->id_lang))) { $smarty->ps_language = $ps_language; } /* get page name to display it in body id */ $page_name = isset($this->php_self) ? preg_replace('/\\.php$/', '', $this->php_self) : ''; if (preg_match('#^' . __PS_BASE_URI__ . '(|' . ((int) Configuration::get('PS_REWRITING_SETTINGS') && isset($smarty->ps_language) && !empty($smarty->ps_language) ? $smarty->ps_language->iso_code . '/' : '') . ')modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) { $page_name = 'module-' . $m[2] . '-' . str_replace(array('.php', '/'), array('', '-'), $m[3]); } $smarty->assign(Tools::getMetaTags($cookie->id_lang, $page_name)); $protocol_link = _PS_SSL_ENABLED_ || Tools::usingSecureMode() ? 'https://' : 'http://'; $useSSL = isset($this->ssl) && $this->ssl && _PS_SSL_ENABLED_ || Tools::usingSecureMode(); $protocol_content = $useSSL ? 'https://' : 'http://'; if (!defined('_PS_BASE_URL_')) { define('_PS_BASE_URL_', Tools::getShopDomain(true)); } if (!defined('_PS_BASE_URL_SSL_')) { define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true)); } $link->preloadPageLinks(); $this->canonicalRedirection(); Product::initPricesComputation(); $display_tax_label = $defaultCountry->display_tax_label; if (Validate::isLoadedObject($cart) && ($tmp = (int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})) { $infos = Address::getCountryAndState($tmp); $country = new Country((int) $infos['id_country']); if (Validate::isLoadedObject($country)) { $display_tax_label = $country->display_tax_label; } } $smarty->assign(array('request_uri' => Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])), 'navigationPipe' => Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>', 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $cookie, 'page_name' => $page_name, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => Language::getLanguages(), 'priceDisplay' => Product::getTaxCalculationMethod(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE'), 'id_currency_cookie' => (int) $currency->id, 'logged' => $cookie->isLogged(), 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false)); // TODO for better performances (cache usage), remove these assign and use a smarty function to get the right media server in relation to the full ressource name $assignArray = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_); foreach ($assignArray as $assignKey => $assignValue) { if (substr($assignValue, 0, 1) == '/' || $protocol_content == 'https://') { $smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue); } else { $smarty->assign($assignKey, $assignValue); } } // setting properties from global var self::$cookie = $cookie; self::$cart = $cart; self::$smarty = $smarty; self::$link = $link; if ($this->maintenance) { $this->displayMaintenancePage(); } if ($this->restrictedCountry) { $this->displayRestrictedCountryPage(); } /* Check Live Edit parameters */ if (Tools::isSubmit('live_edit')) { $ad = Tools::getValue('ad'); if (!$ad || Tools::getValue('liveToken') != sha1($ad . _COOKIE_KEY_) || !is_dir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $ad)) { die(Tools::displayError()); } } $this->iso = $iso; $this->setMedia(); }
/** * Combine Compress and Cache (ccc) JS calls * * @param array js_files * @return array processed js_files */ public static function cccJS($js_files) { //inits $compressed_js_files_not_found = array(); $js_files_infos = array(); $js_files_date = 0; $compressed_js_filename = ''; $js_external_files = array(); $protocol_link = Tools::getCurrentUrlProtocolPrefix(); $cache_path = _PS_THEME_DIR_ . 'cache/'; // get js files infos foreach ($js_files as $filename) { if (Validate::isAbsoluteUrl($filename)) { $js_external_files[] = $filename; } else { $infos = array(); $infos['uri'] = $filename; $url_data = parse_url($filename); $infos['path'] = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']); if (!@filemtime($info['path'])) { $infos['path'] = _PS_CORE_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']); } $js_files_infos[] = $infos; $js_files_date = max(file_exists($infos['path']) ? @filemtime($infos['path']) : 0, $js_files_date); $compressed_js_filename .= $filename; } } // get compressed js file infos $compressed_js_filename = md5($compressed_js_filename); $version = (int) Configuration::get('PS_CCCJS_VERSION'); $compressed_js_path = $cache_path . 'v_' . $version . '_' . $compressed_js_filename . '.js'; $compressed_js_file_date = file_exists($compressed_js_path) ? @filemtime($compressed_js_path) : 0; // aggregate and compress js files content, write new caches files if ($js_files_date > $compressed_js_file_date) { if ($compressed_js_file_date) { Configuration::updateValue('PS_CCCJS_VERSION', ++$version); } $compressed_js_path = $cache_path . 'v_' . $version . '_' . $compressed_js_filename . '.js'; $content = ''; foreach ($js_files_infos as $file_infos) { if (file_exists($file_infos['path'])) { $tmp_content = file_get_contents($file_infos['path']); if (preg_match('@\\.(min|pack)\\.[^/]+$@', $file_infos['path'], $matches)) { $content .= preg_replace('/\\/\\/@\\ssourceMappingURL\\=[_a-zA-Z0-9-.]+\\.' . $matches[1] . '\\.map\\s+/', '', $tmp_content); } else { $content .= Media::packJS($tmp_content); } } else { $compressed_js_files_not_found[] = $file_infos['path']; } } if (!empty($compressed_js_files_not_found)) { $content = '/* WARNING ! file(s) not found : "' . implode(',', $compressed_js_files_not_found) . '" */' . "\n" . $content; } file_put_contents($compressed_js_path, $content); chmod($compressed_js_path, 0777); } // rebuild the original js_files array if (strpos($compressed_js_path, _PS_ROOT_DIR_) !== false) { $url = str_replace(_PS_ROOT_DIR_ . '/', __PS_BASE_URI__, $compressed_js_path); } if (strpos($compressed_js_path, _PS_CORE_DIR_) !== false) { $url = str_replace(_PS_CORE_DIR_ . '/', __PS_BASE_URI__, $compressed_js_path); } return array_merge(array($protocol_link . Tools::getMediaServer($url) . $url), $js_external_files); }
/** * Assign common header data to smarty variables */ public function assignCommonHeaderData() { $this->setShopId(); $id_shop = (int) $this->shop->id; $shop_name = Configuration::get('PS_SHOP_NAME', null, null, $id_shop); $path_logo = $this->getLogo(); $width = 0; $height = 0; if (!empty($path_logo)) { list($width, $height) = getimagesize($path_logo); } // Limit the height of the logo for the PDF render $maximum_height = 100; if ($height > $maximum_height) { $ratio = $maximum_height / $height; $height *= $ratio; $width *= $ratio; } $this->smarty->assign(array('logo_path' => $path_logo, 'img_ps_dir' => 'http://' . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_, 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'date' => $this->date, 'title' => $this->title, 'shop_name' => $shop_name, 'shop_details' => Configuration::get('PS_SHOP_DETAILS', null, null, (int) $id_shop), 'width_logo' => $width, 'height_logo' => $height)); }
public function init() { /* * Globals are DEPRECATED as of version 1.5. * Use the Context to access objects instead. * Example: $this->context->cart */ global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency; if (self::$initialized) { return; } self::$initialized = true; parent::init(); // If current URL use SSL, set it true (used a lot for module redirect) if (Tools::usingSecureMode()) { $useSSL = true; } // For compatibility with globals, DEPRECATED as of version 1.5 $css_files = $this->css_files; $js_files = $this->js_files; // If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol if (Configuration::get('PS_SSL_ENABLED') && $_SERVER['REQUEST_METHOD'] != 'POST' && $this->ssl != Tools::usingSecureMode()) { header('HTTP/1.1 301 Moved Permanently'); header('Cache-Control: no-cache'); if ($this->ssl) { header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']); } else { header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']); } exit; } if ($this->ajax) { $this->display_header = false; $this->display_footer = false; } // if account created with the 2 steps register process, remove 'accoun_created' from cookie if (isset($this->context->cookie->account_created)) { $this->context->smarty->assign('account_created', 1); unset($this->context->cookie->account_created); } ob_start(); // Init cookie language // @TODO This method must be moved into switchLanguage Tools::setCookieLanguage($this->context->cookie); $protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://'; $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false; $protocol_content = $useSSL ? 'https://' : 'http://'; $link = new Link($protocol_link, $protocol_content); $this->context->link = $link; if ($id_cart = (int) $this->recoverCart()) { $this->context->cookie->id_cart = (int) $id_cart; } if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed)) { Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : '')); } /* Theme is missing */ if (!is_dir(_PS_THEME_DIR_)) { throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\')))); } if (Configuration::get('PS_GEOLOCATION_ENABLED')) { if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault)) { $this->context->country = $newDefault; } } $currency = Tools::setCurrency($this->context->cookie); if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) { $this->context->customer->logout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); } elseif (isset($_GET['mylogout'])) { $this->context->customer->mylogout(); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null); } /* Cart already exists */ if ((int) $this->context->cookie->id_cart) { $cart = new Cart($this->context->cookie->id_cart); if ($cart->OrderExists()) { unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS); $this->context->cookie->check_cgv = false; } elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 && !FrontController::isInWhitelistForGeolocation() && !in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) { unset($this->context->cookie->id_cart, $cart); } elseif ($this->context->cookie->id_customer != $cart->id_customer || $this->context->cookie->id_lang != $cart->id_lang || $currency->id != $cart->id_currency) { if ($this->context->cookie->id_customer) { $cart->id_customer = (int) $this->context->cookie->id_customer; } $cart->id_lang = (int) $this->context->cookie->id_lang; $cart->id_currency = (int) $currency->id; $cart->update(); } /* Select an address if not set */ if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) { $to_update = false; if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) { $to_update = true; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); } if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) { $to_update = true; $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer); } if ($to_update) { $cart->update(); } } } if (!isset($cart) || !$cart->id) { $cart = new Cart(); $cart->id_lang = (int) $this->context->cookie->id_lang; $cart->id_currency = (int) $this->context->cookie->id_currency; $cart->id_guest = (int) $this->context->cookie->id_guest; $cart->id_shop_group = (int) $this->context->shop->id_shop_group; $cart->id_shop = $this->context->shop->id; if ($this->context->cookie->id_customer) { $cart->id_customer = (int) $this->context->cookie->id_customer; $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer); $cart->id_address_invoice = $cart->id_address_delivery; } else { $cart->id_address_delivery = 0; $cart->id_address_invoice = 0; } // Needed if the merchant want to give a free product to every visitors $this->context->cart = $cart; CartRule::autoAddToCart($this->context); } else { $this->context->cart = $cart; } /* get page name to display it in body id */ // Are we in a payment module $module_name = ''; if (Validate::isModuleName(Tools::getValue('module'))) { $module_name = Tools::getValue('module'); } if (!empty($this->page_name)) { $page_name = $this->page_name; } elseif (!empty($this->php_self)) { $page_name = $this->php_self; } elseif (Tools::getValue('fc') == 'module' && $module_name != '' && Module::getInstanceByName($module_name) instanceof PaymentModule) { $page_name = 'module-payment-submit'; } elseif (preg_match('#^' . preg_quote($this->context->shop->physical_uri, '#') . 'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) { $page_name = 'module-' . $m[1] . '-' . str_replace(array('.php', '/'), array('', '-'), $m[2]); } else { $page_name = Dispatcher::getInstance()->getController(); $page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name; } $this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name)); $this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); /* Breadcrumb */ $navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>'; $this->context->smarty->assign('navigationPipe', $navigationPipe); // Automatically redirect to the canonical URL if needed if (!empty($this->php_self) && !Tools::getValue('ajax')) { $this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id)); } Product::initPricesComputation(); $display_tax_label = $this->context->country->display_tax_label; if (isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) { $infos = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $country = new Country((int) $infos['id_country']); $this->context->country = $country; if (Validate::isLoadedObject($country)) { $display_tax_label = $country->display_tax_label; } } $languages = Language::getLanguages(true, $this->context->shop->id); $meta_language = array(); foreach ($languages as $lang) { $meta_language[] = $lang['iso_code']; } $compared_products = array(); if (Configuration::get('PS_COMPARATOR_MAX_ITEM') && isset($this->context->cookie->id_compare)) { $compared_products = CompareProduct::getCompareProducts($this->context->cookie->id_compare); } $this->context->smarty->assign(array('mobile_device' => $this->context->getMobileDevice(), 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $this->context->cookie, 'page_name' => $page_name, 'hide_left_column' => !$this->display_column_left, 'hide_right_column' => !$this->display_column_right, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__, 'base_uri' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__ . (!Configuration::get('PS_REWRITING_SETTINGS') ? 'index.php' : ''), 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $this->context->language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace(array('\'', '\\'), '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => $languages, 'meta_language' => implode(',', $meta_language), 'priceDisplay' => Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer), 'is_logged' => (bool) $this->context->customer->isLogged(), 'is_guest' => (bool) $this->context->customer->isGuest(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'show_taxes' => (int) (Configuration::get('PS_TAX_DISPLAY') == 1 && (int) Configuration::get('PS_TAX')), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE') || !(bool) Group::getCurrent()->show_prices, 'b2b_enable' => (bool) Configuration::get('PS_B2B_ENABLE'), 'request' => $link->getPaginationLink(false, false, false, true), 'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT'), 'quick_view' => (bool) Configuration::get('PS_QUICK_VIEW'), 'shop_phone' => Configuration::get('PS_SHOP_PHONE'), 'compared_products' => is_array($compared_products) ? $compared_products : array(), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'))); // Add the tpl files directory for mobile if ($this->useMobileTheme()) { $this->context->smarty->assign(array('tpl_mobile_uri' => _PS_THEME_MOBILE_DIR_)); } // Deprecated $this->context->smarty->assign(array('id_currency_cookie' => (int) $currency->id, 'logged' => $this->context->customer->isLogged(), 'customerName' => $this->context->customer->logged ? $this->context->cookie->customer_firstname . ' ' . $this->context->cookie->customer_lastname : false)); $assign_array = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_); // Add the images directory for mobile if ($this->useMobileTheme()) { $assign_array['img_mobile_dir'] = _THEME_MOBILE_IMG_DIR_; } // Add the CSS directory for mobile if ($this->useMobileTheme()) { $assign_array['css_mobile_dir'] = _THEME_MOBILE_CSS_DIR_; } foreach ($assign_array as $assign_key => $assign_value) { if (substr($assign_value, 0, 1) == '/' || $protocol_content == 'https://') { $this->context->smarty->assign($assign_key, $protocol_content . Tools::getMediaServer($assign_value) . $assign_value); } else { $this->context->smarty->assign($assign_key, $assign_value); } } /* * These shortcuts are DEPRECATED as of version 1.5. * Use the Context to access objects instead. * Example: $this->context->cart */ self::$cookie = $this->context->cookie; self::$cart = $cart; self::$smarty = $this->context->smarty; self::$link = $link; $defaultCountry = $this->context->country; $this->displayMaintenancePage(); if ($this->restrictedCountry) { $this->displayRestrictedCountryPage(); } if (Tools::isSubmit('live_edit') && !$this->checkLiveEditAccess()) { Tools::redirect('index.php?controller=404'); } $this->iso = $iso; $this->context->cart = $cart; $this->context->currency = $currency; }
public function hookhook_home_03($position = '') { if ($this->context->controller->php_self == "index") { $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $id_shop = $this->context->shop->id; $options = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'pk_bannercarousel_options`'); if ($options['single'] == 1) { $id_lang = $this->context->language->id; } $slides = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'pk_bannercarousel` WHERE (id_lang =' . $id_lang . ' AND id_shop = ' . $id_shop . ' AND active = 1) ORDER BY id_order ASC'); $this->smarty->assign('slides', $slides); $this->smarty->assign('minicSlider', array('options' => array('current' => $options['current'], 'slices' => $options['slices'], 'cols' => $options['cols'], 'rows' => $options['rows'], 'speed' => $options['speed'], 'pause' => $options['pause'], 'manual' => $options['manual'], 'hover' => $options['hover'], 'buttons' => $options['buttons'], 'control' => $options['control'], 'thumbnail' => $options['thumbnail'], 'random' => $options['random'], 'startSlide' => $options['start_slide'], 'single' => $options['single'], 'width' => $options['width'], 'height' => $options['height'], 'front' => $options['front']), 'path' => array('images' => '//' . Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/uploads/', 'thumbs' => '//' . Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/uploads/thumbs/'), 'position' => $position)); return $this->display(__FILE__, 'views/templates/front/front.tpl'); } }