当前位置: 首页>>代码示例>>PHP>>正文


PHP CMSCategory::getLinkRewrite方法代码示例

本文整理汇总了PHP中CMSCategory::getLinkRewrite方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSCategory::getLinkRewrite方法的具体用法?PHP CMSCategory::getLinkRewrite怎么用?PHP CMSCategory::getLinkRewrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMSCategory的用法示例。


在下文中一共展示了CMSCategory::getLinkRewrite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: autoCatch

 private function autoCatch($page_name, $id_lang, $id_shop)
 {
     $uri_var = $this->formatLink($_SERVER['REQUEST_URI']);
     $cache_enabled = (bool) Configuration::get('MGRT_URLCACHE');
     $cache_name = 'MR2_' . $id_shop . '_' . Tools::str2url($uri_var);
     $cache_file = $this->cache_folder . md5($cache_name);
     // Better checking this before
     if ($cache_enabled === true && is_writable(_PS_CACHE_DIR_) && file_exists($this->cache_folder)) {
         $time_cache = (int) Configuration::get('MGRT_CACHETIME');
         if (file_exists($cache_file) && filemtime($cache_file) > time() - $time_cache * 60) {
             // Checked, can go ahead
             return;
         } else {
             try {
                 file_put_contents($cache_file, 'checked', LOCK_EX);
             } catch (Exception $e) {
                 PrestaShopLogger::addLog('Redirect Cache folder not writable, please check your modules folder permissions.');
             }
         }
     }
     $link = new Link();
     $db = Db::getInstance();
     $force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE');
     $full_uri = 'http' . ($force_ssl === true ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     if ($full_uri == $link->getPageLink('404')) {
         // nothing to stare
         return;
     }
     if ($page_name == 'pagenotfound') {
         // Check if similar redirect exist, tryig to avoid duplicates
         $exist = $db->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'redirect r WHERE r.old = "' . pSQL($uri_var) . '"');
         if (!empty($uri_var) && empty($exist)) {
             // Let's log it
             $redirect = new Redirect();
             $redirect->old = trim($uri_var);
             $redirect->new = '/';
             $redirect->type = '301';
             $redirect->regex = false;
             $redirect->active = (bool) Configuration::get('MGRT_AUTOACTIVE');
             $redirect->add();
             // Multishop
             $db->execute('INSERT INTO `' . _DB_PREFIX_ . 'redirect_shop` (`id_redirect`, `id_shop`) VALUES (' . (int) $redirect->id . ',' . (int) $id_shop . ')');
             // Update counter
             $t = (int) Configuration::get('MGRT_COUNTER');
             Configuration::updateValue('MGRT_COUNTER', $t + 1);
         }
         if (!empty($exist)) {
             // Test exist in current shop, if not adding it
             $exist_shop = $db->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'redirect_shop WHERE id_shop = ' . (int) $id_shop . ' AND id_redirect = ' . (int) $exist['id_redirect']);
             if (empty($exist_shop)) {
                 $db->execute('INSERT INTO `' . _DB_PREFIX_ . 'redirect_shop` (`id_redirect`, `id_shop`) VALUES (' . (int) $exist['id_redirect'] . ',' . (int) $id_shop . ')');
             }
         }
     } else {
         // We try to find some concordance in available pages
         // considering link rewrite and manipulated url structures
         $rewrite = Tools::isSubmit('rewrite') ? Tools::getValue('rewrite') : null;
         if (empty($rewrite)) {
             $id = Tools::getValue('id_' . $page_name) ? (int) Tools::getValue('id_' . $page_name) : null;
             switch ($page_name) {
                 case 'manufacturer':
                     if (!empty($id)) {
                         $manufacturer = new Manufacturer($id, $id_lang);
                         $rewrite = $manufacturer->link_rewrite;
                     }
                     break;
                 case 'supplier':
                     if (!empty($id)) {
                         $supplier = new Supplier($id, $id_lang);
                         $rewrite = $supplier->link_rewrite;
                     }
                     break;
                 case 'cms':
                     if (!empty($id)) {
                         $link_rewrite = CMS::getUrlRewriteInformations($id);
                     }
                     if (isset($link_rewrite[$id_lang])) {
                         $rewrite = $link_rewrite[$id_lang]['link_rewrite'];
                     }
                     break;
                 case 'product':
                     if (!empty($id)) {
                         $product = new Product($id, false, $id_lang);
                         $rewrite = $product->link_rewrite;
                     }
                     break;
                 case 'category':
                     if (!empty($id)) {
                         $category = new Category($id, $id_lang, $id_shop);
                         $rewrite = $category->link_rewrite;
                     }
                     break;
                 case 'cms_category':
                     if (!empty($id)) {
                         $rewrite = CMSCategory::getLinkRewrite($id, $id_lang);
                     }
                     break;
                 default:
                     // UFO or Module ? Hard to find an equivalent.
                     if (strpos('module', $page_name)) {
//.........这里部分代码省略.........
开发者ID:acreno,项目名称:pm-ps,代码行数:101,代码来源:magicredirect.php

示例2: getCMSLink

 /**
  * Create a link to a CMS page
  *
  * @param mixed $cms CMS object (can be an ID CMS, but deprecated)
  * @param string $alias
  * @param bool $ssl
  * @param int $id_lang
  * @return string
  */
 public function getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop = null)
 {
     if (!$id_lang) {
         $id_lang = Context::getContext()->language->id;
     }
     $url = $this->getBaseLink($id_shop, $ssl) . $this->getLangLink($id_lang, null, $id_shop);
     $dispatcher = Dispatcher::getInstance();
     if (!is_object($cms)) {
         $cms = new CMS($cms, $id_lang);
         if (!Validate::isLoadedObject($cms) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title', $id_shop)) {
             return $url . $dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int) $cms, 'rewrite' => (string) $alias), $this->allow, '', $id_shop);
         }
         $cms = new CMS($cms, $id_lang);
     }
     // Set available keywords
     $params = array();
     $params['id'] = $cms->id;
     $params['rewrite'] = !$alias ? is_array($cms->link_rewrite) ? $cms->link_rewrite[(int) $id_lang] : $cms->link_rewrite : $alias;
     $params['meta_keywords'] = '';
     if (isset($cms->meta_keywords) && !empty($cms->meta_keywords)) {
         $params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int) $id_lang]) : Tools::str2url($cms->meta_keywords);
     }
     $params['meta_title'] = '';
     if (isset($cms->meta_title) && !empty($cms->meta_title)) {
         $params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int) $id_lang]) : Tools::str2url($cms->meta_title);
     }
     $params['category_cms_rewrite'] = '';
     if (isset($cms->id_cms_category) && !empty($cms->id_cms_category)) {
         $params['category_cms_rewrite'] = Tools::str2url(CMSCategory::getLinkRewrite($cms->id_cms_category, $id_lang));
     }
     return $url . $dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop);
 }
开发者ID:TheTypoMaster,项目名称:neonflexible,代码行数:41,代码来源:Link.php


注:本文中的CMSCategory::getLinkRewrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。