public static function executeCronTask() { $ts_module = new TrustedShops(); $ts_common = new TSCommon(); $common_count = 0; if (is_array(TSCommon::$available_languages)) { $to_remove = array(); foreach (array_keys(TSCommon::$available_languages) as $iso) { $alerts_infos = RatingAlert::getAlertsInformations($iso); ///print_r($alerts_infos); if ($alerts_infos != false) { $common_count += count($alerts_infos); foreach ($alerts_infos as $infos) { $cert = Configuration::get(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($infos['iso'])); $certificate = (array) Tools::jsonDecode(Tools::htmlentitiesDecodeUTF8($cert)); $subject = $ts_module->l('title_part_1') . ' ' . Configuration::get('PS_SHOP_NAME') . $ts_module->l('title_part_2'); $template_vars = array('{ts_id}' => $certificate['tsID'], '{button_url}' => TSCommon::getHttpHost(true, true) . _MODULE_DIR_ . $ts_module->name . '/views/img', '{rating_url}' => $ts_common->getRatingUrlWithBuyerEmail($infos['id_lang'], $infos['id_order'], $infos['email'])); $result = Mail::Send((int) $infos['id_lang'], self::MAIL_TEMPLATE, $subject, $template_vars, $infos['email'], null, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, dirname(__FILE__) . '/../mails/'); if ($result) { $to_remove[] = (int) $infos['id_alert']; } } } } if (count($to_remove) > 0) { self::removeAlerts($to_remove); } } return count($to_remove) == $common_count; }
public function getTranslationsFieldsChild() { parent::validateFieldsLang(); $fieldsArray = array('meta_title', 'meta_description', 'meta_keywords', 'link_rewrite'); $fields = array(); $languages = Language::getLanguages(); $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); foreach ($languages as $language) { $fields[$language['id_lang']]['id_lang'] = $language['id_lang']; $fields[$language['id_lang']][$this->identifier] = intval($this->id); $fields[$language['id_lang']]['content'] = isset($this->content[$language['id_lang']]) ? Tools::htmlentitiesDecodeUTF8(pSQL($this->content[$language['id_lang']], true)) : ''; foreach ($fieldsArray as $field) { if (!Validate::isTableOrIdentifier($field)) { die(Tools::displayError()); } if (isset($this->{$field}[$language['id_lang']]) and !empty($this->{$field}[$language['id_lang']])) { $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]); } elseif (in_array($field, $this->fieldsRequiredLang)) { $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]); } else { $fields[$language['id_lang']][$field] = ''; } } } return $fields; }
function decode_content() { // CMS_LANG $sql = 'SELECT `id_cms`, `content`, `id_lang` FROM `' . _DB_PREFIX_ . 'cms_lang`'; $result = Db::getInstance()->ExecuteS($sql); foreach ($result as $cms) { Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'cms_lang` SET `content` = \'' . pSql(Tools::htmlentitiesDecodeUTF8($cms['content']), true) . '\' WHERE `id_cms`= ' . intval($cms['id_cms']) . ' AND `id_lang` = ' . intval($cms['id_lang'])); } // MANUFACTURER_LANG $sql = 'SELECT `id_manufacturer`, `description`, `short_description`, `id_lang` FROM `' . _DB_PREFIX_ . 'manufacturer_lang`'; $result = Db::getInstance()->ExecuteS($sql); foreach ($result as $manu) { Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'manufacturer_lang` SET `description` = \'' . pSql(Tools::htmlentitiesDecodeUTF8($manu['description']), true) . '\', `short_description` = \'' . pSql(Tools::htmlentitiesDecodeUTF8($manu['short_description']), true) . '\' WHERE `id_manufacturer`= ' . intval($manu['id_manufacturer']) . ' AND `id_lang` = ' . intval($manu['id_lang'])); } // PRODUCT_LANG $sql = 'SELECT `id_product`, `description`, `description_short`, `id_lang` FROM `' . _DB_PREFIX_ . 'product_lang`'; $result = Db::getInstance()->ExecuteS($sql); foreach ($result as $prod) { Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'product_lang` SET `description` = \'' . pSql(Tools::htmlentitiesDecodeUTF8($prod['description']), true) . '\', `description_short` = \'' . pSql(Tools::htmlentitiesDecodeUTF8($prod['description_short']), true) . '\' WHERE `id_product`= ' . intval($prod['id_product']) . ' AND `id_lang` = ' . intval($prod['id_lang'])); } }
public function renderList() { $this->context->smarty->assign(array('campaign_id' => $this->campaign_id, 'campaign_name' => Tools::htmlentitiesDecodeUTF8($this->name), 'campaign_sended' => $this->campaign_sended, 'count_planned' => $this->count_planned_recipients, 'count_cancelled' => $this->count_cancelled_recipients)); $display = $this->getTemplatePath() . 'footer_validation.tpl'; $this->context->smarty->assign('footer_validation', $this->context->smarty->fetch($display)); $display = $this->getTemplatePath() . 'marketingf_step8/marketingf_step8.tpl'; $output = $this->context->smarty->fetch($display); $footer = $this->getTemplatePath() . 'footer.tpl'; $output .= $this->context->smarty->fetch($footer); return $output; }
public function renderList() { $this->context->smarty->assign(array('campaign_id' => $this->campaign_id, 'count_delivered' => $this->count_delivered_recipients, 'count_sending' => $this->count_transmiting_recipients + $this->count_delivering_recipients, 'count_not_delivered' => $this->count_not_delivered_recipients, 'count_planned' => $this->count_planned_recipients, 'count_cancelled' => $this->count_cancelled_recipients, 'count_detail_array' => $this->cost_sms_detail, 'campaign_name' => Tools::htmlentitiesDecodeUTF8($this->campaign_name), 'campaign_text' => $this->campaign_text, 'campaign_sended' => $this->campaign_sended)); $display = $this->getTemplatePath() . 'marketings_stats/cost_s_stats.tpl'; $this->context->smarty->assign('cost_sms_detail', $this->context->smarty->fetch($display)); $display = $this->getTemplatePath() . 'footer_validation.tpl'; $this->context->smarty->assign('footer_validation', $this->context->smarty->fetch($display)); $display = $this->getTemplatePath() . 'marketings_step7/marketings_step7.tpl'; $output = $this->context->smarty->fetch($display); $footer = $this->getTemplatePath() . 'footer.tpl'; $output .= $this->context->smarty->fetch($footer); return $output; }
function upgrade_module_2_0($object) { $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $items = $db->executeS("Select * From " . _DB_PREFIX_ . "customparallax_module_lang"); if ($items) { foreach ($items as $item) { $content = @Tools::htmlentitiesDecodeUTF8($item['content']); if (isset($content) && $content) { $db->update('customparallax_module_lang', array('content' => $db->escape($content, true)), "`module_id`='" . $item['module_id'] . "' AND `id_lang`='" . $item['id_lang'] . "'"); } } } return true; }
function upgrade_module_2_0($object) { $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $items = $db->executeS("Select * From " . _DB_PREFIX_ . "flexgroupbanners_banner_lang"); if ($items) { foreach ($items as $item) { $description = @Tools::htmlentitiesDecodeUTF8($item['description']); if (isset($description) && $description) { $db->update('flexgroupbanners_banner_lang', array('description' => $db->escape($description, true)), "`banner_id`='" . $item['banner_id'] . "' AND `id_lang`='" . $item['id_lang'] . "'"); } } } return true; }
function update_order_messages() { $step = 3000; $count_messages = Db::getInstance()->getValue('SELECT count(id_message) FROM ' . _DB_PREFIX_ . 'message'); $nb_loop = $start = 0; $pattern = '<br|&[a-zA-Z]{1,8};'; if ($count_messages > 0) { $nb_loop = ceil($count_messages / $step); } for ($i = 0; $i < $nb_loop; $i++) { $sql = 'SELECT id_message, message FROM `' . _DB_PREFIX_ . 'message` WHERE message REGEXP \'' . pSQL($pattern, true) . '\' LIMIT ' . (int) $start . ', ' . (int) $step; $start = intval(($i + 1) * $step); if ($messages = Db::getInstance()->query($sql)) { while ($message = Db::getInstance()->nextRow($messages)) { if (is_array($message)) { Db::getInstance()->execute(' UPDATE `' . _DB_PREFIX_ . 'message` SET message = \'' . pSQL(preg_replace('/' . $pattern . '/', '', Tools::htmlentitiesDecodeUTF8(br2nl($message['message'])))) . '\' WHERE id_message = ' . (int) $message['id_message']); } } } } $nb_loop = $start = 0; if ($count_messages > 0) { $nb_loop = ceil($count_messages / $step); } for ($i = 0; $i < $nb_loop; $i++) { $sql = 'SELECT id_customer_message, message FROM `' . _DB_PREFIX_ . 'customer_message` WHERE message REGEXP \'' . pSQL($pattern, true) . '\' LIMIT ' . (int) $start . ', ' . (int) $step; $start = intval(($i + 1) * $step); if ($messages = Db::getInstance()->query($sql)) { while ($message = Db::getInstance()->nextRow($messages)) { if (is_array($message)) { Db::getInstance()->execute(' UPDATE `' . _DB_PREFIX_ . 'customer_message` SET message = \'' . pSQL(preg_replace('/' . $pattern . '/', '', Tools::htmlentitiesDecodeUTF8(str_replace('&', '&', $message['message'])))) . '\' WHERE id_customer_message = ' . (int) $message['id_customer_message']); } } } } }
function update_order_messages() { $step = 3000; $count_messages = Db::getInstance()->getValue('SELECT count(id_message) FROM ' . _DB_PREFIX_ . 'message'); $nb_loop = $start = 0; if ($count_messages > 0) { $nb_loop = ceil($count_messages / $step); } for ($i = 0; $i < $nb_loop; $i++) { $sql = 'SELECT id_message, message FROM ' . _DB_PREFIX_ . 'message LIMIT ' . (int) $start . ', ' . (int) $step; if ($messages = Db::getInstance()->executeS($sql)) { if (is_array($messages)) { foreach ($messages as $message) { $sql = 'UPDATE ' . _DB_PREFIX_ . 'message SET message = \'' . pSQL(Tools::htmlentitiesDecodeUTF8(br2nl($message['message']))) . '\' WHERE id_message = ' . (int) $message['id_message']; $result = Db::getInstance()->execute($sql); } } $start += $step + 1; } } $count_messages = Db::getInstance()->getValue('SELECT count(id_customer_message) FROM ' . _DB_PREFIX_ . 'customer_message'); $nb_loop = $start = 0; if ($count_messages > 0) { $nb_loop = ceil($count_messages / $step); } for ($i = 0; $i < $nb_loop; $i++) { $sql = 'SELECT id_customer_message, message FROM ' . _DB_PREFIX_ . 'customer_message LIMIT ' . (int) $start . ', ' . (int) $step; if ($messages = Db::getInstance()->executeS($sql)) { if (is_array($messages)) { foreach ($messages as $message) { $sql = 'UPDATE ' . _DB_PREFIX_ . 'customer_message SET message = \'' . pSQL(Tools::htmlentitiesDecodeUTF8(str_replace('&', '&', $message['message']))) . '\' WHERE id_customer_message = ' . (int) $message['id_customer_message']; Db::getInstance()->execute($sql); } } $start += $step + 1; } } }
function upgrade_module_2_0($object) { $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $items = $db->executeS("Select * From " . _DB_PREFIX_ . "megamenus_group_lang"); if ($items) { foreach ($items as $item) { $description = @Tools::htmlentitiesDecodeUTF8($item['description']); if (isset($description) && $description) { $db->update('megamenus_group_lang', array('description' => $db->escape($description, true)), "`group_id`='" . $item['group_id'] . "' AND `id_lang`='" . $item['id_lang'] . "'"); } } } $items = $db->executeS("Select * From " . _DB_PREFIX_ . "megamenus_menuitem_lang"); if ($items) { foreach ($items as $item) { $html = @Tools::htmlentitiesDecodeUTF8($item['html']); if (isset($html) && $html) { $db->update('megamenus_menuitem_lang', array('html' => $db->escape($html, true)), "`menuitem_id`='" . $item['menuitem_id'] . "' AND `id_lang`='" . $item['id_lang'] . "'"); } } } return true; }
function upgrade_module_2_0($object) { $db = Db::getInstance(_PS_USE_SQL_SLAVE_); //Db::getInstance()->escape($string) $items = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS("Select * From " . _DB_PREFIX_ . "simplecategory_module_lang"); if ($items) { foreach ($items as $item) { $description = @Tools::htmlentitiesDecodeUTF8($item['description']); if (isset($description) && $description) { Db::getInstance()->update('simplecategory_module_lang', array('description' => $db->escape($description, true)), "`module_id`='" . $item['module_id'] . "' AND `id_lang`='" . $item['id_lang'] . "'"); } } } $items = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS("Select * From " . _DB_PREFIX_ . "simplecategory_group_lang"); if ($items) { foreach ($items as $item) { $description = @Tools::htmlentitiesDecodeUTF8($item['description']); if (isset($description) && $description) { Db::getInstance()->update('simplecategory_group_lang', array('description' => $db->escape($description, true)), "`group_id`='" . $item['group_id'] . "' AND `id_lang`='" . $item['id_lang'] . "'"); } } } return true; }
public function renderList() { $output = ''; if ($this->session_api->connectFromCredentials('email')) { Tools::clearCache($this->context->smarty); $response_array = array(); $parameters = array('account_id' => $this->session_api->account_id, 'max_lines' => 20, 'campaign_id' => (int) Tools::getValue('campaign_id')); if ($this->session_api->call('email', 'campaign', 'enum_last_sent', $parameters, $response_array)) { if (is_array($response_array) && count($response_array)) { // On retrouve tous les jours d'envoi (envois fractionnés sur plusieurs jours) // --------------------------------------------------------------------------- $tools = new EMTools(); $days = array(); foreach ($response_array as $day) { $days[] = array('day_api' => $day['stat_date'], 'day_lang' => $tools->getLocalizableDate($day['stat_date'])); } $this->context->smarty->assign(array('days' => $days, 'current_index' => AdminController::$currentIndex . '&campaign_id=' . $response_array[0]['campaign_id'], 'campaign_id' => $response_array[0]['campaign_id'], 'campaign_name' => Tools::htmlentitiesDecodeUTF8($response_array[0]['name']))); // S'il y a un stat_date, il faut ré-intéroger l'API pour obtenir les stats du jour sélectionné // -------------------------------------------------------------------------------------------- if (Tools::getValue('stat_date')) { $stat_array = array(); $parameters = array('account_id' => $this->session_api->account_id, 'campaign_id' => (int) Tools::getValue('campaign_id'), 'stat_date' => (int) Tools::getValue('stat_date')); if ($this->session_api->call('email', 'campaign', 'get_statistics', $parameters, $stat_array)) { $response_array = array($stat_array); } // Pour rester compatible avec le code ci-dessous } // S'il n'y a pas de stat_date, l'API nous retourne directement les stats du dernier envoi // --------------------------------------------------------------------------------------- $this->context->smarty->assign(array('select_day' => $response_array[0]['stat_date'], 'sent' => $response_array[0]['sent'], 'not_sent' => $response_array[0]['not_sent'], 'delivered' => $response_array[0]['delivered'], 'not_delivered' => $response_array[0]['not_delivered'], 'opened' => $response_array[0]['opened'], 'not_opened' => $response_array[0]['not_opened'], 'unique_clickers' => $response_array[0]['unique_clickers'], 'all_clicks' => $response_array[0]['all_clicks'], 'unsubscribes' => $response_array[0]['unsubscribes'], 'abuses' => $response_array[0]['abuses'], 'ratio_sent' => $response_array[0]['ratio_sent'], 'ratio_not_sent' => $response_array[0]['ratio_not_sent'], 'ratio_delivered' => $response_array[0]['ratio_delivered'], 'ratio_not_delivered' => $response_array[0]['ratio_not_delivered'], 'ratio_opened' => $response_array[0]['ratio_opened'], 'ratio_not_opened' => $response_array[0]['ratio_not_opened'], 'ratio_unique_clickers' => $response_array[0]['ratio_unique_clickers'], 'ratio_unsubscribes' => $response_array[0]['ratio_unsubscribes'], 'ratio_abuses' => $response_array[0]['ratio_abuses'])); // On affiche le tableau des stats // ------------------------------- $diplay = $this->getTemplatePath() . 'marketinge_stats/marketinge_stats.tpl'; $output = $this->context->smarty->fetch($diplay); // On charge les données du graphique des "opened" // ----------------------------------------------- $delivered = array(); /* ne pas utiliser le nom response_array SVP */ $parameters = array('account_id' => $this->session_api->account_id, 'campaign_id' => $response_array[0]['campaign_id'], 'stat_date' => $response_array[0]['stat_date']); $this->session_api->call('email', 'campaign', 'get_graph_delivered_per_hour', $parameters, $delivered); $this->context->smarty->assign('delivered', $delivered); $graph = $this->getTemplatePath() . 'marketinge_stats/marketinge_graph.tpl'; $output .= $this->context->smarty->fetch($graph); } else { // On affiche une liste vide // ------------------------- $helper = new HelperList(); $helper->no_link = true; $helper->shopLinkType = ''; $helper->simple_header = false; // Mettre 'search' => false dans chaque fields_list $helper->table = $this->table; $helper->identifier = 'campaign_id'; $helper->show_toolbar = true; $helper->toolbar_scroll = false; $helper->token = Tools::getAdminTokenLite('AdminMarketingEStats'); $helper->currentIndex = $this->context->link->getAdminLink('AdminMarketingEStats', false); $helper->allow_export = false; $helper->title = '<i class="icon-bar-chart"></i> ' . $this->module->l('Broadcast evolution during last 24/48 hours', 'adminmarketingestats'); $helper->toolbar_btn = array('back' => array('href' => 'index.php?controller=AdminMarketingEList&token=' . Tools::getAdminTokenLite('AdminMarketingEList'), 'desc' => $this->module->l('Back to list', 'adminmarketingestats'))); $helper->actions = array('details'); $this->fields_list = array(); $output .= $helper->generateList($this->fields_list, $this->fields_list); } } } $footer = $this->getTemplatePath() . 'footer.tpl'; $output .= $this->context->smarty->fetch($footer); return $output; }
public function processExport($text_delimiter = '"') { // clean buffer if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } $this->getList($this->context->language->id, null, null, 0, false); if (!count($this->_list)) { return; } header('Content-type: text/csv'); header('Content-Type: application/force-download; charset=UTF-8'); header('Cache-Control: no-store, no-cache'); header('Content-disposition: attachment; filename="' . $this->table . '_' . date('Y-m-d_His') . '.csv"'); $headers = array(); foreach ($this->fields_list as $key => $datas) { if ($datas['title'] == 'PDF') { unset($this->fields_list[$key]); } else { $headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']); } } $content = array(); foreach ($this->_list as $i => $row) { $content[$i] = array(); $path_to_image = false; foreach ($this->fields_list as $key => $params) { $field_value = isset($row[$key]) ? Tools::htmlentitiesDecodeUTF8(Tools::nl2br($row[$key])) : ''; if ($key == 'image') { if ($params['image'] != 'p' || Configuration::get('PS_LEGACY_IMAGES')) { $path_to_image = Tools::getShopDomain(true) . _PS_IMG_ . $params['image'] . '/' . $row['id_' . $this->table] . (isset($row['id_image']) ? '-' . (int) $row['id_image'] : '') . '.' . $this->imageType; } else { $path_to_image = Tools::getShopDomain(true) . _PS_IMG_ . $params['image'] . '/' . Image::getImgFolderStatic($row['id_image']) . (int) $row['id_image'] . '.' . $this->imageType; } if ($path_to_image) { $field_value = $path_to_image; } } if (isset($params['callback'])) { $callback_obj = isset($params['callback_object']) ? $params['callback_object'] : $this->context->controller; if (!preg_match('/<([a-z]+)([^<]+)*(?:>(.*)<\\/\\1>|\\s+\\/>)/ism', call_user_func_array(array($callback_obj, $params['callback']), array($field_value, $row)))) { $field_value = call_user_func_array(array($callback_obj, $params['callback']), array($field_value, $row)); } } $content[$i][] = $field_value; } } $this->context->smarty->assign(array('export_precontent' => "", 'export_headers' => $headers, 'export_content' => $content, 'text_delimiter' => $text_delimiter)); $this->layout = 'layout-export.tpl'; }
/** * Uodate the customer note * * @return void */ public function ajaxProcessUpdateCustomerNote() { if ($this->tabAccess['edit'] === '1') { $note = Tools::htmlentitiesDecodeUTF8(Tools::getValue('note')); $customer = new Customer((int) Tools::getValue('id_customer')); if (!Validate::isLoadedObject($customer)) { die('error:update'); } if (!empty($note) && !Validate::isCleanHtml($note)) { die('error:validation'); } $customer->note = $note; if (!$customer->update()) { die('error:update'); } die('ok'); } }
public function __construct() { // need to set this in constructor to allow translation TSBuyerProtection::$payments_type = array('DIRECT_DEBIT' => $this->l('Direct debit'), 'CREDIT_CARD' => $this->l('Credit Card'), 'INVOICE' => $this->l('Invoice'), 'CASH_ON_DELIVERY' => $this->l('Cash on delivery'), 'PREPAYMENT' => $this->l('Prepayment'), 'CHEQUE' => $this->l('Cheque'), 'PAYBOX' => $this->l('Paybox'), 'PAYPAL' => $this->l('PayPal'), 'CASH_ON_PICKUP' => $this->l('Cash on pickup'), 'FINANCING' => $this->l('Financing'), 'LEASING' => $this->l('Leasing'), 'T_PAY' => $this->l('T-Pay'), 'CLICKANDBUY' => $this->l('Click&Buy'), 'GIROPAY' => $this->l('Giropay'), 'GOOGLE_CHECKOUT' => $this->l('Google Checkout'), 'SHOP_CARD' => $this->l('Online shop payment card'), 'DIRECT_E_BANKING' => $this->l('DIRECTebanking.com'), 'MONEYBOOKERS' => $this->l('moneybookers.com'), 'OTHER' => $this->l('Other method of payment')); $this->tab_name = $this->l('Trusted Shops quality seal and buyer protection'); $this->site_url = Tools::htmlentitiesutf8('http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__); TSBPException::setTranslationObject($this); if (!method_exists('Tools', 'jsonDecode') || !method_exists('Tools', 'jsonEncode')) { $this->warnings[] = $this->l('Json functions must be implemented in your php version'); } else { foreach ($this->available_languages as $iso => $lang) { if ($lang === '') { $this->available_languages[$iso] = Language::getLanguage(Language::getIdByIso($iso)); } TSBuyerProtection::$CERTIFICATE[strtoupper($iso)] = (array) Tools::jsonDecode(Tools::htmlentitiesDecodeUTF8(Configuration::get(TSBuyerProtection::PREFIX_TABLE . 'CERTIFICATE_' . strtoupper($iso)))); } if (TSBuyerProtection::$SHOPSW === NULL) { TSBuyerProtection::$SHOPSW = Configuration::get(TSBuyerProtection::PREFIX_TABLE . 'SHOPSW'); TSBuyerProtection::$ET_CID = Configuration::get(TSBuyerProtection::PREFIX_TABLE . 'ET_CID'); TSBuyerProtection::$ET_LID = Configuration::get(TSBuyerProtection::PREFIX_TABLE . 'ET_LID'); TSBuyerProtection::$DEFAULT_LANG = (int) Configuration::get('PS_LANG_DEFAULT'); TSBuyerProtection::$CAT_ID = (int) Configuration::get(TSBuyerProtection::PREFIX_TABLE . 'CAT_ID'); TSBuyerProtection::$ENV_API = Configuration::get(TSBuyerProtection::PREFIX_TABLE . 'ENV_API'); } } }
public function processExport() { // clean buffer if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } $this->getList($this->context->language->id); if (!count($this->_list)) { return; } header('Content-type: text/csv'); header('Content-Type: application/force-download; charset=UTF-8'); header('Cache-Control: no-store, no-cache'); header('Content-disposition: attachment; filename="' . $this->table . '_' . date('Y-m-d_His') . '.csv"'); $headers = array(); foreach ($this->fields_list as $datas) { $headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']); } $content = array(); foreach ($this->_list as $i => $row) { $content[$i] = array(); foreach ($this->fields_list as $key => $value) { if (isset($row[$key])) { $content[$i][] = Tools::htmlentitiesDecodeUTF8($row[$key]); } } } $this->context->smarty->assign(array('export_headers' => $headers, 'export_content' => $content)); $this->layout = 'layout-export.tpl'; }
public function putContent($xml_data, $key, $field, $forbidden, $section) { foreach ($forbidden as $line) { if ($key == $line) { return 0; } } if (!preg_match('/^' . $section . '_/i', $key)) { return 0; } $key = preg_replace('/^' . $section . '_/i', '', $key); $field = Tools::htmlentitiesDecodeUTF8(htmlspecialchars($field)); if (!$field) { return 0; } return "\n\t\t" . '<' . $key . '><![CDATA[' . $field . ']]></' . $key . '>'; }
public static function configXmlStringFormat($string) { return str_replace('\'', '\\\'', Tools::htmlentitiesDecodeUTF8($string)); }
public function processExportOrder($date_begin, $date_endin) { // clean buffer if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } $date_debut = explode('-', $date_begin); $date_debut = mktime(0, 0, 0, $date_debut[1], $date_debut[2], $date_debut[0]); $date_debut = date('d/m/Y', $date_debut); $date_fin = explode('-', $date_endin); $date_fin = mktime(0, 0, 0, $date_fin[1], $date_fin[2], $date_fin[0]); $date_fin = date('d/m/Y', $date_fin); $csv_list = array(); $sql = 'SELECT o.id_order AS order_id, od.product_reference AS product_reference, od.product_name AS product_name, od.product_price AS product_price, od.product_weight AS product_weight, od.product_quantity AS product_quantity, od.product_quantity_refunded AS product_quantity_refunded, od.product_quantity_return AS product_quantity_return, od.tax_rate AS product_tax_rate, od.ecotax AS product_ecotax, od.discount_quantity_applied AS product_discount_quantity_applied, o.id_customer AS customer_id, ainv.firstname AS invoice_firstname, ainv.lastname AS invoice_lastname, ainv.company AS invoice_company, ainv.address1 AS invoice_address1, ainv.address2 AS invoice_address2, ainv.postcode AS invoice_postcode, ainv.city AS invoice_city, ainv.phone AS invoice_phone, ainv.phone_mobile AS invoice_phone_mobile, adel.firstname AS delivery_firstname, adel.lastname AS delivery_lastname, adel.company AS delivery_company, adel.address1 AS delivery_address1, adel.address2 AS delivery_address2, adel.postcode AS delivery_postcode, adel.city AS delivery_city, adel.phone AS delivery_phone, adel.phone_mobile AS delivery_phone_mobile, DATE(o.invoice_date) AS invoice_date, o.payment AS payment, DATE(o.delivery_date) AS delivery_date, o.shipping_number AS shipping_number, (SELECT osl.name FROM ' . _DB_PREFIX_ . 'order_history oh, ' . _DB_PREFIX_ . 'order_state_lang osl WHERE o.id_order=oh.id_order AND oh.id_order_state = osl.id_order_state ORDER BY id_order_history DESC LIMIT 1) AS status, o.total_discounts AS total_discounts, o.total_paid AS total_paid, o.total_paid_real AS total_paid_real, o.total_products AS total_products, o.total_products_wt AS total_products_wt, o.total_shipping AS total_shipping, o.total_wrapping AS total_wrapping, cur.name AS currency FROM ' . _DB_PREFIX_ . 'orders o LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON o.id_order=od.id_order LEFT JOIN ' . _DB_PREFIX_ . 'address ainv ON o.id_address_invoice=ainv.id_address LEFT JOIN ' . _DB_PREFIX_ . 'address adel ON o.id_address_delivery=adel.id_address LEFT JOIN ' . _DB_PREFIX_ . 'currency cur ON o.id_currency=cur.id_currency LEFT JOIN ' . _DB_PREFIX_ . 'product op ON od.product_id = op.id_product WHERE o.valid=1 AND o.date_add>="' . pSQL($date_begin) . ' 00:00:00" AND o.date_add<="' . pSQL($date_endin) . ' 23:59:59" ORDER BY o.id_order, od.id_order_detail ASC'; $result = Db::getInstance()->ExecuteS($sql); foreach ($result as $row) { foreach (array('product_price', 'product_weight', 'product_tax_rate', 'product_ecotax', 'product_discount_quantity_applied', 'total_discounts', 'total_paid', 'total_paid_real', 'total_products', 'total_products_wt', 'total_shipping', 'total_wrapping') as $field) { $row[$field] = str_replace('.', ',', $row[$field]); } //phone format foreach (array('invoice_phone', 'invoice_phone_mobile', 'delivery_phone', 'delivery_phone_mobile') as $field) { $row[$field] = preg_replace('[^0-9]', '', $row[$field]) . ' '; } array_push($csv_list, array($row['order_id'], $row['product_reference'], $row['product_name'], $row['product_price'], $row['product_weight'], $row['product_quantity'], $row['product_quantity_refunded'], $row['product_quantity_return'], $row['product_tax_rate'], $row['product_ecotax'], $row['product_discount_quantity_applied'], $row['customer_id'], $row['invoice_firstname'], $row['invoice_lastname'], $row['invoice_company'], $row['invoice_address1'], $row['invoice_address2'], $row['invoice_postcode'], $row['invoice_city'], $row['invoice_phone'], $row['invoice_phone_mobile'], $row['delivery_firstname'], $row['delivery_lastname'], $row['delivery_company'], $row['delivery_address1'], $row['delivery_address2'], $row['delivery_postcode'], $row['delivery_city'], $row['delivery_phone'], $row['delivery_phone_mobile'], $row['invoice_date'], $row['payment'], $row['delivery_date'], $row['shipping_number'], $row['status'], $row['total_discounts'], $row['total_paid'], $row['total_paid_real'], $row['total_products'], $row['total_products_wt'], $row['total_shipping'], $row['total_wrapping'], $row['currency'])); } header('Content-type: text/csv'); header('Content-Type: application/force-download; charset=UTF-8'); header('Cache-Control: no-store, no-cache'); header('Content-disposition: attachment; filename="export_orders_' . date('Y-m-d_H-m-s') . '.csv"'); $headers = array(); $titles = array($this->l('order_id'), $this->l('product_reference'), $this->l('product_name'), $this->l('product_price'), $this->l('product_weight'), $this->l('product_quantity'), $this->l('product_quantity_refunded'), $this->l('product_quantity_return'), $this->l('product_tax_rate'), $this->l('product_ecotax'), $this->l('product_discount_quantity_applied'), $this->l('customer_id'), $this->l('invoice_firstname'), $this->l('invoice_lastname'), $this->l('invoice_company'), $this->l('invoice_address1'), $this->l('invoice_address2'), $this->l('invoice_postcode'), $this->l('invoice_city'), $this->l('invoice_phone'), $this->l('invoice_phone_mobile'), $this->l('delivery_firstname'), $this->l('delivery_lastname'), $this->l('delivery_company'), $this->l('delivery_address1'), $this->l('delivery_address2'), $this->l('delivery_postcode'), $this->l('delivery_city'), $this->l('delivery_phone'), $this->l('delivery_phone_mobile'), $this->l('invoice_date'), $this->l('payment'), $this->l('delivery_date'), $this->l('shipping_number'), $this->l('status'), $this->l('total_discounts'), $this->l('total_paid'), $this->l('total_paid_real'), $this->l('total_products'), $this->l('total_products_wt'), $this->l('total_shipping'), $this->l('total_wrapping'), $this->l('currency')); foreach ($titles as $datas) { $headers[] = Tools::htmlentitiesDecodeUTF8($datas); } $content = array(); foreach ($csv_list as $i => $row) { $content[$i] = array(); foreach ($row as $key => $value) { if (isset($row[$key])) { $content[$i][] = Tools::htmlentitiesDecodeUTF8($row[$key]); } } } $this->context->smarty->assign(array('export_precontent' => "", 'export_headers' => $headers, 'export_content' => $content)); $this->layout = 'layout-export.tpl'; }
public function processExport() { // clean buffer if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } $this->getList($this->context->language->id); if (!count($this->_list)) { return; } header('Content-type: text/csv'); header('Content-Type: application/force-download; charset=UTF-8'); header('Cache-Control: no-store, no-cache'); header('Content-disposition: attachment; filename="' . $this->table . '_' . date('Y-m-d_His') . '.csv"'); $headers = array(); foreach ($this->fields_list as $datas) { $headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']); } $content = array(); foreach ($this->_list as $i => $row) { $content[$i] = array(); $path_to_image = false; foreach ($this->fields_list as $key => $params) { $field_value = isset($row[$key]) ? Tools::htmlentitiesDecodeUTF8($row[$key]) : ''; if ($key == 'image') { if ($params['image'] != 'p' || Configuration::get('PS_LEGACY_IMAGES')) { $path_to_image = Tools::getShopDomain(true) . _PS_IMG_ . $params['image'] . '/' . $row['id_' . $this->table] . (isset($row['id_image']) ? '-' . (int) $row['id_image'] : '') . '.' . $this->imageType; } else { $path_to_image = Tools::getShopDomain(true) . _PS_IMG_ . $params['image'] . '/' . Image::getImgFolderStatic($row['id_image']) . (int) $row['id_image'] . '.' . $this->imageType; } if ($path_to_image) { $field_value = $path_to_image; } } $content[$i][] = $field_value; } } $this->context->smarty->assign(array('export_precontent' => "", 'export_headers' => $headers, 'export_content' => $content)); $this->layout = 'layout-export.tpl'; }
private function getFieldsValues() { if ($this->session_api->connectFromCredentials('sms')) { $response_array = array(); $parameters = array('campaign_id' => $this->campaign_id); if ($this->session_api->call('sms', 'campaign', 'get_infos', $parameters, $response_array)) { $this->campaign_name = $response_array['name']; $this->campaign_text = $response_array['text']; $this->campaign_state = $response_array['state']; $this->start_date = $response_array['start_date']; $this->finished_date = $response_array['finished_date']; $this->planning_start_hour = $response_array['planning_start_hour']; $this->planning_stop_hour = $response_array['planning_stop_hour']; $this->max_delivrered_allowed = $response_array['max_delivrered_allowed']; $this->max_delivrered_allowed_per_day = $response_array['max_delivrered_allowed_per_day']; $this->planning_allow_monday = $response_array['planning_allow_monday']; $this->planning_allow_tuesday = $response_array['planning_allow_tuesday']; $this->planning_allow_wednesday = $response_array['planning_allow_wednesday']; $this->planning_allow_thursday = $response_array['planning_allow_thursday']; $this->planning_allow_friday = $response_array['planning_allow_friday']; $this->planning_allow_saturday = $response_array['planning_allow_saturday']; $this->planning_allow_sunday = $response_array['planning_allow_sunday']; $this->count_total_recipients = $response_array['count_total_recipients']; $this->count_delivered_recipients = $response_array['count_delivered_recipients']; $this->count_not_delivered_recipients = $response_array['count_not_delivered_recipients']; $this->count_cancelled_recipients = $response_array['count_cancelled_recipients']; $this->count_delivering_recipients = $response_array['count_delivering_recipients']; $this->count_transmiting_recipients = $response_array['count_transmiting_recipients']; $this->count_planned_recipients = $response_array['count_planned_recipients']; $this->count_recipients_to_send = $response_array['count_recipients_to_send']; $this->count_invalid_recipients = $response_array['count_invalid_recipients']; $this->count_absent_recipients = $response_array['count_absent_recipients']; $this->count_duplicate_recipients = $response_array['count_duplicate_recipients']; $this->count_recipients_in_not_allowed_country = $response_array['count_recipients_in_not_allowed_country']; $this->count_recipients_on_system_redlist = $response_array['count_recipients_on_system_redlist']; $this->count_recipients_on_noads_redlist = $response_array['count_recipients_on_noads_redlist']; $this->count_recipients_on_personnal_redlist = $response_array['count_recipients_on_personnal_redlist']; $this->fields_value['campaign_name'] = Tools::htmlentitiesDecodeUTF8($this->campaign_name); $this->fields_value['campaign_text'] = $this->campaign_text; $this->fields_value['campaign_state'] = $this->campaign_state; } if ($this->session_api->call('sms', 'campaign', 'enum_count_sms_detail', $parameters, $response_array)) { $this->cost_sms_detail = $response_array; } } return true; }
public function generateXmlFlow() { global $cart, $cookie; $cookie->id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); // url rewriting case $cart = new Cart(); $link = new Link(); $defaultCurrencyIsoCode = strtoupper(Db::getInstance()->getValue('SELECT c.iso_code FROM ' . _DB_PREFIX_ . 'currency c WHERE c.id_currency = ' . (int) Configuration::get('PS_CURRENCY_DEFAULT'))); $defaultIdLang = (int) Configuration::get('PS_LANG_DEFAULT'); $sqlLangs = Db::getInstance()->ExecuteS('SELECT l.id_lang, l.iso_code FROM ' . _DB_PREFIX_ . 'lang l'); foreach ($sqlLangs as $sqlLang) { $langs[$sqlLang['id_lang']] = $sqlLang['iso_code']; } $xmlString = <<<XML <?xml version="1.0" encoding="UTF-8"?> <products> </products> XML; $products = new SimpleXMLExtended($xmlString); $infos = $products->addChild('infos'); $infos->addCData('url', $this->_getShopURL()); $infos->addCData('logo', $this->_getShopURL()); $languages = Db::getInstance()->ExecuteS(' SELECT l.iso_code FROM ' . _DB_PREFIX_ . 'lang l WHERE l.active = 1'); foreach ($languages as $language) { $infos->addChild('lang', $language['iso_code']); } $limit_sql = ''; $limit_start = (int) Tools::getValue('limit_start'); $limit_end = (int) Tools::getValue('limit_end'); if ($limit_start > 0) { if ($limit_end < $limit_start) { $limit_end = $limit_start + 10; } $limit_sql = ' LIMIT ' . (int) $limit_start . ',' . (int) $limit_end; } $sqlProducts = Db::getInstance()->ExecuteS(' SELECT p.id_product, p.reference, p.weight, m.name manufacturer, s.name supplier, p.on_sale, p.id_manufacturer, pd.id_product_download FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) LEFT JOIN ' . _DB_PREFIX_ . 'supplier s ON (s.id_supplier = p.id_supplier) LEFT JOIN ' . _DB_PREFIX_ . 'product_download pd ON (pd.id_product = p.id_product) WHERE p.active = 1' . $limit_sql); foreach ($sqlProducts as $sqlProduct) { $id_product = $sqlProduct['id_product']; $product = $products->addChild('product'); $product->addChild('sku', (int) $sqlProduct['id_product']); $product->addCData('manufacturer', $sqlProduct['manufacturer']); if (file_exists(dirname(__FILE__) . '/../../img/m/' . (int) $sqlProduct['id_manufacturer'] . 'jpg')) { $product->addCData('manufacturer-logo', $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'img/m/' . (int) $sqlProduct['id_manufacturer'] . 'jpg'); } $product->addChild('weight', (double) $sqlProduct['weight']); $product->addChild('weight_unit', strtolower(Configuration::get('PS_WEIGHT_UNIT'))); $product->addCData('supplier', $sqlProduct['supplier']); $name = $product->addChild('name'); $languageVariant = $name->addChild('language-variant'); $texts = Db::getInstance()->ExecuteS(' SELECT pl.name, pl.description_short, pl.link_rewrite, l.iso_code, l.id_lang FROM ' . _DB_PREFIX_ . 'product_lang pl LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = pl.id_lang) WHERE pl.id_product = ' . (int) $sqlProduct['id_product']); foreach ($texts as $text) { $variant = $languageVariant->addChild('variant'); $variant->addChild('locale', $text['iso_code']); $variant->addCData('value', $text['name']); if ($text['id_lang'] == $defaultIdLang) { $productName = $text['name']; $productLinkRewrite = $text['link_rewrite']; } } $product->addCData('page-url', $link->getProductLink((int) $sqlProduct['id_product'], $productLinkRewrite)); $shortDescription = $product->addChild('short-description'); $languageVariant = $shortDescription->addChild('language-variant'); foreach ($texts as $text) { $variant = $languageVariant->addChild('variant'); $variant->addChild('locale', $text['iso_code']); $variant->addCData('value', Tools::htmlentitiesDecodeUTF8(strip_tags($text['description_short']))); } $accessories = Db::getInstance()->ExecuteS(' SELECT a.id_product_2 FROM ' . _DB_PREFIX_ . 'accessory a WHERE a.id_product_1 = ' . (int) $sqlProduct['id_product']); foreach ($accessories as $accessory) { $product->addChild('accessory-sku', (int) $accessory['id_product_2']); } $price = $product->addChild('price'); $price->addChild('currency', $defaultCurrencyIsoCode); $price->addChild('retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true, NULL, 6, NULL, false, false)); $price->addChild('retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, NULL, 6, NULL, false, false)); $price->addChild('final-retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true)); if (version_compare(_PS_VERSION_, '1.4') < 0) { $price->addChild('final-retail-price-without-tax', Product::getPriceStatic(intval($sqlProduct['id_product']), false)); $price->addChild('reduction_percent', floatval($sqlProduct['reduction_percent'])); $price->addChild('reduction_price', floatval($sqlProduct['reduction_price'])); } else { $price->addChild('final-retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $specificPrice)); $price->addChild('reduction_percent', ($specificPrice and $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.0); $price->addChild('reduction_price', ($specificPrice and $specificPrice['reduction_type'] == 'amount') ? (double) $specificPrice['reduction'] : 0.0); } $price->addChild('display-on-sale', (int) $sqlProduct['on_sale']); $product->addChild('downloadable', $sqlProduct['id_product_download'] >= 1 ? 1 : 0); $pack = Db::getInstance()->ExecuteS(' SELECT p.id_product, pp.quantity FROM ' . _DB_PREFIX_ . 'pack pp LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = pp.id_product_item) WHERE pp.id_product_pack = ' . (int) $sqlProduct['id_product']); if (sizeof($pack)) { $pack = $product->addChild('pack'); foreach ($pack as $p) { $packItem = $pack->addChild('pack-item'); $packItem->addChild('quantity', (int) $p['quantity']); $packItem->addChild('sku', (int) $p['id_product']); } } $images = Db::getInstance()->ExecuteS(' SELECT i.id_image, il.legend, l.iso_code FROM ' . _DB_PREFIX_ . 'image i LEFT JOIN ' . _DB_PREFIX_ . 'image_lang il ON (il.id_image = i.id_image) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = il.id_lang) WHERE i.id_product = ' . (int) $sqlProduct['id_product']); $imagesLegends = array(); foreach ($images as $image) { $imagesLegends[(int) $image['id_image']][$image['iso_code']]['legend'] = $image['legend']; $imagesLegends[(int) $image['id_image']][$image['iso_code']]['iso_code'] = $image['iso_code']; } $imagesAlreadyDone = array(); foreach ($images as $imageSQL) { if (isset($imagesAlreadyDone[$imageSQL['id_image']])) { continue; } $imagesAlreadyDone[(int) $imageSQL['id_image']] = 1; $image = $product->addChild('image'); $image->addAttribute('id', $imageSQL['id_image']); $image->addCData('image-url', $link->getImageLink($productLinkRewrite, (int) $sqlProduct['id_product'] . '-' . (int) $imageSQL['id_image'], 'large')); if (isset($imagesLegends[$imageSQL['id_image']]) and sizeof($imagesLegends[$imageSQL['id_image']])) { $imageCaption = $image->addChild('image-caption'); $languageVariant = $imageCaption->addChild('language-variant'); foreach ($imagesLegends[(int) $imageSQL['id_image']] as $legend) { $variant = $languageVariant->addChild('variant'); $variant->addChild('locale', $legend['iso_code']); $variant->addCData('value', $legend['legend']); } } } if (version_compare(_PS_VERSION_, '1.4') < 0) { $quantityDiscounts = Db::getInstance()->ExecuteS(' SELECT dq.quantity, dq.value, dq.id_discount_type FROM ' . _DB_PREFIX_ . 'discount_quantity dq WHERE dq.id_product = ' . intval($sqlProduct['id_product'])); foreach ($quantityDiscounts as $quantityDiscount) { $discount = $product->addChild('discount'); $discount->addChild('discount-quantity', intval($quantityDiscount['quantity'])); $discount->addChild('discount-value', floatval($quantityDiscount['value'])); $discount->addChild('discount-type', $quantityDiscount['id_discount_type'] == 1 ? $defaultCurrencyIsoCode : '%'); } } else { $quantityDiscounts = SpecificPrice::getQuantityDiscounts((int) $sqlProduct['id_product'], (int) Shop::getCurrentShop(), 0, 0, 0); foreach ($quantityDiscounts as $quantityDiscount) { $discount = $product->addChild('discount'); $discount->addChild('discount-quantity', (int) $quantityDiscount['from_quantity']); $discount->addChild('discount-value', ((double) $quantityDiscount['price'] and $quantityDiscount['reduction_type'] == 'amount') ? (double) $quantityDiscount['price'] : $quantityDiscount['reduction'] * 100); $discount->addChild('discount-type', $quantityDiscount['reduction_type'] == 'amount' ? $defaultCurrencyIsoCode : '%'); } } $categories = Db::getInstance()->ExecuteS(' SELECT cl.name, l.iso_code FROM ' . _DB_PREFIX_ . 'category_product cp LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = cp.id_category) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = cl.id_lang) WHERE cp.id_product = ' . (int) $sqlProduct['id_product']); if (sizeof($categories)) { $category = $product->addChild('category'); $languageVariant = $category->addChild('language-variant'); foreach ($categories as $category) { $variant = $languageVariant->addChild('variant'); $variant->addChild('locale', $category['iso_code']); $variant->addCData('value', $category['name']); } } $tags = Db::getInstance()->ExecuteS(' SELECT pt.id_product, pt.id_tag, l.iso_code, t.name FROM ' . _DB_PREFIX_ . 'product_tag pt LEFT JOIN ' . _DB_PREFIX_ . 'tag t ON (t.id_tag = pt.id_tag) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = t.id_lang) WHERE pt.id_product = ' . (int) $sqlProduct['id_product']); if (!empty($tags) && sizeof($tags) > 0) { $tagsTexts = array(); $tagsIso = array(); foreach ($tags as $tag) { if (!in_array($tag['iso_code'], $tagsIso)) { $tagsIso[] = $tag['iso_code']; } $tagsTexts[$tag['iso_code']][] = $tag['name']; } $tags_item = $product->addChild('tags'); foreach ($tagsIso as $iso) { $languageVariant = $tags_item->addChild('language-variant'); $languageVariant->addChild('locale', $iso); $languageVariant->addCData('value', implode(',', $tagsTexts[$iso])); } } $groupAttributes = Db::getInstance()->ExecuteS(' SELECT DISTINCT agl.id_attribute_group, agl.name, l.iso_code, a.id_attribute, al.name as attribute_name, al.id_lang, pa.id_product_attribute FROM ' . _DB_PREFIX_ . 'attribute_group_lang agl LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = agl.id_attribute_group) LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute = a.id_attribute) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = al.id_lang) LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute) LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute) WHERE pa.id_product = ' . (int) $sqlProduct['id_product'] . ' GROUP BY a.id_attribute, l.iso_code'); $groups = array(); foreach ($groupAttributes as $groupAttribute) { $id_group_attribute = $groupAttribute['id_attribute_group']; $id_attribute = $groupAttribute['id_attribute']; $id_product_attribute = $groupAttribute['id_product_attribute']; $groups[$id_group_attribute]['name'][$groupAttribute['iso_code']] = $groupAttribute['name']; $groups[$id_group_attribute]['attributes'][$groupAttribute['id_attribute']][$groupAttribute['iso_code']] = $groupAttribute['attribute_name']; } if (!empty($groups)) { foreach ($groups as $id_group => $group) { $xml_group = $product->addChild('attribute-group'); $xml_group->addAttribute('id', $id_group); if (!empty($group['name'])) { $nameGroup = $xml_group->addChild('name'); $languageVariant = $nameGroup->addChild('language-variant'); foreach ($group['name'] as $iso2 => $name_group) { $variant = $languageVariant->addChild('variant'); $variant->addChild('locale', $iso2); $variant->addCData('value', $name_group); } } if (!empty($group['attributes'])) { foreach ($group['attributes'] as $id_attribute => $attribute) { $xml_attribute = $xml_group->addChild('attribute'); $xml_attribute->addAttribute('id', $id_attribute); $languageVariant = $xml_attribute->addChild('language-variant'); foreach ($attribute as $iso2 => $name_attribute) { $variant = $languageVariant->addChild('variant'); $variant->addChild('locale', $iso2); $variant->addCData('value', $name_attribute); } } } } } $groupAttributes = Db::getInstance()->ExecuteS(' SELECT agl.id_attribute_group, agl.name, l.iso_code, a.id_attribute, al.name attribute_name, al.id_lang, pa.id_product_attribute FROM ' . _DB_PREFIX_ . 'attribute_group_lang agl LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = agl.id_lang) LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = agl.id_attribute_group) LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute = a.id_attribute) LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute) LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute) WHERE pa.id_product = ' . (int) $sqlProduct['id_product']); $combinaison = array(); foreach ($groupAttributes as $groupAttribute) { $id_group_attribute = $groupAttribute['id_attribute_group']; $id_attribute = $groupAttribute['id_attribute']; $id_product_attribute = $groupAttribute['id_product_attribute']; $combinaison[$id_product_attribute][$id_group_attribute] = $id_attribute; } $productAttributes = Db::getInstance()->ExecuteS(' SELECT pa.id_product_attribute, pa.weight, pa.quantity, pi.id_image FROM ' . _DB_PREFIX_ . 'product_attribute pa LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_image pi ON (pa.id_product_attribute = pi.id_product_attribute) WHERE pa.id_product = ' . (int) $sqlProduct['id_product']); if (!empty($productAttributes)) { foreach ($productAttributes as $productAttribute) { $id_product_attribute = (int) $productAttribute['id_product_attribute']; $attributeCombination = $product->addChild('attribute-combination'); $attributeCombination->addAttribute('id', $id_product_attribute); $attributeCombination->addChild('weight', (double) ($sqlProduct['weight'] + $productAttribute['weight'])); $attributeCombination->addChild('final-retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true, $id_product_attribute)); $attributeCombination->addChild('final-retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, $id_product_attribute)); $attributeCombination->addChild('quantity', $productAttribute['quantity']); if (isset($productAttribute['id_image']) && !empty($productAttribute['id_image'])) { $image = $attributeCombination->addChild('image'); $image->addAttribute('ref-id', $productAttribute['id_image']); } if (isset($combinaison[$id_product_attribute]) && !empty($combinaison[$id_product_attribute])) { foreach ($combinaison[$id_product_attribute] as $id_group_attribute => $id_attribute) { $attribute = $attributeCombination->addChild('attribute'); $attribute->addAttribute('group-ref-id', $id_group_attribute); $attribute->addAttribute('ref-id', $id_attribute); } } } } } echo $products->asXML(); }
public function __construct() { self::$template_version = version_compare(_PS_VERSION_, '1.6', '<') ? '1.5' : '1.6'; // need to set this in constructor to allow translation TSCommon::$payments_type = array('DIRECT_DEBIT' => $this->l('Direct debit'), 'CREDIT_CARD' => $this->l('Credit Card'), 'INVOICE' => $this->l('Invoice'), 'CASH_ON_DELIVERY' => $this->l('Cash on delivery'), 'PREPAYMENT' => $this->l('Prepayment'), 'CHEQUE' => $this->l('Cheque'), 'PAYBOX' => $this->l('Paybox'), 'PAYPAL' => $this->l('PayPal'), 'AMAZON_PAYMENTS' => $this->l('Amazon payments'), 'CASH_ON_PICKUP' => $this->l('Cash on pickup'), 'FINANCING' => $this->l('Financing'), 'LEASING' => $this->l('Leasing'), 'T_PAY' => $this->l('T-Pay'), 'CLICKANDBUY' => $this->l('Click&Buy'), 'GIROPAY' => $this->l('Giropay'), 'GOOGLE_CHECKOUT' => $this->l('Google Checkout'), 'SHOP_CARD' => $this->l('Online shop payment card'), 'DIRECT_E_BANKING' => $this->l('DIRECTebanking.com'), 'MONEYBOOKERS' => $this->l('moneybookers.com'), 'DOTPAY' => $this->l('Dotpay'), 'PLATNOSCI' => $this->l('Platnosci'), 'PRZELEWY24' => $this->l('Przelewy24'), 'OTHER' => $this->l('Other method of payment')); $this->tab_name = $this->l('Trusted Shops quality seal and buyer protection'); $this->site_url = Tools::htmlentitiesutf8('http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__); TSBPException::setTranslationObject($this); if (!method_exists('Tools', 'jsonDecode') || !method_exists('Tools', 'jsonEncode')) { $this->warnings[] = $this->l('Json functions must be implemented in your php version'); } else { foreach (array_keys(self::$available_languages) as $iso) { $certificate = Configuration::get(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($iso)); TSCommon::$certificates[Tools::strtoupper($iso)] = (array) Tools::jsonDecode(Tools::htmlentitiesDecodeUTF8($certificate)); if (!isset(TSCommon::$certificates[Tools::strtoupper($iso)]['tsID']) || isset(TSCommon::$certificates[Tools::strtoupper($iso)]['tsID']) && TSCommon::$certificates[Tools::strtoupper($iso)]['tsID'] == '') { TSCommon::$available_languages_for_adding[Tools::strtoupper($iso)] = Tools::strtoupper($iso); } } if (TSCommon::$shopsw === null) { TSCommon::$shopsw = Configuration::get(TSCommon::PREFIX_TABLE . 'SHOPSW'); TSCommon::$et_cid = Configuration::get(TSCommon::PREFIX_TABLE . 'ET_CID'); TSCommon::$et_lid = Configuration::get(TSCommon::PREFIX_TABLE . 'ET_LID'); TSCommon::$default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); TSCommon::$cat_id = (int) Configuration::get(TSCommon::PREFIX_TABLE . 'CAT_ID'); TSCommon::$env_api = Configuration::get(TSCommon::PREFIX_TABLE . 'ENV_API'); } } }
public function displayDeleteLink($token = null, $id, $name = null) { if ($this->tabAccess['delete'] == 1) { $tpl = $this->createTemplate('helpers/list/list_action_delete.tpl'); if (!array_key_exists('Delete', self::$cache_lang)) { self::$cache_lang['Delete'] = $this->l('Delete', 'Helper'); } if (!array_key_exists('DeleteItem', self::$cache_lang)) { self::$cache_lang['DeleteItem'] = $this->l('Delete selected item?', 'Helper'); } if (!array_key_exists('Name', self::$cache_lang)) { self::$cache_lang['Name'] = $this->l('Name:', 'Helper'); } if (!is_null($name)) { $name = '\\n\\n' . self::$cache_lang['Name'] . ' ' . $name; } $data = array($this->identifier => $id, 'href' => $this->context->link->getAdminLink('AdminCarriers') . '&id_carrier=' . (int) $id . '&deletecarrier=1', 'action' => self::$cache_lang['Delete']); if ($this->specificConfirmDelete !== false) { $data['confirm'] = !is_null($this->specificConfirmDelete) ? '\\r' . $this->specificConfirmDelete : addcslashes(Tools::htmlentitiesDecodeUTF8(self::$cache_lang['DeleteItem'] . $name), '\''); } $tpl->assign(array_merge($this->tpl_delete_link_vars, $data)); return $tpl->fetch(); } else { return; } }
/** * AdminController::getList() override * @see AdminController::getList() */ 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); for ($i = 0; $i < $nb_items; ++$i) { if (isset($this->_list[$i]['messages'])) { $this->_list[$i]['messages'] = Tools::htmlentitiesDecodeUTF8($this->_list[$i]['messages']); } } }
public function getGCategFieldsValues() { $gcatexport_active = ''; $gcatcondition_edit = ''; $gcatavail_edit = ''; $gcatgender_edit = ''; $gcatage_edit = ''; $gcatcolor_edit = ''; $gcatmaterial_edit = ''; $gcatpattern_edit = ''; $gcatsize_edit = ''; $gcategory_edit = ''; $gcatlabel_edit = ''; if (Tools::isSubmit('updategshoppingflux') || Tools::isSubmit('statusgshoppingflux')) { $id_lang = $this->context->cookie->id_lang; $gcateg = GCategories::getCategLang(Tools::getValue('id_gcategory'), (int) Shop::getContextShopID(), $id_lang); foreach ($gcateg['gcategory'] as $key => $categ) { $gcateg['gcategory'][$key] = Tools::htmlentitiesDecodeUTF8($categ); } $gcatexport_active = $gcateg['export']; $gcatcondition_edit = $gcateg['condition']; $gcatavail_edit = $gcateg['availability']; $gcatgender_edit = $gcateg['gender']; $gcatage_edit = $gcateg['age_group']; $gcatcolor_edit = $gcateg['color']; $gcatmaterial_edit = $gcateg['material']; $gcatpattern_edit = $gcateg['pattern']; $gcatsize_edit = $gcateg['size']; $gcategory_edit = $gcateg['gcategory']; $gcatlabel_edit = $gcateg['breadcrumb']; } $fields_values = array('id_gcategory' => Tools::getValue('id_gcategory'), 'breadcrumb' => isset($gcatlabel_edit) ? $gcatlabel_edit : '', 'export' => Tools::getValue('export', isset($gcatexport_active) ? $gcatexport_active : ''), 'condition' => Tools::getValue('condition', isset($gcatcondition_edit) ? $gcatcondition_edit : ''), 'availability' => Tools::getValue('availability', isset($gcatavail_edit) ? $gcatavail_edit : ''), 'gender' => Tools::getValue('gender', isset($gcatgender_edit) ? $gcatgender_edit : ''), 'age_group' => Tools::getValue('age_group', isset($gcatage_edit) ? $gcatage_edit : ''), 'color[]' => explode(';', Tools::getValue('color[]', isset($gcatcolor_edit) ? $gcatcolor_edit : '')), 'material[]' => explode(';', Tools::getValue('material[]', isset($gcatmaterial_edit) ? $gcatmaterial_edit : '')), 'pattern[]' => explode(';', Tools::getValue('pattern[]', isset($gcatpattern_edit) ? $gcatpattern_edit : '')), 'size[]' => explode(';', Tools::getValue('size[]', isset($gcatsize_edit) ? $gcatsize_edit : ''))); if (Tools::getValue('submitAddmodule')) { foreach (Language::getLanguages(false) as $lang) { $fields_values['gcategory'][$lang['id_lang']] = ''; } } else { foreach (Language::getLanguages(false) as $lang) { $fields_values['gcategory'][$lang['id_lang']] = Tools::getValue('gcategory_' . (int) $lang['id_lang'], isset($gcategory_edit[$lang['id_lang']]) ? html_entity_decode($gcategory_edit[$lang['id_lang']]) : ''); } } return $fields_values; }
public function getAddLinkFieldsValues() { $links_label_edit = ''; $labels_edit = ''; $new_window_edit = ''; if (Tools::isSubmit('updatelinksmenutop')) { $link = MenuTopLinks::getLinkLang(Tools::getValue('id_linksmenutop'), (int) Shop::getContextShopID()); foreach ($link['link'] as $key => $label) { $link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label); } $links_label_edit = $link['link']; $labels_edit = $link['label']; $new_window_edit = $link['new_window']; } $fields_values = array('new_window' => Tools::getValue('new_window', $new_window_edit), 'id_linksmenutop' => Tools::getValue('id_linksmenutop')); if (Tools::getValue('submitAddmodule')) { foreach (Language::getLanguages(false) as $lang) { $fields_values['label'][$lang['id_lang']] = ''; $fields_values['link'][$lang['id_lang']] = ''; } } else { foreach (Language::getLanguages(false) as $lang) { $fields_values['label'][$lang['id_lang']] = Tools::getValue('label_' . (int) $lang['id_lang'], isset($labels_edit[$lang['id_lang']]) ? $labels_edit[$lang['id_lang']] : ''); $fields_values['link'][$lang['id_lang']] = Tools::getValue('link_' . (int) $lang['id_lang'], isset($links_label_edit[$lang['id_lang']]) ? $links_label_edit[$lang['id_lang']] : ''); } } return $fields_values; }
public function __construct() { global $smarty; $this->smarty = $smarty; $this->name = 'dibs'; $this->tab = 'payments_gateways'; $this->version = '1.0'; parent::__construct(); $this->displayName = $this->l('DIBS'); $this->description = $this->l('DIBS payment API'); if (self::$site_url === NULL) { self::$site_url = Tools::htmlentitiesutf8(Tools::getProtocol() . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__); } self::$ID_MERCHANT = Configuration::get('DIBS_ID_MERCHANT'); self::$ACCEPTED_URL = Configuration::get('DIBS_ACCEPTED_URL'); self::$CANCELLED_URL = Configuration::get('DIBS_CANCELLED_URL'); self::$TESTING = (int) Configuration::get('DIBS_TESTING'); self::$MORE_SETTINGS = Configuration::get('DIBS_MORE_SETTINGS') != '' ? unserialize(Tools::htmlentitiesDecodeUTF8(Configuration::get('DIBS_MORE_SETTINGS'))) : array(); if (!isset(self::$MORE_SETTINGS['k1']) or isset(self::$MORE_SETTINGS['k1']) and (self::$MORE_SETTINGS['k1'] === '' or self::$MORE_SETTINGS['k2'] === '')) { $this->warning = $this->l('For security reasons, you must set key #1 and key #2 used by MD5 control of DIBS API.'); } if (!self::$ID_MERCHANT or self::$ID_MERCHANT === '') { $this->warning = $this->l('You have to set your merchant ID to use DIBS API.'); } }
public static function configXmlStringFormat($string) { return Tools::htmlentitiesDecodeUTF8($string); }
public function __construct() { $this->name = 'dibs'; $this->tab = 'payments_gateways'; $this->version = '1.3.1'; $this->author = 'PrestaShop'; $this->module_key = 'a4fca203207d61700d13bd40a29764c9'; parent::__construct(); $this->displayName = $this->l('DIBS'); $this->description = $this->l('DIBS payment API'); if (self::$site_url === NULL) { if (method_exists('Tools', 'getProtocol')) { self::$site_url = Tools::htmlentitiesutf8(Tools::getProtocol() . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__); } else { self::$site_url = Tools::htmlentitiesutf8((!is_null($use_ssl) && $use_ssl ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__); } } self::$ID_MERCHANT = Configuration::get('DIBS_ID_MERCHANT'); self::$ACCEPTED_URL = Configuration::get('DIBS_ACCEPTED_URL'); self::$CANCELLED_URL = Configuration::get('DIBS_CANCELLED_URL'); self::$TESTING = (int) Configuration::get('DIBS_TESTING'); self::$MORE_SETTINGS = Configuration::get('DIBS_MORE_SETTINGS') != '' ? unserialize(Tools::htmlentitiesDecodeUTF8(Configuration::get('DIBS_MORE_SETTINGS'))) : array(); if (!isset(self::$MORE_SETTINGS['k1']) or isset(self::$MORE_SETTINGS['k1']) and (self::$MORE_SETTINGS['k1'] === '' or self::$MORE_SETTINGS['k2'] === '')) { $this->warning = $this->l('For security reasons, you must set key #1 and key #2 used by MD5 control of DIBS API.'); } if (!self::$ID_MERCHANT or self::$ID_MERCHANT === '') { $this->warning = $this->l('You have to set your merchant ID to use DIBS API.'); } /* 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 . '_')); } } } /** Backward compatibility */ require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php'; }