public function __construct() { global $cookie; $lang = strtoupper(Language::getIsoById($cookie->id_lang)); $this->className = 'Configuration'; $this->table = 'configuration'; /* Collect all font files and build array for combo box */ $fontFiles = scandir(_PS_FPDF_PATH_ . 'font'); $fontList = array(); $arr = array(); foreach ($fontFiles as $file) { if (substr($file, -4) == '.php' and $file != 'index.php') { $arr['mode'] = substr($file, 0, -4); $arr['name'] = substr($file, 0, -4); array_push($fontList, $arr); } } /* Collect all encoding map files and build array for combo box */ $encodingFiles = scandir(_PS_FPDF_PATH_ . 'font/makefont'); $encodingList = array(); $arr = array(); foreach ($encodingFiles as $file) { if (substr($file, -4) == '.map') { $arr['mode'] = substr($file, 0, -4); $arr['name'] = substr($file, 0, -4); array_push($encodingList, $arr); } } $this->_fieldsPDF = array('PS_PDF_ENCODING_' . $lang => array('title' => $this->l('Encoding:'), 'desc' => $this->l('Encoding for PDF invoice'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $encodingList), 'PS_PDF_FONT_' . $lang => array('title' => $this->l('Font:'), 'desc' => $this->l('Font for PDF invoice'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $fontList)); parent::__construct(); }
public function getAuthorisation() { global $cookie, $cart; // Getting cart informations $currency = new Currency(intval($cart->id_currency)); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $vars = '?fromPayPal=1'; $returnURL = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'modules/paypalapi/payment/submit.php' . $vars; $cancelURL = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'order.php'; $paymentAmount = floatval($cart->getOrderTotal()); $currencyCodeType = strval($currency->iso_code); $paymentType = 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1'; if ($this->_pp_integral) { $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } else { $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login'; } $request .= '&LOCALECODE=' . Language::getIsoById($cart->id_lang); if ($this->_header) { $request .= '&HDRIMG=' . urlencode($this->_header); } // Calling PayPal API include _PS_MODULE_DIR_ . 'paypalapi/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $country = new Country((int) $this->order->id_address_invoice); // $invoice_address = new Address((int)$this->order->id_address_invoice); // $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); // $formatted_delivery_address = ''; // // if ($this->order->id_address_delivery != $this->order->id_address_invoice) // { // $delivery_address = new Address((int)$this->order->id_address_delivery); // $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); // } // // $customer = new Customer((int)$this->order->id_customer); // // $this->smarty->assign(array( // 'order' => $this->order, // 'order_details' => $this->order_invoice->getProducts(), // 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), // 'delivery_address' => $formatted_delivery_address, // 'invoice_address' => $formatted_invoice_address, // 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), // 'tax_tab' => $this->getTaxTabContent(), // 'customer' => $customer // )); // // return $this->smarty->fetch($this->getTemplate('info')); $context = Context::getContext(); $iso = Language::getIsoById(intval($context->language->id)); return $this->smarty->fetch($this->getTemplateByCountry($iso)); }
/** * @see FrontController::initContent() */ public function initContent() { $this->display_column_left = false; parent::initContent(); if (!$this->isTokenValid()) { die($this->module->l($this->module->displayName . ' Error: (invalid token)')); } $cart = $this->context->cart; $address = new Address((int) $cart->id_address_invoice); $customer = new Customer((int) $cart->id_customer); $currency = $this->context->currency; $country = new Country((int) $address->id_country); $lang = Language::getIsoById((int) $cart->id_lang); if (!Configuration::get('SOFORTBANKING_USER_ID')) { die($this->module->l($this->module->displayName . ' Error: (invalid or undefined userId)')); } if (!Configuration::get('SOFORTBANKING_PROJECT_ID')) { die($this->module->l($this->module->displayName . ' Error: (invalid or undefined projectId)')); } if (!Validate::isLoadedObject($address) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($currency)) { die($this->module->l($this->module->displayName . ' Error: (invalid address or customer)')); } $parameters = array('user_id' => Configuration::get('SOFORTBANKING_USER_ID'), 'project_id' => Configuration::get('SOFORTBANKING_PROJECT_ID'), 'sender_holder' => '', '', '', 'sender_country_id' => $country->iso_code, 'amount' => number_format($cart->getOrderTotal(), 2, '.', ''), 'currency_id' => $currency->iso_code, 'reason_1' => time() . '-' . (int) $cart->id, 'reason_2' => $customer->firstname . ' ' . Tools::ucfirst(Tools::strtolower($customer->lastname)), 'user_variable_0' => $customer->secure_key, 'user_variable_1' => (int) $cart->id, 'user_variable_2' => '', 'user_variable_3' => '', 'user_variable_4' => '', 'user_variable_5' => '', 'project_password' => Configuration::get('SOFORTBANKING_PROJECT_PW')); $this->context->smarty->assign(array('this_path' => $this->module->getPathUri(), 'nbProducts' => $cart->nbProducts(), 'total' => $cart->getOrderTotal(), 'version' => _PS_VERSION_, 'hash' => sha1(implode('|', $parameters)), 'gateway' => 'https://www.sofortueberweisung.de/payment/start', 'cprotect' => Configuration::get('SOFORTBANKING_CPROTECT'), 'parameters' => $parameters, 'mod_lang' => $this->isSupportedLang())); $this->setTemplate(Configuration::get('SOFORTBANKING_REDIRECT') == 'Y' ? 'payment_redirect.tpl' : 'payment_execution.tpl'); }
function smartyTranslate($params, &$smarty) { /* * Warning : 2 lines have been added to the Smarty class. * "public $currentTemplate = null;" into the class itself * "$this->currentTemplate = substr(basename($resource_name), 0, -4);" into the "display" method */ global $_LANG, $_MODULES, $cookie, $_MODULE; if (!isset($params['js'])) { $params['js'] = 0; } if (!isset($params['mod'])) { $params['mod'] = false; } $msg = false; $string = str_replace('\'', '\\\'', $params['s']); $key = $smarty->currentTemplate . '_' . md5($string); if ($params['mod']) { if (file_exists(_PS_THEME_DIR_ . 'modules/' . $params['mod'] . '/' . Language::getIsoById($cookie->id_lang) . '.php')) { $translationsFile = _PS_THEME_DIR_ . 'modules/' . $params['mod'] . '/' . Language::getIsoById($cookie->id_lang) . '.php'; $modKey = '<{' . $params['mod'] . '}' . _THEME_NAME_ . '>' . $key; } else { $translationsFile = _PS_MODULE_DIR_ . $params['mod'] . '/' . Language::getIsoById($cookie->id_lang) . '.php'; $modKey = '<{' . $params['mod'] . '}prestashop>' . $key; } if (@(include_once $translationsFile)) { $_MODULES = array_merge($_MODULES, $_MODULE); } $msg = (is_array($_MODULES) and key_exists($modKey, $_MODULES)) ? $params['js'] ? addslashes($_MODULES[$modKey]) : stripslashes($_MODULES[$modKey]) : false; } if (!$msg) { $msg = (is_array($_LANG) and key_exists($key, $_LANG)) ? $params['js'] ? addslashes($_LANG[$key]) : stripslashes($_LANG[$key]) : $params['s']; } return $params['js'] ? $msg : Tools::htmlentitiesUTF8($msg); }
public function process() { if ($id_supplier = Tools::getValue('id_supplier')) { $this->supplier = new Supplier((int) $id_supplier, self::$cookie->id_lang); if (Validate::isLoadedObject($this->supplier) and $this->supplier->active) { $nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign(array('nb_products' => $nbProducts, 'products' => $this->supplier->getProducts($id_supplier, (int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay), 'path' => $this->supplier->active ? Tools::safeOutput($this->supplier->name) : '', 'supplier' => $this->supplier)); } else { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->errors[] = Tools::displayError('Supplier does not exist'); } } else { if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $data = call_user_func(array('Supplier', 'getSuppliers'), true, (int) self::$cookie->id_lang, true); $nbProducts = count($data); $this->pagination($nbProducts); $data = call_user_func(array('Supplier', 'getSuppliers'), true, (int) self::$cookie->id_lang, true, $this->p, $this->n); $imgDir = _PS_MANU_IMG_DIR_; foreach ($data as &$item) { $item['image'] = !file_exists($imgDir . '/' . $item['id_supplier'] . '-medium.jpg') ? Language::getIsoById((int) self::$cookie->id_lang) . '-default' : $item['id_supplier']; } self::$smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbSuppliers' => $nbProducts, 'mediumSize' => Image::getSize('medium'), 'suppliers' => $data, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'))); } else { self::$smarty->assign('nbSuppliers', 0); } } }
static function translate($params, &$smarty) { global $_LANG, $_MODULES, $cookie, $_MODULE; if (!isset($params['js'])) { $params['js'] = 0; } if (!isset($params['mod'])) { $params['mod'] = false; } $msg = FALSE; $string = str_replace('\'', '\\\'', $params['s']); if (!file_exists(_PS_MODULE_DIR_ . 'coremanager/lang/coremanager.' . $params['mod'] . '.lang.tpl')) { $key = $smarty->currentTemplate . '_' . md5($string); } else { $key = 'coremanager.' . $params['mod'] . '.lang_' . md5($string); $params['mod'] = 'coremanager'; } if ($params['mod']) { if (file_exists(_PS_THEME_DIR_ . 'modules/' . $params['mod'] . '/' . Language::getIsoById($cookie->id_lang) . '.php')) { $translationsFile = _PS_THEME_DIR_ . 'modules/' . $params['mod'] . '/' . Language::getIsoById($cookie->id_lang) . '.php'; $modKey = '<{' . $params['mod'] . '}' . _THEME_NAME_ . '>' . $key; } else { $translationsFile = _PS_MODULE_DIR_ . $params['mod'] . '/' . Language::getIsoById($cookie->id_lang) . '.php'; $modKey = '<{' . $params['mod'] . '}prestashop>' . $key; } if (@(include_once $translationsFile)) { $_MODULES = array_merge($_MODULES, $_MODULE); } $msg = (is_array($_MODULES) and key_exists($modKey, $_MODULES)) ? $params['js'] ? addslashes($_MODULES[$modKey]) : stripslashes($_MODULES[$modKey]) : FALSE; } if (!$msg) { $msg = (is_array($_LANG) and key_exists($key, $_LANG)) ? $params['js'] ? addslashes($_LANG[$key]) : stripslashes($_LANG[$key]) : $params['s']; } return $params['js'] ? $msg : Tools::htmlentitiesUTF8($msg); }
public function run() { $this->init(); $this->preProcess(); global $cookie, $link; $id_product = Tools::getValue('id'); $product = new Product($id_product, true, 1); $id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0; if ($id_customer) { $sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $product->id; $res = Db::getInstance()->ExecuteS($sql); if ($res) { self::$smarty->assign("in_wishlist", true); } else { self::$smarty->assign("in_wishlist", false); } } else { self::$smarty->assign("in_wishlist", false); } $idImage = $product->getCoverWs(); if ($idImage) { $idImage = $productObj->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $image_link = $link->getImageLink($productObj->link_rewrite, $idImage, 'thickbox'); self::$smarty->assign('product', $product); self::$smarty->assign('imagelink', $image_link); self::$smarty->assign('productlink', $product->getLink()); die(self::$smarty->display(_PS_THEME_DIR_ . 'quick-view.tpl')); }
public function loadLocalisationPack($file, $selection, $install_mode = false, $iso_localization_pack = null) { if (!($xml = @simplexml_load_string($file))) { return false; } libxml_clear_errors(); $main_attributes = $xml->attributes(); $this->name = (string) $main_attributes['name']; $this->version = (string) $main_attributes['version']; if ($iso_localization_pack) { $id_country = (int) Country::getByIso($iso_localization_pack); if ($id_country) { $country = new Country($id_country); } if (!$id_country || !Validate::isLoadedObject($country)) { $this->_errors[] = Tools::displayError(sprintf('Cannot load country : %1d', $id_country)); return false; } if (!$country->active) { $country->active = 1; if (!$country->update()) { $this->_errors[] = Tools::displayError(sprintf('Cannot enable the associated country: %1s', $country->name)); } } } $res = true; if (empty($selection)) { $res &= $this->_installStates($xml); $res &= $this->_installTaxes($xml); $res &= $this->_installCurrencies($xml, $install_mode); $res &= $this->installConfiguration($xml); $res &= $this->installModules($xml); $res &= $this->updateDefaultGroupDisplayMethod($xml); if (($res || $install_mode) && isset($this->iso_code_lang)) { if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang, true))) { $id_lang = 1; } if (!$install_mode) { Configuration::updateValue('PS_LANG_DEFAULT', $id_lang); } } elseif (!isset($this->iso_code_lang) && $install_mode) { $id_lang = 1; } if (!Language::isInstalled(Language::getIsoById($id_lang))) { $res &= $this->_installLanguages($xml, $install_mode); $res &= $this->_installUnits($xml); } if ($install_mode && $res && isset($this->iso_currency)) { Cache::clean('Currency::getIdByIsoCode_*'); $res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency)); Currency::refreshCurrencies(); } } else { foreach ($selection as $selected) { // No need to specify the install_mode because if the selection mode is used, then it's not the install $res &= Validate::isLocalizationPackSelection($selected) ? $this->{'_install' . $selected}($xml) : false; } } return $res; }
public static function getSubCategories($id_lang, $active = true, $id_category = 2, $p = 0, $n = 6) { $sql_groups_where = ''; $sql_groups_join = ''; if (Group::isFeatureActive()) { $sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)'; $groups = FrontController::getCurrentCustomerGroups(); $sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . pSQL(implode(',', $groups)) . ')' : '=' . (int) Group::getCurrent()->id); } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description FROM `' . _DB_PREFIX_ . 'category` c ' . Shop::addSqlAssociation('category', 'c') . ' LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . (int) $id_lang . ' ' . Shop::addSqlRestrictionOnLang('cl') . ') ' . $sql_groups_join . ' WHERE `id_parent` = ' . (int) $id_category . ' ' . ($active ? 'AND `active` = 1' : '') . ' ' . $sql_groups_where . ' GROUP BY c.`id_category` ORDER BY `level_depth` ASC, category_shop.`position` ASC LIMIT ' . (int) $p . ', ' . (int) $n); foreach ($result as &$row) { $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_ . $row['id_category'] . '.jpg') ? (int) $row['id_category'] : Language::getIsoById($id_lang) . '-default'; $row['legend'] = 'no picture'; } return $result; }
public function getSettings($id_lang = false) { $settings = $this->index_settings; $attributes_to_index = array(); $attributes_for_faceting = array(); foreach ($this->index_settings['attributesToIndex'] as $attribute) { if ($id_lang === false) { foreach (Language::getLanguages() as $language) { array_push($attributes_to_index, $attribute . "_" . $language['iso_code']); } } else { array_push($attributes_to_index, $attribute . "_" . Language::getIsoById($id_lang)); } } foreach ($this->index_settings['attributesForFaceting'] as $attribute) { if ($id_lang === false) { foreach (Language::getLanguages() as $language) { array_push($attributes_for_faceting, $attribute . "_" . $language['iso_code']); } } else { array_push($attributes_for_faceting, $attribute . "_" . Language::getIsoById($id_lang)); } } $settings['attributesToIndex'] = $attributes_to_index; $settings['attributesForFaceting'] = $attributes_for_faceting; return $settings; }
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) { parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); $nb_items = count($this->_list); $this->tpl_list_vars['nb_items'] = $nb_items; if ($nb_items > 0) { for ($i = 0; $i < $nb_items; ++$i) { $item =& $this->_list[$i]; $item['token'] = Tools::getAdminTokenLite($item['controller']); } } $currentLanguage = Language::getIsoById((int) $this->context->language->id); $urlEShop = URL_ESHOP_EN; $urlTechnicalSupport = URL_TECHNICAL_SUPPORT_EN; if ($currentLanguage == 'fr') { $urlEShop = URL_ESHOP_FR; $urlTechnicalSupport = URL_TECHNICAL_SUPPORT_FR; } elseif ($currentLanguage == 'es') { $urlTechnicalSupport = URL_TECHNICAL_SUPPORT_ES; } elseif ($currentLanguage == 'it') { $urlTechnicalSupport = URL_TECHNICAL_SUPPORT_IT; } $this->context->smarty->assign(array('token' => Tools::getValue('token'), 'urlEShop' => $urlEShop, 'urlTechnicalSupport' => $urlTechnicalSupport, 'licenceActive' => date('Y-m-d') > Configuration::get('ERP_WS_DATE_END') ? false : true)); // Configuration CSS/JS if (version_compare(_PS_VERSION_, '1.6') == -1) { $this->context->controller->addCSS(_MODULE_DIR_ . '/erpillicopresta/css/bs3.css'); } $this->context->controller->addCSS(_MODULE_DIR_ . '/erpillicopresta/css/adminerp.css'); $this->context->controller->addJS(_MODULE_DIR_ . '/erpillicopresta/js/tools.js'); }
/** * Create link after language change * * @param integer $id_lang Language ID * @return string link */ public function getLanguageLink($id_lang) { if ($this->allow == 1) { return _PS_BASE_URL_ . __PS_BASE_URI__ . 'lang-' . Language::getIsoById($id_lang) . '/' . substr(preg_replace('#/lang-([a-z]{2})/#', '/', $_SERVER['REQUEST_URI']), strlen(__PS_BASE_URI__)); } else { return $this->getUrlWith('id_lang', intval($id_lang)); } }
public function process() { parent::process(); //echo "vao day";die; if (self::$cookie->RoleID == 1) { Tools::redirect('hotelpage.php?mid=' . self::$cookie->HotelID); } $continentCode = Tools::getUserContinentCode(self::$cookie->CompanyID); $search_form = array(); $search_form['CityId'] = 0; $search_form['AreaId'] = 0; if ((self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) && self::$cookie->OldLoginUserName == NULL) { $search_form['CheckIn'] = date('Y-m-d', strtotime(date('Y-m-d') . " + 5 days")); $search_form['Nights'] = 1; $search_form['CheckOut'] = date('Y-m-d', strtotime($search_form['CheckIn'] . " + {$search_form['Nights']} days")); } $search_form['HotelClassId'] = 0; $search_form['HotelName'] = ''; $search_form['ContinentCode'] = $continentCode; $roomtype_list = RoomPlan::getRoomTypeList(); $roomtype_form_list = array(); foreach ($roomtype_list as $roomtype) { $roomTypeId = $roomtype['RoomTypeId']; $roomtype_form_list[$roomTypeId] = 0; } $search_form['RoomTypeVals'] = $roomtype_form_list; self::$smarty->assign("roomTypeList", $roomtype_list); self::$smarty->assign("search_form", $search_form); self::$smarty->assign("classList", Tools::getAllHotelClasses()); self::$smarty->assign("areaList", Tools::getJapanAreas()); //get Hotel List and Promotion List $promotionList = Promotion::getHomePromotionList(Promotion::$TYPE_PROMOTION); self::$smarty->assign('homePromotionList', $promotionList); $eventList = Promotion::getHomePromotionList(Promotion::$TYPE_EVENT); self::$smarty->assign('homeEventList', $eventList); // Get Popular Hotel List $poList = HotelDetail::getPopularHotelList(3); // 東京・横浜 - 関東 areaid = 3 $popularList = array(); global $cookie; $iso = Language::getIsoById((int) $cookie->LanguageID); foreach ($poList as $popular) { $image = HotelDetail::getFirstFileOfHotel($popular['HotelId'], 150, 150); if (is_file(_TAS_ROOT_DIR_ . "/asset/" . $image['w5_path'])) { $popular['HotelFilePath'] = $image['w5_path']; $popular['w5'] = $image['w5']; $popular['h5'] = $image['h5']; } $popular['LowestPrice'] = HotelDetail::getLowestPriceOfHotel($popular['HotelId']); $popular['AreaName'] = HotelDetail::getAreaName($popular['HotelArea']); $HotelNameKey = 'HotelName_' . $iso; $popular['HotelName'] = $popular[$HotelNameKey]; $popularList[] = $popular; } //self::$smarty->assign('homeAreaList', Db::getInstance()->ExecuteS("select *, AreaName_".$this->iso." as AreaName from HT_Area where AreaId in (3, 5, 8, 12)")); self::$smarty->assign('homeAreaList', Db::getInstance()->ExecuteS('select *, AreaName_' . $this->iso . ' as AreaName from `HT_Area` where isPopular = 1')); self::$smarty->assign("popularList", $popularList); }
public function __construct() { global $cookie; $lang = strtoupper(Language::getIsoById($cookie->id_lang)); $this->className = 'Configuration'; $this->table = 'configuration'; $this->_fieldsLocalization = array('PS_WEIGHT_UNIT' => array('title' => $this->l('Weight unit:'), 'desc' => $this->l('The weight unit of your shop'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text')); parent::__construct(); }
function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, $nb ? $nb : 10); $smarty->assign(array('allow_buy_when_out_of_stock' => Configuration::get('PS_ORDER_OUT_OF_STOCK', false), 'max_quantity_to_allow_display' => Configuration::get('PS_LAST_QTIES'), 'category' => $category, 'products' => $products, 'currency' => new Currency(intval($params['cart']->id_currency)), 'lang' => Language::getIsoById(intval($params['cookie']->id_lang)), 'productNumber' => sizeof($products), 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); }
public function installCarriers() { $id_lang_default = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')); $carriers_list = array('MYMOD_CA_CLDE' => 'Classic delivery', 'MYMOD_CA_REPO' => 'Relay Point'); foreach ($carriers_list as $carrier_key => $carrier_name) { if (Configuration::get($carrier_key) < 1) { // Create new carrier $carrier = new Carrier(); $carrier->name = $carrier_name; $carrier->id_tax_rules_group = 0; $carrier->active = 1; $carrier->deleted = 0; foreach (Language::getLanguages(true) as $language) { $carrier->delay[(int) $language['id_lang']] = 'Delay ' . $carrier_name; } $carrier->shipping_handling = false; $carrier->range_behavior = 0; $carrier->is_module = true; $carrier->shipping_external = true; $carrier->external_module_name = $this->name; $carrier->need_range = true; if (!$carrier->add()) { return false; } // Associate carrier to all groups $groups = Group::getGroups(true); foreach ($groups as $group) { Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group'])); } // Create price range $rangePrice = new RangePrice(); $rangePrice->id_carrier = $carrier->id; $rangePrice->delimiter1 = '0'; $rangePrice->delimiter2 = '10000'; $rangePrice->add(); // Create weight range $rangeWeight = new RangeWeight(); $rangeWeight->id_carrier = $carrier->id; $rangeWeight->delimiter1 = '0'; $rangeWeight->delimiter2 = '10000'; $rangeWeight->add(); // Associate carrier to all zones $zones = Zone::getZones(true); foreach ($zones as $zone) { Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone'])); Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0')); Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0')); } // Copy the carrier logo copy(dirname(__FILE__) . '/views/img/' . $carrier_key . '.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg'); // Save the carrier ID in the Configuration table Configuration::updateValue($carrier_key, $carrier->id); } } return true; }
public function __construct() { global $cookie; $lang = strtoupper(Language::getIsoById($cookie->id_lang)); $this->className = 'Configuration'; $this->table = 'configuration'; $this->_fieldsLocalization = array('PS_WEIGHT_UNIT' => array('title' => $this->l('Weight unit:'), 'desc' => $this->l('The weight unit of your shop (eg. kg or lbs)'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'), 'PS_DISTANCE_UNIT' => array('title' => $this->l('Distance unit:'), 'desc' => $this->l('The distance unit of your shop (eg. km or mi)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text'), 'PS_VOLUME_UNIT' => array('title' => $this->l('Volume unit:'), 'desc' => $this->l('The volume unit of your shop'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'), 'PS_DIMENSION_UNIT' => array('title' => $this->l('Dimension unit:'), 'desc' => $this->l('The dimension unit of your shop (eg. cm or in)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text')); $this->_fieldsOptions = array('PS_LOCALE_LANGUAGE' => array('title' => $this->l('Language locale:'), 'desc' => $this->l('Your server\'s language locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text'), 'PS_LOCALE_COUNTRY' => array('title' => $this->l('Country locale:'), 'desc' => $this->l('Your server\'s country locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text')); parent::__construct(); }
public function hookRightColumn($params) { $productsViewed = isset($params['cookie']->viewed) && !empty($params['cookie']->viewed) ? array_slice(array_reverse(explode(',', $params['cookie']->viewed)), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array(); if (count($productsViewed)) { $defaultCover = Language::getIsoById($params['cookie']->id_lang) . '-default'; $productIds = implode(',', array_map('intval', $productsViewed)); $productsImages = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT MAX(image_shop.id_image) id_image, p.id_product, p.price, il.legend, product_shop.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p') . ' LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = p.id_product' . Shop::addSqlRestrictionOnLang('pl') . ') LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = p.id_product)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . ' LEFT JOIN ' . _DB_PREFIX_ . 'image_lang il ON (il.id_image = image_shop.id_image) LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ') WHERE p.id_product IN (' . $productIds . ') AND pl.id_lang = ' . (int) $params['cookie']->id_lang . ' AND cl.id_lang = ' . (int) $params['cookie']->id_lang . ' GROUP BY product_shop.id_product'); $productsImagesArray = array(); foreach ($productsImages as $pi) { $productsImagesArray[$pi['id_product']] = $pi; } $productsViewedObj = array(); foreach ($productsViewed as $productViewed) { $obj = (object) 'Product'; if (!isset($productsImagesArray[$productViewed]) || !($obj->active = $productsImagesArray[$productViewed]['active'])) { continue; } else { $obj->id = (int) $productsImagesArray[$productViewed]['id_product']; $obj->price = $productsImagesArray[$productViewed]['price']; $obj->id_image = (int) $productsImagesArray[$productViewed]['id_image']; $obj->cover = (int) $productsImagesArray[$productViewed]['id_product'] . '-' . (int) $productsImagesArray[$productViewed]['id_image']; $obj->legend = $productsImagesArray[$productViewed]['legend']; $obj->name = $productsImagesArray[$productViewed]['name']; $obj->description_short = $productsImagesArray[$productViewed]['description_short']; $obj->link_rewrite = $productsImagesArray[$productViewed]['link_rewrite']; $obj->category_rewrite = $productsImagesArray[$productViewed]['category_rewrite']; // $obj is not a real product so it cannot be used as argument for getProductLink() $obj->product_link = $this->context->link->getProductLink($obj->id, $obj->link_rewrite, $obj->category_rewrite); if (!isset($obj->cover) || !$productsImagesArray[$productViewed]['id_image']) { $obj->cover = $defaultCover; $obj->legend = ''; } $productsViewedObj[] = $obj; } } if (!count($productsViewedObj)) { return; } $this->smarty->assign(array('productsViewedObj' => $productsViewedObj, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blockviewed.tpl'); } return; }
public function getAuthorisation() { global $cookie, $cart; // Getting cart informations $currency = new Currency((int) $cart->id_currency); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $vars = '?fromPayPal=1'; $returnURL = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/payment/submit.php' . $vars; $cancelURL = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php'; $paymentAmount = (double) $cart->getOrderTotal(); $currencyCodeType = strval($currency->iso_code); $paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1'; if (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0) { $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } else { $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login'; } $request .= '&LOCALECODE=' . strtoupper(Language::getIsoById($cart->id_lang)); if (Configuration::get('PAYPAL_HEADER')) { $request .= '&HDRIMG=' . urlencode(Configuration::get('PAYPAL_HEADER')); } // Customer informations $customer = new Customer((int) $cart->id_customer); $request .= '&EMAIL=' . urlencode($customer->email); //customer // address of delivery $address = new Address((int) $cart->id_address_delivery); $country = new Country((int) $address->id_country); if ($address->id_state) { $state = new State((int) $address->id_state); } $request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname); $request .= '&SHIPTOSTREET=' . urlencode($address->address1); $request .= '&SHIPTOSTREET2=' . urlencode($address->address2); $request .= '&SHIPTOCITY=' . urlencode($address->city); $request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code); $request .= '&SHIPTOZIP=' . urlencode($address->postcode); $request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code); $request .= '&SHIPTOPHONENUM=' . urlencode($address->phone); $request .= '&ADDROVERRIDE=1'; // Calling PayPal API include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
/** * Check supported languages * * @param string $iso * @return string iso */ private function isSupportedLang($iso = null) { if ($iso === null) { $iso = Language::getIsoById((int) $this->context->cart->id_lang); } if (in_array($iso, $this->languages)) { return $iso; } else { return 'en'; } }
private function _getTplBody($tpl_file, $vars = array()) { $iso = Language::getIsoById(intval(Configuration::get(PS_LANG_DEFAULT))); $file = dirname(__FILE__) . '/mails/' . $iso . '/' . $tpl_file; if (!file_exists($file)) { die($file); } $tpl = file($file); $template = str_replace(array_keys($vars), array_values($vars), $tpl); return implode("\n", $template); }
public function preProcess() { if (!Tools::hasFunction('feature_manage')) { Tools::redirect('index.php'); } $this->brandNavi[] = array("name" => "Hotel Features Edit", "url" => "featuremanage.php"); if (Tools::isSubmit("delete")) { $idList = $_POST['idlist'] == '' ? '' : $_POST['idlist']; if (is_array($idList)) { foreach ($idList as $aid) { HotelFeature::DeleteFeatures($aid); } } exit; } else { if (Tools::isSubmit("submit")) { $feature = new HotelFeature((int) Tools::getValue("idx")); $feature->FeatureType = (int) Tools::getValue("type"); $name = Tools::getValue("name"); $feature->FeatureName = $name; global $cookie; $iso = Language::getIsoById((int) $cookie->LanguageID); if ($iso != '') { if ($iso == 'en') { $feature->FeatureName_en = $name; } if ($iso == 'jp') { $feature->FeatureName_jp = $name; } if ($iso == 'S_CN') { $feature->FeatureName_S_CN = $name; } if ($iso == 'T_CN') { $feature->FeatureName_T_CN = $name; } } if ($feature->FeatureId == '') { $feature->FeatureName_en = $name; $feature->FeatureName_jp = $name; $feature->FeatureName_S_CN = $name; $feature->FeatureName_T_CN = $name; } if ($feature->FeatureId > 0) { $feature->update(); } else { $feature->add(); } //p($feature); echo "success"; exit; } } }
public function __construct() { global $cookie, $_LANGADM; $langFile = _PS_MODULE_DIR_ . $this->module . '/' . Language::getIsoById(intval($cookie->id_lang)) . '.php'; if (file_exists($langFile)) { require_once $langFile; foreach ($_MODULE as $key => $value) { if (substr(strip_tags($key), 0, 5) == 'Admin') { $_LANGADM[str_replace('_', '', strip_tags($key))] = $value; } } } parent::__construct(); }
public function displayFrontForm() { global $smarty; $error = false; $confirm = false; if (isset($_POST['submitAddtoafriend'])) { global $cookie, $link; /* Product informations */ $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang)); $productLink = $link->getProductLink($product); /* Fields verifications */ if (empty($_POST['email']) or empty($_POST['name'])) { $error = $this->l('You must fill all fields.'); } elseif (!Validate::isEmail($_POST['email'])) { $error = $this->l('Your friend\'s email is invalid.'); } elseif (!Validate::isName($_POST['name'])) { $error = $this->l('Your friend\'s name is invalid.'); } elseif (!isset($_GET['id_product']) or !is_numeric($_GET['id_product'])) { $error = $this->l('An error occurred during the process.'); } else { /* Email generation */ $subject = ($cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend')) . ' ' . $this->l('send you a link to') . ' ' . $product->name; $templateVars = array('{product}' => $product->name, '{product_link}' => $productLink, '{customer}' => $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend'), '{name}' => Tools::safeOutput($_POST['name'])); /* Email sending */ if (!Mail::Send(intval($cookie->id_lang), 'send_to_a_friend', $subject, $templateVars, $_POST['email'], NULL, $cookie->email ? $cookie->email : NULL, $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : NULL, NULL, NULL, dirname(__FILE__) . '/mails/')) { $error = $this->l('An error occurred during the process.'); } else { $confirm = $this->l('An email has been sent successfully to') . ' ' . Tools::safeOutput($_POST['email']) . '.'; } } } else { global $cookie, $link; /* Product informations */ $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang)); $productLink = $link->getProductLink($product); } /* Image */ $images = $product->getImages(intval($cookie->id_lang)); foreach ($images as $k => $image) { if ($image['cover']) { $cover['id_image'] = intval($product->id) . '-' . intval($image['id_image']); $cover['legend'] = $image['legend']; } } if (!isset($cover)) { $cover = array('id_image' => Language::getIsoById(intval($cookie->id_lang)) . '-default', 'legend' => 'No picture'); } $smarty->assign(array('cover' => $cover, 'errors' => $error, 'confirm' => $confirm, 'product' => $product, 'productLink' => $productLink)); return $this->display(__FILE__, 'sendtoafriend.tpl'); }
public static function linkPost($id_news, $rewrite, $id_lang, $context = NULL) { if (is_null($context) || !$context instanceof Context) { $context = Context::getContext(); } $languages = Language::getLanguages(true, $context->shop->id); $shop_url = $context->shop->getBaseURL(); if (Configuration::get('PS_REWRITING_SETTINGS')) { $iso = $id_lang > 0 && count($languages) > 1 ? Language::getIsoById(intval($id_lang)) . '/' : ''; return $shop_url . $iso . 'news/' . $id_news . '-' . $rewrite; } else { $id_lang = $id_lang > 0 && count($languages) > 1 ? '&id_lang=' . $id_lang : ''; return $shop_url . 'index.php?fc=module&module=psnews&controller=news&news=' . $id_news . $id_lang; } }
public function renderContent($args, $setting) { $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $plimit = $setting['limit'] ? (int) $setting['limit'] : 10; $image_type = $setting['image'] ? $setting['image'] : 'small' . '_default'; $data = Manufacturer::getManufacturers(true, Context::getContext()->language->id, true, 1, $plimit, false); foreach ($data as &$item) { $id_images = !file_exists(_PS_MANU_IMG_DIR_ . '/' . $item['id_manufacturer'] . '-' . $image_type . '.jpg') ? Language::getIsoById(Context::getContext()->language->id) . '-default' : $item['id_manufacturer']; $item['image'] = _THEME_MANU_DIR_ . $id_images . '-' . $image_type . '.jpg'; } $setting['manufacturers'] = $data; $output = array('type' => 'manufacture', 'data' => $setting); return $output; }
private function getP() { $default_lang = $this->context->language->id; $lang = Language::getIsoById($default_lang); $pl = array('es', 'fr'); if (!in_array($lang, $pl)) { $lang = 'en'; } $base = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https://' . $this->context->shop->domain_ssl : 'http://' . $this->context->shop->domain; $uri = $base . $this->context->shop->getBaseURI(); $path = _PS_MODULE_DIR_ . 'lgconsultas' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'publi' . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . 'index.php'; $object = Tools::file_get_contents($path); $object = str_replace('src="/modules/', 'src="' . $uri . 'modules/', $object); return $object; }
function hookRightColumn($params) { global $link, $smarty; $id_product = intval(Tools::getValue('id_product')); if ($id_product) { $product = new Product($id_product); } $productsViewed = (isset($params['cookie']->viewed) and !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array(); if (sizeof($productsViewed)) { $productsViewedObj = array(); foreach ($productsViewed as $productViewed) { $obj = new Product(intval($productViewed), false, intval($params['cookie']->id_lang)); if (!Validate::isLoadedObject($obj) or !$obj->active) { continue; } else { $images = $obj->getImages(intval($params['cookie']->id_lang)); foreach ($images as $k => $image) { if ($image['cover']) { $obj->cover = $obj->id . '-' . $image['id_image']; $obj->legend = $image['legend']; break; } } if (!isset($obj->cover)) { $obj->cover = Language::getIsoById($params['cookie']->id_lang) . '-default'; $obj->legend = ''; } $productsViewedObj[] = $obj; } } if (isset($product) and $product and !in_array($product->id, $productsViewed)) { array_unshift($productsViewed, $product->id); } $viewed = ''; foreach ($productsViewed as $id_product_viewed) { $viewed .= intval($id_product_viewed) . ','; } $params['cookie']->viewed = rtrim($viewed, ','); if (!sizeof($productsViewedObj)) { return; } $smarty->assign(array('productsViewedObj' => $productsViewedObj, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blockviewed.tpl'); } elseif (isset($product) and Validate::isLoadedObject($product)) { $params['cookie']->viewed = intval($product->id); } return; }
public function __construct() { $this->name = 'sharezblock'; $this->tab = 'pricing_promotion'; $this->version = '1.3.0'; $this->author = 'zapalm'; $this->need_instance = 0; $this->bootstrap = false; parent::__construct(); $this->displayName = $this->l('Special offer block in the product page'); $this->description = $this->l('It shows a special offer block on product page to enable cross selling.'); $this->quantity_prop = array(self::QTY_RESTRICT_ONE => $this->l('Only one'), self::QTY_RESTRICT_PROPORTIONAL => $this->l('Proportional'), self::QTY_RESTRICT_MANY => $this->l('Many')); global $cookie; $this->iso_code = Language::getIsoById((int) $cookie->id_lang); $this->defaultCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); }