public function initContent() { if ((empty($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off') && Configuration::get('PS_SSL_ENABLED')) { // You can uncomment these lines if you want to force https even from localhost and automatically redirect // header('HTTP/1.1 301 Moved Permanently'); // header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); // exit(); $clientIsMaintenanceOrLocal = in_array(Tools::getRemoteAddr(), array_merge(array('127.0.0.1'), explode(',', Configuration::get('PS_MAINTENANCE_IP')))); // If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP if ($clientIsMaintenanceOrLocal) { $this->errors[] = Tools::displayError('SSL is activated. However, your IP is allowed to use unsecure mode (Maintenance or local IP).'); } else { $warningSslMessage = Tools::displayError('SSL is activated. Please connect using the following url to log in in secure mode (https).'); $warningSslMessage .= '<a href="https://' . Tools::safeOutput(Tools::getServerName()) . Tools::safeOutput($_SERVER['REQUEST_URI']) . '">https://' . Tools::safeOutput(Tools::getServerName()) . Tools::safeOutput($_SERVER['REQUEST_URI']) . '</a>'; $this->context->smarty->assign(array('warningSslMessage' => $warningSslMessage)); } } if (file_exists(_PS_ADMIN_DIR_ . '/../install') || file_exists(_PS_ADMIN_DIR_ . '/../admin')) { $this->context->smarty->assign(array('randomNb' => rand(100, 999), 'wrong_folder_name' => true)); } // Redirect to admin panel if (Tools::isSubmit('redirect') && Validate::isControllerName(Tools::getValue('redirect'))) { $this->context->smarty->assign('redirect', Tools::getValue('redirect')); } else { $tab = new Tab((int) $this->context->employee->default_tab); $this->context->smarty->assign('redirect', $this->context->link->getAdminLink($tab->class_name)); } if ($nb_errors = count($this->errors)) { $this->context->smarty->assign(array('errors' => $this->errors, 'nbErrors' => $nb_errors, 'shop_name' => Tools::safeOutput(Configuration::get('PS_SHOP_NAME')), 'disableDefaultErrorOutPut' => true)); } $this->setMedia(); $this->initHeader(); parent::initContent(); $this->initFooter(); }
public function initContent() { $this->errors[] = Tools::displayError('Controller not found'); $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller')); $this->context->smarty->assign($tpl_vars); parent::initContent(); }
public function initContent() { $this->errors[] = $this->trans('Controller not found', array(), 'Admin.Notifications.Error'); $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller')); $this->context->smarty->assign($tpl_vars); parent::initContent(); }
public function initContent() { if ($this->action == 'select_delete') { $this->context->smarty->assign(array('delete_form' => true, 'url_delete' => htmlentities($_SERVER['REQUEST_URI']), 'boxes' => $this->boxes)); } parent::initContent(); }
public function initContent() { parent::initContent(); $this->addJqueryPlugin('cooki-plugin'); $data = Shop::getTree(); foreach ($data as $key_group => &$group) { foreach ($group['shops'] as $key_shop => &$shop) { $current_shop = new Shop($shop['id_shop']); $urls = $current_shop->getUrls(); foreach ($urls as $key_url => &$url) { $title = $url['domain'] . $url['physical_uri'] . $url['virtual_uri']; if (strlen($title) > 23) { $title = substr($title, 0, 23) . '...'; } $url['name'] = $title; $shop['urls'][$url['id_shop_url']] = $url; } } } $shops_tree = new HelperTreeShops('shops-tree', 'Multistore tree'); $shops_tree->setNodeFolderTemplate('shop_tree_node_folder.tpl')->setNodeItemTemplate('shop_tree_node_item.tpl')->setHeaderTemplate('shop_tree_header.tpl')->setActions(array(new TreeToolbarLink('Collapse All', '#', '$(\'#' . $shops_tree->getId() . '\').tree(\'collapseAll\'); return false;', 'icon-collapse-alt'), new TreeToolbarLink('Expand All', '#', '$(\'#' . $shops_tree->getId() . '\').tree(\'expandAll\'); return false;', 'icon-expand-alt')))->setAttribute('url_shop_group', $this->context->link->getAdminLink('AdminShopGroup'))->setAttribute('url_shop', $this->context->link->getAdminLink('AdminShop'))->setAttribute('url_shop_url', $this->context->link->getAdminLink('AdminShopUrl'))->setData($data); $shops_tree = $shops_tree->render(null, false, false); if ($this->display == 'edit') { $this->toolbar_title[] = $this->object->name; } $this->context->smarty->assign(array('toolbar_scroll' => 1, 'toolbar_btn' => $this->toolbar_btn, 'title' => $this->toolbar_title, 'shops_tree' => $shops_tree)); }
public function initContent() { if ($this->display == 'add') { $this->display = 'list'; } return parent::initContent(); }
public function initContent() { $array_carrier = array(); $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); foreach ($carriers as $key => $carrier) { if ($carrier['is_free']) { unset($carriers[$key]); } else { $array_carrier[] = $carrier['id_carrier']; } } $id_carrier = (int) Tools::getValue('id_carrier'); if (count($carriers) && isset($array_carrier[0])) { if (!$id_carrier) { $id_carrier = (int) $array_carrier[0]; } $carrierSelected = new Carrier((int) $id_carrier); } else { $carrierSelected = new Carrier((int) $id_carrier); } $currency = $this->context->currency; $rangeObj = $carrierSelected->getRangeObject(); $rangeTable = $carrierSelected->getRangeTable(); $suffix = $carrierSelected->getRangeSuffix(); $rangeIdentifier = 'id_' . $rangeTable; $ranges = $rangeObj->getRanges($id_carrier); $delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier); $deliveryArray = array(); foreach ($delivery as $deliv) { $deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price']; } $this->context->smarty->assign(array('zones' => $carrierSelected->getZones(), 'carriers' => $carriers, 'ranges' => $ranges, 'currency' => $currency, 'deliveryArray' => $deliveryArray, 'carrierSelected' => $carrierSelected, 'id_carrier' => $id_carrier, 'suffix' => $suffix, 'rangeIdentifier' => $rangeIdentifier, 'action_fees' => self::$currentIndex . '&token=' . $this->token)); parent::initContent(); }
public function initContent() { if ($this->display != 'add' && $this->display != 'edit') { $this->checkForWarning(); } parent::initContent(); }
public function initContent() { $this->display = 'options'; if (!$this->isGeoLiteCityAvailable()) { $this->displayWarning($this->l('In order to use Geolocation, please download') . ' <a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">' . $this->l('this file') . '</a> ' . $this->l('and extract it (using Winrar or Gzip) into the /tools/geoip/ directory')); } parent::initContent(); }
public function initContent() { $this->display = 'options'; if (!$this->isGeoLiteCityAvailable()) { $this->displayWarning($this->l('In order to use Geolocation, please download') . ' <a href="http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz" target="_blank">' . $this->l('this file') . '</a> ' . $this->l('and extract it (using Winrar or Gzip) into the /app/Resources/geoip/ directory.')); Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0); } parent::initContent(); }
public function initContent() { parent::initContent(); // INIT $smarty = $this->context->smarty; $smarty->assign('abc', 'lorem ipsum'); // TEMPLATE // Ajouter le tpl dans /adminXXX/themes/default/template/controllers/eewee/eewee.tpl $this->setTemplate('eewee.tpl'); }
public function initContent() { if ($this->action == 'select_delete') { $this->context->smarty->assign(array('delete_form' => true, 'url_delete' => htmlentities($_SERVER['REQUEST_URI']), 'boxes' => $this->boxes)); } if (!$this->can_add_customer && !$this->display) { $this->informations[] = $this->l('You have to select a shop if you want to create a customer.'); } parent::initContent(); }
public function initContent() { $parent_domain = Tools::getHttpHost(true) . substr($_SERVER['REQUEST_URI'], 0, -1 * strlen(basename($_SERVER['REQUEST_URI']))); $iso_lang = $this->context->language->iso_code; $iso_currency = $this->context->currency->iso_code; $iso_country = $this->context->country->iso_code; $addons_url = 'http://addons.prestashop.com/iframe/search-1.6.php?psVersion=' . _PS_VERSION_ . '&isoLang=' . $iso_lang . '&isoCurrency=' . $iso_currency . '&isoCountry=' . $iso_country . '&parentUrl=' . $parent_domain; $addons_content = Tools::file_get_contents($addons_url); $this->context->smarty->assign(array('iso_lang' => $iso_lang, 'iso_currency' => $iso_currency, 'iso_country' => $iso_country, 'display_addons_content' => $addons_content !== false, 'addons_content' => $addons_content, 'parent_domain' => $parent_domain)); parent::initContent(); }
public function initContent() { $this->list_simple_header = true; parent::initContent(); if ($this->display == 'options') { unset($this->toolbar_btn); $this->toolbar_btn['new'] = array('desc' => $this->l('Add new shop group'), 'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token); $this->toolbar_btn['new_2'] = array('desc' => $this->l('Add new shop'), 'href' => $this->context->link->getAdminLink('AdminShop') . '&addshop', 'imgclass' => 'new'); } $this->addJqueryPlugin('cookie-plugin'); $this->addJqueryPlugin('jstree'); $this->addCSS(_PS_JS_DIR_ . 'jquery/plugins/jstree/themes/classic/style.css'); if ($this->display == 'edit') { $this->toolbar_title[] = $this->object->name; } $this->context->smarty->assign(array('toolbar_scroll' => 1, 'toolbar_btn' => $this->toolbar_btn, 'title' => $this->toolbar_title, 'selected_tree_id' => $this->display == 'edit' ? 'tree-group-' . $this->id_object : 'tree-root')); }
public function initContent() { $this->list_simple_header = true; parent::initContent(); $this->addJqueryPlugin('cookie-plugin'); $this->addJqueryPlugin('jstree'); $this->addCSS(_PS_JS_DIR_ . 'jquery/plugins/jstree/themes/classic/style.css'); if ($this->display == 'edit') { $this->toolbar_title[] = $this->object->name; } else { if (!$this->display && $this->id_shop_group) { $group = new ShopGroup($this->id_shop_group); $this->toolbar_title[] = $group->name; } } $this->context->smarty->assign(array('toolbar_scroll' => 1, 'toolbar_btn' => $this->toolbar_btn, 'title' => $this->toolbar_title, 'selected_tree_id' => $this->display == 'edit' ? 'tree-shop-' . $this->id_object : (Tools::getValue('id_shop_group') ? 'tree-group-' . Tools::getValue('id_shop_group') : ''))); }
public function initContent() { parent::initToolbar(); parent::initTabModuleList(); parent::initPageHeaderToolbar(); $this->addHeaderToolbarBtn(); parent::initContent(); $this->show_page_header_toolbar = (bool) $this->showContentHeader; if ($this->title) { $this->context->smarty->assign(array('title' => $this->title)); } $vars = array('maintenance_mode' => !(bool) Configuration::get('PS_SHOP_ENABLE'), 'headerTabContent' => $this->headerTabContent, 'content' => '{$content}', 'enableSidebar' => $this->enableSidebar); if (!empty($this->helpLink)) { $vars['help_link'] = $this->helpLink; } $this->context->smarty->assign($vars); }
public function initContent() { parent::initContent(); $this->initTabModuleList(); $this->initToolbar(); $this->initPageHeaderToolbar(); $this->addToolBarModulesListButton(); unset($this->toolbar_btn['save']); $back = $this->context->link->getAdminLink('AdminDashboard'); $this->toolbar_btn['back'] = array('href' => $back, 'desc' => $this->l('Back to the dashboard')); $api_key = Configuration::get('NEWSLETTER2GO_API_KEY'); if (!$api_key) { $this->createNewServiceAccount(); } $version = $this->getPluginVersion(); $this->context->smarty->assign(array('web_services_api_key' => $api_key, 'plugin_version' => $version, 'url_post' => self::$currentIndex . '&token=' . $this->token, 'show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn)); $this->setTemplate('newsletter2go.tpl'); }
public function initContent() { $id_confirmpayment = (int) Tools::getValue('id_confirmpayment'); if (Tools::isSubmit('saveconfirmpayment')) { if ($this->processSaveConfirmPayment()) { return $this->html . $this->renderList(); } else { return $this->html . $this->renderForm(); } } if ($this->action == 'select_delete') { $this->context->smarty->assign(array('delete_form' => true, 'url_delete' => htmlentities($_SERVER['REQUEST_URI']), 'boxes' => $this->boxes)); } if (!$this->can_add_confirmpayment && !$this->display) { $this->informations[] = $this->l('testing'); } parent::initContent(); }
public function initContent() { if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { $this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate the Advanced Stock Management feature before you can use this feature.'); return false; } parent::initContent(); }
public function initContent() { if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { $this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to use this feature.'); return false; } parent::initContent(); }
public function initContent() { $this->display = 'view'; return parent::initContent(); }
public function initContent() { if (isset($_GET['filename']) && file_exists(_PS_UPLOAD_DIR_ . $_GET['filename']) && Validate::isFileName($_GET['filename'])) { AdminCustomerThreadsController::openUploadedFile(); } return parent::initContent(); }
/** * AdminController::initContent() override * @see AdminController::initContent() */ public function initContent() { if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { $this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate the Advanced Stock Management feature prior to using this feature.'); return false; } // Manage the add stock form if ($this->display == 'addstock' || $this->display == 'removestock' || $this->display == 'transferstock') { if (Tools::isSubmit('id_product') || Tools::isSubmit('id_product_attribute')) { // get id product and product attribute if possible $id_product = (int) Tools::getValue('id_product', 0); $id_product_attribute = (int) Tools::getValue('id_product_attribute', 0); $product_is_valid = false; $is_pack = false; $is_virtual = false; $lang_id = $this->context->language->id; $default_wholesale_price = 0; // try to load product attribute first if ($id_product_attribute > 0) { // try to load product attribute $combination = new Combination($id_product_attribute); if (Validate::isLoadedObject($combination)) { $product_is_valid = true; $id_product = $combination->id_product; $reference = $combination->reference; $ean13 = $combination->ean13; $upc = $combination->upc; $manufacturer_reference = $combination->supplier_reference; // get the full name for this combination $query = new DbQuery(); $query->select('IFNULL(CONCAT(pl.`name`, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.`name` SEPARATOR \', \')),pl.`name`) as name'); $query->from('product_attribute', 'a'); $query->join('INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang` = ' . (int) $lang_id . ') LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.`id_product_attribute` = a.`id_product_attribute`) LEFT JOIN ' . _DB_PREFIX_ . 'attribute atr ON (atr.`id_attribute` = pac.`id_attribute`) LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.`id_attribute` = atr.`id_attribute` AND al.`id_lang` = ' . (int) $lang_id . ') LEFT JOIN ' . _DB_PREFIX_ . 'attribute_group_lang agl ON (agl.`id_attribute_group` = atr.`id_attribute_group` AND agl.`id_lang` = ' . (int) $lang_id . ')'); $query->where('a.`id_product_attribute` = ' . $id_product_attribute); $name = Db::getInstance()->getValue($query); $p = new Product($id_product, false, $lang_id); $default_wholesale_price = $combination->wholesale_price > 0 ? $combination->wholesale_price : $p->wholesale_price; } } else { $product = new Product($id_product, false, $lang_id); if (is_int($product->id)) { $product_is_valid = true; $reference = $product->reference; $ean13 = $product->ean13; $upc = $product->upc; $name = $product->name; $manufacturer_reference = $product->supplier_reference; $is_pack = $product->cache_is_pack; $is_virtual = $product->is_virtual; $default_wholesale_price = $product->wholesale_price; } } if ($product_is_valid === true && $is_virtual == false) { // init form $this->renderForm(); $this->getlanguages(); $helper = new HelperForm(); $this->initPageHeaderToolbar(); // Check if form template has been overriden if (file_exists($this->context->smarty->getTemplateDir(0) . '/' . $this->tpl_folder . 'form.tpl')) { $helper->tpl = $this->tpl_folder . 'form.tpl'; } $this->setHelperDisplay($helper); $helper->submit_action = $this->display; $helper->id = null; // no display standard hidden field in the form $helper->languages = $this->_languages; $helper->default_form_language = $this->default_form_language; $helper->allow_employee_form_lang = $this->allow_employee_form_lang; $helper->show_cancel_button = true; $helper->back_url = $this->context->link->getAdminLink('AdminStockManagement'); $helper->fields_value = array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'reference' => $reference, 'manufacturer_reference' => $manufacturer_reference, 'name' => $name, 'ean13' => $ean13, 'upc' => $upc, 'check' => md5(_COOKIE_KEY_ . $id_product . $id_product_attribute), 'quantity' => Tools::getValue('quantity', ''), 'id_warehouse' => Tools::getValue('id_warehouse', ''), 'usable' => $this->fields_value['usable'] ? $this->fields_value['usable'] : Tools::getValue('usable', 1), 'price' => Tools::getValue('price', (double) Tools::convertPrice($default_wholesale_price, null)), 'id_currency' => Tools::getValue('id_currency', ''), 'id_stock_mvt_reason' => Tools::getValue('id_stock_mvt_reason', ''), 'is_post' => 1); if ($this->display == 'addstock') { $_POST['id_product'] = (int) $id_product; } if ($this->display == 'transferstock') { $helper->fields_value['id_warehouse_from'] = Tools::getValue('id_warehouse_from', ''); $helper->fields_value['id_warehouse_to'] = Tools::getValue('id_warehouse_to', ''); $helper->fields_value['usable_from'] = Tools::getValue('usable_from', '1'); $helper->fields_value['usable_to'] = Tools::getValue('usable_to', '1'); } $this->content .= $helper->generateForm($this->fields_form); $this->context->smarty->assign(array('content' => $this->content, 'show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn)); } else { $this->errors[] = Tools::displayError('The specified product is not valid.'); } } } else { parent::initContent(); } }
public function initContent() { if (Tools::isSubmit('addnewmodule') && $this->context->mode == Context::MODE_HOST) { $this->display = 'add'; $this->context->smarty->assign(array('iso_code' => $this->context->language->iso_code)); return parent::initContent(); } $this->meta_title = 'Modules'; // If we are on a module configuration, no need to load all modules if (Tools::getValue('configure') != '') { $this->context->smarty->assign(array('maintenance_mode' => !(bool) Configuration::Get('PS_SHOP_ENABLE'))); return true; } $this->initToolbar(); $this->initPageHeaderToolbar(); // Init $smarty = $this->context->smarty; $autocomplete_list = 'var moduleList = ['; $category_filtered = array(); $filter_categories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_' . (int) $this->id_employee)); if (count($filter_categories) > 0) { foreach ($filter_categories as $fc) { if (!empty($fc)) { $category_filtered[$fc] = 1; } } } if (empty($category_filtered) && Tools::getValue('tab_module')) { $category_filtered[Tools::getValue('tab_module')] = 1; } foreach ($this->list_modules_categories as $k => $v) { $this->list_modules_categories[$k]['nb'] = 0; } // Retrieve Modules Preferences $modules_preferences = ''; $tab_modules_preferences = array(); $modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'module_preference` WHERE `id_employee` = ' . (int) $this->id_employee); $tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'tab_module_preference` WHERE `id_employee` = ' . (int) $this->id_employee); foreach ($tab_modules_preferences_tmp as $i => $j) { $tab_modules_preferences[$j['module']][] = $j['id_tab']; } foreach ($modules_preferences_tmp as $k => $v) { if ($v['interest'] == null) { unset($v['interest']); } if ($v['favorite'] == null) { unset($v['favorite']); } $modules_preferences[$v['module']] = $v; } // Retrieve Modules List $modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee); $this->initModulesList($modules); $this->nb_modules_total = count($modules); $module_errors = array(); $module_success = array(); $upgrade_available = array(); $dont_filter = false; //Add succes message for one module update if (Tools::getValue('updated') && Tools::getValue('module_name')) { $module_names = (string) Tools::getValue('module_name'); if (strpos($module_names, '|')) { $module_names = explode('|', $module_names); $dont_filter = true; } if (!is_array($module_names)) { $module_names = (array) $module_names; } foreach ($modules as $km => $module) { if (in_array($module->name, $module_names)) { $module_success[] = array('name' => $module->displayName, 'message' => array(0 => sprintf($this->l('Current version: %s'), $module->version))); } } } if (Tools::getValue('allUpdated')) { $this->confirmations[] = $this->l('All modules updated successfully.'); } // Browse modules list foreach ($modules as $km => $module) { //if we are in favorites view we only display installed modules if (Tools::getValue('select') == 'favorites' && !$module->id) { unset($modules[$km]); continue; } // Upgrade Module process, init check if a module could be upgraded if (Module::initUpgradeModule($module)) { // When the XML cache file is up-to-date, the module may not be loaded yet if (!class_exists($module->name)) { if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) { continue; } require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php'; } if ($object = Adapter_ServiceLocator::get($module->name)) { /** @var Module $object */ $object->runUpgradeModule(); if (count($errors_module_list = $object->getErrors())) { $module_errors[] = array('name' => $module->displayName, 'message' => $errors_module_list); } elseif (count($conf_module_list = $object->getConfirmations())) { $module_success[] = array('name' => $module->displayName, 'message' => $conf_module_list); } unset($object); } } elseif (Module::getUpgradeStatus($module->name)) { // When the XML cache file is up-to-date, the module may not be loaded yet if (!class_exists($module->name)) { if (file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) { require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php'; $object = Adapter_ServiceLocator::get($module->name); $module_success[] = array('name' => $module->name, 'message' => array(0 => sprintf($this->l('Current version: %s'), $object->version), 1 => $this->l('No file upgrades applied (none exist).'))); } else { continue; } } unset($object); } // Make modules stats $this->makeModulesStats($module); // Assign warnings if ($module->active && isset($module->warning) && !empty($module->warning) && !$this->ajax) { $href = Context::getContext()->link->getAdminLink('AdminModules', true) . '&module_name=' . $module->name . '&tab_module=' . $module->tab . '&configure=' . $module->name; $this->context->smarty->assign('text', sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning)); $this->context->smarty->assign('module_link', $href); $this->displayWarning($this->context->smarty->fetch('controllers/modules/warning_module.tpl')); } // AutoComplete array $autocomplete_list .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author, 'image' => isset($module->image) ? (string) $module->image : '', 'option' => '')) . ', '; // Apply filter if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites') { unset($modules[$km]); } else { if (isset($modules_preferences[$modules[$km]->name])) { $modules[$km]->preferences = $modules_preferences[$modules[$km]->name]; } $this->fillModuleData($module, 'array'); $module->categoryName = isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']; } unset($object); if ($module->installed && isset($module->version_addons) && $module->version_addons) { $upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->name, 'displayName' => $module->displayName); } if (in_array($module->name, $this->list_partners_modules)) { $module->type = 'addonsPartner'; } if (isset($module->description_full) && trim($module->description_full) != '') { $module->show_quick_view = true; } } // Don't display categories without modules $cleaned_list = array(); foreach ($this->list_modules_categories as $k => $list) { if ($list['nb'] > 0) { $cleaned_list[$k] = $list; } } // Actually used for the report of the upgraded errors if (count($module_errors)) { $html = $this->generateHtmlMessage($module_errors); $this->errors[] = sprintf(Tools::displayError('The following module(s) were not upgraded successfully: %s.'), $html); } if (count($module_success)) { $html = $this->generateHtmlMessage($module_success); $this->confirmations[] = sprintf($this->l('The following module(s) were upgraded successfully: %s.'), $html); } ConfigurationKPI::updateValue('UPDATE_MODULES', count($upgrade_available)); if (count($upgrade_available) == 0 && (int) Tools::getValue('check') == 1) { $this->confirmations[] = $this->l('Everything is up-to-date'); } // Init tpl vars for smarty $tpl_vars = array('token' => $this->token, 'upgrade_available' => $upgrade_available, 'currentIndex' => self::$currentIndex, 'dirNameCurrentIndex' => dirname(self::$currentIndex), 'ajaxCurrentIndex' => str_replace('index', 'ajax-tab', self::$currentIndex), 'autocompleteList' => rtrim($autocomplete_list, ' ,') . '];', 'showTypeModules' => $this->filter_configuration['PS_SHOW_TYPE_MODULES_' . (int) $this->id_employee], 'showCountryModules' => $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_' . (int) $this->id_employee], 'showInstalledModules' => $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_' . (int) $this->id_employee], 'showEnabledModules' => $this->filter_configuration['PS_SHOW_ENABLED_MODULES_' . (int) $this->id_employee], 'nameCountryDefault' => Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT')), 'isoCountryDefault' => $this->iso_default_country, 'categoryFiltered' => $category_filtered, 'modules' => $modules, 'nb_modules' => $this->nb_modules_total, 'nb_modules_favorites' => count($this->context->employee->favoriteModulesList()), 'nb_modules_installed' => $this->nb_modules_installed, 'nb_modules_uninstalled' => $this->nb_modules_total - $this->nb_modules_installed, 'nb_modules_activated' => $this->nb_modules_activated, 'nb_modules_unactivated' => $this->nb_modules_installed - $this->nb_modules_activated, 'list_modules_categories' => $cleaned_list, 'list_modules_authors' => $this->modules_authors, 'add_permission' => $this->tabAccess['add'], 'tab_modules_preferences' => $tab_modules_preferences, 'kpis' => $this->renderKpis(), 'module_name' => Tools::getValue('module_name'), 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn, 'modules_uri' => __PS_BASE_URI__ . basename(_PS_MODULE_DIR_), 'dont_filter' => $dont_filter, 'is_contributor' => (int) $this->context->cookie->is_contributor, 'maintenance_mode' => !(bool) Configuration::Get('PS_SHOP_ENABLE')); if ($this->logged_on_addons) { $tpl_vars['logged_on_addons'] = 1; $tpl_vars['username_addons'] = $this->context->cookie->username_addons; } $smarty->assign($tpl_vars); }
public function initContent() { if ($this->display == 'list') { $this->display = ''; } if (isset($this->display) && method_exists($this, 'render' . $this->display)) { $this->content .= $this->initPageHeaderToolbar(); $this->content .= $this->{'render' . $this->display}(); $this->context->smarty->assign(array('content' => $this->content, 'show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn)); } else { $themes = array(); foreach (Theme::getThemes() as $theme) { $themes[] = $theme->directory; } foreach (scandir(_PS_ALL_THEMES_DIR_) as $theme_dir) { if ($theme_dir[0] != '.' && Validate::isDirName($theme_dir) && is_dir(_PS_ALL_THEMES_DIR_ . $theme_dir) && file_exists(_PS_ALL_THEMES_DIR_ . $theme_dir . '/preview.jpg') && !in_array($theme_dir, $themes)) { $config_file = false; $default_config = _PS_ROOT_DIR_ . '/config/xml/themes/default.xml'; $theme_config = _PS_ROOT_DIR_ . '/config/xml/themes/' . $theme_dir . '.xml'; if (file_exists($theme_config)) { $config_file = $theme_config; } elseif (file_exists($default_config)) { $config_file = $default_config; } if ($config_file) { $this->importThemeXmlConfig(simplexml_load_file($config_file), $theme_dir); } } } $content = ''; if (Configuration::hasKey('PS_LOGO') && trim(Configuration::get('PS_LOGO')) != '' && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO'))) { list($width, $height, $type, $attr) = getimagesize(_PS_IMG_DIR_ . Configuration::get('PS_LOGO')); Configuration::updateValue('SHOP_LOGO_HEIGHT', (int) round($height)); Configuration::updateValue('SHOP_LOGO_WIDTH', (int) round($width)); } if (file_exists(_PS_IMG_DIR_ . 'logo_mobile.jpg') && Configuration::get('PS_LOGO_MOBILE') && trim(Configuration::get('PS_LOGO_MOBILE')) != '') { list($width, $height, $type, $attr) = getimagesize(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MOBILE')); Configuration::updateValue('SHOP_LOGO_MOBILE_HEIGHT', (int) round($height)); Configuration::updateValue('SHOP_LOGO_MOBILE_WIDTH', (int) round($width)); } $this->content .= $content; return parent::initContent(); } }
public function initContent() { if ($this->context->employee->id == Tools::getValue('id_employee')) { $this->display = 'edit'; } return parent::initContent(); }
public function initContent($token = null) { if ($this->display == 'edit' || $this->display == 'add') { $this->fields_form = array(); // Check if Module if (substr($this->tab_display, 0, 6) == 'Module') { $this->tab_display_module = strtolower(substr($this->tab_display, 6, Tools::strlen($this->tab_display) - 6)); $this->tab_display = 'Modules'; } if (method_exists($this, 'initForm' . $this->tab_display)) { $this->tpl_form = strtolower($this->tab_display) . '.tpl'; } if ($this->ajax) { $this->content_only = true; } else { $product_tabs = array(); // tab_display defines which tab to display first if (!method_exists($this, 'initForm' . $this->tab_display)) { $this->tab_display = $this->default_tab; } $advanced_stock_management_active = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'); $stock_management_active = Configuration::get('PS_STOCK_MANAGEMENT'); foreach ($this->available_tabs as $product_tab => $value) { // if it's the warehouses tab and advanced stock management is disabled, continue if ($advanced_stock_management_active == 0 && $product_tab == 'Warehouses') { continue; } $product_tabs[$product_tab] = array('id' => $product_tab, 'selected' => strtolower($product_tab) == strtolower($this->tab_display) || isset($this->tab_display_module) && 'module' . $this->tab_display_module == Tools::strtolower($product_tab), 'name' => $this->available_tabs_lang[$product_tab], 'href' => $this->context->link->getAdminLink('AdminProducts') . '&id_product=' . (int) Tools::getValue('id_product') . '&action=' . $product_tab); } $this->tpl_form_vars['product_tabs'] = $product_tabs; } } else { if ($id_category = (int) $this->id_current_category) { self::$currentIndex .= '&id_category=' . (int) $this->id_current_category; } // If products from all categories are displayed, we don't want to use sorting by position if (!$id_category) { $this->_defaultOrderBy = $this->identifier; if ($this->context->cookie->{$this->table . 'Orderby'} == 'position') { unset($this->context->cookie->{$this->table . 'Orderby'}); unset($this->context->cookie->{$this->table . 'Orderway'}); } } if (!$id_category) { $id_category = 1; } $this->tpl_list_vars['is_category_filter'] = (bool) $this->id_current_category; // Generate category selection tree $tree = new HelperTreeCategories('categories-tree', $this->l('Filter by category')); $tree->setAttribute('is_category_filter', (bool) $this->id_current_category)->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex) . '&token=' . $this->token)->setInputName('id-category')->setSelectedCategories(array((int) $id_category)); $this->tpl_list_vars['category_tree'] = $tree->render(); // used to build the new url when changing category $this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex) . '&token=' . $this->token; } // @todo module free $this->tpl_form_vars['vat_number'] = file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'); parent::initContent(); }
public function initContent() { $this->show_toolbar = false; $this->display = 'view'; parent::initContent(); }
public function initContent() { $this->checkMobileNeeds(); $themes = array(); foreach (Theme::getThemes() as $theme) { $themes[] = $theme->directory; } foreach (scandir(_PS_ALL_THEMES_DIR_) as $theme_dir) { if ($theme_dir[0] != '.' && Validate::isDirName($theme_dir) && is_dir(_PS_ALL_THEMES_DIR_ . $theme_dir) && file_exists(_PS_ALL_THEMES_DIR_ . $theme_dir . '/preview.jpg') && !in_array($theme_dir, $themes)) { $theme = new Theme(); $theme->name = $theme->directory = $theme_dir; $theme->add(); } } $content = ''; if (file_exists(_PS_IMG_DIR_ . 'logo.jpg')) { list($width, $height, $type, $attr) = getimagesize(_PS_IMG_DIR_ . Configuration::get('PS_LOGO')); Configuration::updateValue('SHOP_LOGO_HEIGHT', (int) round($height)); Configuration::updateValue('SHOP_LOGO_WIDTH', (int) round($width)); } $this->content .= $content; return parent::initContent(); }
public function initContent() { if (!Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) { // You can uncomment these lines if you want to force https even from localhost and automatically redirect // header('HTTP/1.1 301 Moved Permanently'); // header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); // exit(); $clientIsMaintenanceOrLocal = in_array(Tools::getRemoteAddr(), array_merge(array('127.0.0.1'), explode(',', Configuration::get('PS_MAINTENANCE_IP')))); // If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP if ($clientIsMaintenanceOrLocal) { $warningSslMessage = Tools::displayError('SSL is activated. However, your IP is allowed to enter unsecure mode for maintenance or local IP issues.'); } else { $url = 'https://' . Tools::safeOutput(Tools::getServerName()) . Tools::safeOutput($_SERVER['REQUEST_URI']); $warningSslMessage = sprintf(Translate::ppTags(Tools::displayError('SSL is activated. Please connect using the following link to [1]log into secure mode (https://)[/1]', false), array('<a href="%s">')), $url); } $this->context->smarty->assign('warningSslMessage', $warningSslMessage); } if (file_exists(_PS_ADMIN_DIR_ . '/../install')) { $this->context->smarty->assign('wrong_install_name', true); } if (basename(_PS_ADMIN_DIR_) == 'admin' && file_exists(_PS_ADMIN_DIR_ . '/../admin/')) { $rand = 'admin' . sprintf('%03d', rand(0, 999)) . Tools::strtolower(Tools::passwdGen(6)) . '/'; if (@rename(_PS_ADMIN_DIR_ . '/../admin/', _PS_ADMIN_DIR_ . '/../' . $rand)) { Tools::redirectAdmin('../' . $rand); } else { $this->context->smarty->assign(array('wrong_folder_name' => true)); } } else { $rand = basename(_PS_ADMIN_DIR_) . '/'; } $this->context->smarty->assign(array('randomNb' => $rand, 'adminUrl' => Tools::getCurrentUrlProtocolPrefix() . Tools::getShopDomain() . __PS_BASE_URI__ . $rand)); // Redirect to admin panel if (Tools::isSubmit('redirect') && Validate::isControllerName(Tools::getValue('redirect'))) { $this->context->smarty->assign('redirect', Tools::getValue('redirect')); } else { $tab = new Tab((int) $this->context->employee->default_tab); $this->context->smarty->assign('redirect', $this->context->link->getAdminLink($tab->class_name)); } if ($nb_errors = count($this->errors)) { $this->context->smarty->assign(array('errors' => $this->errors, 'nbErrors' => $nb_errors, 'shop_name' => Tools::safeOutput(Configuration::get('PS_SHOP_NAME')), 'disableDefaultErrorOutPut' => true)); } if ($email = Tools::getValue('email')) { $this->context->smarty->assign('email', $email); } if ($password = Tools::getValue('password')) { $this->context->smarty->assign('password', $password); } $this->setMedia(); $this->initHeader(); parent::initContent(); $this->initFooter(); //force to disable modals $this->context->smarty->assign('modals', null); }