/** * Render shop list * * @return string */ public function getRenderedShopList() { if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) { return ''; } $shop_context = Shop::getContext(); $context = Context::getContext(); $tree = Shop::getTree(); if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) { $current_shop_value = ''; $current_shop_name = Translate::getAdminTranslation('All shops'); } elseif ($shop_context == Shop::CONTEXT_GROUP) { $current_shop_value = 'g-' . Shop::getContextShopGroupID(); $current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']); } else { $current_shop_value = 's-' . Shop::getContextShopID(); foreach ($tree as $group_id => $group_data) { foreach ($group_data['shops'] as $shop_id => $shop_data) { if ($shop_id == Shop::getContextShopID()) { $current_shop_name = $shop_data['name']; break; } } } } $tpl = $this->createTemplate('helpers/shops_list/list.tpl'); $tpl->assign(array('tree' => $tree, 'current_shop_name' => $current_shop_name, 'current_shop_value' => $current_shop_value, 'multishop_context' => $context->controller->multishop_context, 'multishop_context_group' => $context->controller->multishop_context_group, 'is_shop_context' => $context->controller->multishop_context & Shop::CONTEXT_SHOP, 'is_group_context' => $context->controller->multishop_context & Shop::CONTEXT_GROUP, 'shop_context' => $shop_context, 'url' => $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext=')); return $tpl->fetch(); }
private function renderParameter() { $field_days = array(array('short_day' => 'L', 'name' => Translate::getAdminTranslation('Monday')), array('short_day' => 'M', 'name' => Translate::getAdminTranslation('Tuesday')), array('short_day' => 'C', 'name' => Translate::getAdminTranslation('Wednesday')), array('short_day' => 'J', 'name' => Translate::getAdminTranslation('Thursday')), array('short_day' => 'V', 'name' => Translate::getAdminTranslation('Friday')), array('short_day' => 'S', 'name' => Translate::getAdminTranslation('Saturday')), array('short_day' => 'D', 'name' => Translate::getAdminTranslation('Sunday'))); $this->fields_form = array('legend' => array('title' => $this->module->l('Campaign configuration (step 1)', 'adminmarketingsstep1'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => _PS_MODE_DEV_ ? 'text' : 'hidden', 'lang' => false, 'label' => 'Ref :', 'name' => 'campaign_id', 'col' => 1, 'readonly' => 'readonly'), array('type' => 'text', 'lang' => false, 'label' => $this->module->l('Give a name to this campaign :', 'adminmarketingsstep1'), 'name' => 'campaign_name', 'col' => 7, 'required' => true), array('type' => 'datetime', 'lang' => false, 'name' => 'campaign_date_send', 'label' => $this->module->l('Sending date :', 'adminmarketingsstep1'), 'col' => 5, 'required' => true), array('type' => 'checkbox', 'label' => $this->module->l('Limit by day of the week :', 'adminmarketingsstep1'), 'class' => 'checkbox-inline', 'name' => 'week_day_limit', 'values' => array('query' => $field_days, 'id' => 'short_day', 'name' => 'name', 'class' => 'checkbox-inline')), array('type' => 'free', 'name' => 'schedule_sending', 'label' => $this->module->l('Schedule sending :', 'adminmarketingsstep1'))), 'submit' => array('title' => $this->module->l('Next', 'adminmarketingsstep1'), 'name' => 'submitSmsStep1', 'icon' => 'process-icon-next')); $output = parent::renderForm(); return $this->getFormWrapperElement($output); }
function smartyTranslate($params, &$smarty) { $htmlentities = !isset($params['js']); $pdf = isset($params['pdf']); $addslashes = isset($params['slashes']); $sprintf = isset($params['sprintf']) ? $params['sprintf'] : false; if ($pdf) { return Translate::getPdfTranslation($params['s']); } $filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath(); // If the template is part of a module if (!empty($params['mod'])) { return Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf); } // If the tpl is at the root of the template folder if (dirname($filename) == '.') { $class = 'index'; } elseif (strpos($filename, 'helpers') === 0) { $class = 'Helper'; } else { // Split by \ and / to get the folder tree for the file $folder_tree = preg_split('#[/\\\\]#', $filename); $key = array_search('controllers', $folder_tree); // If there was a match, construct the class name using the child folder name // Eg. xxx/controllers/customers/xxx => AdminCustomers if ($key !== false) { $class = 'Admin' . Tools::toCamelCase($folder_tree[$key + 1], true); } else { $class = null; } } return Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf); }
public function __construct() { $this->date_months = array(1 => Translate::getAdminTranslation('January'), 2 => Translate::getAdminTranslation('February'), 3 => Translate::getAdminTranslation('March'), 4 => Translate::getAdminTranslation('April'), 5 => Translate::getAdminTranslation('May'), 6 => Translate::getAdminTranslation('June'), 7 => Translate::getAdminTranslation('July'), 8 => Translate::getAdminTranslation('August'), 9 => Translate::getAdminTranslation('September'), 10 => Translate::getAdminTranslation('October'), 11 => Translate::getAdminTranslation('November'), 12 => Translate::getAdminTranslation('December')); $this->date_suffix = array(1 => $this->l('st'), 2 => $this->l('nd'), 3 => $this->l('rd'), 4 => $this->l('th')); /* FR/PL : |d| |m| |Y| */ /* EN : |M| |d||S|, |Y| */ $this->date_format = $this->l('|M| |d||S|, |Y|'); }
public function renderList() { $this->getFieldsValues(); $field_days = array(array('short_day' => 'L', 'name' => Translate::getAdminTranslation('Monday')), array('short_day' => 'M', 'name' => Translate::getAdminTranslation('Tuesday')), array('short_day' => 'C', 'name' => Translate::getAdminTranslation('Wednesday')), array('short_day' => 'J', 'name' => Translate::getAdminTranslation('Thursday')), array('short_day' => 'V', 'name' => Translate::getAdminTranslation('Friday')), array('short_day' => 'S', 'name' => Translate::getAdminTranslation('Saturday')), array('short_day' => 'D', 'name' => Translate::getAdminTranslation('Sunday'))); $this->fields_form = array('legend' => array('title' => $this->module->l('Campaign configuration (step 1)', 'adminmarketingfstep1'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => _PS_MODE_DEV_ ? 'text' : 'hidden', 'lang' => false, 'label' => 'Ref :', 'name' => 'campaign_id', 'col' => 1, 'readonly' => 'readonly'), array('type' => 'text', 'lang' => false, 'label' => $this->module->l('Campaign name :', 'adminmarketingfstep1'), 'name' => 'campaign_name', 'col' => 5, 'required' => true), array('type' => 'datetime', 'lang' => false, 'name' => 'campaign_date_send', 'label' => $this->module->l('Sending date :', 'adminmarketingfstep1'), 'col' => 5, 'required' => true), array('type' => 'checkbox', 'label' => $this->module->l('Limit by day of the week :', 'adminmarketingfstep1'), 'class' => 'checkbox-inline', 'name' => 'week_day_limit', 'values' => array('query' => $field_days, 'id' => 'short_day', 'name' => 'name', 'class' => 'checkbox-inline')), array('type' => 'free', 'name' => 'start_end_hours', 'label' => $this->module->l('Schedule sending :', 'adminmarketingfstep1'), 'required' => true), array('type' => 'free', 'name' => 'campaign_day_limit', 'label' => $this->module->l('Daily sending limit :', 'adminmarketingfstep1'))), 'submit' => array('title' => $this->module->l('Next', 'adminmarketingfstep1'), 'name' => 'submitFaxStep1', 'icon' => 'process-icon-next')); $output = parent::renderForm(); $footer = $this->getTemplatePath() . 'footer.tpl'; $output .= $this->context->smarty->fetch($footer); return $output; }
public function getCurrentShopName() { $shop_context = Shop::getContext(); $tree = Shop::getTree(); if ($this->noShopSelection()) { $current_shop_name = Translate::getAdminTranslation('All shops'); } elseif ($shop_context == Shop::CONTEXT_GROUP) { $current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']); } else { foreach ($tree as $group_id => $group_data) { foreach ($group_data['shops'] as $shop_id => $shop_data) { if ($shop_id == Shop::getContextShopID()) { $current_shop_name = $shop_data['name']; break; } } } } return $current_shop_name; }
/** * Non-static method which uses AdminController::translate() * * @param string $string Term or expression in english * @param string|null $class Name of the class * @param bool $addslashes If set to true, the return value will pass through addslashes(). Otherwise, stripslashes(). * @param bool $htmlentities If set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8') * @return string The translation if available, or the english default text. */ protected function l($string, $class = null, $addslashes = false, $htmlentities = true) { if ($class === null || $class == 'AdminTab') { $class = substr(get_class($this), 0, -10); } elseif (strtolower(substr($class, -10)) == 'controller') { /* classname has changed, from AdminXXX to AdminXXXController, so we remove 10 characters and we keep same keys */ $class = substr($class, 0, -10); } return Translate::getAdminTranslation($string, $class, $addslashes, $htmlentities); }
/** * for retrocompatibility with old AdminTab, old index.php * * @return void */ function runAdminTab($tab, $ajaxMode = false) { $ajaxMode = (bool) $ajaxMode; require_once _PS_ADMIN_DIR_ . '/init.php'; $cookie = Context::getContext()->cookie; if (empty($tab) && !sizeof($_POST)) { $tab = 'AdminDashboard'; $_POST['tab'] = $tab; $_POST['token'] = Tools::getAdminTokenLite($tab); } // $tab = $_REQUEST['tab']; if ($adminObj = checkingTab($tab)) { Context::getContext()->controller = $adminObj; // init is different for new tabs (AdminController) and old tabs (AdminTab) if ($adminObj instanceof AdminController) { if ($ajaxMode) { $adminObj->ajax = true; } $adminObj->path = dirname($_SERVER["PHP_SELF"]); $adminObj->run(); } else { if (!$ajaxMode) { require_once _PS_ADMIN_DIR_ . '/header.inc.php'; } $isoUser = Context::getContext()->language->id; $tabs = array(); $tabs = Tab::recursiveTab($adminObj->id, $tabs); $tabs = array_reverse($tabs); $bread = ''; foreach ($tabs as $key => $item) { $bread .= ' <img src="../img/admin/separator_breadcrumb.png" style="margin-right:5px" alt=">" />'; if (count($tabs) - 1 > $key) { $bread .= '<a href="?tab=' . $item['class_name'] . '&token=' . Tools::getAdminToken($item['class_name'] . intval($item['id_tab']) . (int) Context::getContext()->employee->id) . '">'; } $bread .= $item['name']; if (count($tabs) - 1 > $key) { $bread .= '</a>'; } } if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL) { echo '<div class="multishop_info">'; if (Shop::getContext() == Shop::CONTEXT_GROUP) { $shop_group = new ShopGroup((int) Shop::getContextShopGroupID()); printf(Translate::getAdminTranslation('You are configuring your store for group shop %s'), '<b>' . $shop_group->name . '</b>'); } elseif (Shop::getContext() == Shop::CONTEXT_SHOP) { printf(Translate::getAdminTranslation('You are configuring your store for shop %s'), '<b>' . Context::getContext()->shop->name . '</b>'); } echo '</div>'; } if (Validate::isLoadedObject($adminObj)) { if ($adminObj->checkToken()) { if ($ajaxMode) { // the differences with index.php is here $adminObj->ajaxPreProcess(); $action = Tools::getValue('action'); // no need to use displayConf() here if (!empty($action) && method_exists($adminObj, 'ajaxProcess' . Tools::toCamelCase($action))) { $adminObj->{'ajaxProcess' . Tools::toCamelCase($action)}(); } else { $adminObj->ajaxProcess(); } // @TODO We should use a displayAjaxError $adminObj->displayErrors(); if (!empty($action) && method_exists($adminObj, 'displayAjax' . Tools::toCamelCase($action))) { $adminObj->{'displayAjax' . $action}(); } else { $adminObj->displayAjax(); } } else { /* Filter memorization */ if (isset($_POST) && !empty($_POST) && isset($adminObj->table)) { foreach ($_POST as $key => $value) { if (is_array($adminObj->table)) { foreach ($adminObj->table as $table) { if (strncmp($key, $table . 'Filter_', 7) === 0 || strncmp($key, 'submitFilter', 12) === 0) { $cookie->{$key} = !is_array($value) ? $value : serialize($value); } } } elseif (strncmp($key, $adminObj->table . 'Filter_', 7) === 0 || strncmp($key, 'submitFilter', 12) === 0) { $cookie->{$key} = !is_array($value) ? $value : serialize($value); } } } if (isset($_GET) && !empty($_GET) && isset($adminObj->table)) { foreach ($_GET as $key => $value) { if (is_array($adminObj->table)) { foreach ($adminObj->table as $table) { if (strncmp($key, $table . 'OrderBy', 7) === 0 || strncmp($key, $table . 'Orderway', 8) === 0) { $cookie->{$key} = $value; } } } elseif (strncmp($key, $adminObj->table . 'OrderBy', 7) === 0 || strncmp($key, $adminObj->table . 'Orderway', 12) === 0) { $cookie->{$key} = $value; } } } $adminObj->displayConf(); $adminObj->postProcess(); $adminObj->displayErrors(); $adminObj->display(); include _PS_ADMIN_DIR_ . '/footer.inc.php'; } } else { if ($ajaxMode) { // If this is an XSS attempt, then we should only display a simple, secure page if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17) $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}' . $adminObj->token . '$2', $_SERVER['REQUEST_URI']); if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) { $url .= '&token=' . $adminObj->token; } // we can display the correct url // die(Tools::jsonEncode(array(Translate::getAdminTranslation('Invalid security token'),$url))); die(Tools::jsonEncode(Translate::getAdminTranslation('Invalid security token'))); } else { // If this is an XSS attempt, then we should only display a simple, secure page if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17) $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}' . $adminObj->token . '$2', $_SERVER['REQUEST_URI']); if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) { $url .= '&token=' . $adminObj->token; } $message = Translate::getAdminTranslation('Invalid security token'); echo '<html><head><title>' . $message . '</title></head><body style="font-family:Arial,Verdana,Helvetica,sans-serif;background-color:#EC8686"> <div style="background-color:#FAE2E3;border:1px solid #000000;color:#383838;font-weight:700;line-height:20px;margin:0 0 10px;padding:10px 15px;width:500px"> <img src="../img/admin/error2.png" style="margin:-4px 5px 0 0;vertical-align:middle"> ' . $message . ' </div>'; echo '<a href="' . htmlentities($url) . '" method="get" style="float:left;margin:10px"> <input type="button" value="' . Tools::htmlentitiesUTF8(Translate::getAdminTranslation('I understand the risks and I really want to display this page')) . '" style="height:30px;margin-top:5px" /> </a> <a href="index.php" method="get" style="float:left;margin:10px"> <input type="button" value="' . Tools::htmlentitiesUTF8(Translate::getAdminTranslation('Take me out of here!')) . '" style="height:40px" /> </a> </body></html>'; die; } } } } } }
* http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ $con = new AdminController(); $con->init(); $con->initToolbar(); $con->initPageHeaderToolbar(); $con->setMedia(); $con->initHeader(); $con->initFooter(); $title = array(Translate::getAdminTranslation('Advanced parameters'), Translate::getAdminTranslation('1-Click upgrade')); Context::getContext()->smarty->assign(array('navigationPipe', Configuration::get('PS_NAVIGATION_PIPE'), 'meta_title' => implode(' ' . Configuration::get('PS_NAVIGATION_PIPE') . ' ', $title), 'display_header' => true, 'display_footer' => true)); $dir = Context::getContext()->smarty->getTemplateDir(0) . 'controllers' . DIRECTORY_SEPARATOR . trim($con->override_folder, '\\/') . DIRECTORY_SEPARATOR; $header_tpl = file_exists($dir . 'header.tpl') ? $dir . 'header.tpl' : 'header.tpl'; $tool_tpl = file_exists($dir . 'page_header_toolbar.tpl') ? $dir . 'page_header_toolbar.tpl' : 'page_header_toolbar.tpl'; Context::getContext()->smarty->assign(array('show_page_header_toolbar' => true, 'title' => implode(' ' . Configuration::get('PS_NAVIGATION_PIPE') . ' ', $title), 'toolbar_btn' => array())); echo Context::getContext()->smarty->fetch($header_tpl); echo Context::getContext()->smarty->fetch($tool_tpl);
public function postProcess() { // On construit un login pour le compte // ------------------------------------ // Si PS_SHOP_EMAIL = info@axalone.com // Alors login = ps-info-axalone // 1/ On ajoute 'ps-' devant l'email // 2/ On retire l'extention .com à la fin // 3/ On remplace toutes les lettres accentuées par leurs équivalents sans accent // 4/ On remplace tous les sigles par des tirets // 5/ Enfin on remplace les doubles/triples tirets par des simples // -------------------------------------------------------------------------------- $company_login = '******' . Configuration::get('PS_SHOP_EMAIL'); $company_login = Tools::substr($company_login, 0, strrpos($company_login, '.')); $company_login = EMTools::removeAccents($company_login); $company_login = Tools::strtolower($company_login); $company_login = preg_replace('/[^a-z0-9-]/', '-', $company_login); $company_login = preg_replace('/-{2,}/', '-', $company_login); $cart_product = (string) Tools::getValue('product', ''); // Initialisation de l'API // ----------------------- if (Tools::isSubmit('submitInscription')) { // On prépare l'ouverture du compte // -------------------------------- $company_name = (string) Tools::getValue('company_name'); $company_email = (string) Tools::getValue('company_email'); $company_phone = (string) Tools::getValue('company_phone'); $company_address1 = (string) Tools::getValue('company_address1'); $company_address2 = (string) Tools::getValue('company_address2'); $company_zipcode = (string) Tools::getValue('company_zipcode'); $company_city = (string) Tools::getValue('company_city'); $country_id = (int) Tools::getValue('country_id'); $country = new Country($country_id); if (!is_object($country) || empty($country->id)) { $this->errors[] = Tools::displayError('Country is invalid'); } else { $company_country = Country::getNameById($this->context->language->id, $country_id); } if (!Validate::isGenericName($company_name)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop name', 'AdminStores') . ' »'); } if (!Validate::isEmail($company_email)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop email', 'AdminStores') . ' »'); } if (!Validate::isPhoneNumber($company_phone)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Phone', 'AdminStores') . ' »'); } if (!Validate::isAddress($company_address1)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop address line 1', 'AdminStores') . ' »'); } if ($country->zip_code_format && !$country->checkZipCode($company_zipcode)) { $this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))); } elseif (empty($company_zipcode) && $country->need_zip_code) { $this->errors[] = Tools::displayError('A Zip/postal code is required.'); } elseif ($company_zipcode && !Validate::isPostCode($company_zipcode)) { $this->errors[] = Tools::displayError('The Zip/postal code is invalid.'); } if (!Validate::isGenericName($company_city)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('City', 'AdminStores') . ' »'); } // We save these informations in the database // ------------------------------------------ Db::getInstance()->insert('expressmailing_order_address', array('id_address' => 1, 'company_name' => pSQL($company_name), 'company_email' => pSQL($company_email), 'company_address1' => pSQL($company_address1), 'company_address2' => pSQL($company_address2), 'company_zipcode' => pSQL($company_zipcode), 'company_city' => pSQL($company_city), 'country_id' => $country_id, 'company_country' => pSQL($company_country), 'company_phone' => pSQL($company_phone), 'product' => pSQL($cart_product)), false, false, Db::REPLACE); // If form contains 1 or more errors, we stop the process // ------------------------------------------------------ if (is_array($this->errors) && count($this->errors)) { return false; } // Open a session on Express-Mailing API // ------------------------------------- if ($this->session_api->openSession()) { // We create the account // --------------------- $response_array = array(); $base_url = Configuration::get('PS_SSL_ENABLED') == 0 ? Tools::getShopDomain(true, true) : Tools::getShopDomainSsl(true, true); $module_dir = Tools::str_replace_once(_PS_ROOT_DIR_, '', _PS_MODULE_DIR_); $parameters = array('login' => $company_login, 'info_company' => $company_name, 'info_email' => $company_email, 'info_phone' => $company_phone, 'info_address' => $company_address1 . "\r\n" . $company_address2, 'info_country' => $company_country, 'info_zipcode' => $company_zipcode, 'info_city' => $company_city, 'info_phone' => $company_phone, 'info_contact_firstname' => $this->context->employee->firstname, 'info_contact_lastname' => $this->context->employee->lastname, 'email_report' => $this->context->employee->email, 'gift_code' => 'prestashop_' . Translate::getModuleTranslation('expressmailing', '3320', 'session_api'), 'INFO_WWW' => $base_url . $module_dir . $this->module->name . '/campaigns/index.php'); if ($this->session_api->createAccount($parameters, $response_array)) { // If the form include the buying process (field 'product') // We initiate a new cart with the product selected // -------------------------------------------------------- if ($cart_product) { Tools::redirectAdmin('index.php?controller=AdminMarketingBuy&submitCheckout&campaign_id=' . $this->campaign_id . '&media=' . $this->next_controller . '&product=' . $cart_product . '&token=' . Tools::getAdminTokenLite('AdminMarketingBuy')); exit; } // Else we back to the mailing process // ----------------------------------- Tools::redirectAdmin($this->next_action); exit; } if ($this->session_api->error == 11) { // Account already existe, we print the rescue form (with password input) // ---------------------------------------------------------------------- $response_array = array(); $parameters = array('login' => $company_login); $this->session_api->resendPassword($parameters, $response_array); $this->generateRescueForm(); return; } else { // Other error // ----------- $this->errors[] = sprintf($this->module->l('Unable to create an account : %s', 'adminmarketinginscription'), $this->session_api->getError()); return false; } } else { $this->errors[] = sprintf($this->module->l('Error during communication with Express-Mailing API : %s', 'adminmarketinginscription'), $this->session_api->getError()); return false; } } elseif (Tools::isSubmit('submitRescue')) { // Rescue form : ask for existing password // --------------------------------------- if ($this->session_api->openSession()) { $response_array = array(); $password = trim((string) Tools::getValue('api_password')); $parameters = array('login' => $company_login, 'password' => $password); if ($this->session_api->connectUser($parameters, $response_array)) { Db::getInstance()->insert('expressmailing', array('api_login' => pSQL($company_login), 'api_password' => pSQL($password)), false, false, Db::REPLACE); // If the form include the buying process (field 'product') // We initiate a new cart with the product selected // -------------------------------------------------------- if ($cart_product) { Tools::redirectAdmin('index.php?controller=AdminMarketingBuy&submitCheckout&campaign_id=' . $this->campaign_id . '&media=' . $this->next_controller . '&product=' . $cart_product . '&token=' . Tools::getAdminTokenLite('AdminMarketingBuy')); exit; } // Else we back to the mailing process // ----------------------------------- Tools::redirectAdmin($this->next_action); exit; } } $this->errors[] = sprintf($this->module->l('Error during communication with Express-Mailing API : %s', 'adminmarketinginscription'), $this->session_api->getError()); return false; } }
function smartyTranslate($params, &$smarty) { $htmlentities = !isset($params['js']); $pdf = isset($params['pdf']); $addslashes = isset($params['slashes']) || isset($params['js']); $sprintf = isset($params['sprintf']) ? $params['sprintf'] : array(); if (!empty($params['d'])) { if (isset($params['tags'])) { $backTrace = debug_backtrace(); $errorMessage = sprintf('Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().', $params['s'], $backTrace[0]['args'][1]->template_resource); if (_PS_MODE_DEV_) { throw new Exception($errorMessage); } else { PrestaShopLogger::addLog($errorMessage); } } if (!is_array($sprintf)) { $backTrace = debug_backtrace(); $errorMessage = sprintf('Unable to translate "%s" in %s. sprintf() parameter should be an array.', $params['s'], $backTrace[0]['args'][1]->template_resource); if (_PS_MODE_DEV_) { throw new Exception($errorMessage); } else { PrestaShopLogger::addLog($errorMessage); return $params['s']; } } return Context::getContext()->getTranslator()->trans($params['s'], $sprintf, $params['d']); } if ($pdf) { return Translate::smartyPostProcessTranslation(Translate::getPdfTranslation($params['s'], $sprintf), $params); } $filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath(); // If the template is part of a module if (!empty($params['mod'])) { return Translate::smartyPostProcessTranslation(Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf, isset($params['js'])), $params); } // If the tpl is at the root of the template folder if (dirname($filename) == '.') { $class = 'index'; } // If the tpl is used by a Helper if (strpos($filename, 'helpers') === 0) { $class = 'Helper'; } else { // If the tpl is used by a Controller if (!empty(Context::getContext()->override_controller_name_for_translations)) { $class = Context::getContext()->override_controller_name_for_translations; } elseif (isset(Context::getContext()->controller)) { $class_name = get_class(Context::getContext()->controller); $class = substr($class_name, 0, strpos(Tools::strtolower($class_name), 'controller')); } else { // Split by \ and / to get the folder tree for the file $folder_tree = preg_split('#[/\\\\]#', $filename); $key = array_search('controllers', $folder_tree); // If there was a match, construct the class name using the child folder name // Eg. xxx/controllers/customers/xxx => AdminCustomers if ($key !== false) { $class = 'Admin' . Tools::toCamelCase($folder_tree[$key + 1], true); } elseif (isset($folder_tree[0])) { $class = 'Admin' . Tools::toCamelCase($folder_tree[0], true); } } } return Translate::smartyPostProcessTranslation(Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf), $params); }
/** * @param ShopgateCart $cart * @return array * @throws PrestaShopException */ protected function _addCoupons(ShopgateCart $cart) { $results = array(); $carrierId = null; if ($cart->getShippingInfos()) { $apiResponse = $cart->getShippingInfos()->getApiResponse(); if (!empty($apiResponse)) { $apiResponse = unserialize($apiResponse); if (!empty($apiResponse['carrierId'])) { $carrierId = $apiResponse['carrierId']; } } } $package = null; if (!empty($carrierId)) { $package = array('products' => null, 'id_carrier' => $carrierId); } foreach ($cart->getExternalCoupons() as $coupon) { $result = new ShopgateExternalCoupon(); $result->setCode($coupon->getCode()); $result->setCurrency($this->_getCurrency()); $result->setIsValid(false); $result->setNotValidMessage(Tools::displayError('This voucher does not exists.')); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { /** @var CartRuleCore $cartRule */ $cartRule = new CartRule(CartRule::getIdByCode($coupon->getCode())); if (Validate::isLoadedObject($cartRule)) { $result->setName($cartRule->getFieldByLang('name'), $this->getPlugin()->getContext()->language->id); $result->setDescription($cartRule->getFieldByLang('description', $this->getPlugin()->getContext()->language->id)); $result->setTaxType(Translate::getAdminTranslation('not_taxable')); $result->setAmountGross($cartRule->getContextualValue(true, $this->getPlugin()->getContext(), null, $package)); /** * validate coupon */ if ($validateException = $cartRule->checkValidity($this->getPlugin()->getContext(), false, true)) { $result->setIsValid(false); $result->setNotValidMessage($validateException); } else { $result->setIsValid(true); $result->setNotValidMessage(null); $this->getPlugin()->getContext()->cart->addCartRule($cartRule->id); $this->getPlugin()->getContext()->cart->save(); } } } $results[] = $result; } return $results; }
public function installAdminTab($tab_class, $tab_active, $tab_name, $tab_class_parent) { if (!Tab::getIdFromClassName((string) $tab_class)) { // Get tab parent id // ----------------- if (in_array((string) $tab_class_parent, $this->ids_tabs)) { $id_tab_parent = $this->ids_tabs[(string) $tab_class_parent]; } else { $id_tab_parent = Tab::getIdFromClassName((string) $tab_class_parent); } // Add the new tab // --------------- $tab = new Tab(); $tab->name = array(); foreach (Language::getLanguages() as $language) { $tab->name[$language['id_lang']] = Translate::getAdminTranslation((string) $tab_name, 'expressmailing', false, false); } $tab->class_name = (string) $tab_class; $tab->module = $this->name; $tab->id_parent = (int) $id_tab_parent; $tab->active = (bool) $tab_active ? 1 : 0; if (!$tab->save()) { return false; } $this->ids_tabs[(string) $tab_class] = $tab->id; } // Else, Tab already installed // --------------------------- return true; }
public function renderList() { $field_days = array(array('short_day' => 'L', 'name' => Translate::getAdminTranslation('Monday')), array('short_day' => 'M', 'name' => Translate::getAdminTranslation('Tuesday')), array('short_day' => 'C', 'name' => Translate::getAdminTranslation('Wednesday')), array('short_day' => 'J', 'name' => Translate::getAdminTranslation('Thursday')), array('short_day' => 'V', 'name' => Translate::getAdminTranslation('Friday')), array('short_day' => 'S', 'name' => Translate::getAdminTranslation('Saturday')), array('short_day' => 'D', 'name' => Translate::getAdminTranslation('Sunday'))); $this->fields_form = array('legend' => array('title' => $this->module->l('Campaign configuration (step 1)', 'adminmarketingestep1'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => _PS_MODE_DEV_ ? 'text' : 'hidden', 'lang' => false, 'label' => 'Ref :', 'name' => 'campaign_id', 'col' => 1, 'readonly' => 'readonly'), array('type' => 'text', 'lang' => false, 'label' => $this->module->l('Emailing subject / object :', 'adminmarketingestep1'), 'name' => 'campaign_name', 'col' => 5, 'required' => true), array('type' => 'datetime', 'lang' => false, 'name' => 'campaign_date_send', 'label' => $this->module->l('Sending date :', 'adminmarketingestep1'), 'col' => 5, 'required' => true), array('type' => 'switch', 'lang' => false, 'class' => 'chosen', 'label' => $this->module->l('Activate opening tracking :', 'adminmarketingestep1'), 'name' => 'campaign_tracking', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->module->l('yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->module->l('no')))), array('type' => 'switch', 'lang' => false, 'label' => $this->module->l('Activate links tracking :', 'adminmarketingestep1'), 'name' => 'campaign_linking', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->module->l('yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->module->l('no')))), array('type' => 'switch', 'lang' => false, 'label' => $this->module->l('In case of unsubscription, add the subscriber on red list :', 'adminmarketingestep1'), 'name' => 'campaign_redlist', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->module->l('yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->module->l('no')))), array('type' => 'free', 'name' => 'limit_daily', 'label' => $this->module->l('Daily sending limit :', 'adminmarketingestep1')), array('type' => 'checkbox', 'label' => $this->module->l('Limit by day of the week :', 'adminmarketingestep1'), 'class' => 'checkbox-inline', 'name' => 'week_day_limit', 'values' => array('query' => $field_days, 'id' => 'short_day', 'name' => 'name', 'class' => 'checkbox-inline'))), 'submit' => array('title' => $this->module->l('Next', 'adminmarketingestep1'), 'name' => 'submitEmailingStep1', 'icon' => 'process-icon-next')); $this->getFieldsValues(); $output = parent::renderForm(); $footer = $this->getTemplatePath() . 'footer.tpl'; $output .= $this->context->smarty->fetch($footer); return $output; }
if (checkTabRights($t2['id_tab']) === true and (bool) $t2['active']) { echo '<li><a href="index.php?controller=' . $t2['class_name'] . '&token=' . Tools::getAdminTokenLite($t2['class_name']) . '">' . $t2['name'] . '</a></li>'; } } echo '</ul></li>'; $echoLi = ''; foreach ($subTabs as $t2) { if (checkTabRights($t2['id_tab']) === true and (bool) $t2['active']) { $echoLi .= '<li class="subitem"><a href="index.php?controller=' . $t2['class_name'] . '&token=' . Tools::getAdminTokenLite($t2['class_name']) . '">' . $t2['name'] . '</a></li>'; } } if ($current) { $mainsubtablist = $echoLi; } $echoLis .= '<div id="tab' . (int) $t['id_tab'] . '_subtabs" style="display:none">' . $echoLi . '</div>'; } } echo ' </ul>' . $echoLis; echo ' </div> <div id="main"> <div id="content">' . (file_exists(_PS_ADMIN_DIR_ . '/../install') ? '<div style="background-color: #FFEBCC;border: 1px solid #F90;line-height: 20px;margin: 0px 0px 10px;padding: 10px 20px;">' . Translate::getAdminTranslation('For security reasons, you must also:') . ' ' . Translate::getAdminTranslation('delete the /install folder') . '</div>' : '') . ' '; if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_) { echo '<div class="warn">This tab is an AdminTab</div>'; } if (Shop::isFeatureActive() && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL) { echo '<div class="multishop_toolbar"> <span class="text_multishop">' . Translate::getAdminTranslation('Multistore configuration for') . '</span>' . Helper::renderShopList(); echo '</div>'; }
public static function renderShopList() { if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) { return null; } $tree = Shop::getTree(); $context = Context::getContext(); // Get default value $shop_context = Shop::getContext(); if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) { $value = ''; } else { if ($shop_context == Shop::CONTEXT_GROUP) { $value = 'g-' . Shop::getContextShopGroupID(); } else { $value = 's-' . Shop::getContextShopID(); } } // Generate HTML $url = $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext='; $shop = new Shop(Shop::getContextShopID()); // $html = '<a href="#"><i class="icon-home"></i> '.$shop->name.'</a>'; $html = '<select class="shopList" onchange="location.href = \'' . htmlspecialchars($url) . '\'+$(this).val();">'; $html .= '<option value="" class="first">' . Translate::getAdminTranslation('All shops') . '</option>'; foreach ($tree as $gID => $group_data) { if (!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP) { $html .= '<option class="group" value="g-' . $gID . '"' . (empty($value) && $shop_context == Shop::CONTEXT_GROUP || $value == 'g-' . $gID ? ' selected="selected"' : '') . ($context->controller->multishop_context_group == false ? ' disabled="disabled"' : '') . '>' . Translate::getAdminTranslation('Group:') . ' ' . htmlspecialchars($group_data['name']) . '</option>'; } else { $html .= '<optgroup class="group" label="' . Translate::getAdminTranslation('Group:') . ' ' . htmlspecialchars($group_data['name']) . '"' . ($context->controller->multishop_context_group == false ? ' disabled="disabled"' : '') . '>'; } if (!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_SHOP) { foreach ($group_data['shops'] as $sID => $shopData) { if ($shopData['active']) { $html .= '<option value="s-' . $sID . '" class="shop"' . ($value == 's-' . $sID ? ' selected="selected"' : '') . '>' . ($context->controller->multishop_context_group == false ? htmlspecialchars($group_data['name']) . ' - ' : '') . $shopData['name'] . '</option>'; } } } if (!(!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP)) { $html .= '</optgroup>'; } } $html .= '</select>'; return $html; }
/** * non-static method which uses AdminController::translate() * * @param mixed $string term or expression in english * @param string $class name of the class * @param boolan $addslashes if set to true, the return value will pass through addslashes(). Otherwise, stripslashes(). * @param boolean $htmlentities if set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8') * @return string the translation if available, or the english default text. */ protected function l($string, $class = null, $addslashes = false, $htmlentities = true) { if ($class === null || $class == 'AdminTab') { $class = substr(get_class($this), 0, -10); } elseif (strtolower(substr($class, -10)) == 'controller') { $class = substr($class, 0, -10); } return Translate::getAdminTranslation($string, $class, $addslashes, $htmlentities); }
* * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ echo ' </div> </div> ' . Hook::exec('displayBackOfficeFooter') . ' <div id="footer"> <div style="float:left;margin-left:10px;padding-top:6px"> <a href="http://www.prestashop.com/" target="_blank" style="font-weight:700;color:#666666">PrestaShop™ ' . _PS_VERSION_ . '</a><br /> <span style="font-size:10px">' . Translate::getAdminTranslation('Load time:') . ' ' . number_format(microtime(true) - $timerStart, 3, '.', '') . 's</span> </div> <div style="float:right;height:40px;margin-right:10px;line-height:38px;vertical-align:middle">'; if (strtoupper(Context::getContext()->language->iso_code) == 'FR') { echo '<span style="color: #812143; font-weight: bold;">Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> de 09h à 18h '; } echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">' . Translate::getAdminTranslation('Contact') . '</a> | <a href="http://forge.prestashop.com" target="_blank" class="footer_link">' . Translate::getAdminTranslation('Bug Tracker') . '</a> | <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">' . Translate::getAdminTranslation('Forum') . '</a> </div> </div> </div> </div>'; // FrontController::disableParentCalls(); // $fc = new FrontController(); // $fc->displayFooter(); echo ' </body> </html>';
protected function displayValidFields() { /* The following translations are needed later - don't remove the comments! $this->l('Customer'); $this->l('Warehouse'); $this->l('Country'); $this->l('State'); $this->l('Address'); */ $html_tabnav = '<ul class="nav nav-tabs" id="custom-address-fields">'; $html_tabcontent = '<div class="tab-content" >'; $object_list = AddressFormat::getLiableClass('Address'); $object_list['Address'] = null; // Get the available properties for each class $i = 0; $class_tab_active = 'active'; foreach ($object_list as $class_name => &$object) { if ($i != 0) { $class_tab_active = ''; } $fields = array(); $html_tabnav .= '<li class="' . $class_tab_active . '""> <a href="#availableListFieldsFor_' . $class_name . '"><i class="icon-caret-down"></i> ' . Translate::getAdminTranslation($class_name, 'AdminCountries') . '</a></li>'; foreach (AddressFormat::getValidateFields($class_name) as $name) { $fields[] = '<a href="javascript:void(0);" class="addPattern btn btn-default btn-xs" id="' . ($class_name == 'Address' ? $name : $class_name . ':' . $name) . '"> <i class="icon-plus-sign"></i> ' . ObjectModel::displayFieldName($name, $class_name) . '</a>'; } $html_tabcontent .= ' <div class="tab-pane availableFieldsList panel ' . $class_tab_active . '" id="availableListFieldsFor_' . $class_name . '"> ' . implode(' ', $fields) . '</div>'; unset($object); $i++; } $html_tabnav .= '</ul>'; $html_tabcontent .= '</div>'; return $html = $html_tabnav . $html_tabcontent; }
private function displayAddress() { // Need to center button into footer-panel // --------------------------------------- $this->addCSS(_PS_MODULE_DIR_ . 'expressmailing/views/css/footer-center.css'); // Build the form // -------------- $this->fields_form = array('legend' => array('title' => $this->module->l('Your billing address', 'adminmarketingbuy'), 'icon' => 'icon-home'), 'input' => array(array('type' => _PS_MODE_DEV_ ? 'text' : 'hidden', 'lang' => false, 'label' => 'Session :', 'name' => 'order_session', 'col' => 3, 'readonly' => 'readonly'), array('type' => 'text', 'lang' => false, 'label' => Translate::getAdminTranslation('Shop name', 'AdminStores') . ' :', 'prefix' => '<i class="icon-home"></i>', 'col' => 4, 'name' => 'company_name', 'validation' => 'isGenericName', 'required' => true), array('type' => 'text', 'lang' => false, 'label' => Translate::getAdminTranslation('Shop email', 'AdminStores') . ' :', 'prefix' => '<i class="icon-envelope-o"></i>', 'col' => 4, 'name' => 'company_email', 'required' => true), array('type' => 'text', 'label' => Translate::getAdminTranslation('Shop address line 1', 'AdminStores') . ' :', 'name' => 'company_address1', 'col' => 4, 'required' => true, 'validation' => 'isAddress'), array('type' => 'text', 'label' => Translate::getAdminTranslation('Shop address line 2', 'AdminStores') . ' :', 'col' => 4, 'name' => 'company_address2', 'validation' => 'isAddress'), array('type' => 'text', 'label' => Translate::getAdminTranslation('Zip/postal code', 'AdminStores') . ' :', 'col' => 1, 'validation' => 'isGenericName', 'name' => 'company_zipcode', 'required' => true), array('type' => 'text', 'label' => Translate::getAdminTranslation('City', 'AdminStores') . ' :', 'validation' => 'isGenericName', 'col' => 4, 'name' => 'company_city', 'required' => true), array('type' => 'select', 'label' => Translate::getAdminTranslation('Country', 'AdminStores') . ' :', 'name' => 'country_id', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'text', 'lang' => false, 'label' => Translate::getAdminTranslation('Phone', 'AdminStores') . ' :', 'validation' => 'isGenericName', 'prefix' => '<i class="icon-phone"></i>', 'col' => 4, 'name' => 'company_phone', 'required' => true)), 'submit' => array('title' => $this->module->l('Proceed to Payment ...', 'adminmarketingbuy'), 'name' => 'submitAddress', 'icon' => 'process-icon-payment', 'class' => 'btn btn-default center-block')); }