public function getTemplateVarSitemap() { $pages = []; $catalog_mode = Configuration::isCatalogMode(); $cms = CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1); foreach ($cms['cms'] as $p) { $pages[] = ['id' => 'cms-page-' . $p['id_cms'], 'label' => $p['meta_title'], 'url' => $this->context->link->getCMSLink(new CMS($p['id_cms']))]; } $pages[] = ['id' => 'stores-page', 'label' => $this->trans('Our stores', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('stores')]; $pages[] = ['id' => 'contact-page', 'label' => $this->trans('Contact us', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('contact')]; $pages[] = ['id' => 'sitemap-page', 'label' => $this->trans('Sitemap', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('sitemap')]; $pages[] = ['id' => 'login-page', 'label' => $this->trans('Log in', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')]; $pages[] = ['id' => 'register-page', 'label' => $this->trans('Create new account', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')]; $catalog = ['new-product' => ['id' => 'new-product-page', 'label' => $this->trans('New products', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('new-products')]]; if ($catalog_mode && Configuration::get('PS_DISPLAY_BEST_SELLERS')) { $catalog['best-sales'] = ['id' => 'best-sales-page', 'label' => $this->trans('Best sellers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('best-sales')]; $catalog['prices-drop'] = ['id' => 'prices-drop-page', 'label' => $this->trans('Price drop', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('prices-drop')]; } if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $manufacturers = Manufacturer::getLiteManufacturersList($this->context->language->id, 'sitemap'); $catalog['manufacturer'] = ['id' => 'manufacturer-page', 'label' => $this->trans('Manufacturers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $manufacturers]; $suppliers = Supplier::getLiteSuppliersList($this->context->language->id, 'sitemap'); $catalog['supplier'] = ['id' => 'supplier-page', 'label' => $this->trans('Suppliers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $suppliers]; } $categories = Category::getRootCategory()->recurseLiteCategTree(0, 0, null, null, 'sitemap'); $catalog['category'] = ['id' => 'category-page', 'label' => $this->trans('Categories', array(), 'Shop.Theme.Catalog'), 'url' => '#', 'children' => $categories['children']]; $sitemap = [['id' => 'page-page', 'label' => $this->trans('Pages', array(), 'Shop.Theme'), 'url' => '#', 'children' => $pages], ['id' => 'catalog-page', 'label' => $this->trans('Catalog', array(), 'Shop.Theme'), 'url' => '#', 'children' => $catalog]]; return $sitemap; }
public function process() { parent::process(); self::$smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1)); self::$smarty->assign('voucherAllowed', (int) Configuration::get('PS_VOUCHERS')); $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); self::$smarty->assign('display_manufacturer_link', (int) $blockmanufacturer->id ? true : false); self::$smarty->assign('display_supplier_link', (int) $blocksupplier->id ? true : false); self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) Configuration::get('PS_VOUCHERS')); $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active); $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->setTemplate(_PS_THEME_DIR_ . 'sitemap.tpl'); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive()); if (Module::isInstalled('blockmanufacturer') && Module::isEnabled('blockmanufacturer')) { $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $this->context->smarty->assign('display_manufacturer_link', isset($blockmanufacturer->active) ? (bool) $blockmanufacturer->active : false); } else { $this->context->smarty->assign('display_manufacturer_link', 0); } if (Module::isInstalled('blocksupplier') && Module::isEnabled('blocksupplier')) { $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('display_supplier_link', isset($blocksupplier->active) ? (bool) $blocksupplier->active : false); } else { $this->context->smarty->assign('display_supplier_link', 0); } $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('PS_DISPLAY_BEST_SELLERS', Configuration::get('PS_DISPLAY_BEST_SELLERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->setTemplate(_PS_THEME_DIR_ . 'sitemap.tpl'); }
/** * This checks if the template set is available for mobile themes, * otherwise the front template is choosen. */ public function setMobileTemplate($template) { // Needed for site map $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive()); $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active); $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('PS_DISPLAY_BEST_SELLERS', Configuration::get('PS_DISPLAY_BEST_SELLERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->context->smarty->assign('conditions', Configuration::get('PS_CONDITIONS')); $this->context->smarty->assign('id_cgv', Configuration::get('PS_CONDITIONS_CMS_ID')); $this->context->smarty->assign('PS_SHOP_NAME', Configuration::get('PS_SHOP_NAME')); $template = $this->getTemplatePath($template); $assign = array(); $assign['tpl_file'] = basename($template, '.tpl'); if (isset($this->php_self)) { $assign['controller_name'] = $this->php_self; } $this->context->smarty->assign($assign); $this->template = $template; }
/** * This checks if the template set is available for mobile themes, * otherwise the front template is choosen. */ public function setMobileTemplate($template) { // Needed for site map $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive()); $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active); $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->context->smarty->assign('conditions', Configuration::get('PS_CONDITIONS')); $this->context->smarty->assign('id_cgv', Configuration::get('PS_CONDITIONS_CMS_ID')); $this->context->smarty->assign('PS_SHOP_NAME', Configuration::get('PS_SHOP_NAME')); $mobile_template = ''; $tpl_file = basename($template); $dirname = dirname($template) . (substr(dirname($template), -1, 1) == '/' ? '' : '/'); if ($dirname == _PS_THEME_DIR_) { if (file_exists(_PS_THEME_MOBILE_DIR_ . $tpl_file)) { $template = _PS_THEME_MOBILE_DIR_ . $tpl_file; } } elseif ($dirname == _PS_THEME_MOBILE_DIR_) { if (!file_exists(_PS_THEME_MOBILE_DIR_ . $tpl_file) && file_exists(_PS_THEME_DIR_ . $tpl_file)) { $template = _PS_THEME_DIR_ . $tpl_file; } } $assign = array(); $assign['tpl_file'] = basename($tpl_file, '.tpl'); if (isset($this->php_self)) { $assign['controller_name'] = $this->php_self; } $this->context->smarty->assign($assign); $this->template = $template; }
public static function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Link $link = null) { if (!$link) { $link = Context::getContext()->link; } if (is_null($id_lang)) { $id_lang = Context::getContext()->language->id; } $sql = 'SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms_category` c JOIN `' . _DB_PREFIX_ . 'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category` WHERE c.`id_cms_category` = ' . (int) $current . ' AND `id_lang` = ' . (int) $id_lang; $category = Db::getInstance()->getRow($sql); $sql = 'SELECT c.`id_cms_category` FROM `' . _DB_PREFIX_ . 'cms_category` c WHERE c.`id_parent` = ' . (int) $current . ($active ? ' AND c.`active` = 1' : ''); $result = Db::getInstance()->executeS($sql); foreach ($result as $row) { $category['children'][] = CMSCategory::getRecurseCategory($id_lang, $row['id_cms_category'], $active, $links); } $sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms` c ' . Shop::addSqlAssociation('cms', 'c') . ' JOIN `' . _DB_PREFIX_ . 'cms_lang` cl ON c.`id_cms` = cl.`id_cms` WHERE `id_cms_category` = ' . (int) $current . ' AND cl.`id_lang` = ' . (int) $id_lang . ($active ? ' AND c.`active` = 1' : '') . ' GROUP BY c.id_cms ORDER BY c.`position`'; $category['cms'] = Db::getInstance()->executeS($sql); if ($links == 1) { $category['link'] = $link->getCMSCategoryLink($current, $category['link_rewrite']); foreach ($category['cms'] as $key => $cms) { $category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']); } } return $category; }
private function _displayForm() { global $currentIndex, $cookie; $cms_blocks_left = $this->getBlocksCMS(0); $cms_blocks_right = $this->getBlocksCMS(1); $this->_html .= ' <script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script> <script type="text/javascript" src="../modules/blockcms/blockcms.js"></script> <script type="text/javascript">CMSBlocksDnD(\'' . $this->secure_key . '\');</script> <fieldset> <legend><img src="' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/logo.gif" alt="" /> ' . $this->l('CMS block configuration') . '</legend> <p><a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&addBlockCMS"><img src="' . _PS_ADMIN_IMG_ . 'add.gif" alt="" /> ' . $this->l('Add a new CMS block') . '</a></p>'; $this->_html .= '<div style="width:440px; float:left; margin-right:10px;" ><h3>' . $this->l('List of Left CMS blocks') . '</h3>'; if (sizeof($cms_blocks_left)) { $this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0" id="table_left" class="tableDnD"> <thead> <tr class="nodrag nodrop"> <th width="10%"><b>' . $this->l('ID') . '</b></th> <th width="30%" class="center"><b>' . $this->l('Name of block') . '</b></th> <th width="30%" class="center"><b>' . $this->l('Category Name') . '</b></th> <th width="10%" class="center"><b>' . $this->l('Position') . '</b></th> <th width="10%" class="center"><b>' . $this->l('Actions') . '</b></th> </tr> </thead> <tbody> '; $irow = 0; foreach ($cms_blocks_left as $cms_block) { $this->_html .= ' <tr id="tr_0_' . $cms_block['id_cms_block'] . '_' . $cms_block['position'] . '" ' . ($irow++ % 2 ? 'class="alt_row"' : '') . '> <td width="10%">' . $cms_block['id_cms_block'] . '</td> <td width="30%" class="center">' . (empty($cms_block['block_name']) ? $cms_block['category_name'] : $cms_block['block_name']) . '</td> <td width="30%" class="center">' . $cms_block['category_name'] . '</td> <td class="center pointer dragHandle"> <a' . (($cms_block['position'] == sizeof($cms_blocks_left) - 1 or sizeof($cms_blocks_left) == 1) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&configure=blockcms&id_cms_block=' . $cms_block['id_cms_block'] . '&way=1&position=' . (int) ($cms_block['position'] + 1) . '&location=0&token=' . Tools::getAdminTokenLite('AdminModules') . '"> <img src="../img/admin/down.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a> <a' . ($cms_block['position'] == 0 ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&configure=blockcms&id_cms_block=' . $cms_block['id_cms_block'] . '&way=0&position=' . (int) ($cms_block['position'] - 1) . '&location=0&token=' . Tools::getAdminTokenLite('AdminModules') . '"> <img src="../img/admin/up.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a> </td> <td width="10%" class="center"> <a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&editBlockCMS&id_cms_block=' . (int) $cms_block['id_cms_block'] . '" title="' . $this->l('Edit') . '"><img src="' . _PS_ADMIN_IMG_ . 'edit.gif" alt="" /></a> <a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&deleteBlockCMS&id_cms_block=' . (int) $cms_block['id_cms_block'] . '" title="' . $this->l('Delete') . '"><img src="' . _PS_ADMIN_IMG_ . 'delete.gif" alt="" /></a> </td> </tr>'; } $this->_html .= ' </tbody> </table>'; } else { $this->_html .= '<p style="margin-left:40px;">' . $this->l('There is no CMS block set') . '</p>'; } $this->_html .= '</div>'; $this->_html .= '<div style="width:440px; float:left;" ><h3>' . $this->l('List of Right CMS blocks') . '</h3>'; if (sizeof($cms_blocks_right)) { $this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0" id="table_right" class="tableDnD"> <thead> <tr class="nodrag nodrop"> <th width="10%"><b>' . $this->l('ID') . '</b></th> <th width="30%" class="center"><b>' . $this->l('Name of block') . '</b></th> <th width="30%" class="center"><b>' . $this->l('Category Name') . '</b></th> <th width="10%" class="center"><b>' . $this->l('Position') . '</b></th> <th width="10%" class="center"><b>' . $this->l('Actions') . '</b></th> </tr> </thead> <tbody> '; $irow = 0; foreach ($cms_blocks_right as $cms_block) { $this->_html .= ' <tr id="tr_1_' . $cms_block['id_cms_block'] . '_' . $cms_block['position'] . '" ' . ($irow++ % 2 ? 'class="alt_row"' : '') . '> <td width="10%">' . $cms_block['id_cms_block'] . '</td> <td width="30%" class="center">' . (empty($cms_block['block_name']) ? $cms_block['category_name'] : $cms_block['block_name']) . '</td> <td width="30%" class="center">' . $cms_block['category_name'] . '</td> <td class="center pointer dragHandle"> <a' . (($cms_block['position'] == sizeof($cms_blocks_right) - 1 or sizeof($cms_blocks_right) == 1) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&configure=blockcms&id_cms_block=' . $cms_block['id_cms_block'] . '&way=1&position=' . (int) ($cms_block['position'] + 1) . '&location=1&token=' . Tools::getAdminTokenLite('AdminModules') . '"> <img src="../img/admin/down.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a> <a' . ($cms_block['position'] == 0 ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&configure=blockcms&id_cms_block=' . $cms_block['id_cms_block'] . '&way=0&position=' . (int) ($cms_block['position'] - 1) . '&location=1&token=' . Tools::getAdminTokenLite('AdminModules') . '"> <img src="../img/admin/up.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a> </td> <td width="10%" class="center"> <a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&editBlockCMS&id_cms_block=' . (int) $cms_block['id_cms_block'] . '" title="' . $this->l('Edit') . '"><img src="' . _PS_ADMIN_IMG_ . 'edit.gif" alt="" /></a> <a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&deleteBlockCMS&id_cms_block=' . (int) $cms_block['id_cms_block'] . '" title="' . $this->l('Delete') . '"><img src="' . _PS_ADMIN_IMG_ . 'delete.gif" alt="" /></a> </td> </tr>'; } $this->_html .= ' </tbody> </table>'; } else { $this->_html .= '<p style="margin-left:40px;">' . $this->l('There is no CMS block set') . '</p>'; } $this->_html .= '</div> <div class="clear"></div> </fieldset><br /> <form method="POST" action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '"> <fieldset> <legend><img src="' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/logo.gif" alt="" /> ' . $this->l('Footer\'s various links Configuration') . '</legend> <input type="checkbox" name="footer_poweredby_active" id="footer_poweredby_active" ' . ((int) Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false ? 'checked="checked"' : '') . '> <label for="footer_poweredby_active" style="float:none;">' . $this->l('Display "Powered by Prestashop"') . '</label><br /><br /> <input type="checkbox" name="footer_active" id="footer_active" ' . (Configuration::get('FOOTER_BLOCK_ACTIVATION') ? 'checked="checked"' : '') . '> <label for="footer_active" style="float:none;">' . $this->l('Display the Footer\'s various links') . '</label><br /><br /> <table cellspacing="0" cellpadding="0" class="table" width="100%"> <tr> <th width="3%"><input type="checkbox" name="checkme" class="noborder" onclick="checkallCMSBoxes($(this).attr(\'checked\'))" /></th> <th width="3%">' . $this->l('ID') . '</th> <th width="94%">' . $this->l('Name') . '</th> </tr>'; $this->displayRecurseCheckboxes(CMSCategory::getRecurseCategory($cookie->id_lang), explode('|', Configuration::get('FOOTER_CMS'))); $this->_html .= ' </table> <p class="center"><input type="submit" class="button" name="submitFooterCMS" value="' . $this->l('Save') . '" /></p> </fieldset> </form>'; }
/** * Récupération de l'arborescence des pages cms * */ public static function getCmsLinks() { //Version basique pour l'instant : ne gère qu'un niveau $categories = CMSCategory::getRecurseCategory(); $categories_html = '<ul>'; if ($categories['children']) { foreach ($categories['children'] as $child) { $categories_html .= '<li>' . $child['name'] . ' <ul>'; foreach ($child['cms'] as $child_cms) { $categories_html .= '<li><a href="#" onclick="addLink(\'{{cms url=' . $child_cms['id_cms'] . '}}\')">' . $child_cms['meta_title'] . '</a></li>'; } $categories_html .= '</ul></li>'; } } foreach ($categories['cms'] as $cms) { $categories_html .= '<li><a href="#" onclick="addLink(\'{{cms url=' . $cms['id_cms'] . '}}\')">' . $cms['meta_title'] . '</a></li>'; } $categories_html .= '</ul>'; return $categories_html; }
/** * Builds menu item * * @param array $menuItem * @param int $id_shop * @param int $id_lang * * @return array */ protected function buildCmsCategoryTree(array $menuItem, $id_shop, $id_lang) { $treeMaxDepth = max(0, (int) $menuItem['tree_max_depth']); $id_cms_category = (int) $menuItem['entity_id']; $cmsCategory = new CMSCategory($id_cms_category, $id_lang, $id_shop); if (!$cmsCategory->active) { return false; } $url = $menuItem['url'] ? $menuItem['url'] : $this->context->link->getCMSCategoryLink($cmsCategory); $cmsCategoryTree = array('name' => $menuItem['name'] ? $menuItem['name'] : $cmsCategory->name, 'url' => $url, 'title' => $menuItem['title'] ? $menuItem['title'] : $cmsCategory->name, 'icon' => $menuItem['icon'], 'no_follow' => $menuItem['no_follow'], 'id' => $menuItem['id_ct_top_menu_item'], 'entity_id' => 'cms-cat-' . $id_cms_category, 'class' => $menuItem['class'], 'type' => 'cms-category-tree', 'sub_items' => array()); // Get the CMS Category tree (CMS included) from PrestaShop API $cmsCategoryTreeItem = CMSCategory::getRecurseCategory($id_lang, $id_cms_category, 1, 1); // Format CMSCategory item using recursive method $tree = $this->buildCmsCategoryTreeItem($cmsCategoryTreeItem, 1, $treeMaxDepth); $cmsCategoryTree['sub_items'] = $tree['sub_items']; return $cmsCategoryTree; }