示例#1
0
 public function init()
 {
     if ($cms_rewrite = Tools::getValue('cms_rewrite')) {
         $sql = 'SELECT l.`id_cms`
             FROM `' . _DB_PREFIX_ . 'cms_lang` l
             LEFT JOIN `' . _DB_PREFIX_ . 'cms_shop` s ON (l.`id_cms` = s.`id_cms`)
             WHERE l.`link_rewrite` = \'' . pSQL(str_replace('.html', '', $cms_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms > 0) {
             $_GET['id_cms'] = $id_cms;
         }
     } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) {
         $sql = 'SELECT `id_cms_category`
             FROM `' . _DB_PREFIX_ . 'cms_category_lang`
             WHERE `link_rewrite` = \'' . pSQL($cms_category_rewrite) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms_category > 0) {
             $_GET['id_cms_category'] = $id_cms_category;
         }
     }
     parent::init();
 }
示例#2
0
 public function initContent()
 {
     parent::initContent();
     $parent_cat = new CMSCategory(1, $this->context->language->id);
     $this->context->smarty->assign('id_current_lang', $this->context->language->id);
     $this->context->smarty->assign('home_title', $parent_cat->name);
     $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
     if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category) {
         $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS');
     } else {
         if (isset($this->cms_category->meta_title)) {
             $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS');
         }
     }
     if ($this->assignCase == 1) {
         $this->context->smarty->assign(array('og_type' => 'article', 'cms' => $this->cms, 'content_only' => (int) Tools::getValue('content_only'), 'path' => $path, 'body_classes' => array($this->php_self . '-' . $this->cms->id, $this->php_self . '-' . $this->cms->link_rewrite)));
         if ($this->cms->indexation == 0) {
             $this->context->smarty->assign('nobots', true);
         }
     } else {
         if ($this->assignCase == 2) {
             $this->context->smarty->assign(array('category' => $this->cms_category, 'cms_category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories($this->context->language->id), 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int) $this->cms_category->id, true, (int) $this->context->shop->id), 'path' => $this->cms_category->id !== 1 ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '', 'body_classes' => array($this->php_self . '-' . $this->cms_category->id, $this->php_self . '-' . $this->cms_category->link_rewrite)));
         }
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'cms.tpl');
 }
    /**
     * Method init() : Initialize cms controller with cms_rewrite params
     *
     * @module now_seo_links
     *
     * @see CmsControllerCore::init()
     */
    public function init()
    {
        // Get rewrite
        $sRewrite = Tools::getValue('cms_rewrite', false);
        if ($sRewrite) {
            $iIdCms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `id_cms`
				FROM `' . _DB_PREFIX_ . 'cms_lang`
				WHERE `link_rewrite` = \'' . $sRewrite . '\'
				AND `id_lang` = ' . Context::getContext()->language->id);
            if ($iIdCms) {
                $_GET['id_cms'] = $iIdCms;
            }
        }
        // Get rewrite
        $sRewriteCategory = Tools::getValue('cms_category_rewrite', false);
        if ($sRewriteCategory) {
            $iIdCmsCategory = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `id_cms_category`
				FROM `' . _DB_PREFIX_ . 'cms_category_lang`
				WHERE `link_rewrite` = \'' . $sRewriteCategory . '\'
				AND `id_lang` = ' . Context::getContext()->language->id);
            if ($iIdCmsCategory) {
                $_GET['id_cms_category'] = $iIdCmsCategory;
            }
        }
        parent::init();
    }
示例#4
0
    public function init()
    {
        if (Tools::getValue('cms_rewrite')) {
            $rewrite_url = Tools::getValue('cms_rewrite');
            $id_cms = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `id_cms`
				FROM `' . _DB_PREFIX_ . 'cms_lang`
				WHERE `link_rewrite` = \'' . $rewrite_url . '\'');
            if ($id_cms > 0) {
                $_GET['id_cms'] = $id_cms;
                //$_GET['noredirect'] = 1;
            } else {
                Tools::display404Error();
                die;
            }
        } else {
            if (Tools::getValue('cms_category_rewrite')) {
                $rewrite_url = Tools::getValue('cms_category_rewrite');
                $id_cms_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `id_cms_category`
				FROM `' . _DB_PREFIX_ . 'cms_category_lang`
				WHERE `link_rewrite` = \'' . $rewrite_url . '\'');
                if ($id_cms_category > 0) {
                    $_GET['id_cms_category'] = $id_cms_category;
                    //$_GET['noredirect'] = 1;
                } else {
                    Tools::display404Error();
                    die;
                }
            }
        }
        parent::init();
    }
示例#5
0
 public function __construct()
 {
     parent::__construct();
     if (Module::isInstalled('agilemultipleseller')) {
         $seller_terms_id = (int) Tools::getValue('id_cms');
         if ($seller_terms_id == (int) Configuration::get('AGILE_MS_SELLER_TERMS')) {
             $seller_terms = new CMS($seller_terms_id, $this->context->language->id);
             if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && Validate::isLoadedObject($seller_terms)) {
                 $this->ssl = true;
             }
         }
     }
 }
    public function init()
    {
        if (Tools::getValue('cms_rewrite')) {
            $rewrite_url = Tools::getValue('cms_rewrite');
            $sql = 'SELECT l.`id_cms`
				FROM `' . _DB_PREFIX_ . 'cms_lang` l
				LEFT JOIN `' . _DB_PREFIX_ . 'cms_shop` s ON (l.`id_cms` = s.`id_cms`)
				WHERE l.`link_rewrite` = \'' . $rewrite_url . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_cms > 0) {
                $_GET['id_cms'] = $id_cms;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        } else {
            if (Tools::getValue('cms_category_rewrite')) {
                $rewrite_url = Tools::getValue('cms_category_rewrite');
                $sql = 'SELECT `id_cms_category`
				FROM `' . _DB_PREFIX_ . 'cms_category_lang`
				WHERE `link_rewrite` = \'' . $rewrite_url . '\'';
                if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                    $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
                }
                $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                if ($id_cms_category > 0) {
                    $_GET['id_cms_category'] = $id_cms_category;
                } else {
                    //TODO: Do we need to send 404?
                    header('HTTP/1.1 404 Not Found');
                    header('Status: 404 Not Found');
                }
            }
        }
        parent::init();
    }