public function renderForm() { if (!$this->object->id) { $this->object->price = -1; } $this->fields_form = array('legend' => array('title' => $this->l('Catalog price rules'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.)'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->l('From'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->l('To'), 'name' => 'to'), array('type' => 'select', 'label' => $this->l('Reduction type'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Reduction with or without taxes'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->l('Tax included'), 'val' => 1), array('lab' => $this->l('Tax excluded'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'))); if (($value = $this->getFieldValue($this->object, 'price')) != -1) { $price = number_format($value, 6); } else { $price = ''; } $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1); $attribute_groups = array(); $attributes = Attribute::getAttributes((int) $this->context->language->id); foreach ($attributes as $attribute) { if (!isset($attribute_groups[$attribute['id_attribute_group']])) { $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']); } $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']); } $features = Feature::getFeatures((int) $this->context->language->id); foreach ($features as &$feature) { $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true); } $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive()); return parent::renderForm(); }
function hookDisplayLeftColumn($params) { $id_lang = (int) Context::getContext()->language->id; if (!$this->isCached('blocksupplier.tpl', $this->getCacheId())) { $this->smarty->assign(array('suppliers' => Supplier::getSuppliers(false, $id_lang), 'link' => $this->context->link, 'text_list' => Configuration::get('SUPPLIER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('SUPPLIER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('SUPPLIER_DISPLAY_FORM'), 'display_link_supplier' => Configuration::get('PS_DISPLAY_SUPPLIERS'))); } return $this->display(__FILE__, 'blocksupplier.tpl', $this->getCacheId()); }
public function initContent() { parent::initContent(); if (isset($this->context->cookie->id_compare)) { $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) $this->context->cookie->id_compare)); } $this->productSort(); // Product sort must be called before assignProductList() $this->assignScenes(); $this->assignSubcategories(); if ($this->category->id != 1) { $this->assignProductList(); } $this->context->smarty->assign(array('category' => $this->category, 'products' => isset($this->cat_products) && $this->cat_products ? $this->cat_products : null, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'), 'allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); $this->setTemplate(_PS_THEME_DIR_ . 'category.tpl'); }
public function process() { if (Validate::isLoadedObject($this->supplier) and $this->supplier->active) { $nbProducts = $this->supplier->getProducts($this->supplier->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign(array('nb_products' => $nbProducts, 'products' => $this->supplier->getProducts($this->supplier->id, (int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay), 'path' => $this->supplier->active ? Tools::safeOutput($this->supplier->name) : '', 'homeSize' => Image::getSize('home'), 'supplier' => $this->supplier)); } elseif (!Tools::getValue('id_supplier')) { if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $result = Supplier::getSuppliers(true, (int) self::$cookie->id_lang, true); $nbProducts = count($result); $this->pagination($nbProducts); $suppliers = Supplier::getSuppliers(true, (int) self::$cookie->id_lang, true, $this->p, $this->n); foreach ($suppliers as &$row) { $row['image'] = !file_exists(_PS_SUPP_IMG_DIR_ . '/' . $row['id_supplier'] . '-medium.jpg') ? Language::getIsoById((int) self::$cookie->id_lang) . '-default' : $row['id_supplier']; } self::$smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbSuppliers' => $nbProducts, 'mediumSize' => Image::getSize('medium'), 'suppliers' => $suppliers, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'))); } else { self::$smarty->assign('nbSuppliers', 0); } } }
/** * AdminController::renderForm() override * @see AdminController::renderForm() */ public function renderForm() { if (Tools::isSubmit('addsupply_order') || Tools::isSubmit('updatesupply_order') || Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitUpdatesupply_order')) { if (Tools::isSubmit('addsupply_order') || Tools::isSubmit('submitAddsupply_order')) { $this->toolbar_title = $this->l('Stock: Create a new supply order'); } $update = false; if (Tools::isSubmit('updatesupply_order') || Tools::isSubmit('submitUpdatesupply_order')) { $this->toolbar_title = $this->l('Stock: Manage supply orders'); $update = true; } if (Tools::isSubmit('mod') && Tools::getValue('mod') === 'template' || $this->object->is_template) { $this->toolbar_title .= ' (' . $this->l('template') . ')'; } $this->addJqueryUI('ui.datepicker'); //get warehouses list $warehouses = Warehouse::getWarehouses(true); // displays warning if there are no warehouses if (!$warehouses) { $this->displayWarning($this->l('You must have at least one warehouse. See Stock/Warehouses')); } //get currencies list $currencies = Currency::getCurrencies(false, true, true); //get suppliers list $suppliers = array_unique(Supplier::getSuppliers(), SORT_REGULAR); //get languages list $languages = Language::getLanguages(true); $this->fields_form = array('legend' => array('title' => $this->l('Order information'), 'icon' => 'icon-pencil'), 'input' => array(array('type' => 'text', 'label' => $this->l('Reference'), 'name' => 'reference', 'required' => true, 'hint' => $this->l('The reference number for your order.')), array('type' => 'select', 'label' => $this->l('Supplier'), 'name' => 'id_supplier', 'required' => true, 'options' => array('query' => $suppliers, 'id' => 'id_supplier', 'name' => 'name'), 'hint' => array($this->l('Select the supplier you\'ll be purchasing from.'), $this->l('Warning: All products already added to the order will be removed.'))), array('type' => 'select', 'label' => $this->l('Warehouse'), 'name' => 'id_warehouse', 'required' => true, 'options' => array('query' => $warehouses, 'id' => 'id_warehouse', 'name' => 'name'), 'hint' => $this->l('Which warehouse will the order be sent to?')), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'required' => true, 'options' => array('query' => $currencies, 'id' => 'id_currency', 'name' => 'name'), 'hint' => array($this->l('The currency of the order.'), $this->l('Warning: All products already added to the order will be removed.'))), array('type' => 'select', 'label' => $this->l('Order Language'), 'name' => 'id_lang', 'required' => true, 'options' => array('query' => $languages, 'id' => 'id_lang', 'name' => 'name'), 'hint' => $this->l('The language of the order.')), array('type' => 'text', 'label' => $this->l('Global discount percentage'), 'name' => 'discount_rate', 'required' => false, 'hint' => $this->l('This is the global discount percentage for the order.')), array('type' => 'text', 'label' => $this->l('Automatically load products'), 'name' => 'load_products', 'required' => false, 'hint' => array($this->l('This will reset the order.'), $this->l('If a value specified, each of your current product (from the selected supplier and warehouse) with a quantity lower than or equal to this value will be loaded. This means that PrestaShop will pre-fill this order with the products that are low on quantity.')))), 'submit' => !$update ? array('title' => $this->l('Save order')) : array(), 'buttons' => !$update ? array('save-and-stay' => array('title' => $this->l('Save order and stay'), 'name' => 'submitAddsupply_orderAndStay', 'type' => 'submit', 'class' => 'btn btn-default pull-right', 'icon' => 'process-icon-save')) : array()); if (Tools::isSubmit('mod') && Tools::getValue('mod') === 'template' || $this->object->is_template) { $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'is_template'); $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'date_delivery_expected'); } else { $this->fields_form['input'][] = array('type' => 'date', 'label' => $this->l('Expected delivery date'), 'name' => 'date_delivery_expected', 'required' => true, 'desc' => $this->l('The expected delivery date for this order is...')); } //specific discount display if (isset($this->object->discount_rate)) { $this->object->discount_rate = Tools::ps_round($this->object->discount_rate, 4); } //specific date display if (isset($this->object->date_delivery_expected)) { $date = explode(' ', $this->object->date_delivery_expected); if ($date) { $this->object->date_delivery_expected = $date[0]; } } $this->displayInformation($this->l('If you wish to order products, they have to be available for the specified supplier/warehouse.') . ' ' . $this->l('See Catalog/Products/[Your Product]/Suppliers & Warehouses.') . '<br />' . $this->l('Changing the currency or the supplier will reset the order.') . '<br />' . '<br />' . $this->l('Please note that you can only order from one supplier at a time.')); return parent::renderForm(); } }
} $category->name = Category::hideCategoryPosition($category->name); $category->description = nl2br2($category->description); $subCategories = $category->getSubCategories(intval($cookie->id_lang)); $smarty->assign('category', $category); if (Db::getInstance()->numRows()) { $smarty->assign('subcategories', $subCategories); } if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include dirname(__FILE__) . '/pagination.php'; $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); } $smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name))); } } $smarty->assign(array('allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'suppliers' => Supplier::getSuppliers(), 'errors' => $errors)); $smarty->assign(array('homeSize' => Image::getSize('home'))); if (isset($subCategories)) { $smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } $smarty->display(_PS_THEME_DIR_ . 'category.tpl'); include dirname(__FILE__) . '/footer.php'; } catch (Exception $e) { echo $e->getMessage(); echo "<br><bR>"; foreach ($e->getTrace() as $line) { echo "{$line['class']}.{$line['function']} @ {$line['file']}:{$line['line']}<br>"; } }
function hookLeftColumn($params) { global $smarty, $link; $smarty->assign(array('suppliers' => Supplier::getSuppliers(false), 'link' => $link, 'text_list' => Configuration::get('SUPPLIER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('SUPPLIER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('SUPPLIER_DISPLAY_FORM'), 'display_link_supplier' => Configuration::get('PS_DISPLAY_SUPPLIERS'))); return $this->display(__FILE__, 'blocksupplier.tpl'); }
/** * Initializes page content variables */ public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . 'category.tpl'); if (!$this->customer_access) { return; } if (isset($this->context->cookie->id_compare)) { $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) $this->context->cookie->id_compare)); } // Product sort must be called before assignProductList() $this->productSort(); $this->assignScenes(); $this->assignSubcategories(); $this->assignProductList(); $products = $this->category->getProducts($this->context->language->id, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay); $products_options = ProductOption::getProductOptions($this->context->language->id); $combinations = $this->getProductAttributeCombinations($products); // $this->context->smarty->assign('combinations', $combinations); $this->context->smarty->assign(array('category' => $this->category, 'combinations' => $combinations, 'description_short' => Tools::truncateString($this->category->description, 350), 'products' => isset($this->cat_products) && $this->cat_products ? $this->cat_products : null, 'products_options' => isset($products_options) && $products_options ? $products_options : null, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers(), 'body_classes' => array($this->php_self . '-' . $this->category->id, $this->php_self . '-' . $this->category->link_rewrite))); }
/** * show megamenu item configuration. */ protected function showFormSetting() { $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/jquery.nestable.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/form.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/plugins/jquery.cookie-plugin.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/ui/jquery.ui.tabs.min.js'); $this->context->controller->addCss(__PS_BASE_URI__ . 'js/jquery/ui/themes/base/jquery.ui.tabs.css'); $this->context->controller->addCss(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/form.css'); // $action_widget = $this->base_config_url.'&widgets=1'; $this->widget->loadEngines(); // $widget = $this->widget; $id_lang = $this->context->language->id; $id_btmegamenu = (int) Tools::getValue('id_btmegamenu'); $obj = new Btmegamenu($id_btmegamenu); $tree = $obj->getTree(); $categories = LeoBtmegamenuHelper::getCategories(); $manufacturers = Manufacturer::getManufacturers(false, $id_lang, true); $suppliers = Supplier::getSuppliers(false, $id_lang, true); $cmss = CMS::listCms($this->context->language->id, false, true); $menus = $obj->getDropdown(null, $obj->id_parent); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))); $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('Create New MegaMenu Item.')), 'input' => array(array('type' => 'hidden', 'label' => $this->l('Megamenu ID'), 'name' => 'id_btmegamenu', 'default' => 0), array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'title', 'value' => true, 'lang' => true, 'default' => ''), array('type' => 'text', 'label' => $this->l('Sub Title:'), 'lang' => true, 'name' => 'text', 'cols' => 40, 'rows' => 10, 'default' => ''), array('type' => 'select', 'label' => $this->l('Parent ID'), 'name' => 'id_parent', 'options' => array('query' => $menus, 'id' => 'id', 'name' => 'title'), 'default' => 'url'), array('type' => 'switch', 'label' => $this->l('Is Active'), 'name' => 'active', 'values' => $soption, 'default' => '1'), array('type' => 'switch', 'label' => $this->l('Show Title'), 'name' => 'show_title', 'values' => $soption, 'default' => '1'), array('type' => 'select', 'label' => $this->l('Menu Type'), 'name' => 'type', 'id' => 'menu_type', 'desc' => $this->l('Select a menu link type and fill data for following input'), 'options' => array('query' => array(array('id' => 'url', 'name' => $this->l('Url')), array('id' => 'category', 'name' => $this->l('Category')), array('id' => 'product', 'name' => $this->l('Product')), array('id' => 'manufacture', 'name' => $this->l('Manufacture')), array('id' => 'supplier', 'name' => $this->l('Supplier')), array('id' => 'cms', 'name' => $this->l('Cms')), array('id' => 'html', 'name' => $this->l('Html'))), 'id' => 'id', 'name' => 'name'), 'default' => 'url'), array('type' => 'text', 'label' => $this->l('Product ID'), 'name' => 'product_type', 'id' => 'product_type', 'class' => 'menu-type-group', 'default' => ''), array('type' => 'select', 'label' => $this->l('CMS Type'), 'name' => 'cms_type', 'id' => 'cms_type', 'options' => array('query' => $cmss, 'id' => 'id_cms', 'name' => 'meta_title'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'text', 'label' => $this->l('URL'), 'name' => 'url', 'id' => 'url_type', 'required' => true, 'lang' => true, 'class' => 'url-type-group-lang', 'default' => ''), array('type' => 'select', 'label' => $this->l('Category Type'), 'name' => 'category_type', 'id' => 'category_type', 'options' => array('query' => $categories, 'id' => 'id_category', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'select', 'label' => $this->l('Manufacture Type'), 'name' => 'manufacture_type', 'id' => 'manufacture_type', 'options' => array('query' => $manufacturers, 'id' => 'id_manufacturer', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'select', 'label' => $this->l('Supplier Type'), 'name' => 'supplier_type', 'id' => 'supplier_type', 'options' => array('query' => $suppliers, 'id' => 'id_supplier', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'textarea', 'label' => $this->l('HTML Type'), 'name' => 'content_text', 'desc' => $this->l('This menu is only for display content,PLease do not select it for menu level 1'), 'lang' => true, 'default' => '', 'autoload_rte' => true, 'class' => 'menu-type-group-lang'), array('type' => 'select', 'label' => $this->l('Target Open'), 'name' => 'target', 'options' => array('query' => array(array('id' => '_self', 'name' => $this->l('Self')), array('id' => '_blank', 'name' => $this->l('Blank')), array('id' => '_parent', 'name' => $this->l('Parent')), array('id' => '_top', 'name' => $this->l('Top'))), 'id' => 'id', 'name' => 'name'), 'default' => '_self'), array('type' => 'text', 'label' => $this->l('Menu Class'), 'name' => 'menu_class', 'display_image' => true, 'default' => ''), array('type' => 'text', 'label' => $this->l('Menu Icon Class'), 'name' => 'icon_class', 'display_image' => true, 'default' => '', 'desc' => $this->l('The module integrated with FontAwesome') . '. ' . $this->l('Check list of icons and class name in here') . ' <a href="http://fontawesome.io/" target="_blank">http://fontawesome.io/</a> or your icon class'), array('type' => 'file', 'label' => $this->l('Or Menu Icon Image'), 'name' => 'image', 'display_image' => true, 'default' => '', 'desc' => $this->l('Use image icon if no use con Class'), 'thumb' => '', 'title' => $this->l('Icon Preview')), array('type' => 'switch', 'label' => $this->l('Group Submenu'), 'name' => 'is_group', 'values' => $soption, 'default' => '0', 'desc' => $this->l('Group all sub menu to display in same level')), array('type' => 'text', 'label' => $this->l('Column'), 'name' => 'colums', 'values' => $soption, 'default' => '1', 'desc' => $this->l('Set each sub menu item as column'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger')); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) { $helper->languages[] = array('id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => $default_lang == $lang['id_lang'] ? 1 : 0); } $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'save' . $this->name; $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($obj), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); $live_editor_url = AdminController::$currentIndex . '&configure=' . $this->name . '&liveeditor=1&token=' . Tools::getAdminTokenLite('AdminModules'); $action = AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'); $helper->toolbar_btn = array('back' => array('href' => AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list'))); $html = $this->_html . '<div class="col-lg-12"> <div class="alert alert-info clearfix"><div class="pull-right">Using <a href="' . $live_editor_url . '" class="btn btn-danger"> ' . $this->l('Live Edit Tools') . '</a> ' . $this->l('To Make Rich Content For Megamenu') . '</div></div></div>'; $output = $html . ' <ul class="nav nav-tabs clearfix"> <li class="active"><a href="#megamenu" data-toggle="tab">' . $this->l('Megamenu') . '</a></li> </ul> <div class="tab-content clearfix"> <div class="tab-pane active" id="megamenu"> '; $show_cavas = Configuration::get('LEO_MEGAMENU_CAVAS'); $addnew = AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&configure=' . $this->name . '&tab_module=front_office_features&module_name=' . $this->name; $output .= '<div class="col-md-4"><div class="panel panel-default"><h3 class="panel-title">' . $this->l('Tree Megamenu Management') . '</h3> <div class="panel-content">' . $this->l('To sort orders or update parent-child, you drap and drop expected menu, then click to Update button to Save') . '<hr><p><input type="button" value="' . $this->l('New Menu Item') . '" id="addcategory" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-danger" name="addcategory"> <a href="' . Context::getContext()->link->getAdminLink('AdminLeotempcpWidgets') . '" class="leo-modal-action btn btn-modeal btn-success btn-info">' . $this->l('List Widget') . '</a></p> <hr><p><input type="button" value="' . $this->l('Update') . '" id="show_cavas" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-info" ></p> <label>' . $this->l('Show Cavas') . '</label> <select name="show_cavas" class="show_cavas"> <option value="1" ' . (isset($show_cavas) && $show_cavas == 1 ? 'checked' : null) . '>' . $this->l('Yes') . '</option> <option value="0" ' . (isset($show_cavas) && $show_cavas == 0 ? 'checked' : null) . '>' . $this->l('No') . '</option> </select> <hr><p><input type="button" value="' . $this->l('Update Positions') . '" id="serialize" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-danger" name="serialize"></p><hr>' . $tree . '</div></div></div> <div class="col-md-8">' . $helper->generateForm($this->fields_form) . '</div> <script type="text/javascript">var addnew ="' . $addnew . '"; var action="' . $action . '";$("#content").PavMegaMenuList({action:action,addnew:addnew});</script>'; $output .= '</div>'; $output .= '</div><script>$(\'#myTab a[href="#profile"]\').tab(\'show\')</script>'; return $output; }
protected function makeMenu() { $menu_items = $this->getMenuItems(); $id_lang = (int)$this->context->language->id; $id_shop = (int)Shop::getContextShopID(); $iteration = 1; foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int)substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups), 0, $iteration); $iteration++; break; case 'PRD': $selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : ''; $product = new Product((int)$id, true, (int)$id_lang); if (!is_null($product->id)) { $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($product->getLink()).'" title="'.$product->name.'">'.$product->name.'</a></li>'.PHP_EOL; } break; case 'CMS': $selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : ''; $cms = CMS::getLinks((int)$id_lang, array($id)); if (count($cms)) { $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($cms[0]['link']).'" title="'.Tools::safeOutput($cms[0]['meta_title']).'">'.Tools::safeOutput($cms[0]['meta_title']).'</a></li>'.PHP_EOL; } break; case 'CMS_CAT': $category = new CMSCategory((int)$id, (int)$id_lang); if (count($category)) { $this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($category->getLink()).'" title="'.$category->name.'">'.$category->name.'</a>'; $this->getCMSMenuItems($category->id); $this->_menu .= '</li>'.PHP_EOL; } break; // Case to handle the option to show all Manufacturers case 'ALLMAN': $link = new Link; $this->_menu .= '<li><a href="'.$link->getPageLink('manufacturer').'" title="'.$this->l('All manufacturers').'">'.$this->l('All manufacturers').'</a><ul>'.PHP_EOL; $manufacturers = Manufacturer::getManufacturers(); foreach ($manufacturers as $key => $manufacturer) { $this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'">'.Tools::safeOutput($manufacturer['name']).'</a></li>'.PHP_EOL; } $this->_menu .= '</ul>'; break; case 'MAN': $selected = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer((int)$id, (int)$id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); } else { $manufacturer->link_rewrite = 0; } $link = new Link; $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int)$id, $manufacturer->link_rewrite)).'" title="'.Tools::safeOutput($manufacturer->name).'">'.Tools::safeOutput($manufacturer->name).'</a></li>'.PHP_EOL; } break; // Case to handle the option to show all Suppliers case 'ALLSUP': $link = new Link; $this->_menu .= '<li><a href="'.$link->getPageLink('supplier').'" title="'.$this->l('All suppliers').'">'.$this->l('All suppliers').'</a><ul>'.PHP_EOL; $suppliers = Supplier::getSuppliers(); foreach ($suppliers as $key => $supplier) { $this->_menu .= '<li><a href="'.$link->getSupplierLink((int)$supplier['id_supplier'], $supplier['link_rewrite']).'" title="'.Tools::safeOutput($supplier['name']).'">'.Tools::safeOutput($supplier['name']).'</a></li>'.PHP_EOL; } $this->_menu .= '</ul>'; break; case 'SUP': $selected = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : ''; $supplier = new Supplier((int)$id, (int)$id_lang); if (!is_null($supplier->id)) { $link = new Link; $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getSupplierLink((int)$id, $supplier->link_rewrite)).'" title="'.$supplier->name.'">'.$supplier->name.'</a></li>'.PHP_EOL; } break; case 'SHOP': $selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover"' : ''; $shop = new Shop((int)$id); if (Validate::isLoadedObject($shop)) { $link = new Link; $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($shop->getBaseURL()).'" title="'.$shop->name.'">'.$shop->name.'</a></li>'.PHP_EOL; } break; case 'LNK': $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop); if (count($link)) { if (!isset($link[0]['label']) || ($link[0]['label'] == '')) { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID()); } $this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($link[0]['link']).'"'.(($link[0]['new_window']) ? ' onclick="return !window.open(this.href);"': '').' title="'.Tools::safeOutput($link[0]['label']).'">'.Tools::safeOutput($link[0]['label']).'</a></li>'.PHP_EOL; } break; } } }
public function initFormSuppliers($obj) { $data = $this->createTemplate($this->tpl_form); if ($obj->id) { if ($this->product_exists_in_shop) { // Get all id_product_attribute $attributes = $obj->getAttributesResume($this->context->language->id); if (empty($attributes)) { $attributes[] = array('id_product' => $obj->id, 'id_product_attribute' => 0, 'attribute_designation' => ''); } $product_designation = array(); foreach ($attributes as $attribute) { $product_designation[$attribute['id_product_attribute']] = rtrim($obj->name[$this->context->language->id] . ' - ' . $attribute['attribute_designation'], ' - '); } // Get all available suppliers $suppliers = Supplier::getSuppliers(); // Get already associated suppliers $associated_suppliers = ProductSupplier::getSupplierCollection($obj->id); // Get already associated suppliers and force to retreive product declinaisons $product_supplier_collection = ProductSupplier::getSupplierCollection($obj->id, false); $default_supplier = 0; foreach ($suppliers as &$supplier) { $supplier['is_selected'] = false; $supplier['is_default'] = false; foreach ($associated_suppliers as $associated_supplier) { if ($associated_supplier->id_supplier == $supplier['id_supplier']) { $associated_supplier->name = $supplier['name']; $supplier['is_selected'] = true; if ($obj->id_supplier == $supplier['id_supplier']) { $supplier['is_default'] = true; $default_supplier = $supplier['id_supplier']; } } } } $data->assign(array('attributes' => $attributes, 'suppliers' => $suppliers, 'default_supplier' => $default_supplier, 'associated_suppliers' => $associated_suppliers, 'associated_suppliers_collection' => $product_supplier_collection, 'product_designation' => $product_designation, 'currencies' => Currency::getCurrencies(), 'product' => $obj, 'link' => $this->context->link, 'token' => $this->token, 'id_default_currency' => Configuration::get('PS_CURRENCY_DEFAULT'))); } else { $this->displayWarning($this->l('You must save the product in this shop before managing suppliers.')); } } else { $this->displayWarning($this->l('You must save this product before managing suppliers.')); } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
/** * Assign template vars if displaying the supplier list */ protected function assignAll() { if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $result = Supplier::getSuppliers(true, $this->context->language->id, true); $nbProducts = count($result); $this->pagination($nbProducts); $suppliers = Supplier::getSuppliers(true, $this->context->language->id, true, $this->p, $this->n); foreach ($suppliers as &$row) { $row['image'] = !file_exists(_PS_SUPP_IMG_DIR_ . '/' . $row['id_supplier'] . '-' . ImageType::getFormatedName('medium') . '.jpg') ? $this->context->language->iso_code . '-default' : $row['id_supplier']; } $this->context->smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbSuppliers' => $nbProducts, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'suppliers_list' => $suppliers, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'))); } else { Tools::redirect('index.php?controller=404'); } }
$currentIndex = 'index.php?tab=AdminCatalog'; $manufacturers = Manufacturer::getManufacturers(); if ($manufacturers) { $jsonArray = array(); foreach ($manufacturers as $manufacturer) { $jsonArray[] = '{"optionValue": "' . $manufacturer['id_manufacturer'] . '", "optionDisplay": "' . htmlspecialchars($manufacturer['name']) . '"}'; } die('[' . implode(',', $jsonArray) . ']'); } } if (isset($_GET['ajaxReferrers'])) { require 'tabs/AdminReferrers.php'; } if (isset($_GET['ajaxProductSuppliers'])) { $currentIndex = 'index.php?tab=AdminCatalog'; $suppliers = Supplier::getSuppliers(); if ($suppliers) { $jsonArray = array(); foreach ($suppliers as $supplier) { $jsonArray[] = '{"optionValue": "' . $supplier['id_supplier'] . '", "optionDisplay": "' . htmlspecialchars($supplier['name']) . '"}'; } die('[' . implode(',', $jsonArray) . ']'); } } if (isset($_GET['ajaxProductAccessories'])) { $currentIndex = 'index.php?tab=AdminCatalog'; $jsonArray = array(); $products = Db::getInstance()->ExecuteS(' SELECT p.`id_product`, pl.`name` FROM `' . _DB_PREFIX_ . 'product` p NATURAL LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
private function _displayForm() { $params = $this->params; $id_lang = $this->context->language->id; $id_btmegamenu = (int) Tools::getValue('id_btmegamenu'); $obj = new Btmegamenu($id_btmegamenu); $tree = $obj->getTree(); $categories = LeoBtmegamenuHelper::getCategories(); $manufacturers = Manufacturer::getManufacturers(false, $id_lang, true); $suppliers = Supplier::getSuppliers(false, $id_lang, true); $cmss = CMS::listCms($this->context->language->id, false, true); $menus = $obj->getDropdown(null, $obj->id_parent); require_once dirname(__FILE__) . '/form.php'; }
private function initiContentForInformation() { $vhafmkgxjva = "category_nbr"; $mvcrgvbvcb = "language"; $myqwjjy = "category_nbr"; $dutlbmuk = "categories"; ${$mvcrgvbvcb} = new Language($this->id_language); ${${"GLOBALS"}["jhyxxhuo"]} = file_exists(_PS_ROOT_DIR_ . "/js/tiny_mce/langs/" . $language->iso_code . ".js") ? $language->iso_code : "en"; ${"GLOBALS"}["gfbjkeb"] = "ad"; ${${"GLOBALS"}["kuvwml"]} = str_replace("\\", "\\\\", dirname($_SERVER["PHP_SELF"])); $crebbb = "categories"; $this->sellerinfo = new SellerInfo(SellerInfo::getIdByCustomerId(self::$cookie->id_customer), self::$cookie->id_lang); ${$dutlbmuk} = array(); ${$myqwjjy} = (int) Db::getInstance()->getValue("SELECT COUNT(*) AS cnt FROM " . _DB_PREFIX_ . "category"); if (${$vhafmkgxjva} <= 1000) { $kmgfuo = "specialcids"; ${"GLOBALS"}["uvadbayndxqr"] = "specialcids"; $uxpwiboxxa = "sql"; ${${"GLOBALS"}["vvskebgpewm"]} = "SELECT c.id_category, c.id_parent, cl.name \n\t\t\tFROM " . _DB_PREFIX_ . "category c \n\t\t\t\tINNER JOIN " . _DB_PREFIX_ . "category_owner co ON (c.id_category=co.id_category AND (IFNULL(co.id_owner,0)=0 OR IFNULL(co.id_owner,0)=" . intval($this->sellerinfo->id_seller) . "))\n\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "category_lang cl ON (c.id_category=cl.id_category AND cl.id_lang=" . $this->context->language->id . " AND cl.id_shop=" . $this->context->shop->id . ")\n\t\t\t\tWHERE c.id_category > 1\n\t\t\t\t"; $einijh = "specialcids"; ${"GLOBALS"}["wzpgiddtedw"] = "caterows"; ${$kmgfuo} = AgileMultipleSeller::getSpecialCatrgoryIds(); if (!empty(${${"GLOBALS"}["uvadbayndxqr"]})) { ${$uxpwiboxxa} .= " AND c.id_category NOT IN (" . ${$einijh} . ")"; } ${${"GLOBALS"}["gmagdrofuuu"]} = Db::getInstance()->ExecuteS(${${"GLOBALS"}["vvskebgpewm"]}); ${${"GLOBALS"}["kkajzqyo"]} = AgileHelper::getSortedFullnameCategory(${${"GLOBALS"}["wzpgiddtedw"]}); } $ohvjrmga = "HOOK_PRODYCT_LIST_OPTIONS"; ${$ohvjrmga} = ""; if (Module::isInstalled("agilesellerlistoptions")) { include_once _PS_ROOT_DIR_ . "/modules/agilesellerlistoptions/agilesellerlistoptions.php"; ${${"GLOBALS"}["nbpjcibnley"]} = new AgileSellerListOptions(); ${${"GLOBALS"}["kenogesux"]} = $aslo_module->hookAgileAdminProductsFormTop(array("for_front" => 1, "id_product" => $this->object->id), true); } $newCatFormat = $this->getNewCategoryFormat(); self::$smarty->assign(array("ad" => ${${"GLOBALS"}["gfbjkeb"]}, "isoTinyMCE" => ${${"GLOBALS"}["jhyxxhuo"]}, "theme_css_dir" => _THEME_CSS_DIR_, "ajaxurl" => _MODULE_DIR_, "suppliers" => Supplier::getSuppliers(), "manufacturers" => Manufacturer::getManufacturers(), "currency" => new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT")), "ps_ssl_enabled" => Configuration::get("PS_SSL_ENABLED"), "is_pack" => $this->object->id && Pack::isPack($this->object->id) || Tools::getValue("ppack") || Tools::getValue("type_product") == Product::PTYPE_PACK, "categories" => ${$crebbb}, "new_categories" => $newCatFormat, "order_out_of_stock" => Configuration::get("PS_ORDER_OUT_OF_STOCK"), "bullet_common_field" => "", "is_agilesellerlistoptions_installed" => Module::isInstalled("agilesellerlistoptions"), "HOOK_PRODYCT_LIST_OPTIONS" => ${${"GLOBALS"}["kenogesux"]})); }
private function _postProcess() { // Dismiss Addons rating if (isset($_GET['dismissRating'])) { $this->_html = ''; self::_cleanBuffer(); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { Configuration::updateGlobalValue('PM_' . self::$_module_prefix . '_DISMISS_RATING', 1); } else { Configuration::updateValue('PM_' . self::$_module_prefix . '_DISMISS_RATING', 1); } die; } $this->saveConfig(); $this->saveAdvancedConfig(); if (isset($_GET['displayPreview'])) { $this->_html = ''; $this->displayPreview(); self::_cleanBuffer(); echo $this->_html; die; } elseif (Tools::getValue('activeMaintenance')) { echo $this->_postProcessMaintenance(self::$_module_prefix); die; } elseif (Tools::getValue('actionColumn') == 'get_select_columns') { $id_menu = Tools::getValue('id_menu', false); if (!$id_menu) { die; } $columns = AdvancedTopMenuColumnClass::getMenuColumsByIdMenu((int) $id_menu, $this->_cookie->id_lang, false); $column_selected = Tools::getValue('column_selected', false); $this->_smarty->assign(array('columns' => $columns, 'column_selected' => $column_selected, 'objADTM' => new PM_AdvancedTopMenu())); self::_cleanBuffer(); $this->_smarty->display(dirname(__FILE__) . '/column_select.tpl'); die; } elseif (Tools::getValue('actionColumn') == 'get_select_columnsWrap') { $id_menu = Tools::getValue('id_menu', false); if (!$id_menu) { die; } $columnsWrap = AdvancedTopMenuColumnWrapClass::getMenuColumnsWrap((int) $id_menu, $this->_cookie->id_lang, false); $columnWrap_selected = Tools::getValue('columnWrap_selected', false); $this->_smarty->assign(array('columnsWrap' => $columnsWrap, 'columnWrap_selected' => $columnWrap_selected)); self::_cleanBuffer(); $this->_smarty->display(dirname(__FILE__) . '/columnwrap_select.tpl'); die; } elseif (isset($_GET['columnElementsPosition'])) { $order = $_GET['columnElementsPosition'] ? explode(',', $_GET['columnElementsPosition']) : array(); foreach ($order as $position => $id_element) { $row = array('position' => intval($position)); Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_elements', $row, 'UPDATE', 'id_element =' . intval($id_element)); } $this->clearCache(); self::_cleanBuffer(); echo $this->l('Save'); die; } elseif (isset($_GET['menuPosition'])) { $order = $_GET['menuPosition'] ? explode(',', $_GET['menuPosition']) : array(); foreach ($order as $position => $id_menu) { if (!trim($id_menu)) { continue; } $row = array('position' => intval($position)); Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu', $row, 'UPDATE', 'id_menu =' . intval($id_menu)); } $this->clearCache(); self::_cleanBuffer(); echo $this->l('Save'); die; } elseif (isset($_GET['columnPosition'])) { $order = $_GET['columnPosition'] ? explode(',', $_GET['columnPosition']) : array(); foreach ($order as $position => $id_column) { if (!trim($id_column)) { continue; } $row = array('position' => intval($position)); Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_columns', $row, 'UPDATE', 'id_column =' . intval($id_column)); } $this->clearCache(); self::_cleanBuffer(); echo $this->l('Save'); die; } elseif (isset($_GET['columnWrapPosition'])) { $order = $_GET['columnWrapPosition'] ? explode(',', $_GET['columnWrapPosition']) : array(); foreach ($order as $position => $id_wrap) { if (!trim($id_wrap)) { continue; } $row = array('position' => intval($position)); Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_columns_wrap', $row, 'UPDATE', 'id_wrap =' . intval($id_wrap)); } $this->clearCache(); self::_cleanBuffer(); echo $this->l('Save'); die; } elseif (Tools::getValue('activeMenu') && Tools::getValue('id_menu')) { $return = ''; $ObjAdvancedTopMenuClass = new AdvancedTopMenuClass(Tools::getValue('id_menu')); $ObjAdvancedTopMenuClass->active = $ObjAdvancedTopMenuClass->active ? 0 : 1; if ($ObjAdvancedTopMenuClass->save()) { $return .= '$("#imgActiveMenu' . $ObjAdvancedTopMenuClass->id . '").attr("src","../img/admin/' . ($ObjAdvancedTopMenuClass->active ? 'enabled' : 'disabled') . '.gif");'; $return .= 'show_info("activemenu","' . $this->l('Save') . '");'; } else { $return .= 'show_info("activemenu","' . $this->l('Error during update menu') . '");'; } $this->clearCache(); self::_cleanBuffer(); echo $return; die; } elseif (Tools::getValue('activeColumnWrap') && Tools::getValue('id_wrap')) { $return = ''; $ObjAdvancedTopMenuColumnWrapClass = new AdvancedTopMenuColumnWrapClass(Tools::getValue('id_wrap')); $ObjAdvancedTopMenuColumnWrapClass->active = $ObjAdvancedTopMenuColumnWrapClass->active ? 0 : 1; if ($ObjAdvancedTopMenuColumnWrapClass->save()) { $return .= '$("#imgActiveColumnWrap' . $ObjAdvancedTopMenuColumnWrapClass->id . '").attr("src","../img/admin/' . ($ObjAdvancedTopMenuColumnWrapClass->active ? 'enabled' : 'disabled') . '.gif");'; $return .= 'show_info("activecolumnwrap","' . $this->l('Save') . '");'; } else { $return .= 'show_info("activecolumnwrap","' . $this->l('Error during update column') . '");'; } $this->clearCache(); self::_cleanBuffer(); echo $return; die; } elseif (Tools::getValue('activeColumn') && Tools::getValue('id_column')) { $return = ''; $ObjAdvancedTopMenuColumnClass = new AdvancedTopMenuColumnClass(Tools::getValue('id_column')); $ObjAdvancedTopMenuColumnClass->active = $ObjAdvancedTopMenuColumnClass->active ? 0 : 1; if ($ObjAdvancedTopMenuColumnClass->save()) { $return .= '$("#imgActiveColumn' . $ObjAdvancedTopMenuColumnClass->id . '").attr("src","../img/admin/' . ($ObjAdvancedTopMenuColumnClass->active ? 'enabled' : 'disabled') . '.gif");'; $return .= 'show_info("activegroup","' . $this->l('Save') . '");'; } else { $return .= 'show_info("activegroup","' . $this->l('Error during update group') . '");'; } $this->clearCache(); self::_cleanBuffer(); echo $return; die; } elseif (Tools::getValue('activeElement') && Tools::getValue('id_element')) { $return = ''; $AdvancedTopMenuElementsClass = new AdvancedTopMenuElementsClass(Tools::getValue('id_element')); $AdvancedTopMenuElementsClass->active = $AdvancedTopMenuElementsClass->active ? 0 : 1; if ($AdvancedTopMenuElementsClass->save()) { $return .= '$("#imgActiveElement' . $AdvancedTopMenuElementsClass->id . '").attr("src","../img/admin/' . ($AdvancedTopMenuElementsClass->active ? 'enabled' : 'disabled') . '.gif");'; $return .= 'show_info("activeelement","' . $this->l('Save') . '");'; } else { $return .= 'show_info("activeelement","' . $this->l('Error during update element') . '");'; } $this->clearCache(); self::_cleanBuffer(); echo $return; die; } elseif (Tools::getValue('deleteMenu') && Tools::getValue('id_menu')) { $ObjAdvancedTopMenuClass = new AdvancedTopMenuClass(Tools::getValue('id_menu')); if ($ObjAdvancedTopMenuClass->delete()) { $this->_html .= $this->displayConfirmation($this->l('Menu has been deleted')); } else { $this->errors[] = $this->l('Error during delete column'); } $this->clearCache(); } elseif (Tools::getValue('deleteColumnWrap') && Tools::getValue('id_wrap')) { $ObjAdvancedTopMenuColumnWrapClass = new AdvancedTopMenuColumnWrapClass(Tools::getValue('id_wrap')); if ($ObjAdvancedTopMenuColumnWrapClass->delete()) { $this->_html .= $this->displayConfirmation($this->l('Column has been deleted')); } else { $this->errors[] = $this->l('Error during delete column'); } $this->clearCache(); } elseif (Tools::getValue('deleteColumn') && Tools::getValue('id_column')) { $ObjAdvancedTopMenuColumnClass = new AdvancedTopMenuColumnClass(Tools::getValue('id_column')); if ($ObjAdvancedTopMenuColumnClass->delete()) { $this->_html .= $this->displayConfirmation($this->l('Group has been deleted')); } else { $this->errors[] = $this->l('Error during delete Group'); } $this->clearCache(); } elseif (Tools::getValue('deleteElement') && Tools::getValue('id_element')) { $AdvancedTopMenuElementsClass = new AdvancedTopMenuElementsClass(Tools::getValue('id_element')); if ($AdvancedTopMenuElementsClass->delete()) { $this->_html .= $this->displayConfirmation($this->l('Item has been deleted')); } else { $this->errors[] = $this->l('Error during delete item'); } $this->clearCache(); } elseif (Tools::getValue('getMenuForm')) { $ObjAdvancedTopMenuClass = false; if (Tools::getValue('editMenu') && Tools::getValue('id_menu')) { $ObjAdvancedTopMenuClass = new AdvancedTopMenuClass(Tools::getValue('id_menu')); } $cms = CMS::listCms(intval($this->_cookie->id_lang)); $categories = Category::getCategories(intval($this->_cookie->id_lang), false); $manufacturer = Manufacturer::getManufacturers(false, $this->_cookie->id_lang, true); $supplier = Supplier::getSuppliers(false, $this->_cookie->id_lang, true); self::_cleanBuffer(); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $this->_html = ''; } $this->displayMenuForm($cms, $categories, $manufacturer, $supplier, $ObjAdvancedTopMenuClass); $this->initColorPicker(); $this->initTinyMce(); echo $this->_html; die; } elseif (Tools::getValue('getColumnWrapForm')) { $ObjAdvancedTopMenuColumnWrapClass = false; if (Tools::getValue('editColumnWrap') && Tools::getValue('id_wrap')) { $ObjAdvancedTopMenuColumnWrapClass = new AdvancedTopMenuColumnWrapClass(Tools::getValue('id_wrap')); } $menus = AdvancedTopMenuClass::getMenus($this->_cookie->id_lang, false); self::_cleanBuffer(); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $this->_html = ''; } $this->displayColumnWrapForm($menus, $ObjAdvancedTopMenuColumnWrapClass); $this->initColorPicker(); $this->initTinyMce(); echo $this->_html; die; } elseif (Tools::getValue('getColumnForm')) { $ObjAdvancedTopMenuColumnClass = false; if (Tools::getValue('editColumn') && Tools::getValue('id_column')) { $ObjAdvancedTopMenuColumnClass = new AdvancedTopMenuColumnClass(Tools::getValue('id_column')); } $cms = CMS::listCms(intval($this->_cookie->id_lang)); $categories = Category::getCategories(intval($this->_cookie->id_lang), false); $manufacturer = Manufacturer::getManufacturers(false, $this->_cookie->id_lang, true); $supplier = Supplier::getSuppliers(false, $this->_cookie->id_lang, true); $menus = AdvancedTopMenuClass::getMenus($this->_cookie->id_lang, false); self::_cleanBuffer(); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $this->_html = ''; } $this->displayColumnForm($menus, $cms, $categories, $manufacturer, $supplier, $ObjAdvancedTopMenuColumnClass); $this->initColorPicker(); $this->initTinyMce(); echo $this->_html; die; } elseif (Tools::getValue('getElementForm')) { $ObjAdvancedTopMenuElementsClass = false; if (Tools::getValue('editElement') && Tools::getValue('id_element')) { $ObjAdvancedTopMenuElementsClass = new AdvancedTopMenuElementsClass(Tools::getValue('id_element')); } $cms = CMS::listCms(intval($this->_cookie->id_lang)); $categories = Category::getCategories(intval($this->_cookie->id_lang), false); $manufacturer = Manufacturer::getManufacturers(false, $this->_cookie->id_lang, true); $supplier = Supplier::getSuppliers(false, $this->_cookie->id_lang, true); $menus = AdvancedTopMenuClass::getMenus($this->_cookie->id_lang, false); self::_cleanBuffer(); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $this->_html = ''; } $this->displayElementForm($menus, array(), $cms, $categories, $manufacturer, $supplier, $ObjAdvancedTopMenuElementsClass); $this->initColorPicker(); echo $this->_html; die; } elseif (isset($_POST['submitMenu'])) { $this->_postProcessMenu(); $this->clearCache(); } elseif (isset($_POST['submitColumnWrap'])) { $this->_postProcessColumnWrap(); $this->clearCache(); } elseif (isset($_POST['submitColumn'])) { $this->_postProcessColumn(); $this->clearCache(); } elseif (isset($_POST['submitElement'])) { $this->_postProcessColumnElement(); $this->clearCache(); } elseif (isset($_POST['submitFastChangeColumn'])) { $id_column = Tools::getValue('id_column'); $id_wrap = Tools::getValue('id_wrap'); if ($id_wrap && $id_column) { $row = array('id_wrap' => intval($id_wrap)); Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_columns', $row, 'UPDATE', 'id_column =' . intval($id_column)); } $this->clearCache(); } }
/** * show megamenu item configuration. */ protected function showFormSetting() { $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/psmegamenu/views/js/admin/jquery.nestable.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/psmegamenu/views/js/admin/form.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/plugins/jquery.cookie-plugin.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/ui/jquery.ui.tabs.min.js'); $this->context->controller->addCss(__PS_BASE_URI__ . 'js/jquery/ui/themes/base/jquery.ui.tabs.css'); $this->context->controller->addCss(__PS_BASE_URI__ . 'modules/psmegamenu/views/css/admin/form.css'); $this->widget->loadEngines(); $id_lang = $this->context->language->id; $id_psmegamenu = (int) Tools::getValue('id_psmegamenu'); $obj = new Psbtmegamenu($id_psmegamenu); $tree = $obj->getTree(); $categories = PsMegamenuHelper::getCategories(); $manufacturers = Manufacturer::getManufacturers(false, $id_lang, true); $suppliers = Supplier::getSuppliers(false, $id_lang, true); $cmss = CMS::listCms($this->context->language->id, false, true); $menus = $obj->getDropdown(null, $obj->id_parent); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))); $image_url = ''; if ($obj->image && is_file(_PSMEGAMENU_IMAGE_DIR_ . $obj->image)) { $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; $image_url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST']) . _PSMEGAMENU_IMAGE_URL_ . $obj->image; } $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('Create New MegaMenu Item.')), 'input' => array(array('type' => 'hidden', 'label' => $this->l('Megamenu ID'), 'name' => 'id_psmegamenu', 'default' => 0), array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'title', 'value' => true, 'lang' => true, 'default' => ''), array('type' => 'text', 'label' => $this->l('Sub Title:'), 'lang' => true, 'name' => 'text', 'cols' => 40, 'rows' => 10, 'default' => ''), array('type' => 'select', 'label' => $this->l('Parent ID'), 'name' => 'id_parent', 'options' => array('query' => $menus, 'id' => 'id', 'name' => 'title'), 'default' => 'url'), array('type' => 'switch', 'label' => $this->l('Is Active'), 'name' => 'active', 'values' => $soption, 'default' => '1'), array('type' => 'switch', 'label' => $this->l('Show Title'), 'name' => 'show_title', 'values' => $soption, 'default' => '1'), array('type' => 'select', 'label' => $this->l('Menu Type'), 'name' => 'type', 'id' => 'menu_type', 'desc' => $this->l('Select a menu link type and fill data for following input'), 'options' => array('query' => array(array('id' => 'url', 'name' => $this->l('Url')), array('id' => 'category', 'name' => $this->l('Category')), array('id' => 'product', 'name' => $this->l('Product')), array('id' => 'manufacture', 'name' => $this->l('Manufacture')), array('id' => 'supplier', 'name' => $this->l('Supplier')), array('id' => 'cms', 'name' => $this->l('Cms')), array('id' => 'html', 'name' => $this->l('Html'))), 'id' => 'id', 'name' => 'name'), 'default' => 'url'), array('type' => 'text', 'label' => $this->l('Product ID'), 'name' => 'product_type', 'id' => 'product_type', 'class' => 'menu-type-group', 'default' => ''), array('type' => 'select', 'label' => $this->l('CMS Type'), 'name' => 'cms_type', 'id' => 'cms_type', 'options' => array('query' => $cmss, 'id' => 'id_cms', 'name' => 'meta_title'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'text', 'label' => $this->l('URL'), 'name' => 'url', 'id' => 'url_type', 'class' => 'menu-type-group', 'default' => ''), array('type' => 'select', 'label' => $this->l('Category Type'), 'name' => 'category_type', 'id' => 'category_type', 'options' => array('query' => $categories, 'id' => 'id_category', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'select', 'label' => $this->l('Manufacture Type'), 'name' => 'manufacture_type', 'id' => 'manufacture_type', 'options' => array('query' => $manufacturers, 'id' => 'id_manufacturer', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'select', 'label' => $this->l('Supplier Type'), 'name' => 'supplier_type', 'id' => 'supplier_type', 'options' => array('query' => $suppliers, 'id' => 'id_supplier', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'textarea', 'label' => $this->l('HTML Type'), 'name' => 'content_text', 'lang' => true, 'default' => '', 'autoload_rte' => true, 'class' => 'menu-type-group-lang'), array('type' => 'select', 'label' => $this->l('Target Open'), 'name' => 'target', 'options' => array('query' => array(array('id' => '_self', 'name' => $this->l('Self')), array('id' => '_blank', 'name' => $this->l('Blank')), array('id' => '_parent', 'name' => $this->l('Parent')), array('id' => '_top', 'name' => $this->l('Top'))), 'id' => 'id', 'name' => 'name'), 'default' => '_self'), array('type' => 'text', 'label' => $this->l('Menu Class'), 'name' => 'menu_class', 'display_image' => true, 'default' => ''), array('type' => 'text', 'label' => $this->l('Menu Icon Class'), 'name' => 'icon_class', 'display_image' => true, 'default' => '', 'desc' => $this->l('The module integrated with FontAwesome') . '.' . $this->l('Check list of icons and class name in here') . ' <a href="http://fontawesome.io/" target="_blank">http://fontawesome.io/</a> or your icon class'), array('type' => 'file_pts', 'label' => $this->l('Or Menu Icon Image'), 'name' => 'image', 'display_image' => true, 'default' => '', 'image' => $image_url, 'delete_url' => $this->base_config_url . '&delete_icon=1', 'title' => $this->l('Icon Preview')), array('type' => 'select', 'label' => $this->l('Sub Menu Type'), 'name' => 'type_submenu', 'options' => array('query' => array(array('id' => 'menu', 'name' => $this->l('Menu')), array('id' => 'html', 'name' => $this->l('HTML'))), 'id' => 'id', 'name' => 'name'), 'default' => 'menu', 'desc' => $this->l('Submenu will be showed if select option Menu')), array('type' => 'textarea', 'label' => $this->l('Sub Menu Content:'), 'name' => 'submenu_content_text', 'value' => true, 'lang' => true, 'default' => '', 'autoload_rte' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger')); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) { $helper->languages[] = array('id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => $default_lang == $lang['id_lang'] ? 1 : 0); } $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'save' . $this->name; $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($obj), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); $liveeditor_url = AdminController::$currentIndex . '&configure=' . $this->name . '&liveeditor=1&token=' . Tools::getAdminTokenLite('AdminModules'); $action = AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'); $helper->toolbar_btn = array('back' => array('href' => AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list'))); $html = $this->_html . '<div class="col-lg-12"> <div class="alert alert-info clearfix"> <div class="pull-right">Using <a href="' . $liveeditor_url . '" class="btn btn-danger"> ' . $this->l('Live Megamenu Editor') . '</a> ' . $this->l('To Make Rich Content For Megamenu') . '</div></div></div>'; $output = $html . ' <ul class="nav nav-tabs clearfix" id="myTab"> <li class="active"><a href="#megamenu" data-toggle="tab">' . $this->l('Megamenu') . '</a></li> <li><a href="#widgets" data-toggle="tab">' . $this->l('Widgets') . '</a></li> </ul> <div class="tab-content clearfix"> <div class="tab-pane active" id="megamenu"> '; $addnew = AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&configure=' . $this->name . '&tab_module=front_office_features&module_name=' . $this->name; $output .= '<div class="col-md-4"><div class="panel panel-default"><h3 class="panel-title">' . $this->l('Tree Megamenu Management') . '</h3> <div class="panel-content"><div class="alert alert-warning">' . $this->l('To sort orders or update parent-child, you drap and drop expected menu, then click to Update button to Save') . '</div> <hr> <p> <div class="pull-right"> <input type="button" value="' . $this->l('New Category') . '" id="addcategory" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-default " name="addcategory"> <a href="' . $liveeditor_url . '" class="btn btn-danger"> ' . $this->l('Editor') . '</a> </div> <input type="button" value="' . $this->l('Update Positions') . '" id="serialize" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-primary" name="serialize"></p><hr>' . $tree . '<p><input type="button" value="' . $this->l('Update Positions') . '" id="serialize-tree" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-primary" name="serialize"></p></div></div></div> <div class="col-md-8">' . $helper->generateForm($this->fields_form) . '</div> <script type="text/javascript">var addnew ="' . $addnew . '"; var action="' . $action . '"; $("#content").PavMegaMenuList({action:action,addnew:addnew});</script>'; $output .= '</div>'; $output .= '<div class="tab-pane" id="widgets"> <div> <p><a href="' . AdminController::$currentIndex . '& configure=' . $this->name . '&widgets=1&token=' . Tools::getAdminTokenLite('AdminModules') . '" class="btn btn-info pts-modal-action btn btn-modeal btn-success btn-action">' . $this->l('Create Widget') . '</a></p> </div>' . $this->widgetsList() . '</div>'; $output .= '</div><script>$(\'#myTab a[href="#profile"]\').tab(\'show\')</script>'; return $output; }
protected function assignAllByCategory($id_category) { if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $result = Supplier::getSuppliers(true, $this->context->language->id, true); $nbProducts = count($result); $this->pagination($nbProducts); $supplierTmp = array(); $suppliers = Supplier::getSuppliers(true, $this->context->language->id, true, $this->p, $this->n); $allSuppliers = Supplier::getSuppliers(true, $this->context->language->id, true, $this->p); foreach ($suppliers as &$row) { $row['image'] = !file_exists(_PS_SUPP_IMG_DIR_ . '/' . $row['id_supplier'] . '-' . ImageType::getFormatedName('medium') . '.jpg') ? $this->context->language->iso_code . '-default' : $row['id_supplier']; } foreach ($allSuppliers as &$row) { $row['image'] = !file_exists(_PS_SUPP_IMG_DIR_ . '/' . $row['id_supplier'] . '-' . ImageType::getFormatedName('medium') . '.jpg') ? $this->context->language->iso_code . '-default' : $row['id_supplier']; $rowTmp = new Supplier($row['id_supplier']); if ($rowTmp->getCategoryById($id_category)) { array_push($supplierTmp, $row); } //$row['category'] = $rowTmp->getCategoryById($id_category); } usort($supplierTmp, function ($a, $b) { $result = 0; if ($a['association_discount'] < $b['association_discount']) { $result = 1; } else { if ($a['association_discount'] > $b['association_discount']) { $result = -1; } } return $result; }); $this->context->smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbSuppliers' => $nbProducts, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'suppliers_list' => $suppliers, 'allSuppliers_list' => $supplierTmp, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'))); } else { Tools::redirect('index.php?controller=404'); } }
public function getContent() { global $cookie; if (Tools::isSubmit('submitBlocktopmenu')) { if (Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items'))) { $this->_html .= $this->displayConfirmation($this->l('Settings Updated')); } else { $this->_html .= $this->displayError($this->l('Unable to update settings')); } Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool) Tools::getValue('search')); } if (Tools::isSubmit('submitBlocktopmenuLinks')) { if (Tools::getValue('link') == '') { $this->_html .= $this->displayError($this->l('Unable to add this link')); } else { MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0)); $this->_html .= $this->displayConfirmation($this->l('The link has been added')); } } if (Tools::isSubmit('submitBlocktopmenuRemove')) { $id_link = Tools::getValue('id_link', 0); MenuTopLinks::remove($id_link); Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK' . $id_link . ',', 'LNK' . $id_link), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS'))); $this->_html .= $this->displayConfirmation($this->l('The link has been removed')); } $this->_html .= ' <fieldset> <legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend> <form action="' . $_SERVER['REQUEST_URI'] . '" method="post" id="form"> <div style="display: none"> <label>' . $this->l('Items') . '</label> <div class="margin-form"> <input type="text" name="items" id="itemsInput" value="' . Configuration::get('MOD_BLOCKTOPMENU_ITEMS') . '" size="70" /> </div> </div> <div class="clear"> </div> <table style="margin-left: 130px;"> <tbody> <tr> <td> <select multiple="multiple" id="items" style="width: 300px; height: 160px;">'; $this->makeMenuOption(); $this->_html .= '</select><br/> <br/> <a href="#" id="removeItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);">' . $this->l('Remove') . ' >></a> </td> <td style="padding-left: 20px;"> <select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">'; // BEGIN CMS $this->_html .= '<optgroup label="' . $this->l('CMS') . '">'; $_cms = CMS::listCms($cookie->id_lang); foreach ($_cms as $cms) { $this->_html .= '<option value="CMS' . $cms['id_cms'] . '" style="margin-left:10px;">' . $cms['meta_title'] . '</option>'; } $this->_html .= '</optgroup>'; // END CMS // BEGIN SUPPLIER $this->_html .= '<optgroup label="' . $this->l('Supplier') . '">'; $suppliers = Supplier::getSuppliers(false, $cookie->id_lang); foreach ($suppliers as $supplier) { $this->_html .= '<option value="SUP' . $supplier['id_supplier'] . '" style="margin-left:10px;">' . $supplier['name'] . '</option>'; } $this->_html .= '</optgroup>'; // END SUPPLIER // BEGIN Manufacturer $this->_html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; $manufacturers = Manufacturer::getManufacturers(false, $cookie->id_lang); foreach ($manufacturers as $manufacturer) { $this->_html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '" style="margin-left:10px;">' . $manufacturer['name'] . '</option>'; } $this->_html .= '</optgroup>'; // END Manufacturer // BEGIN Categories $this->_html .= '<optgroup label="' . $this->l('Categories') . '">'; $this->getCategoryOption(1, $cookie->id_lang); $this->_html .= '</optgroup>'; // END Categories // BEGIN Products $this->_html .= '<optgroup label="' . $this->l('Products') . '">'; $this->_html .= '<option value="PRODUCT" style="margin-left:10px;font-style:italic">' . $this->l('Choose ID product') . '</option>'; $this->_html .= '</optgroup>'; // END Products // BEGIN Menu Top Links $this->_html .= '<optgroup label="' . $this->l('Menu Top Links') . '">'; $links = MenuTopLinks::gets($cookie->id_lang); foreach ($links as $link) { $this->_html .= '<option value="LNK' . $link['id_link'] . '" style="margin-left:10px;">' . $link['label'] . '</option>'; } $this->_html .= '</optgroup>'; // END Menu Top Links $this->_html .= '</select><br /> <br /> <a href="#" id="addItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);"><< ' . $this->l('Add') . '</a> </td> </tr> </tbody> </table> <div class="clear"> </div> <script type="text/javascript"> $(document).ready(function(){ $("#addItem").click(add); $("#availableItems").dblclick(add); $("#removeItem").click(remove); $("#items").dblclick(remove); function add() { $("#availableItems option:selected").each(function(i){ var val = $(this).val(); var text = $(this).text(); if(val == "PRODUCT") { val = prompt("' . $this->l('Set ID product') . '"); if(val == null || val == "" || isNaN(val)) return; text = "' . $this->l('Product ID') . ' "+val; val = "PRD"+val; } $("#items").append("<option value=\\""+val+"\\">"+text+"</option>"); }); serialize(); return false; } function remove() { $("#items option:selected").each(function(i){ $(this).remove(); }); serialize(); return false; } function serialize() { var options = ""; $("#items option").each(function(i){ options += $(this).val()+","; }); $("#itemsInput").val(options.substr(0, options.length - 1)); } }); </script> <label for="s">' . $this->l('Search Bar') . '</label> <div class="margin-form"> <input type="checkbox" name="search" id="s" value="1"' . (Configuration::get('MOD_BLOCKTOPMENU_SEARCH') ? ' checked=""' : '') . '/> </div> <p class="center"> <input type="submit" name="submitBlocktopmenu" value="' . $this->l(' Save ') . '" class="button" /> </p> </form> </fieldset><br />'; $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); $iso = Language::getIsoById($defaultLanguage); $divLangName = 'link_label'; $this->_html .= ' <fieldset> <legend><img src="../img/admin/add.gif" alt="" title="" />' . $this->l('Add Menu Top Link') . '</legend> <form action="' . $_SERVER['REQUEST_URI'] . '" method="post" id="form"> <label>' . $this->l('Label') . '</label> <div class="margin-form">'; foreach ($languages as $language) { $this->_html .= ' <div id="link_label_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <input type="text" name="label[' . $language['id_lang'] . ']" id="label_' . $language['id_lang'] . '" size="70" value="" /> </div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'link_label', true); $this->_html .= '</div><p class="clear"> </p> <label>' . $this->l('Link') . '</label> <div class="margin-form"> <input type="text" name="link" value="" size="70" /> </div> <label>' . $this->l('New Window') . '</label> <div class="margin-form"> <input type="checkbox" name="new_window" value="1" /> </div> <p class="center"> <input type="submit" name="submitBlocktopmenuLinks" value="' . $this->l(' Add ') . '" class="button" /> </p> </form> </fieldset><br />'; $this->_html .= ' <fieldset> <legend><img src="../img/admin/details.gif" alt="" title="" />' . $this->l('List Menu Top Link') . '</legend> <table style="width:100%;"> <thead> <tr> <th>' . $this->l('Id Link') . '</th> <th>' . $this->l('Label') . '</th> <th>' . $this->l('Link') . '</th> <th>' . $this->l('New Window') . '</th> <th>' . $this->l('Action') . '</th> </tr> </thead> <tbody>'; $links = MenuTopLinks::gets($cookie->id_lang); foreach ($links as $link) { $this->_html .= ' <tr> <td>' . $link['id_link'] . '</td> <td>' . $link['label'] . '</td> <td>' . $link['link'] . '</td> <td>' . ($link['new_window'] ? $this->l('Yes') : $this->l('No')) . '</td> <td> <form action="' . $_SERVER['REQUEST_URI'] . '" method="post"> <input type="hidden" name="id_link" value="' . $link['id_link'] . '" /> <input type="submit" name="submitBlocktopmenuRemove" value="' . $this->l('Remove') . '" class="button" /> </form> </td> </tr>'; } $this->_html .= '</tbody> </table> </fieldset>'; echo $this->_html; }
<?php } } ?> </select> </div> </div> <div class="link_type link_type_supplier"> <label><?php echo $module->l('Supplier:'); ?> </label> <div class="margin-form"> <select name="link_type_supplier"> <?php $suppliers = Supplier::getSuppliers(false, $id_lang, true); if ($cates) { foreach ($suppliers as $c) { ?> <option value="<?php echo $c['id_supplier']; ?> "<?php echo $obj->linktype == 'supplier' && $c['id_supplier'] == $obj->link_content ? 'selected=selected' : ''; ?> ><?php echo $c['name']; ?> </option> <?php }
private function getAllDefaultLink($id_lang = null, $link = false) { if (is_null($id_lang)) { $id_lang = (int) $this->context->language->id; } $html = '<optgroup label="' . $this->l('Category') . '">'; $html .= $this->getCategoryOption(1, $id_lang, false, true, $link); $html .= '</optgroup>'; //CMS option $html .= '<optgroup label="' . $this->l('Cms') . '">'; $html .= $this->getCMSOptions(0, 0, $id_lang, $link); $html .= '</optgroup>'; //Manufacturer option $html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; $manufacturers = Manufacturer::getManufacturers(false, $id_lang); foreach ($manufacturers as $manufacturer) { if ($link) { $html .= '<option value="' . $this->context->link->getManufacturerLink($manufacturer['id_manufacturer']) . '">' . $manufacturer['name'] . '</option>'; } else { $html .= '<option value="MAN' . (int) $manufacturer['id_manufacturer'] . '">' . $manufacturer['name'] . '</option>'; } } $html .= '</optgroup>'; //Supplier option $html .= '<optgroup label="' . $this->l('Supplier') . '">'; $suppliers = Supplier::getSuppliers(false, $id_lang); foreach ($suppliers as $supplier) { if ($link) { $html .= '<option value="' . $this->context->link->getSupplierLink($supplier['id_supplier']) . '">' . $supplier['name'] . '</option>'; } else { $html .= '<option value="SUP' . (int) $supplier['id_supplier'] . '">' . $supplier['name'] . '</option>'; } } $html .= '</optgroup>'; //Page option $html .= '<optgroup label="' . $this->l('Page') . '">'; $html .= $this->getPagesOption($id_lang, $link); $shoplink = Shop::getShops(); if (count($shoplink) > 1) { $html .= '<optgroup label="' . $this->l('Shops') . '">'; foreach ($shoplink as $sh) { $html .= '<option value="SHO' . (int) $sh['id_shop'] . '">' . $sh['name'] . '</option>'; } } $html .= '</optgroup>'; return $html; }
private function getSupplierOption($selected_id = null) { $html = ''; $suppliers = Supplier::getSuppliers(false, $this->context->language->id); foreach ($suppliers as $supplier) { $html .= '<option value="' . $supplier['id_supplier'] . '" ' . (!is_null($selected_id) && $selected_id == $supplier['id_supplier'] ? 'selected = "selected"' : '') . '>' . $supplier['name'] . '</option>'; } return $html; }
public function processData() { if (Module::isInstalled('agilemultipleshop') && Shop::$id_shop_owner > 0) { if (!Validate::isLoadedObject($this->seller)) { $this->errors[] = Tools::displayError('Seller does not exist'); } elseif (!$this->seller->active) { self::$smarty->assign('seller', $this->seller); } else { $rewrited_url = self::$link->getAgileSellerLink((int) $this->seller->id, $this->getSellerLinkRwrite()); $this->seller_info->description = _PS_VERSION_ > '1.5' ? Tools::nl2br($this->seller_info->description) : nl2br2($this->seller_info->description); self::$smarty->assign('seller', $this->seller); self::$smarty->assign('seller_info', $this->seller_info); $sellermodule = new AgileMultipleSeller(); $conf = Configuration::getMultiple($sellermodule->getCustomFields()); $custom_labels = $sellermodule->getCustomLabels(); self::$smarty->assign('conf', $conf); self::$smarty->assign('custom_labels', $custom_labels); $nbProducts = $this->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $seller_products = $this->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay); AgileHelper::AssignProductImgs($seller_products); $si_1531_later = version_compare(_PS_VERSION_, '1.5.3.1', ">="); $HOOK_SELLER_RATINGS = ''; if (Module::isInstalled('agilesellerratings')) { require_once _PS_ROOT_DIR_ . "/modules/agilesellerratings/agilesellerratings.php"; $rmodule = new AgileSellerRatings(); $HOOK_SELLER_RATINGS = $rmodule->getAverageRating($this->id_seller, AgileSellerRatings::RATING_TYPE_SELLER); } self::$smarty->assign(array('products' => (isset($seller_products) and $seller_products) ? $seller_products : NULL, 'id_seller' => (int) $this->seller->id, 'path' => $this->seller_info->company, 'agilesellerproducts_tpl' => _PS_ROOT_DIR_ . "/modules/agilesellerproducts/", 'agilemultipleshop_tpl' => _PS_ROOT_DIR_ . "/modules/agilemultipleshop/", 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('category') : 'category'), 'mediumSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('medium') : 'medium'), 'thumbSceneSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('thumb_scene') : 'thumb_scene'), 'homeSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('home') : 'home'), 'HOOK_SELLER_RATINGS' => $HOOK_SELLER_RATINGS, 'page_name' => 'agileseller')); $ver = (int) str_replace(".", "", _PS_VERSION_); if ($ver <= 1430) { } else { if ($ver <= 1451) { if (isset(self::$cookie->id_customer)) { self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer)); } elseif (isset(self::$cookie->id_guest)) { self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest)); } } else { if (isset(self::$cookie->id_compare)) { self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) self::$cookie->id_compare)); } } } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); } }
private function _tdAdminOptionDesign() { global $cookie; $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); $languages = Language::getLanguages(false); $iso = Language::getIsoById((int) $cookie->id_lang); $id_lang = Context::getContext()->language->id; $divLangName = 'title¤description¤link'; $this->_html .= '<fieldset> <legend><img src="../img/admin/add.gif" alt="" title="" />' . $this->l('Add Menu Links') . '</legend> <form action="index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=front_office_features&module_name=' . $this->name . '" method="post" id="form"> <label>' . $this->l('Links type') . '</label> <div class="from-block"> <select id="selected_menu_type" name="menu_type"> <option value="selmenutype">' . $this->l('Select Menu type') . ' </option> <option value="cat">' . $this->l('Categories') . '</option> <option value="cms">' . $this->l('CMS') . '</option> <option value="manu">' . $this->l('Manufacturer') . '</option> <option value="sup">' . $this->l('Supplier') . '</option> <option value="custom">' . $this->l('Custom Options') . '</option>'; $this->_html .= '</select> </div> <div id="category_block"> <label>' . $this->l('Categories') . '</label> <div class="from-block"> <select id="cat_id" name="cat_id"> <option value="sel_cat">' . $this->l('Select Category Links') . '</option>'; $this->_html .= $this->getCategoryOption(); $this->_html .= '</select> </div> </div> <div id="cms-block"> <label>' . $this->l('CMS') . '</label> <div class="from-block"> <select id="cms_id" name="cms_id"> <option value="selcms"> ' . $this->l('Select CMS Links') . '</option>'; $this->_html .= $this->getCMSOptions(); $this->_html .= '</select> </div> </div> <div id="menuf-block"> <label>' . $this->l('Manufacturer') . '</label> <div class="from-block"> <select id="manufac_id" name="manufac_id"> <option value="selmanuf">' . $this->l('Select Manufacturer Links') . '</option>'; $manufacturers = Manufacturer::getManufacturers(false, $id_lang); foreach ($manufacturers as $manufacturer) { $this->_html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . ' ' . $manufacturer['name'] . '</option>'; } $this->_html .= '</select> </div> </div> <div id="supplier-block"> <label>' . $this->l('Supplier') . '</label> <div class="from-block"> <select id="sup_id" name="sup_id"> <option value="selsup">' . $this->l('Select Supplier Links') . '</option>'; $suppliers = Supplier::getSuppliers(false, $id_lang); foreach ($suppliers as $supplier) { $this->_html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . ' ' . $supplier['name'] . '</option>'; } $this->_html .= '</select> </div> </div> <div id="custom-box"> <label>' . $this->l('Custom Links') . '</label> <div class="from-block"> <select id="custom-block-section" name="custom-block-section"> <option value="customtype">' . $this->l('Select Custom type') . '</option> <option value="cus_links">' . $this->l('Custom Link') . '</option> <option value="cus_html">' . $this->l('Custom HTML Block') . '</option>'; $this->_html .= '</select> </div> </div> <div id="menu_links_block"> <label>' . $this->l('Title') . '</label> <div class="from-block">'; foreach ($languages as $language) { $this->_html .= '<div id="title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <input type="text" name="title_' . $language['id_lang'] . '" id="title_' . $language['id_lang'] . '" size="66" /></div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'title', true); $this->_html .= '</div></div><p class="clear"> </p> <div id="custom_links_block"> <label>' . $this->l('Link') . '</label> <div class="from-block">'; foreach ($languages as $language) { $this->_html .= '<div id="link_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">' . '<input id="link_' . $language['id_lang'] . '" type="text" name="link_' . $language['id_lang'] . '" size="66" /></div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'link', true); $this->_html .= '</div> </div> <div id="description"> <label>' . $this->l('Custom HTML Block') . '</label> <div class="from-block">'; foreach ($languages as $language) { $this->_html .= ' <div id="description_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <textarea name="description_' . $language['id_lang'] . '" id="description_' . $language['id_lang'] . '" rows="5" cols="63" >'; $this->_html .= '</textarea> </div> '; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'description', true); $this->_html .= '</div> </div>'; $this->_html .= '<p class="clear"> </p> <label>' . $this->l('Parent') . '</label> <div class="from-block"> <select name="parent"> <option value="0">' . $this->l('Root') . '</option>'; $this->_html .= $this->displayParentMenu(); $this->_html .= '</select> </div>'; $this->_html .= '<label>' . $this->l('Menu Order') . '</label> <div class="from-block"> <input type="text" name="order" /> </div>'; $this->_html .= '<input type="submit" name="submitMenuLinks" class="button" value="' . $this->l(' Add Links ') . '" />'; $this->_html .= '</form> </fieldset><br />'; return $this->_html; }
public function process() { parent::process(); if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } else { if (!Validate::isLoadedObject($this->category)) { $this->errors[] = Tools::displayError('Category does not exist'); } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this category.'); } elseif (!$this->category->active) { self::$smarty->assign('category', $this->category); } else { $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == 'thumb_scene') { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType['name'] == 'large_scene') { $largeSceneImageType = $sceneImageType; } } self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $this->category->description = nl2br2($this->category->description); $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang); self::$smarty->assign('category', $this->category); if (Db::getInstance()->numRows()) { self::$smarty->assign('subcategories', $subCategories); self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } if ($this->category->id != 1) { $nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $cat_products = $this->category->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay); } self::$smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'))); } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); }
protected function generateSupplierData() { $delimiter = ';'; $line = array(); $titles = array(); $id_lang = $this->use_lang; $new_path = new Sampledatainstall(); $f = fopen($new_path->sendPath() . 'output/suppliers.vsc', 'w'); foreach ($this->suppliers_fields as $field => $array) { $titles[] = $array['label']; } fputcsv($f, $titles, $delimiter, '"'); $suppliers = Supplier::getSuppliers(false, $id_lang, true); foreach ($suppliers as $supplier) { $s = new Supplier($supplier['id_supplier'], $id_lang); foreach ($this->suppliers_fields as $field => $array) { $line[$field] = property_exists('Supplier', $field) && !is_array($s->{$field}) && !Tools::isEmpty($s->{$field}) ? $s->{$field} : ''; } if (file_exists(_PS_SUPP_IMG_DIR_ . $s->id . '.jpg')) { $this->copyConverFileName(_PS_SUPP_IMG_DIR_ . $s->id . '.jpg'); } if (!$line[$field]) { $line[$field] = ''; } fputcsv($f, $line, $delimiter, '"'); } fclose($f); }
public function getContent() { $id_lang = (int) Context::getContext()->language->id; $languages = $this->context->controller->getLanguages(); $default_language = (int) Configuration::get('PS_LANG_DEFAULT'); $labels = Tools::getValue('label') ? array_filter(Tools::getValue('label'), 'strlen') : array(); $links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array(); $spacer = str_repeat(' ', $this->spacer_size); $divLangName = 'link_label'; $update_cache = false; if (Tools::isSubmit('submitBlocktopmenu')) { if (Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items'))) { $this->_html .= $this->displayConfirmation($this->l('Settings Updated')); } else { $this->_html .= $this->displayError($this->l('Unable to update settings')); } Configuration::updateValue('MOD_BLOCKTOPMENU_HOME', (bool) Tools::getValue('home')); $update_cache = true; } else { if (Tools::isSubmit('submitBlocktopmenuLinks')) { if (!count($links_label) && !count($labels)) { } else { if (!count($links_label)) { $this->_html .= $this->displayError($this->l('Please, fill the "Link" field')); } else { if (!count($labels)) { $this->_html .= $this->displayError($this->l('Please add a label')); } else { if (!isset($labels[$default_language])) { $this->_html .= $this->displayError($this->l('Please add a label for your default language')); } else { MenuTopLinks_mod::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int) Shop::getContextShopID()); $this->_html .= $this->displayConfirmation($this->l('The link has been added')); } } } } $update_cache = true; } else { if (Tools::isSubmit('submitBlocktopmenuRemove')) { $id_linksmenutop = Tools::getValue('id_linksmenutop', 0); MenuTopLinks_mod::remove($id_linksmenutop, (int) Shop::getContextShopID()); Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK' . $id_linksmenutop . ',', 'LNK' . $id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS'))); $this->_html .= $this->displayConfirmation($this->l('The link has been removed')); $update_cache = true; } else { if (Tools::isSubmit('submitBlocktopmenuEdit')) { $id_linksmenutop = (int) Tools::getValue('id_linksmenutop', 0); $id_shop = (int) Shop::getContextShopID(); if (!Tools::isSubmit('link')) { $tmp = MenuTopLinks_mod::getLinkLang($id_linksmenutop, $id_shop); $links_label_edit = $tmp['link']; $labels_edit = $tmp['label']; $new_window_edit = $tmp['new_window']; } else { MenuTopLinks_mod::update(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int) $id_shop, (int) $id_linksmenutop, (int) $id_linksmenutop); $this->_html .= $this->displayConfirmation($this->l('The link has been edited')); } $update_cache = true; } } } } if ($update_cache) { $this->clearMenuCache(); } $this->_html .= ' <fieldset> <div class="multishop_info"> ' . $this->l('The modifications will be applied to') . ' ' . (Shop::getContext() == Shop::CONTEXT_SHOP ? $this->l('shop:') . ' ' . $this->context->shop->name : $this->l('all shops')) . '. </div> <legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend> <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" id="form"> <div style="display: none"> <label>' . $this->l('Items') . '</label> <div class="margin-form"> <input type="text" name="items" id="itemsInput" value="' . Tools::safeOutput(Configuration::get('MOD_BLOCKTOPMENU_ITEMS')) . '" size="70" /> </div> </div> <div class="clear"> </div> <table style="margin-left: 130px;"> <tbody> <tr> <td style="padding-left: 20px;"> <select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">'; // BEGIN CMS $this->_html .= '<optgroup label="' . $this->l('CMS') . '">'; $this->getCMSOptions(0, 1, $id_lang); $this->_html .= '</optgroup>'; // BEGIN SUPPLIER $this->_html .= '<optgroup label="' . $this->l('Supplier') . '">'; $suppliers = Supplier::getSuppliers(false, $id_lang); foreach ($suppliers as $supplier) { $this->_html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . $spacer . $supplier['name'] . '</option>'; } $this->_html .= '</optgroup>'; // BEGIN Manufacturer $this->_html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; $manufacturers = Manufacturer::getManufacturers(false, $id_lang); foreach ($manufacturers as $manufacturer) { $this->_html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . $spacer . $manufacturer['name'] . '</option>'; } $this->_html .= '</optgroup>'; // BEGIN Categories $this->_html .= '<optgroup label="' . $this->l('Categories') . '">'; $this->getCategoryOption(1, (int) $id_lang, (int) Shop::getContextShopID()); $this->_html .= '</optgroup>'; // BEGIN Shops if (Shop::isFeatureActive()) { $this->_html .= '<optgroup label="' . $this->l('Shops') . '">'; $shops = Shop::getShopsCollection(); foreach ($shops as $shop) { if (!$shop->setUrl() && !$shop->getBaseURL()) { continue; } $this->_html .= '<option value="SHOP' . (int) $shop->id . '">' . $spacer . $shop->name . '</option>'; } $this->_html .= '</optgroup>'; } // BEGIN Products $this->_html .= '<optgroup label="' . $this->l('Products') . '">'; $this->_html .= '<option value="PRODUCT" style="font-style:italic">' . $spacer . $this->l('Choose ID product') . '</option>'; $this->_html .= '</optgroup>'; // BEGIN Menu Top Links $this->_html .= '<optgroup label="' . $this->l('Menu Top Links') . '">'; $links = MenuTopLinks_mod::gets($id_lang, null, (int) Shop::getContextShopID()); foreach ($links as $link) { if ($link['label'] == '') { $link = MenuTopLinks_mod::get($link['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); $this->_html .= '<option value="LNK' . (int) $link[0]['id_linksmenutop'] . '">' . $spacer . $link[0]['label'] . '</option>'; } else { $this->_html .= '<option value="LNK' . (int) $link['id_linksmenutop'] . '">' . $spacer . $link['label'] . '</option>'; } } $this->_html .= '</optgroup>'; $this->_html .= '</select><br /> <br /> <a href="#" id="addItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);">' . $this->l('Add') . ' >></a> </td> <td> <select multiple="multiple" id="items" style="width: 300px; height: 160px;">'; $this->makeMenuOption(); $this->_html .= '</select><br/> <br/> <a href="#" id="removeItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);"><< ' . $this->l('Remove') . '</a> </td> </tr> </tbody> </table> <div class="clear"> </div> <script type="text/javascript"> $(document).ready(function(){ $("#addItem").click(add); $("#availableItems").dblclick(add); $("#removeItem").click(remove); $("#items").dblclick(remove); function add() { $("#availableItems option:selected").each(function(i){ var val = $(this).val(); var text = $(this).text(); text = text.replace(/(^\\s*)|(\\s*$)/gi,""); if (val == "PRODUCT") { val = prompt("' . $this->l('Set ID product') . '"); if (val == null || val == "" || isNaN(val)) return; text = "' . $this->l('Product ID') . ' "+val; val = "PRD"+val; } $("#items").append("<option value=\\""+val+"\\">"+text+"</option>"); }); serialize(); return false; } function remove() { $("#items option:selected").each(function(i){ $(this).remove(); }); serialize(); return false; } function serialize() { var options = ""; $("#items option").each(function(i){ options += $(this).val()+","; }); $("#itemsInput").val(options.substr(0, options.length - 1)); } }); </script> <label for="s">' . $this->l('Home Item') . '</label> <div class="margin-form"> <input type="checkbox" name="home" id="s" value="1"' . (Configuration::get('MOD_BLOCKTOPMENU_HOME') ? ' checked=""' : '') . '/> </div> <p class="center"> <input type="submit" name="submitBlocktopmenu" value="' . $this->l(' Save ') . '" class="button" /> </p> </form> </fieldset><br />'; $this->_html .= ' <fieldset> <legend><img src="../img/admin/add.gif" alt="" title="" />' . $this->l('Add Menu Top Link') . '</legend> <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" id="form"> '; foreach ($languages as $language) { $this->_html .= ' <div id="link_label_' . (int) $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $id_lang ? 'block' : 'none') . ';"> <label>' . $this->l('Label') . '</label> <div class="margin-form"> <input type="text" name="label[' . (int) $language['id_lang'] . ']" id="label_' . (int) $language['id_lang'] . '" size="70" value="' . (isset($labels_edit[$language['id_lang']]) ? Tools::safeOutput($labels_edit[$language['id_lang']]) : '') . '" /> </div> '; $this->_html .= ' <label>' . $this->l('Link') . '</label> <div class="margin-form"> <input type="text" name="link[' . (int) $language['id_lang'] . ']" id="link_' . (int) $language['id_lang'] . '" value="' . (isset($links_label_edit[$language['id_lang']]) ? Tools::safeOutput($links_label_edit[$language['id_lang']]) : '') . '" size="70" /> </div> </div>'; } $this->_html .= '<label>' . $this->l('Language') . '</label> <div class="margin-form">' . $this->displayFlags($languages, (int) $id_lang, $divLangName, 'link_label', true) . '</div><p style="clear: both;"> </p>'; $this->_html .= '<label style="clear: both;">' . $this->l('New Window') . '</label> <div class="margin-form"> <input style="clear: both;" type="checkbox" name="new_window" value="1" ' . (isset($new_window_edit) && $new_window_edit ? 'checked' : '') . '/> </div> <div class="margin-form">'; if (Tools::isSubmit('id_linksmenutop')) { $this->_html .= '<input type="hidden" name="id_linksmenutop" value="' . (int) Tools::getValue('id_linksmenutop') . '" />'; } if (Tools::isSubmit('submitBlocktopmenuEdit')) { $this->_html .= '<input type="submit" name="submitBlocktopmenuEdit" value="' . $this->l('Edit') . '" class="button" />'; } $this->_html .= ' <input type="submit" name="submitBlocktopmenuLinks" value="' . $this->l(' Add ') . '" class="button" /> </div> </form> </fieldset><br />'; $links = MenuTopLinks_mod::gets((int) $id_lang, null, (int) Shop::getContextShopID()); if (!count($links)) { return $this->_html; } $this->_html .= ' <fieldset> <legend><img src="../img/admin/details.gif" alt="" title="" />' . $this->l('List Menu Top Link') . '</legend> <table style="width:100%;"> <thead> <tr style="text-align: left;"> <th>' . $this->l('Id Link') . '</th> <th>' . $this->l('Label') . '</th> <th>' . $this->l('Link') . '</th> <th>' . $this->l('New Window') . '</th> <th>' . $this->l('Action') . '</th> </tr> </thead> <tbody>'; foreach ($links as $link) { $this->_html .= ' <tr> <td>' . (int) $link['id_linksmenutop'] . '</td> <td>' . Tools::safeOutput($link['label']) . '</td> <td><a href="' . Tools::safeOutput($link['link']) . '"' . ($link['new_window'] ? ' target="_blank"' : '') . '>' . Tools::safeOutput($link['link']) . '</a></td> <td>' . ($link['new_window'] ? $this->l('Yes') : $this->l('No')) . '</td> <td> <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post"> <input type="hidden" name="id_linksmenutop" value="' . (int) $link['id_linksmenutop'] . '" /> <input type="submit" name="submitBlocktopmenuEdit" value="' . $this->l('Edit') . '" class="button" /> <input type="submit" name="submitBlocktopmenuRemove" value="' . $this->l('Remove') . '" class="button" /> </form> </td> </tr>'; } $this->_html .= '</tbody> </table> </fieldset>'; return $this->_html; }
protected function generateAllLinkOptions($selected = '') { $suppliers = Supplier::getSuppliers(false, false); $manufacturers = Manufacturer::getManufacturers(false, false); $allLink = ''; if ($selected == 'CUSTOMLINK|0') { $allLink .= '<option selected="selected" value="CUSTOMLINK|0">' . $this->l('-- Custom Link --') . '</option>'; } else { $allLink .= '<option value="CUSTOMLINK|0">' . $this->l('-- Custom Link --') . '</option>'; } $allLink .= '<optgroup label="' . $this->l('Category Link') . '">' . $this->generateCategoryLinkOption(0, $selected) . '</optgroup>'; $allLink .= '<optgroup label="' . $this->l('CMS Link') . '">' . $this->generateCMSLinkOption(0, 1, false, $selected) . '</optgroup>'; $allLink .= '<optgroup label="' . $this->l('Supplier Link') . '">'; if ($selected == 'ALLSUP|0') { $allLink .= '<option selected="selected" value="ALLSUP|0">' . $this->l('All suppliers') . '</option>'; } else { $allLink .= '<option value="ALLSUP|0">' . $this->l('All suppliers') . '</option>'; } foreach ($suppliers as $supplier) { $key = 'SUP|' . $supplier['id_supplier']; if ($key == $selected) { $allLink .= '<option selected="selected" value="' . $key . '">|- ' . $supplier['name'] . '</option>'; } else { $allLink .= '<option value="' . $key . '">|- ' . $supplier['name'] . '</option>'; } } $allLink .= '</optgroup>'; $allLink .= '<optgroup label="' . $this->l('Manufacturer Link') . '">'; if ($selected == 'ALLMAN|0') { $allLink .= '<option selected="selected" value="ALLMAN|0">' . $this->l('All manufacturers') . '</option>'; } else { $allLink .= '<option value="ALLMAN|0">' . $this->l('All manufacturers') . '</option>'; } foreach ($manufacturers as $manufacturer) { $key = 'MAN|' . $manufacturer['id_manufacturer']; if ($key == $selected) { $allLink .= '<option selected="selected" value="' . $key . '">|- ' . $manufacturer['name'] . '</option>'; } else { $allLink .= '<option value="' . $key . '">|- ' . $manufacturer['name'] . '</option>'; } } $allLink .= '</optgroup>'; $allLink .= '<optgroup label="' . $this->l('Page Link') . '">' . $this->generatePageLinkOption(0, $selected) . '</optgroup>'; if (Shop::isFeatureActive()) { $allLink .= '<optgroup label="' . $this->l('Shops Link') . '">'; $shops = Shop::getShopsCollection(); foreach ($shops as $shop) { if (!$shop->setUrl() && !$shop->getBaseURL()) { continue; } $key = 'SHO|' . $shop->id; if ($key == $selected) { $allLink .= '<option selected="selected" value="' . $key . '">' . $shop->name . '</option>'; } else { $allLink .= '<option value="' . $key . '">' . $shop->name . '</option>'; } } $allLink .= '</optgroup>'; } $allLink .= '<optgroup label="' . $this->l('Product Link') . '">'; if ($selected == 'PRODUCT|0') { $allLink .= '<option selected value="PRODUCT|0" style="font-style:italic">' . $this->l('Choose product ID') . '</option>'; } else { $allLink .= '<option value="PRODUCT|0" style="font-style:italic">' . $this->l('Choose product ID') . '</option>'; } $allLink .= '</optgroup>'; return $allLink; }
public function renderChoicesSelect() { $spacer = str_repeat(' ', $this->spacer_size); $items = $this->getMenuItems(); $html = '<select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">'; $html .= '<optgroup label="' . $this->l('CMS') . '">'; $html .= $this->getCMSOptions(0, 1, $this->context->language->id, $items); $html .= '</optgroup>'; // BEGIN SUPPLIER $html .= '<optgroup label="' . $this->l('Supplier') . '">'; // Option to show all Suppliers $html .= '<option value="ALLSUP0">' . $this->l('All suppliers') . '</option>'; $suppliers = Supplier::getSuppliers(false, $this->context->language->id); foreach ($suppliers as $supplier) { if (!in_array('SUP' . $supplier['id_supplier'], $items)) { $html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . $spacer . $supplier['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Manufacturer $html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; // Option to show all Manufacturers $html .= '<option value="ALLMAN0">' . $this->l('All manufacturers') . '</option>'; $manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id); foreach ($manufacturers as $manufacturer) { if (!in_array('MAN' . $manufacturer['id_manufacturer'], $items)) { $html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . $spacer . $manufacturer['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Categories $shop = new Shop((int) Shop::getContextShopID()); $html .= '<optgroup label="' . $this->l('Categories') . '">'; $shops_to_get = Shop::getContextListShopID(); foreach ($shops_to_get as $shop_id) { $html .= $this->generateCategoriesOption($this->customGetNestedCategories($shop_id, null, (int) $this->context->language->id, false), $items); } $html .= '</optgroup>'; // BEGIN Shops if (Shop::isFeatureActive()) { $html .= '<optgroup label="' . $this->l('Shops') . '">'; $shops = Shop::getShopsCollection(); foreach ($shops as $shop) { if (!$shop->setUrl() && !$shop->getBaseURL()) { continue; } if (!in_array('SHOP' . (int) $shop->id, $items)) { $html .= '<option value="SHOP' . (int) $shop->id . '">' . $spacer . $shop->name . '</option>'; } } $html .= '</optgroup>'; } // BEGIN Products $html .= '<optgroup label="' . $this->l('Products') . '">'; $html .= '<option value="PRODUCT" style="font-style:italic">' . $spacer . $this->l('Choose product ID') . '</option>'; $html .= '</optgroup>'; // BEGIN Menu Top Links $html .= '<optgroup label="' . $this->l('Menu Top Links') . '">'; $links = MenuTopLinks::gets($this->context->language->id, null, (int) Shop::getContextShopID()); foreach ($links as $link) { if ($link['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); if (!in_array('LNK' . (int) $link[0]['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link[0]['id_linksmenutop'] . '">' . $spacer . Tools::safeOutput($link[0]['label']) . '</option>'; } } elseif (!in_array('LNK' . (int) $link['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link['id_linksmenutop'] . '">' . $spacer . Tools::safeOutput($link['label']) . '</option>'; } } $html .= '</optgroup>'; $html .= '</select>'; return $html; }
public function processData() { if (Module::isInstalled('agilemultipleshop') && Shop::$id_shop_owner > 0) { if (!Validate::isLoadedObject($this->seller)) { $this->errors[] = Tools::displayError('Seller does not exist'); } elseif (!$this->seller->active) { self::$smarty->assign('seller', $this->seller); } else { $rewrited_url = self::$link->getAgileSellerLink((int) $this->seller->id, $this->getSellerLinkRwrite()); $this->seller_info->description = _PS_VERSION_ > '1.5' ? Tools::nl2br($this->seller_info->description) : nl2br2($this->seller_info->description); // Setting language and language level $language_level = explode(',', $this->seller_info->language_level); $language = explode(',', $this->seller_info->language); $language_array = array(); for ($x = 0; $x < count($language); $x++) { $language_array[] = $language[$x] . ' - ' . $language_level[$x]; } $this->seller_info->language = $language_array; self::$smarty->assign('seller', $this->seller); self::$smarty->assign('seller_info', $this->seller_info); $imgPath = _PS_ROOT_DIR_ . DS . 'img' . DS . 'as' . DS . $this->seller_info->id_sellerinfo; $licenseImg = _PS_ROOT_DIR_ . DS . 'img' . DS . 'as' . DS . $this->seller_info->id_sellerinfo . '_license'; $images = scandir($imgPath); unset($images[0]); unset($images[1]); $images = array_values($images); @($licenseDir = scandir($licenseImg)); $licenseExist = count($licenseDir) > 2 ? 1 : 0; $this->seller_info->seller_images = $images; $sellermodule = new AgileMultipleSeller(); $conf = Configuration::getMultiple($sellermodule->getCustomFields()); $custom_labels = $sellermodule->getCustomLabels(); self::$smarty->assign('conf', $conf); self::$smarty->assign('custom_labels', $custom_labels); $nbProducts = $this->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $seller_products = $this->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay); AgileHelper::AssignProductImgs($seller_products); $si_1531_later = version_compare(_PS_VERSION_, '1.5.3.1', ">="); $HOOK_SELLER_RATINGS = ''; if (Module::isInstalled('agilesellerratings')) { require_once _PS_ROOT_DIR_ . "/modules/agilesellerratings/agilesellerratings.php"; $rmodule = new AgileSellerRatings(); $HOOK_SELLER_RATINGS = $rmodule->getAverageRating($this->id_seller, AgileSellerRatings::RATING_TYPE_SELLER); } /*foreach($seller_products as $k => $v) { $country = $v['country']; $flagId = Country::getIdByName(1, $country); $seller_products[$k]['img_exist'] = file_exists(_PS_ROOT_DIR_ . DS . 'flag' . DS . 'mini'. DS . $flagId . '.jpg')? 1 : 0; $seller_products[$k]['img_name'] = $flagId . '.jpg'; }*/ foreach ($seller_products as $key => $value) { $seller_id = $value['id_seller']; $flagIds = self::getFlagsId($seller_id); foreach ($flagIds as $k => $flgId) { $seller_products[$key]['img_exist'][$k] = file_exists(_PS_ROOT_DIR_ . DS . 'flag' . DS . 'mini' . DS . $flgId . '.jpg') ? 1 : 0; $seller_products[$key]['img_name'][$k] = $flgId . '.jpg'; } } // die('<pre>' . print_r($seller_products, true)); self::$smarty->assign(array('products' => (isset($seller_products) and $seller_products) ? $seller_products : NULL, 'license_exist' => $licenseExist, 'id_seller' => (int) $this->seller->id, 'path' => $this->seller_info->company, 'agilesellerproducts_tpl' => _PS_ROOT_DIR_ . "/modules/agilesellerproducts/", 'agilemultipleshop_tpl' => _PS_ROOT_DIR_ . "/modules/agilemultipleshop/", 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('category') : 'category'), 'mediumSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('medium') : 'medium'), 'thumbSceneSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('thumb_scene') : 'thumb_scene'), 'homeSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('home') : 'home'), 'HOOK_SELLER_RATINGS' => $HOOK_SELLER_RATINGS, 'page_name' => 'agileseller')); $ver = (int) str_replace(".", "", _PS_VERSION_); if ($ver <= 1430) { } else { if ($ver <= 1451) { if (isset(self::$cookie->id_customer)) { self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer)); } elseif (isset(self::$cookie->id_guest)) { self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest)); } } else { if (isset(self::$cookie->id_compare)) { self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) self::$cookie->id_compare)); } } } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); } }