Пример #1
0
 protected static function _createShurl($nonSefUrl)
 {
     if (empty($nonSefUrl)) {
         return '';
     }
     // only create a shURL if current page returns a 200
     $headers = JResponse::getHeaders();
     // check if we have a status
     foreach ($headers as $header) {
         if (strtolower($header['name']) == 'status' && $header['value'] != 200) {
             // error or redirection, don't shurl that
             return '';
         }
     }
     // check various conditions, to avoid overloading ourselves with shURL
     // not on homepage
     if (shIsAnyHomepage($nonSefUrl)) {
         return '';
     }
     // not for format = raw, format = pdf or printing
     $format = shGetURLVar($nonSefUrl, 'format');
     if (in_array(strtolower($format), array('raw', 'pdf'))) {
         return '';
     }
     $print = shGetURLVar($nonSefUrl, 'print');
     if ($print == 1) {
         return '';
     }
     // not if tmpl not empty or not index
     $tmpl = shGetURLVar($nonSefUrl, 'tmpl');
     if (!empty($tmpl) && $tmpl != 'index') {
         return '';
     }
     // force global setting
     shMustCreatePageId('set', true);
     // get a model and create shURL
     $model =& JModel::getInstance('Pageids', 'Sh404sefModel');
     $shURL = $model->createPageId('', $nonSefUrl);
     return $shURL;
 }
Пример #2
0
        $title = array($item->route);
    }
}
if (empty($title)) {
    ShlSystem_Log::debug('sh404sef', 'Loading component own router.php file from inside com_virtuemart.php');
    $functionName = ucfirst(str_replace('com_', '', $option)) . 'BuildRoute';
    if (!function_exists($functionName)) {
        include JPATH_ROOT . '/components/' . $option . '/router.php';
    }
    $helper = vmrouterHelper::getInstance($originalVars);
    $menuItem = $helper->menuVmitems;
    $shopName = empty($menuItem) ? 'vm' : $menuItem[0]->alias;
    // check for shop root url, else normal routing
    if (!empty($originalVars['view']) && $originalVars['view'] == 'virtuemart') {
        // if VM is homepage, then that's fine
        if (!shIsAnyHomepage($string)) {
            // else use menu item alias as slug
            $title[] = $shopName;
            unset($originalVars['view']);
        }
    } else {
        // various checks as VM2 seem to produce funky non-sef urls
        if (!empty($originalVars['view']) && $originalVars['view'] == 'productdetails') {
            if (empty($originalVars['virtuemart_product_id'])) {
                // request for product details, but product id is 0
                return;
            }
        }
        // when limitstart is not set, VM2 fetches start from the session, instead
        // of just assuming 0
        if (!empty($originalVars['view']) && $originalVars['view'] == 'category') {
Пример #3
0
 private function _mustCreatePageid($nonSefUrl)
 {
     // currently disabled by sef url plugin
     if (!self::$_mustCreate) {
         return false;
     }
     // if enabled at sef url plugin level, check configuration
     $sefConfig =& Sh404sefFactory::getConfig();
     // check global flags
     if (!$sefConfig->enablePageId || $sefConfig->stopCreatingShurls) {
         return false;
     }
     // make sure we have a language
     $pageInfo =& Sh404sefFactory::getPageInfo();
     $nonSefUrl = shSetURLVar($nonSefUrl, 'lang', $pageInfo->shMosConfig_shortcode);
     // not on homepage
     if (shIsAnyHomepage($nonSefUrl)) {
         return '';
     }
     // check at component level
     $option = shGetURLVar($nonSefUrl, 'option');
     $option = str_replace('com_', '', $option);
     $enable = !empty($option) && in_array($option, $sefConfig->compEnablePageId);
     // check non sef url content black list
     $sefConfig->shurlNonSefBlackList = JString::trim($sefConfig->shurlNonSefBlackList);
     if (empty($sefConfig->shurlNonSefBlackList)) {
         $blackList = array();
     } else {
         if (strpos($sefConfig->shurlNonSefBlackList, '|') !== false) {
             $blackList = explode('|', $sefConfig->shurlNonSefBlackList);
         } else {
             $blackList = array($sefConfig->shurlNonSefBlackList);
         }
     }
     if (!empty($blackList)) {
         foreach ($blackList as $bit) {
             if (!empty($bit) && strpos($nonSefUrl, $bit) !== false) {
                 // match, don't create a shurl for this non sef url
                 $enable = false;
                 break;
             }
         }
     }
     return $enable;
 }