示例#1
0
    private static function getAlertsInformations($iso)
    {
        $id_lang = Language::getIdByIso($iso);
        $cert = Configuration::get(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($iso));
        if ($cert != false) {
            $certificate = (array) Tools::jsonDecode(Tools::htmlentitiesDecodeUTF8($cert));
            if (trim($certificate['tsID']) != '') {
                $query = '
				SELECT
					a.id_alert,
					a.`iso`,
					c.`email`,
					o.`id_order`,
					o.`id_lang`
				FROM `' . _DB_PREFIX_ . self::TABLE_NAME . '` a
				LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON (a.id_order = o.id_order)
				LEFT JOIN ' . _DB_PREFIX_ . 'customer c ON (c.id_customer = o.id_customer)
				WHERE
					o.`id_lang`=' . (int) $id_lang . '
					AND
					DATE_ADD(
						o.`date_add`, INTERVAL ' . (int) $certificate['send_seperate_mail_delay'] . ' DAY
					) <= NOW()';
                return Db::getInstance()->ExecuteS($query);
            }
        }
        return false;
    }
示例#2
0
 public function __construct()
 {
     global $cookie;
     $this->name = 'ebay';
     $this->tab = 'market_place';
     $this->version = '1.3.1';
     $this->author = 'PrestaShop';
     parent::__construct();
     $this->displayName = $this->l('eBay');
     $this->description = $this->l('Open your shop on the eBay market place !');
     $this->id_lang = Language::getIdByIso('fr');
     // Check the country and ask the bypass if not 'fr'
     if (strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))) != 'fr' && !isset($cookie->ebay_country_default_fr)) {
         $this->warning = $this->l('eBay module currently works only for eBay.fr');
         return false;
     }
     // Checking Extension
     if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) {
         if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) {
             $this->warning = $this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.');
         } elseif (!extension_loaded('curl')) {
             $this->warning = $this->l('You must enable cURL extension on your server if you want to use this module.');
         } elseif (!ini_get('allow_url_fopen')) {
             $this->warning = $this->l('You must enable allow_url_fopen option on your server if you want to use this module.');
         }
         return false;
     }
     // Checking compatibility with older PrestaShop and fixing it
     if (!Configuration::get('PS_SHOP_DOMAIN')) {
         Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
     }
     // Generate eBay Security Token if not exists
     if (!Configuration::get('EBAY_SECURITY_TOKEN')) {
         Configuration::updateValue('EBAY_SECURITY_TOKEN', Tools::passwdGen(30));
     }
     /* For 1.4.3 and less compatibility */
     $updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT');
     if (!Configuration::get('PS_OS_PAYMENT')) {
         foreach ($updateConfig as $u) {
             if (!Configuration::get($u) && defined('_' . $u . '_')) {
                 Configuration::updateValue($u, constant('_' . $u . '_'));
             }
         }
     }
     // Check if installed
     if (self::isInstalled($this->name)) {
         // Upgrade eBay module
         if (Configuration::get('EBAY_VERSION') != $this->version) {
             $this->upgrade();
         }
         // Generate warnings
         if (!Configuration::get('EBAY_API_TOKEN')) {
             $this->warning = $this->l('You must register your module on eBay.');
         }
         // Loading Shipping Method
         $this->loadShippingMethod();
         // Warning uninstall
         $this->confirmUninstall = $this->l('Are you sure you want uninstall this module ? All your configuration will be lost.');
     }
 }
示例#3
0
 public function submitCopyLang()
 {
     global $currentIndex;
     if (!($fromLang = strval(Tools::getValue('fromLang'))) or !($toLang = strval(Tools::getValue('toLang')))) {
         $this->_errors[] = $this->l('you must select 2 languages in order to copy data from one to another');
     } elseif (!($fromTheme = strval(Tools::getValue('fromTheme'))) or !($toTheme = strval(Tools::getValue('toTheme')))) {
         $this->_errors[] = $this->l('you must select 2 themes in order to copy data from one to another');
     } elseif (!Language::copyLanguageData(Language::getIdByIso($fromLang), Language::getIdByIso($toLang))) {
         $this->_errors[] = $this->l('an error occurred while copying data');
     } elseif ($fromLang == $toLang and $fromTheme == $toTheme) {
         $this->_errors[] = $this->l('nothing to copy! (same language and theme)');
     }
     if (sizeof($this->_errors)) {
         return;
     }
     $bool = true;
     $items = Language::getFilesList($fromLang, $fromTheme, $toLang, $toTheme, false, false, true);
     foreach ($items as $source => $dest) {
         $bool &= $this->checkDirAndCreate($dest);
         $bool &= @copy($source, $dest);
     }
     if ($bool) {
         Tools::redirectLink($currentIndex . '&conf=14&token=' . $this->token);
     }
     $this->_errors[] = $this->l('a part of the data has been copied but some language files could not be found or copied');
 }
示例#4
0
    /**
     * Load default routes group by languages
     */
    protected function loadRoutes($id_shop = null)
    {
        $context = Context::getContext();
        // Load custom routes from modules
        $modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false);
        if (is_array($modules_routes) && count($modules_routes)) {
            foreach ($modules_routes as $module_route) {
                if (is_array($module_route) && count($module_route)) {
                    foreach ($module_route as $route => $route_details) {
                        if (array_key_exists('controller', $route_details) && array_key_exists('rule', $route_details) && array_key_exists('keywords', $route_details) && array_key_exists('params', $route_details)) {
                            if (!isset($this->default_routes[$route])) {
                                $this->default_routes[$route] = array();
                                $this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
                            }
                        }
                    }
                }
            }
        }
        // Set default routes
        //new edit by Ha!*!*y :: Select only active languages
        foreach (Language::getLanguages(TRUE) as $lang) {
            foreach ($this->default_routes as $id => $route) {
                $this->addRoute($id, $route['rule'], $route['controller'], $lang['id_lang'], $route['keywords'], isset($route['params']) ? $route['params'] : array(), $id_shop);
            }
        }
        if ($this->use_routes) {
            // Get iso lang
            $iso_lang = Tools::getValue('isolang');
            $id_lang = $context->language->id;
            if (!empty($iso_lang)) {
                $id_lang = Language::getIdByIso($iso_lang);
            }
            // Load routes from meta table
            $sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
					FROM `' . _DB_PREFIX_ . 'meta` m
					LEFT JOIN `' . _DB_PREFIX_ . 'meta_lang` ml ON (m.id_meta = ml.id_meta' . Shop::addSqlRestrictionOnLang('ml', $id_shop) . ')
					ORDER BY LENGTH(ml.url_rewrite) DESC';
            if ($results = Db::getInstance()->executeS($sql)) {
                foreach ($results as $row) {
                    if ($row['url_rewrite']) {
                        $this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop);
                    }
                }
            }
            // Set default empty route if no empty route (that's weird I know)
            if (!$this->empty_route) {
                $this->empty_route = array('routeID' => 'index', 'rule' => '', 'controller' => 'index');
            }
            // Load custom routes
            foreach ($this->default_routes as $route_id => $route_data) {
                if ($custom_route = Configuration::get('PS_ROUTE_' . $route_id, null, null, $id_shop)) {
                    foreach (Language::getLanguages() as $lang) {
                        $this->addRoute($route_id, $custom_route, $route_data['controller'], $lang['id_lang'], $route_data['keywords'], isset($route_data['params']) ? $route_data['params'] : array(), $id_shop);
                    }
                }
            }
        }
    }
 function install()
 {
     if (!parent::install()) {
         return false;
     }
     $this->installModuleTab('AdminCache', array(Language::getIdByIso('fr') => 'Quadra Gestion Cache', Language::getIdByIso('en') => 'Quadra Cache Admin'), '8');
     Configuration::updateValue('PS_QUADRA_CACHE_ACTIVE', 0);
 }
 public function getIdLang()
 {
     $id_lang = Language::getIdByIso($this->getIsoCode());
     if (!$id_lang) {
         //Fix for UK
         $id_lang = Configuration::get('PS_LANG_DEFAULT');
     }
     return (int) $id_lang;
 }
示例#7
0
 public function initContent()
 {
     Configuration::updateValue('SEGMENT_CUSTOMER_TOKEN', Tools::getValue('token'));
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         Context::getContext()->controller->addJqueryUI('ui.datepicker');
     }
     $this->clearCacheLang();
     $this->initLang();
     Context::getContext()->smarty->assign(array('mj__PS_BASE_URI__' => __PS_BASE_URI__, 'mj_PS_JS_DIR_' => _PS_JS_DIR_, 'mj_MODULE_DIR_' => _MODULE_DIR_, 'mj_hint_fieldset' => array($this->l('This module enables you to create segments of customers according to any criteria you think of. You can then either display and export the selected customers or associate them to an existing customer group.', 'mailjet'), $this->l('These segments are particularly useful to create special offers associated with customer groups (e.g., send a coupon to the customers interested in some products)', 'mailjet'), $this->l('Create an infinite number of filters corresponding to your needs!', 'mailjet')), 'mj_datePickerJsFormat' => Context::getContext()->cookie->id_lang == Language::getIdByIso('fr') ? 'dd-mm-yy' : 'yy-mm-dd', 'mj_datepickerPersonnalized' => version_compare(_PS_VERSION_, '1.5', '<') ? '<script type="text/javascript" src="' . _PS_JS_DIR_ . 'jquery/datepicker/jquery-ui-personalized-1.6rc4.packed.js"></script>' : '', 'mj_token' => Tools::getValue('token'), 'mj_ajaxFile' => _MODULE_DIR_ . 'mailjet/ajax/ajax.php', 'mj_ajaxSyncFile' => _MODULE_DIR_ . 'mailjet/ajax/sync.php', 'mj_ajaxBundle' => _MODULE_DIR_ . 'mailjet/ajax/bundlejs_prestashop.php', 'mj_id_employee' => (int) Context::getContext()->cookie->id_employee, 'mj_lblMan' => stripReturn($this->ll(20)), 'mj_lblWoman' => stripReturn($this->ll(21)), 'mj_lblUnknown' => stripReturn($this->ll(43)), 'mj_trads' => array_map('stripReturn', $this->trad), 'mj_groups' => Group::getGroups((int) Context::getContext()->cookie->id_lang), 'mj_filter_list' => Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'mj_filter`'), 'mj_base_select' => Db::getInstance()->ExecuteS('SELECT id_basecondition, label FROM `' . _DB_PREFIX_ . 'mj_basecondition`')));
     return '';
 }
 public function uninstall()
 {
     foreach ($this->available_languages as $language) {
         Configuration::deleteByName('TS_TAB0_ID_' . (int) Language::getIdByIso($language));
         Configuration::deleteByName('TS_TAB0_ID_ACTIVE_' . (int) Language::getIdByIso($language));
     }
     Configuration::deleteByName('TS_TAB0_DISPLAY_IN_SHOP');
     Configuration::deleteByName('TS_TAB0_DISPLAY_RATING_FRONT_END');
     Configuration::deleteByName('TS_TAB0_DISPLAY_RATING_OC');
     Configuration::deleteByName('TS_TAB0_SEND_RATING');
     Configuration::deleteByName('TS_TAB0_SEND_SEPERATE_MAIL');
     Configuration::deleteByName('TS_TAB0_SEND_SEPERATE_MAIL_DELAY');
     Configuration::deleteByName('PS_TS_TAB0_SECURE_KEY');
     return RatingAlert::dropTable();
 }
示例#9
0
 public function __construct()
 {
     global $cookie;
     $this->name = 'ebay';
     $this->tab = 'market_place';
     $this->version = '1.1';
     parent::__construct();
     $this->displayName = $this->l('eBay');
     $this->description = $this->l('Open your shop on the eBay market place !');
     $this->id_lang = Language::getIdByIso('fr');
     // Check the country and ask the bypass if not 'fr'
     if (strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))) != 'fr' && !isset($cookie->ebay_country_default_fr)) {
         $this->warning = $this->l('eBay module currently works only for eBay.fr');
         return false;
     }
     // Checking Extension
     if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) {
         if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) {
             $this->warning = $this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.');
         } else {
             if (!extension_loaded('curl')) {
                 $this->warning = $this->l('You must enable cURL extension on your server if you want to use this module.');
             } else {
                 if (!ini_get('allow_url_fopen')) {
                     $this->warning = $this->l('You must enable allow_url_fopen option on your server if you want to use this module.');
                 }
             }
         }
         return false;
     }
     // Checking compatibility with older PrestaShop and fixing it
     if (!Configuration::get('PS_SHOP_DOMAIN')) {
         Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
     }
     // Generate eBay Security Token if not exists
     if (!Configuration::get('EBAY_SECURITY_TOKEN')) {
         Configuration::updateValue('EBAY_SECURITY_TOKEN', Tools::passwdGen(30));
     }
     // Check if installed
     if (self::isInstalled($this->name)) {
         // Generate warnings
         if (!Configuration::get('EBAY_API_TOKEN')) {
             $this->warning = $this->l('You must register your module on eBay.');
         }
         // Shipping methods
         $this->_shippingMethod = array(7104 => array('description' => 'Colissimo', 'shippingService' => 'FR_ColiposteColissimo', 'shippingServiceID' => '7104'), 7112 => array('description' => 'Ecopli', 'shippingService' => 'FR_Ecopli', 'shippingServiceID' => '7112'), 57104 => array('description' => 'La Poste - Courrier International Prioritaire', 'shippingService' => 'FR_LaPosteInternationalPriorityCourier', 'shippingServiceID' => '57104'), 7101 => array('description' => 'Lettre', 'shippingService' => 'FR_PostOfficeLetter', 'shippingServiceID' => '7101'), 57105 => array('description' => 'La Poste - Courrier International Economique', 'shippingService' => 'FR_LaPosteInternationalEconomyCourier', 'shippingServiceID' => '57105'), 57106 => array('description' => 'La Poste - Colissimo International', 'shippingService' => 'FR_LaPosteColissimoInternational', 'shippingServiceID' => '57106'), 7102 => array('description' => 'Lettre avec suivi', 'shippingService' => 'FR_PostOfficeLetterFollowed', 'shippingServiceID' => '7102'), 57107 => array('description' => 'La Poste - Colis Economique International', 'shippingService' => 'FR_LaPosteColisEconomiqueInternational', 'shippingServiceID' => '57107'), 7103 => array('description' => 'Lettre recommand&eacute;e', 'shippingService' => 'FR_PostOfficeLetterRecommended', 'shippingServiceID' => '7103'), 7121 => array('description' => 'Lettre Max', 'shippingService' => 'FR_LaPosteLetterMax', 'shippingServiceID' => '7121'), 7113 => array('description' => 'Coli&eacute;co', 'shippingService' => 'FR_Colieco', 'shippingServiceID' => '7113'), 57108 => array('description' => 'La Poste - Colissimo Emballage International', 'shippingService' => 'FR_LaPosteColissimoEmballageInternational', 'shippingServiceID' => '57108'), 57114 => array('description' => 'Chronopost Express International', 'shippingService' => 'FR_ChronopostExpressInternational', 'shippingServiceID' => '57114'), 7106 => array('description' => 'Colissimo Recommand&eacute;', 'shippingService' => 'FR_ColiposteColissimoRecommended', 'shippingServiceID' => '7106'), 57109 => array('description' => 'Chronopost Classic International', 'shippingService' => 'FR_ChronopostClassicInternational', 'shippingServiceID' => '57109'), 57110 => array('description' => 'Chronopost Premium International', 'shippingService' => 'FR_ChronopostPremiumInternational', 'shippingServiceID' => '57110'), 7117 => array('description' => 'Chronopost - Chrono Relais', 'shippingService' => 'FR_ChronopostChronoRelais', 'shippingServiceID' => '7117'), 57111 => array('description' => 'UPS Standard', 'shippingService' => 'FR_UPSStandardInternational', 'shippingServiceID' => '57111'), 7111 => array('description' => 'Autre mode d\'envoi de courrier', 'shippingService' => 'FR_Autre', 'shippingServiceID' => '7111'), 57112 => array('description' => 'UPS Express', 'shippingService' => 'FR_UPSExpressInternational', 'shippingServiceID' => '57112'), 7114 => array('description' => 'Autre mode d\'envoi de colis', 'shippingService' => 'FR_AuteModeDenvoiDeColis', 'shippingServiceID' => '7114'), 57113 => array('description' => 'DHL', 'shippingService' => 'FR_DHLInternational', 'shippingServiceID' => '57113'), 57101 => array('description' => 'Frais de livraison internationale fixes', 'shippingService' => 'FR_StandardInternational', 'shippingServiceID' => '57101'), 7116 => array('description' => 'Chronopost', 'shippingService' => 'FR_Chronopost', 'shippingServiceID' => '7116'), 57102 => array('description' => 'Frais fixes pour livraison internationale express', 'shippingService' => 'FR_ExpeditedInternational', 'shippingServiceID' => '57102'), 57103 => array('description' => 'Autres livraisons internationales (voir description)', 'shippingService' => 'FR_OtherInternational', 'shippingServiceID' => '57103'), 7118 => array('description' => 'Chrono 10', 'shippingService' => 'FR_Chrono10', 'shippingServiceID' => '7118'), 7119 => array('description' => 'Chrono 13', 'shippingService' => 'FR_Chrono13', 'shippingServiceID' => '7119'), 7120 => array('description' => 'Chrono 18', 'shippingService' => 'FR_Chrono18', 'shippingServiceID' => '7120'), 7105 => array('description' => 'Coliposte - Colissimo Direct', 'shippingService' => 'FR_ColiposteColissimoDirect', 'shippingServiceID' => '7105'), 7107 => array('description' => 'Chronoposte - Chrono Classic International', 'shippingService' => 'FR_ChronoposteInternationalClassic', 'shippingServiceID' => '7107'), 7108 => array('description' => 'DHL - Express Europack', 'shippingService' => 'FR_DHLExpressEuropack', 'shippingServiceID' => '7108'), 7109 => array('description' => 'UPS - Standard', 'shippingService' => 'FR_UPSStandard', 'shippingServiceID' => '7109'));
     }
 }
 function install()
 {
     $tab = new Tab();
     $tab->id_parent = 1;
     $tab->name = array(Language::getIdByIso('fr') => 'Carrousel d\'images', Language::getIdByIso('en') => 'Images carrousel');
     $tab->class_name = 'AdminGallerySlider';
     $tab->module = 'quadragalleryslider';
     $tab->add();
     if (!parent::install()) {
         return false;
     }
     Configuration::updateValue('PS_QUADRA_SLIDER_HEIGHT', 200);
     Configuration::updateValue('PS_QUADRA_SLIDER_WIDTH', 500);
     Configuration::updateValue('PS_QUADRA_V_DISPLAY', 0);
     //creation de la table
     $this->createTable();
     return $this->registerHook('home');
 }
示例#11
0
 /**
  * Loads the order status data from the order model.
  *
  * @param Order $order the model.
  */
 public function loadData(Order $order)
 {
     // We prefer to use the English state name for the status code, as we use it as an unique identifier of that
     // particular order status. The status label will primarily be in the language of the order.
     $id_lang = (int) Language::getIdByIso('en');
     if (empty($id_lang)) {
         $id_lang = (int) $order->id_lang;
     }
     $state = $order->getCurrentStateFull($id_lang);
     if (!empty($state['name'])) {
         $state_name = $state['name'];
         $this->code = $this->convertNameToCode($state_name);
         if ($id_lang !== (int) $order->id_lang) {
             $state = $order->getCurrentStateFull((int) $order->id_lang);
             if (!empty($state['name'])) {
                 $state_name = $state['name'];
             }
         }
         $this->label = $state_name;
     }
 }
 protected function _installLanguages($xml, $install_mode = false)
 {
     $attributes = array();
     if (isset($xml->languages->language)) {
         foreach ($xml->languages->language as $data) {
             $attributes = $data->attributes();
             if (Language::getIdByIso($attributes['iso_code'])) {
                 continue;
             }
             $native_lang = Language::getLanguages();
             $native_iso_code = array();
             foreach ($native_lang as $lang) {
                 $native_iso_code[] = $lang['iso_code'];
             }
             if (in_array((string) $attributes['iso_code'], $native_iso_code) and !$install_mode or !in_array((string) $attributes['iso_code'], $native_iso_code)) {
                 $errno = 0;
             }
             $errstr = '';
             if (@fsockopen('www.prestashop.com', 80, $errno, $errstr, 10)) {
                 if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $attributes['iso_code']))) {
                     if ($content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $attributes['iso_code'] . '.gzip')) {
                         $file = _PS_TRANSLATIONS_DIR_ . $attributes['iso_code'] . '.gzip';
                         if (file_put_contents($file, $content)) {
                             $gz = new Archive_Tar($file, true);
                             if (!$gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
                                 $this->_errors[] = Tools::displayError('Cannot decompress the translation file of the language: ') . (string) $attributes['iso_code'];
                                 return false;
                             }
                             if (!Language::checkAndAddLanguage((string) $attributes['iso_code'])) {
                                 $this->_errors[] = Tools::displayError('An error occurred while creating the language: ') . (string) $attributes['iso_code'];
                                 return false;
                             }
                             @unlink($file);
                         } else {
                             $this->_errors[] = Tools::displayError('Server does not have permissions for writing.');
                         }
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
             }
         }
     }
     // change the default language if there is only one language in the localization pack
     if (!sizeof($this->_errors) and $install_mode and isset($attributes['iso_code']) and sizeof($xml->languages->language) == 1) {
         $this->iso_code_lang = $attributes['iso_code'];
     }
     return true;
 }
    public function displayFormMails($lang, $noDisplay = false)
    {
        global $cookie, $currentIndex;
        $core_mails = array();
        $module_mails = array();
        $theme_mails = array();
        $str_output = '';
        // get all mail subjects, this method parse each files in Prestashop !!
        $subject_mail = array();
        $modules_has_mails = $this->getModulesHasMails();
        $arr_files_to_parse = array(_PS_ROOT_DIR_ . '/controllers', _PS_ROOT_DIR_ . '/classes', PS_ADMIN_DIR . '/tabs', PS_ADMIN_DIR);
        $arr_files_to_parse = array_merge($arr_files_to_parse, $modules_has_mails);
        foreach ($arr_files_to_parse as $path) {
            $subject_mail = self::getSubjectMail($path, $subject_mail);
        }
        $core_mails = $this->getMailFiles(_PS_MAIL_DIR_, $lang, 'core_mail');
        $core_mails['subject'] = $this->getSubjectMailContent(_PS_MAIL_DIR_ . $lang);
        foreach ($modules_has_mails as $module_name => $module_path) {
            $module_mails[$module_name] = $this->getMailFiles($module_path . '/mails/', $lang, 'module_mail');
            $module_mails[$module_name]['subject'] = $core_mails['subject'];
        }
        // Before 1.4.0.14 each theme folder was parsed,
        // This page was really to low to load.
        // Now just use the current theme.
        if (_THEME_NAME_ !== AdminTranslations::DEFAULT_THEME_NAME) {
            if (file_exists(_PS_THEME_DIR_ . 'mails')) {
                $theme_mails['theme_mail'] = $this->getMailFiles(_PS_THEME_DIR_ . 'mails/', $lang, 'theme_mail');
                $theme_mails['theme_mail']['subject'] = $this->getSubjectMailContent(_PS_THEME_DIR_ . 'mails/' . $lang);
            }
            if (file_exists(_PS_THEME_DIR_ . '/modules')) {
                foreach (scandir(_PS_THEME_DIR_ . '/modules') as $module_dir) {
                    if ($module_dir[0] != '.' and file_exists(_PS_THEME_DIR_ . 'modules/' . $module_dir . '/mails')) {
                        $theme_mails[$module_dir] = $this->getMailFiles(_PS_THEME_DIR_ . 'modules/' . $module_dir . '/mails/', $lang, 'theme_module_mail');
                        $theme_mails[$module_dir]['subject'] = $theme_mails['theme_mail']['subject'];
                    }
                }
            }
        }
        if ($noDisplay) {
            $empty = 0;
            $total = 0;
            $total += (int) $core_mails['total_filled'];
            $empty += (int) $core_mails['empty_values'];
            foreach ($module_mails as $mod_infos) {
                $total += (int) $mod_infos['total_filled'];
                $empty += (int) $mod_infos['empty_values'];
            }
            foreach ($theme_mails as $themes_infos) {
                $total += (int) $themes_infos['total_filled'];
                $empty += (int) $themes_infos['empty_values'];
            }
            return array('total' => $total, 'empty' => $empty);
        }
        $obj_lang = new Language(Language::getIdByIso($lang));
        // TinyMCE
        $str_output .= $this->getTinyMCEForMails($obj_lang->iso_code);
        $str_output .= '<!--' . $this->l('Language') . '-->';
        $str_output .= '
		<h2>' . $this->l('Language') . ' : ' . Tools::strtoupper($lang) . ' - ' . $this->l('E-mail template translations') . '</h2>' . $this->l('Click on the titles to open fieldsets') . '.<br /><br />';
        // display form
        $str_output .= '
		<form method="post" action="' . $currentIndex . '&token=' . $this->token . '&type=mails&lang=' . $obj_lang->iso_code . '" class="form">';
        $str_output .= $this->displayToggleButton();
        $str_output .= $this->displaySubmitButtons(Tools::getValue('type'));
        $str_output .= '<br/><br/>';
        // core emails
        $str_output .= $this->l('Core e-mails:');
        $str_output .= $this->displayMailContent($core_mails, $subject_mail, $obj_lang, 'core', $this->l('Core e-mails'));
        // module mails
        $str_output .= $this->l('Modules e-mails:');
        foreach ($module_mails as $module_name => $mails) {
            $str_output .= $this->displayMailContent($mails, $subject_mail, $obj_lang, Tools::strtolower($module_name), sprintf($this->l('E-mails for %s module'), '<em>' . $module_name . '</em>'), $module_name);
        }
        // mail theme and module theme
        if (!empty($theme_mails)) {
            $str_output .= $this->l('Themes e-mails:');
            $bool_title = false;
            foreach ($theme_mails as $theme_or_module_name => $mails) {
                $title = $theme_or_module_name != 'theme_mail' ? ucfirst(_THEME_NAME_) . ' ' . sprintf($this->l('E-mails for %s module'), '<em>' . $theme_or_module_name . '</em>') : ucfirst(_THEME_NAME_) . ' ' . $this->l('e-mails');
                if ($theme_or_module_name != 'theme_mail' && !$bool_title) {
                    $bool_title = true;
                    $str_output .= $this->l('E-mails modules in theme:');
                }
                $str_output .= $this->displayMailContent($mails, $subject_mail, $obj_lang, 'theme_' . Tools::strtolower($theme_or_module_name), $title, $theme_or_module_name != 'theme_mail' ? $theme_or_module_name : false);
            }
        }
        $str_output .= '
				<input type="hidden" name="lang" value="' . $lang . '" />
				<input type="hidden" name="type" value="' . Tools::getValue('type') . '" />';
        $str_output .= $this->displaySubmitButtons(Tools::getValue('type'));
        $str_output .= '<br /><br />';
        $str_output .= '</form>';
        echo $str_output;
    }
示例#14
0
 /**
  * Change language in cookie while clicking on a flag
  *
  * @return string iso code
  */
 public static function setCookieLanguage()
 {
     global $cookie;
     /* If language does not exist or is disabled, erase it */
     if ($cookie->id_lang) {
         $lang = new Language((int) $cookie->id_lang);
         if (!Validate::isLoadedObject($lang) or !$lang->active) {
             $cookie->id_lang = NULL;
         }
     }
     /* Automatically detect language if not already defined */
     if (!$cookie->id_lang and isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $array = explode(',', self::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
         if (self::strlen($array[0]) > 2) {
             $tab = explode('-', $array[0]);
             $string = $tab[0];
         } else {
             $string = $array[0];
         }
         if (Validate::isLanguageIsoCode($string)) {
             $lang = new Language((int) Language::getIdByIso($string));
             if (Validate::isLoadedObject($lang) and $lang->active) {
                 $cookie->id_lang = (int) $lang->id;
             }
         }
     }
     /* If language file not present, you must use default language file */
     if (!$cookie->id_lang or !Validate::isUnsignedId($cookie->id_lang)) {
         $cookie->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     }
     $iso = Language::getIsoById((int) $cookie->id_lang);
     @(include_once _PS_THEME_DIR_ . 'lang/' . $iso . '.php');
     return $iso;
 }
示例#15
0
 public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false, $params_lang = null)
 {
     if (Language::getIdByIso($iso_code)) {
         return true;
     }
     // Initialize the language
     $lang = new Language();
     $lang->iso_code = Tools::strtolower($iso_code);
     $lang->language_code = $iso_code;
     // Rewritten afterwards if the language code is available
     $lang->active = true;
     // If the language pack has not been provided, retrieve it from prestashop.com
     if (!$lang_pack) {
         $lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $iso_code));
     }
     // If a language pack has been found or provided, prefill the language object with the value
     if ($lang_pack) {
         foreach (get_object_vars($lang_pack) as $key => $value) {
             if ($key != 'iso_code' && isset(Language::$definition['fields'][$key])) {
                 $lang->{$key} = $value;
             }
         }
     }
     // Use the values given in parameters to override the data retrieved automatically
     if ($params_lang !== null && is_array($params_lang)) {
         foreach ($params_lang as $key => $value) {
             if ($key != 'iso_code' && isset(Language::$definition['fields'][$key])) {
                 $lang->{$key} = $value;
             }
         }
     }
     if (!$lang->name && $lang->iso_code) {
         $lang->name = $lang->iso_code;
     }
     if (!$lang->validateFields() || !$lang->validateFieldsLang() || !$lang->add(true, false, $only_add)) {
         return false;
     }
     if (isset($params_lang['allow_accented_chars_url']) && in_array($params_lang['allow_accented_chars_url'], array('1', 'true'))) {
         Configuration::updateGlobalValue('PS_ALLOW_ACCENTED_CHARS_URL', 1);
     }
     $flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/' . $iso_code . '.jpg');
     if ($flag != null && !preg_match('/<body>/', $flag)) {
         $file = fopen(_PS_ROOT_DIR_ . '/img/l/' . (int) $lang->id . '.jpg', 'w');
         if ($file) {
             fwrite($file, $flag);
             fclose($file);
         } else {
             Language::_copyNoneFlag((int) $lang->id);
         }
     } else {
         Language::_copyNoneFlag((int) $lang->id);
     }
     $files_copy = array('/en.jpg', '/en-default-' . ImageType::getFormatedName('thickbox') . '.jpg', '/en-default-' . ImageType::getFormatedName('home') . '.jpg', '/en-default-' . ImageType::getFormatedName('large') . '.jpg', '/en-default-' . ImageType::getFormatedName('medium') . '.jpg', '/en-default-' . ImageType::getFormatedName('small') . '.jpg', '/en-default-' . ImageType::getFormatedName('scene') . '.jpg');
     foreach (array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_) as $to) {
         foreach ($files_copy as $file) {
             @copy(_PS_ROOT_DIR_ . '/img/l' . $file, $to . str_replace('/en', '/' . $iso_code, $file));
         }
     }
     return true;
 }
 /**
  * build xml with customer's and order's data et send it to FIA-NET
  * 
  * @param int $id_order
  * @return boolean 
  */
 public function sendXML($id_order)
 {
     $order = new Order($id_order);
     $montant = $order->total_paid;
     $date = $order->date_add;
     $customer = new Customer($order->id_customer);
     $lastname = $customer->lastname;
     $firstname = $customer->firstname;
     $id_currency = $order->id_currency;
     $currency = new Currency($id_currency);
     if (_PS_VERSION_ < '1.5') {
         $civility = $customer->id_gender;
         $accepted_civility = array("1", "2", "3");
         if (!in_array($civility, $accepted_civility)) {
             $civility = '1';
         }
     } else {
         $gender = new Gender($customer->id_gender);
         $id_lang = Language::getIdByIso($this->context->language->iso_code);
         $civility = $gender->name[$id_lang] == 'Mr.' ? 1 : 2;
     }
     //xml construction
     if (_PS_VERSION_ < '1.5') {
         $fianetsceau = new Sceau();
     } else {
         $fianetsceau = new Sceau((int) $order->id_shop);
     }
     $utilisateur = new SceauXMLElement('<utilisateur></utilisateur>');
     $nom = $utilisateur->childNom($customer->lastname);
     $nom->addAttribute('titre', $civility);
     $utilisateur->childPrenom($customer->firstname);
     $utilisateur->childEmail(strtolower($customer->email));
     $infocommande = new SceauXMLElement('<infocommande></infocommande>');
     $infocommande->childSiteid($fianetsceau->getSiteid());
     $infocommande->childRefid($id_order);
     $montant = $infocommande->childMontant($order->total_paid);
     $montant->addAttribute('devise', $currency->iso_code);
     $ip = new SceauXMLElement('<ip>' . $this->getCustomerIP($id_order) . '</ip>');
     $ip->addAttribute('timestamp', $order->date_add);
     $infocommande->childIp($ip);
     $paiement = new SceauXMLElement('<paiement></paiement>');
     $paiement->childType($this->getPaymentFianetType($id_order));
     $lang = Language::getIsoById($order->id_lang);
     $langue = $infocommande->childLangue($lang);
     $xml_order = new SceauControl();
     $xml_order->childUtilisateur($utilisateur);
     $xml_order->childInfocommande($infocommande);
     $xml_order->childPaiement($paiement);
     $fianetsceau->addCrypt($xml_order);
     $result = $fianetsceau->sendSendrating($xml_order);
     if (!($result === false)) {
         $resxml = new SceauXMLElement($result);
         if ($resxml->getAttribute('type') != "OK") {
             //update fianetsceau_state 3:error
             $this->updateOrder($id_order, array('id_fianetsceau_state' => '3'));
             SceauLogger::insertLogSceau(__METHOD__ . " : " . __LINE__, 'Order ' . $id_order . ' XML Send error : ' . $resxml->getChildByName('detail')->getValue());
             return false;
         } else {
             //update fianetsceau_state 2:sent
             $this->updateOrder($id_order, array('id_fianetsceau_state' => '2'));
         }
         return true;
     } else {
         //update fianetsceau_state 3:error
         $this->updateOrder($id_order, array('id_fianetsceau_state' => '3'));
         SceauLogger::insertLogSceau(__METHOD__ . " : " . __LINE__, 'Order ' . $id_order . ' XML Send error : ' . $resxml->getChildByName('detail')->getValue());
         return false;
     }
 }
示例#17
0
 public static function checkAndAddLanguage($iso_code)
 {
     if (Language::getIdByIso($iso_code)) {
         return true;
     } else {
         if (@fsockopen('www.prestashop.com', 80)) {
             $lang = new Language();
             $lang->iso_code = $iso_code;
             $lang->active = true;
             if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $iso_code))) {
                 if (isset($lang_pack->name) && isset($lang_pack->version) && isset($lang_pack->iso_code)) {
                     $lang->name = $lang_pack->name;
                 }
             }
             if (!$lang->name or !$lang->add()) {
                 return false;
             }
             $insert_id = (int) $lang->id;
             if ($lang_pack) {
                 $flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/' . $iso_code . '.jpg');
                 if ($flag != NULL && !preg_match('/<body>/', $flag)) {
                     $file = fopen(dirname(__FILE__) . '/../img/l/' . $insert_id . '.jpg', 'w');
                     if ($file) {
                         fwrite($file, $flag);
                         fclose($file);
                     } else {
                         self::_copyNoneFlag($insert_id);
                     }
                 } else {
                     self::_copyNoneFlag($insert_id);
                 }
             } else {
                 self::_copyNoneFlag($insert_id);
             }
             $files_copy = array('/en.jpg', '/en-default-thickbox.jpg', '/en-default-home.jpg', '/en-default-large.jpg', '/en-default-medium.jpg', '/en-default-small.jpg', '/en-default-large_scene.jpg');
             $tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
             foreach ($tos as $to) {
                 foreach ($files_copy as $file) {
                     $name = str_replace('/en', '/' . $iso_code, $file);
                     copy(dirname(__FILE__) . '/../img/l' . $file, $to . $name);
                 }
             }
             return true;
         } else {
             return false;
         }
     }
 }
示例#18
0
 /**
  * Create link after language change, for the change language block
  *
  * @param integer $id_lang Language ID
  * @return string link
  */
 public function getLanguageLink($id_lang)
 {
     global $cookie;
     $matches = array();
     $request = $_SERVER['REQUEST_URI'];
     preg_match('#^/([a-z]{2})/([^\\?]*).*$#', $request, $matches);
     if ($matches) {
         $current_iso = $matches[1];
         $rewrite = $matches[2];
         $url_rewrite = Meta::getEquivalentUrlRewrite($id_lang, Language::getIdByIso($current_iso), $rewrite);
         $request = str_replace($rewrite, $url_rewrite, $request);
     }
     $queryTab = array();
     parse_str($_SERVER['QUERY_STRING'], $queryTab);
     unset($queryTab['isolang']);
     $query = http_build_query($queryTab);
     if (!empty($query) or !$this->allow) {
         $query = '?' . $query;
     }
     $switchLangLink = $this->getPageLink(substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)), false, $id_lang) . $query;
     if (!$this->allow) {
         if ($id_lang != $cookie->id_lang) {
             if (strpos($switchLangLink, 'id_lang')) {
                 $switchLangLink = preg_replace('`id_lang=[0-9]*`', 'id_lang=' . $id_lang, $switchLangLink);
             } else {
                 $switchLangLink = $switchLangLink . '&amp;id_lang=' . $id_lang;
             }
         }
     }
     return $switchLangLink;
 }
 private function buildXMLOrder($id_order)
 {
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, 'construction du flux pour order ' . $id_order);
     $order = new Order($id_order);
     //gets back the delivery address
     $address_delivery = new Address((int) $order->id_address_delivery);
     //gets back the invoice address
     $address_invoice = new Address((int) $order->id_address_invoice);
     //gets back the customer
     $customer = new Customer((int) $order->id_customer);
     //initializatino of the XML root: <control>
     $xml_element_control = new CertissimControl();
     //gets the lang used in the order
     $id_lang = $order->id_lang;
     //sets the gender, depends on PS version
     if (_PS_VERSION_ < '1.5') {
         $gender = $customer->id_gender == 2 ? $this->l('Ms.') : $this->l('Mr.');
     } else {
         $customer_gender = new Gender($customer->id_gender);
         $lang_id = Language::getIdByIso('en');
         if (empty($lang_id)) {
             $lang_id = Language::getIdByIso('fr');
         }
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "id_gender = " . $customer->id_gender . ", gender name =" . $customer_gender->name[$lang_id]);
         $gender = $this->l($customer_gender->name[$lang_id]);
     }
     //initialization of the element <utilisateur type='facturation'...>
     $xml_element_invoice_customer = new CertissimUtilisateur('facturation', $gender, $address_invoice->lastname, $address_invoice->firstname, $address_invoice->company, $address_invoice->phone, $address_invoice->phone_mobile, null, $customer->email);
     //gets customer stats
     $customer_stats = $customer->getStats();
     //gets already existing orders for the customer
     $all_orders = Order::getCustomerOrders((int) $customer->id);
     //initialization of the element <siteconso>
     $xml_element_invoice_customer_stats = new CertissimSiteconso($customer_stats['total_orders'], $customer_stats['nb_orders'], $all_orders[count($all_orders) - 1]['date_add'], count($all_orders) > 1 ? $all_orders[1]['date_add'] : null);
     //gets back the invoice country
     $country = new Country((int) $address_invoice->id_country);
     //initialization of the element <adresse type="facturation" ...>
     $xml_element_invoice_address = new CertissimAdresse('facturation', $address_invoice->address1, $address_invoice->address2, $address_invoice->postcode, $address_invoice->city, $country->name[$id_lang]);
     //gets back the carrier used for this order
     $carrier = new Carrier((int) $order->id_carrier);
     //gets the carrier certissim type
     if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
         $carrier_type = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE', null, null, $order->id_shop);
     } else {
         $carrier_type = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE');
     }
     //if the order is to be delivered at home: element <utilisateur type="livraison"...> has to be added
     if ($carrier_type == 4) {
         //initialization of the element <utilisateur type="livraison" ...>
         $xml_element_delivery_customer = new CertissimUtilisateur('livraison', $customer->id_gender == 2 ? $this->l('Miss') : $this->l('Mister'), $address_delivery->lastname, $address_delivery->firstname, $address_delivery->company, $address_delivery->phone, $address_delivery->phone_mobile, null, $customer->email);
         //gets back the delivery country
         $country = new Country((int) $address_delivery->id_country);
         //initialization of the element <adresse type="livraison" ...>
         $xml_element_delivery_address = new CertissimAdresse('livraison', $address_delivery->address1, $address_delivery->address2, $address_delivery->postcode, $address_delivery->city, $country->name[$id_lang], null);
     }
     //gets the used currency
     $currency = new Currency((int) $order->id_currency);
     if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
         $siteid = Configuration::get('CERTISSIM_SITEID', null, null, $order->id_shop);
     } else {
         $siteid = Configuration::get('CERTISSIM_SITEID');
     }
     //initialize the element <infocommande>
     $xml_element_order_details = new CertissimInfocommande($siteid, $order->id, (string) $order->total_paid, self::getIpByOrder((int) $order->id), date('Y-m-d H:i:s'), $currency->iso_code);
     //gets the order products
     $products = $order->getProducts();
     //define the default product type (depends on PS version)
     if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
         $default_product_type = Configuration::get('CERTISSIM_DEFAULT_PRODUCT_TYPE', null, null, $order->id_shop);
     } else {
         $default_product_type = Configuration::get('CERTISSIM_DEFAULT_PRODUCT_TYPE');
     }
     //initialization of the element <list ...>
     $xml_element_products_list = new CertissimProductList();
     //initialize the boolean that says if all the products in the order are downloadables
     $alldownloadables = true;
     foreach ($products as $product) {
         //check if the visited product is downloadable and update the boolean value
         $alldownloadables = $alldownloadables && strlen($product['download_hash']) > 0;
         //gets the main product category
         $product_categories = Product::getProductCategories((int) $product['product_id']);
         $product_category = array_pop($product_categories);
         //initilization of the element <produit ...>
         $xml_element_product = new CertissimXMLElement("<produit></produit>");
         //gets the product certissim category (depends on PS version)
         if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
             $product_type = Configuration::get('CERTISSIM' . $product_category . '_PRODUCT_TYPE', null, null, $order->id_shop);
         } else {
             $product_type = Configuration::get('CERTISSIM' . $product_category . '_PRODUCT_TYPE');
         }
         //if a certissim category is set: the type attribute takes the product certissim type value
         if ($product_type) {
             $xml_element_product->addAttribute('type', Configuration::get('CERTISSIM' . $product_category . '_PRODUCT_TYPE', null, null, $order->id_shop));
         } else {
             //if certissim category not set: the type attribute takes the default value
             $xml_element_product->addAttribute('type', $default_product_type);
         }
         //sets the product reference that will be inserted into the XML stream
         //uses the product name by default
         $product_ref = $product['product_name'];
         //prefers ean13 if defined
         if (!empty($product['product_ean13'])) {
             $product_ref = $product['product_ean13'];
         }
         //prefers local reference if defined
         if (!empty($product['product_reference'])) {
             $product_ref = $product['product_reference'];
         }
         //adds attributes ref, nb, prixunit, and sets the value of the element <product> with the product name
         $xml_element_product->addAttribute('ref', CertissimTools::normalizeString($product_ref));
         $xml_element_product->addAttribute('nb', $product['product_quantity']);
         $xml_element_product->addAttribute('prixunit', $product['total_price']);
         $xml_element_product->setValue($product['product_name']);
         //adds the element <product> to the element <list>
         $xml_element_products_list->addProduit($xml_element_product);
     }
     if ($alldownloadables) {
         $real_carrier_type = '5';
     } elseif (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
         //if selected carrier fianet type is defined, the type used will be the one got in the Configuration
         if (in_array(Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE', null, null, $order->id_shop), array_keys($this->_carrier_types))) {
             $real_carrier_type = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE', null, null, $order->id_shop);
             $real_carrier_speed = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_SPEED', null, null, $order->id_shop);
         } else {
             $real_carrier_type = Configuration::get('CERTISSIM_DEFAULT_CARRIER_TYPE', null, null, $order->id_shop);
             $real_carrier_speed = Configuration::get('CERTISSIM_DEFAULT_CARRIER_SPEED', null, null, $order->id_shop);
         }
     } elseif (in_array(Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE'), array_keys($this->_carrier_types))) {
         $real_carrier_type = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE');
         $real_carrier_speed = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_SPEED');
     } else {
         $real_carrier_type = Configuration::get('CERTISSIM_DEFAULT_CARRIER_TYPE');
         $real_carrier_speed = Configuration::get('CERTISSIM_DEFAULT_CARRIER_SPEED');
     }
     //initialization of the element <transport>
     $xml_element_carrier = new CertissimTransport($real_carrier_type, $alldownloadables ? 'Téléchargement' : Tools::htmlentitiesUTF8($carrier->name), $alldownloadables ? '1' : $real_carrier_speed, null);
     //find the id of the payment module used (depends on the PS version)
     if (_PS_VERSION_ >= '1.5') {
         $id_payment_module = PaymentModule::getModuleIdByName($order->module);
     } else {
         $payment_module = Module::getInstanceByName($order->module);
         $id_payment_module = $payment_module->id;
     }
     //initialization of the element <paiement>
     if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
         $payment_type = $this->_payment_types[Configuration::get('CERTISSIM_' . $id_payment_module . '_PAYMENT_TYPE', null, null, $order->id_shop)];
     } else {
         $payment_type = $this->_payment_types[Configuration::get('CERTISSIM_' . $id_payment_module . '_PAYMENT_TYPE')];
     }
     $xml_element_payment = new CertissimPaiement($payment_type);
     //initialization of the element <stack>
     $stack = new CertissimXMLElement("<stack></stack>");
     //agregates each elements in a main stream
     $xml_element_invoice_customer->childSiteconso($xml_element_invoice_customer_stats);
     $xml_element_control->childUtilisateur($xml_element_invoice_customer);
     $xml_element_control->childAdresse($xml_element_invoice_address);
     if (isset($xml_element_delivery_customer)) {
         $xml_element_control->childUtilisateur($xml_element_delivery_customer);
     }
     if (isset($xml_element_delivery_address)) {
         $xml_element_control->childAdresse($xml_element_delivery_address);
     }
     $xml_element_order_details->childTransport($xml_element_carrier);
     $xml_element_order_details->childList($xml_element_products_list);
     $xml_element_control->childInfocommande($xml_element_order_details);
     $xml_element_control->childPaiement($xml_element_payment);
     //add CDATA sections to protect against encoding issues
     $xml_element_control->addCdataSections();
     //add the <control> element into <stack>
     $stack->childControl($xml_element_control);
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "---- flux généré pour commande {$id_order} ----");
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $xml_element_control->getXML());
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "---------------------------------------");
     return $stack;
 }
示例#20
0
 private static function fillInfo($infos, $key, &$entity)
 {
     if (isset(self::$validators[$key][1]) && self::$validators[$key][1] == 'createMultiLangField' && Tools::getValue('iso_lang')) {
         $id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
         $tmp = call_user_func(self::$validators[$key], $infos);
         foreach ($tmp as $id_lang_tmp => $value) {
             if (empty($entity->{$key}[$id_lang_tmp]) or $id_lang_tmp == $id_lang) {
                 $entity->{$key}[$id_lang_tmp] = $value;
             }
         }
     } else {
         $entity->{$key} = isset(self::$validators[$key]) ? call_user_func(self::$validators[$key], $infos) : $infos;
     }
     return true;
 }
 public function postProcess()
 {
     if (isset($_GET['delete' . $this->table])) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) {
                 // English is needed by the system (ex. translations)
                 if ($object->id == Language::getIdByIso('en')) {
                     $this->errors[] = $this->l('You cannot delete the English language because it is a system requirement, you can only deactivate it.');
                 }
                 if ($object->id == Configuration::get('PS_LANG_DEFAULT')) {
                     $this->errors[] = $this->l('You cannot delete the default language');
                 } else {
                     if ($object->id == $this->context->language->id) {
                         $this->errors[] = $this->l('You cannot delete the language currently in use. Please change languages before deleting.');
                     } else {
                         if ($this->deleteNoPictureImages((int) Tools::getValue('id_lang')) && $object->delete()) {
                             Tools::redirectAdmin(self::$currentIndex . '&conf=1' . '&token=' . $this->token);
                         }
                     }
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } else {
         if (Tools::getValue('submitDel' . $this->table) && isset($_POST[$this->table . 'Box'])) {
             if ($this->tabAccess['delete'] === '1') {
                 if (in_array(Configuration::get('PS_LANG_DEFAULT'), $_POST[$this->table . 'Box'])) {
                     $this->errors[] = $this->l('You cannot delete the default language');
                 } else {
                     if (in_array($this->context->language->id, $_POST[$this->table . 'Box'])) {
                         $this->errors[] = $this->l('you cannot delete the language currently in use, please change languages before deleting');
                     } else {
                         foreach ($_POST[$this->table . 'Box'] as $language) {
                             $this->deleteNoPictureImages($language);
                         }
                         parent::postProcess();
                     }
                 }
             } else {
                 $this->errors[] = Tools::displayError('You do not have permission to delete here.');
             }
         } else {
             if (Tools::isSubmit('submitAddlang')) {
                 /* New language */
                 if ((int) Tools::getValue('id_' . $this->table) == 0) {
                     if ($this->tabAccess['add'] === '1') {
                         if (isset($_POST['iso_code']) && !empty($_POST['iso_code']) && Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Language::getIdByIso($_POST['iso_code'])) {
                             $this->errors[] = Tools::displayError('This ISO code is already linked to another language.');
                         }
                         if ((!empty($_FILES['no-picture']['tmp_name']) || !empty($_FILES['flag']['tmp_name'])) && Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
                             if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK) {
                                 $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
                             }
                             // class AdminTab deal with every $_FILES content, don't do that for no-picture
                             unset($_FILES['no-picture']);
                             parent::postProcess();
                         } else {
                             $this->validateRules();
                             $this->errors[] = Tools::displayError('Flag and "No picture" image fields are required.');
                         }
                     } else {
                         $this->errors[] = Tools::displayError('You do not have permission to add here.');
                     }
                 } else {
                     if ($this->tabAccess['edit'] === '1') {
                         if ((isset($_FILES['no-picture']) && !$_FILES['no-picture']['error'] || isset($_FILES['flag']) && !$_FILES['flag']['error']) && Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
                             if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK) {
                                 $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
                             }
                             // class AdminTab deal with every $_FILES content, don't do that for no-picture
                             unset($_FILES['no-picture']);
                             parent::postProcess();
                         }
                         if (!Validate::isLoadedObject($object = $this->loadObject())) {
                             $this->errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                         }
                         if ((int) $object->id == (int) Configuration::get('PS_LANG_DEFAULT') && (int) $_POST['active'] != (int) $object->active) {
                             $this->errors[] = Tools::displayError('You cannot change the status of the default language.');
                         } else {
                             parent::postProcess();
                         }
                         $this->validateRules();
                     } else {
                         $this->errors[] = Tools::displayError('You do not have permission to edit here.');
                     }
                 }
             } else {
                 if (isset($_GET['status' . $this->table]) && isset($_GET['id_lang'])) {
                     if ($this->tabAccess['edit'] === '1') {
                         if (!Validate::isLoadedObject($object = $this->loadObject())) {
                             $this->errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                         }
                         if ((int) $object->id == (int) Configuration::get('PS_LANG_DEFAULT')) {
                             $this->errors[] = Tools::displayError('You cannot change the status of the default language.');
                         } else {
                             return parent::postProcess();
                         }
                     } else {
                         $this->errors[] = Tools::displayError('You do not have permission to edit here.');
                     }
                 } else {
                     return parent::postProcess();
                 }
             }
         }
     }
 }
示例#22
0
 /**
  * @param SimpleXMLElement $xml
  * @param bool $install_mode
  * @return bool
  */
 protected function _installLanguages($xml, $install_mode = false)
 {
     $attributes = array();
     if (isset($xml->languages->language)) {
         foreach ($xml->languages->language as $data) {
             /** @var SimpleXMLElement $data */
             $attributes = $data->attributes();
             // if we are not in an installation context or if the pack is not available in the local directory
             if (Language::getIdByIso($attributes['iso_code']) && !$install_mode) {
                 continue;
             }
             $errors = Language::downloadAndInstallLanguagePack($attributes['iso_code'], $attributes['version'], $attributes);
             if ($errors !== true && is_array($errors)) {
                 $this->_errors = array_merge($this->_errors, $errors);
             }
         }
     }
     // change the default language if there is only one language in the localization pack
     if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->languages->language) == 1) {
         $this->iso_code_lang = $attributes['iso_code'];
     }
     return !count($this->_errors);
 }
示例#23
0
 /**
  * Set cookie id_lang
  */
 public static function switchLanguage(Context $context = null)
 {
     if (!$context) {
         $context = Context::getContext();
     }
     // Install call the dispatcher and so the switchLanguage
     // Stop this method by checking the cookie
     if (!isset($context->cookie)) {
         return;
     }
     if (($iso = Tools::getValue('isolang')) && Validate::isLanguageIsoCode($iso) && ($id_lang = (int) Language::getIdByIso($iso))) {
         $_GET['id_lang'] = $id_lang;
     }
     // update language only if new id is different from old id
     // or if default language changed
     $cookie_id_lang = $context->cookie->id_lang;
     $configuration_id_lang = Configuration::get('PS_LANG_DEFAULT');
     if (($id_lang = (int) Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang) && $cookie_id_lang != (int) $id_lang || $id_lang == $configuration_id_lang && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang) {
         $context->cookie->id_lang = $id_lang;
         $language = new Language($id_lang);
         if (Validate::isLoadedObject($language) && $language->active) {
             $context->language = $language;
         }
         $params = $_GET;
         if (Configuration::get('PS_REWRITING_SETTINGS') || !Language::isMultiLanguageActivated()) {
             unset($params['id_lang']);
         }
     }
 }
示例#24
0
    public function checkAndAddLang($languages, $add = true)
    {
        $errors = '';
        $moduleName = Tools::getValue('moduleName');
        $this->alterTable('language');
        foreach ($languages as $language) {
            $iso = $language['iso_code'];
            if (!Language::isInstalled($iso)) {
                if ($add) {
                    if (@fsockopen('www.prestashop.com', 80)) {
                        if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $iso))) {
                            if ($content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $iso . '.gzip')) {
                                $file = _PS_TRANSLATIONS_DIR_ . $iso . '.gzip';
                                if (file_put_contents($file, $content)) {
                                    require_once '../../tools/tar/Archive_Tar.php';
                                    $gz = new Archive_Tar($file, true);
                                    if ($gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
                                        if (!Language::checkAndAddLanguage($iso)) {
                                            $errors[] = $this->l('Archive cannot be extracted.');
                                        } else {
                                            $newId = Language::getIdByIso($iso);
                                            Db::getInstance()->execute('UPDATE  `' . _DB_PREFIX_ . 'lang`
																		SET  `id_lang_' . bqSQL($moduleName) . '` =  ' . (int) $language['id_lang'] . '
																		WHERE  `id_lang` = ' . (int) $newId);
                                        }
                                    }
                                    $errors[] = $this->l('Archive cannot be extracted.');
                                } else {
                                    $errors[] = $this->l('Server does not have permissions for writing.');
                                }
                            } else {
                                $errors[] = $this->l('Language not found');
                            }
                        } else {
                            $errors[] = $this->l('archive cannot be downloaded from prestashop.com.');
                        }
                    } else {
                        $errors[] = $this->l('archive cannot be downloaded from prestashop.com.');
                    }
                }
            } else {
                $newId = Language::getIdByIso($iso);
                Db::getInstance()->execute('UPDATE  `' . _DB_PREFIX_ . 'lang`
											SET  `id_lang_' . bqSQL($moduleName) . '` =  ' . (int) $language['id_lang'] . '
											WHERE  `id_lang` = ' . (int) $newId);
            }
        }
    }
 public function writeFeed($total, $current = 0)
 {
     if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) {
         die("<?xml version='1.0' encoding='utf-8'?><error>Invalid Token</error>");
     }
     if (!is_file(dirname(__FILE__) . '/feed.xml')) {
         die("<?xml version='1.0' encoding='utf-8'?><error>File error</error>");
     }
     $file = fopen(dirname(__FILE__) . '/feed.xml', 'a+');
     $configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     $lang = Tools::getValue('lang');
     $configuration['PS_LANG_DEFAULT'] = !empty($lang) ? Language::getIdByIso($lang) : $configuration['PS_LANG_DEFAULT'];
     $carrier = Carrier::getCarrierByReference((int) Configuration::get('SHOPPING_FLUX_CARRIER'));
     //manage case PS_CARRIER_DEFAULT is deleted
     $carrier = is_object($carrier) ? $carrier : new Carrier((int) Configuration::get('SHOPPING_FLUX_CARRIER'));
     $products = $this->getSimpleProducts($configuration['PS_LANG_DEFAULT'], $current);
     $str = '';
     foreach ($products as $productArray) {
         $product = new Product((int) $productArray['id_product'], true, $configuration['PS_LANG_DEFAULT']);
         $link = new Link();
         $str .= '<produit>';
         $str .= $this->_getBaseData($product, $configuration, $link, $carrier);
         $str .= $this->_getImages($product, $configuration, $link);
         $str .= $this->_getUrlCategories($product, $configuration, $link);
         $str .= $this->_getFeatures($product, $configuration);
         $str .= $this->_getCombinaisons($product, $configuration, $link, $carrier);
         $str .= $this->_getFilAriane($product, $configuration);
         $str .= '<manufacturer><![CDATA[' . $product->manufacturer_name . ']]></manufacturer>';
         $str .= '<supplier><![CDATA[' . $product->supplier_name . ']]></supplier>';
         if (is_array($product->specificPrice)) {
             $str .= '<from><![CDATA[' . $product->specificPrice['from'] . ']]></from>';
             $str .= '<to><![CDATA[' . $product->specificPrice['to'] . ']]></to>';
         } else {
             $str .= '<from/>';
             $str .= '<to/>';
         }
         $str .= '<url-fournisseur><![CDATA[' . $link->getSupplierLink($product->id_supplier, null, $configuration['PS_LANG_DEFAULT']) . ']]></url-fournisseur>';
         $str .= '<url-fabricant><![CDATA[' . $link->getManufacturerLink($product->id_manufacturer, null, $configuration['PS_LANG_DEFAULT']) . ']]></url-fabricant>';
         $str .= '<solde>' . (int) $product->on_sale . '</solde>';
         $str .= '</produit>';
     }
     fwrite($file, $str);
     fclose($file);
     if ($current + 500 >= $total) {
         $this->closeFeed();
     } else {
         $next_uri = 'http://' . Tools::getHttpHost() . __PS_BASE_URI__ . 'modules/shoppingfluxexport/cron.php?token=' . Configuration::get('SHOPPING_FLUX_TOKEN') . '&current=' . ($current + 500) . '&total=' . $total;
         header('Location:' . $next_uri);
     }
 }
 public function initLang()
 {
     if ($iso = Tools::getValue('lang')) {
         $lang = Tools::substr($iso, 0, 2);
         if ($language_id = Language::getIdByIso($lang)) {
             $this->context->language = new Language($language_id);
         }
     }
 }
示例#27
0
/* Theme is missing or maintenance */
if (!is_dir(dirname(__FILE__) . '/themes/' . _THEME_NAME_)) {
    die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
} elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' and !intval(Configuration::get('PS_SHOP_ENABLE'))) {
    $maintenance = true;
}
ob_start();
global $cart, $cookie, $_CONF, $link;
/* 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;
// Init Cookie
$cookie = new Cookie('ps');
// Switch language if needed and init cookie language
if ($iso = Tools::getValue('isolang') and Validate::isLanguageIsoCode($iso) and $id_lang = intval(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 */
define('_USER_ID_LANG_', intval($cookie->id_lang));
if (isset($_GET['logout']) or $cookie->logged and Customer::isBanned(intval($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);
}
$iso = strtolower(Language::getIsoById($cookie->id_lang ? intval($cookie->id_lang) : 1));
@(include _PS_TRANSLATIONS_DIR_ . $iso . '/fields.php');
示例#28
0
 public function customerImport($offset = false, $limit = false, $validateOnly = false)
 {
     $this->receiveTab();
     $handle = $this->openCsvFile($offset);
     if (!$handle) {
         return false;
     }
     $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
     $id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
     if (!Validate::isUnsignedId($id_lang)) {
         $id_lang = $default_language_id;
     }
     AdminImportController::setLocale();
     $shop_is_feature_active = Shop::isFeatureActive();
     $force_ids = Tools::getValue('forceIDs');
     $line_count = 0;
     for ($current_line = 0; ($line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator)) && (!$limit || $current_line < $limit); $current_line++) {
         $line_count++;
         if ($this->convert) {
             $line = $this->utf8EncodeArray($line);
         }
         if (count($line) == 1 && $line[0] == null) {
             $this->warnings[] = $this->l('There is an empty row in the file that won\'t be imported.');
             continue;
         }
         $info = AdminImportController::getMaskedRow($line);
         $this->customerImportOne($info, $default_language_id, $id_lang, $shop_is_feature_active, $force_ids, $validateOnly);
     }
     $this->closeCsvFile($handle);
     return $line_count;
 }
 public function processAdd()
 {
     if (_PS_MODE_DEMO_) {
         $this->errors[] = Tools::displayError('This functionality has been disabled.');
         return;
     }
     if (isset($_POST['iso_code']) && !empty($_POST['iso_code']) && Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Language::getIdByIso($_POST['iso_code'])) {
         $this->errors[] = Tools::displayError('This ISO code is already linked to another language.');
     }
     if ((!empty($_FILES['no_picture']['tmp_name']) || !empty($_FILES['flag']['tmp_name'])) && Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
         if ($_FILES['no_picture']['error'] == UPLOAD_ERR_OK) {
             $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
         }
         unset($_FILES['no_picture']);
     } else {
         $this->errors[] = Tools::displayError('Flag and "No picture" image fields are required.');
     }
     return parent::processAdd();
 }
示例#30
0
 /**
  * Install languages
  *
  * @return array Association between ID and iso array(id_lang => iso, ...)
  */
 public function installLanguages($languages_list = null)
 {
     if ($languages_list == null || !is_array($languages_list) || !count($languages_list)) {
         $languages_list = $this->language->getIsoList();
     }
     $languages = array();
     foreach ($languages_list as $iso) {
         if (!file_exists(_PS_INSTALL_LANGS_PATH_ . $iso . '/language.xml')) {
             throw new PrestashopInstallerException($this->language->l('File "language.xml" not found for language iso "%s"', $iso));
         }
         if (!($xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_ . $iso . '/language.xml'))) {
             throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso));
         }
         $params_lang = array('name' => (string) $xml->name, 'iso_code' => substr((string) $xml->language_code, 0, 2));
         if (InstallSession::getInstance()->safe_mode) {
             Language::checkAndAddLanguage($iso, false, true, $params_lang);
         } else {
             Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_, $params_lang);
         }
         if (!($id_lang = Language::getIdByIso($iso))) {
             throw new PrestashopInstallerException($this->language->l('Cannot install language "%s"', $xml->name ? $xml->name : $iso));
         }
         $languages[$id_lang] = $iso;
         // Copy language flag
         if (is_writable(_PS_IMG_DIR_ . 'l/')) {
             if (!copy(_PS_INSTALL_LANGS_PATH_ . $iso . '/flag.jpg', _PS_IMG_DIR_ . 'l/' . $id_lang . '.jpg')) {
                 throw new PrestashopInstallerException($this->language->l('Cannot copy flag language "%s"', _PS_INSTALL_LANGS_PATH_ . $iso . '/flag.jpg => ' . _PS_IMG_DIR_ . 'l/' . $id_lang . '.jpg'));
             }
         }
     }
     return $languages;
 }