예제 #1
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $params = SEFTools::GetExtParams('com_content');
     $vars = $uri->getQuery(true);
     extract($vars);
     // Set title.
     $title = array();
     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
     if (!empty($tmpl)) {
         $title[] = $tmpl;
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $this->_createNonSefVars($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, $this->ignoreVars);
     }
     return $newUri;
 }
예제 #2
0
 protected function _createNonSefVars(&$uri)
 {
     if (!isset($this->nonSefVars) && !isset($this->ignoreVars)) {
         $this->nonSefVars = array();
         $this->ignoreVars = array();
     }
     $this->params =& SEFTools::GetExtParams('com_content');
     $sefConfig =& SEFConfig::getConfig();
     if ($sefConfig->appendNonSef && $this->params->get('pagination', '0') != '0') {
         if (!is_null($uri->getVar('limit'))) {
             $this->nonSefVars['limit'] = $uri->getVar('limit');
         }
         if (!is_null($uri->getVar('limitstart'))) {
             $this->nonSefVars['limitstart'] = $uri->getVar('limitstart');
         }
     }
     if (!is_null($uri->getVar('filter'))) {
         $this->nonSefVars['filter'] = $uri->getVar('filter');
     }
     if (!is_null($uri->getVar('return'))) {
         $this->nonSefVars['return'] = $uri->getVar('return');
     }
 }
예제 #3
0
파일: sef_ext.php 프로젝트: sangkasi/joomla
 function create($string, &$vars, &$shAppendString, $shLanguage, $shSaveString = '', &$originalUri)
 {
     $sefConfig =& shRouter::shGetConfig();
     // get DB
     $database =& JFactory::getDBO();
     _log('Calling sef404 create function with ' . $string);
     if ($sefConfig->shInsertGlobalItemidIfNone && !empty($GLOBALS['Itemid'])) {
         // V 1.2.4.t
         $shCurrentItemid = $GLOBALS['Itemid'];
     } else {
         $shCurrentItemid = null;
     }
     _log('CurrentItemid = ' . $shCurrentItemid);
     $index = str_replace($GLOBALS['shConfigLiveSite'], '', $_SERVER['PHP_SELF']);
     $base = dirname($index);
     $base .= $base == '/' ? '' : '/';
     _log('Extracting $vars:', $vars);
     extract($vars);
     if (isset($title)) {
         // V 1.2.4.r : protect against components using 'title' as GET vars (com_jim for instance)
         $sh404SEF_title = $title;
     }
     // means that $sh404SEF_title has to be used in plugins or extensions
     $title = array();
     // V 1.2.4.r
     // get extension plugin
     $extPlugin =& Sh404sefFactory::getExtensionPlugin($option);
     // which plugin file are we supposed to use?
     $extPluginPath = $extPlugin->getSefPluginPath($vars);
     $pluginType = $extPlugin->getPluginType();
     // use Joomla router.php file in extension dir
     switch ($pluginType) {
         case Sh404sefClassBaseextplugin::TYPE_JOOMLA_ROUTER:
             // Load the plug-in file.
             _log('Loading component own router.php file');
             $functionName = ucfirst(str_replace('com_', '', $option)) . 'BuildRoute';
             if (!function_exists($functionName)) {
                 include JPATH_ROOT . DS . 'components' . DS . $option . DS . 'router.php';
             }
             $originalVars = empty($originalUri) ? $vars : $originalUri->getQuery($asArray = true);
             $title = $functionName($originalVars);
             //$title = shRemoveSlugs( $title, $removeWhat = 'removeId');
             global $mainframe;
             $router =& $mainframe->getRouter();
             $title = $router->_encodeSegments($title);
             // manage GET var lists ourselves, as Joomla router.php does not do it
             if (!empty($vars)) {
                 // there are some unused GET vars, we must transfer them to our mechanism, so
                 // that they are eventually appended to the sef url
                 foreach ($vars as $k => $v) {
                     switch ($k) {
                         case 'option':
                         case 'Itemid':
                             shRemoveFromGETVarsList($k);
                             break;
                         default:
                             // if variable has not been used in sef url, add it to list of variables to be
                             // appended to the url as query string elements
                             if (array_key_exists($k, $originalVars)) {
                                 shAddToGETVarsList($k, $v);
                             } else {
                                 shRemoveFromGETVarsList($k);
                             }
                             break;
                     }
                 }
             }
             // special case for search component, as router.php encode the search word in the url
             // wa can't do that, as we are storing each url in the db
             if (isset($originalVars['option']) && $originalVars['option'] == 'com_search' && !empty($vars['searchword'])) {
                 // router.php has encoded that in the url, we need to undo
                 $title = array();
                 $originalVars['searchword'] = $vars['searchword'];
                 shAddToGETVarsList('searchword', $vars['searchword']);
                 if (!empty($vars['view'])) {
                     $vars['view'] = $vars['view'];
                     shAddToGETVarsList('view', $vars['view']);
                 }
             }
             // handle menu items, having only a single Itemid in the url
             // (router.php will return an empty array in that case, even if we have restored
             // the full non-sef url, as we already did)
             /*
              * Build the application route
              */
             $tmp = '';
             if (empty($title) && isset($vars['Itemid']) && !empty($vars['Itemid'])) {
                 $menu =& shRouter::shGetMenu();
                 $item = $menu->getItem($vars['Itemid']);
                 if (is_object($item) && $vars['option'] == $item->component) {
                     $title[] = $item->route;
                 }
             }
             if (empty($title)) {
                 //$title[] = 'comp';
                 $title[] = substr($vars['option'], 4);
             }
             // add user defined prefix
             $prefix = shGetComponentPrefix($option);
             if (!empty($prefix)) {
                 array_unshift($title, $prefix);
             }
             // now process the resulting title string
             $string = shFinalizePlugin($string, $title, $shAppendString, '', isset($limit) ? @$limit : null, isset($limitstart) ? @$limitstart : null, isset($shLangName) ? @$shLangName : null, isset($showall) ? @$showall : null);
             break;
             // use sh404sef plugins, either in ext. dir or in sh404sef dir
         // use sh404sef plugins, either in ext. dir or in sh404sef dir
         case Sh404sefClassBaseextplugin::TYPE_SH404SEF_ROUTER:
             _log('Loading sh404SEF plugin in ' . $extPluginPath);
             include $extPluginPath;
             break;
         case Sh404sefClassBaseextplugin::TYPE_JOOMSEF_ROUTER:
             Sh404sefHelperExtplugins::loadJoomsefCompatLibs();
             include_once $extPluginPath;
             $className = 'SefExt_' . $option;
             $plugin = new $className();
             if (!shIsHomepage($string)) {
                 // make sure the plugin does not try to calculate pagination
                 $params =& SEFTools::GetExtParams('com_content');
                 $params->set('pagination', '1');
                 // ask plugin to build url
                 $plugin->beforeCreate($originalUri);
                 $result = $plugin->create($originalUri);
                 $title = empty($result['title']) ? array() : $result['title'];
                 $plugin->afterCreate($originalUri);
                 // make sure we have a url
                 if (empty($title) && isset($vars['Itemid']) && !empty($vars['Itemid'])) {
                     $menu =& shRouter::shGetMenu();
                     $item = $menu->getItem($vars['Itemid']);
                     if (is_object($item) && $vars['option'] == $item->component) {
                         $title[] = $item->route;
                     }
                 }
                 $prefix = shGetComponentPrefix($option);
                 if (!empty($prefix)) {
                     array_unshift($title, $prefix);
                 }
                 if (empty($title) && !shIsHomepage($string)) {
                     $title[] = substr($vars['option'], 4);
                 }
                 list($usedVars, $ignore) = $plugin->getNonSefVars($result);
                 if (!empty($ignore)) {
                     $usedVars = array_merge($usedVars, $ignore);
                 }
             } else {
                 $string = '';
                 $title[] = '/';
                 $usedVars = array();
             }
             // post process result to adjust to our workflow
             if (!empty($vars)) {
                 foreach ($vars as $key => $value) {
                     if (!array_key_exists($key, $usedVars)) {
                         shRemoveFromGETVarsList($key);
                     }
                 }
             }
             // finalize url
             $string = shFinalizePlugin($string, $title, $shAppendString = '', $shItemidString = '', isset($limit) ? @$limit : null, isset($limitstart) ? @$limitstart : null, isset($shLangName) ? @$shLangName : null, isset($showall) ? @$showall : null);
             break;
         case Sh404sefClassBaseextplugin::TYPE_ACESEF_ROUTER:
             Sh404sefHelperExtplugins::loadAcesefCompatLibs();
             include_once $extPluginPath;
             $className = 'AceSEF_' . $option;
             $plugin = new $className();
             $plugin->AcesefConfig = AcesefFactory::getConfig();
             // some plugins appear to not call the constructor parent, and so AcesefConfig is not set
             $tmp =& JPluginHelper::getPlugin('sh404sefextacesef', $option);
             $params = new JParameter($tmp->params);
             $plugin->setParams($params);
             $segments = array();
             $do_sef = true;
             $metadata = array();
             $item_limitstart = 0;
             $plugin->beforeBuild($originalUri);
             $originalVars = empty($originalUri) ? $vars : $originalUri->getQuery($asArray = true);
             $plugin->build($originalVars, $title, $do_sef, $metadata, $item_limitstart);
             $plugin->afterBuild($originalUri);
             $prefix = shGetComponentPrefix($option);
             if (empty($title) && isset($vars['Itemid']) && !empty($vars['Itemid'])) {
                 $menu =& shRouter::shGetMenu();
                 $item = $menu->getItem($vars['Itemid']);
                 if (is_object($item) && $vars['option'] == $item->component) {
                     $title[] = $item->route;
                 }
             }
             if (!empty($prefix)) {
                 array_unshift($title, $prefix);
             }
             if (empty($title) && !shIsHomepage($string)) {
                 $title[] = substr($vars['option'], 4);
             }
             // acesef plugin don't remove used vars from our GET var manager
             // we'll do it now. Vars used are those not present anymore in
             // $originalVars
             // they will be reappended to the SEF url by shFinalizePlugin
             $usedVars = array_diff($vars, $originalVars);
             if (!empty($usedVars)) {
                 foreach ($usedVars as $key => $value) {
                     shRemoveFromGETVarsList($key);
                 }
             }
             // remove Itemid and option, as these are not unset by plugin
             shRemoveFromGETVarsList('Itemid');
             shRemoveFromGETVarsList('option');
             // finalize url
             $string = shFinalizePlugin($string, $title, $shAppendString = '', $shItemidString = '', isset($limit) ? @$limit : null, isset($limitstart) ? @$limitstart : null, isset($shLangName) ? @$shLangName : null, isset($showall) ? @$showall : null);
             break;
         default:
             _log('Falling back to sefGetLocation');
             if (empty($sefConfig->defaultComponentStringList[str_replace('com_', '', $option)])) {
                 $title[] = getMenuTitle($option, isset($task) ? @$task : null, null, null, $shLanguage);
             } else {
                 $title[] = $sefConfig->defaultComponentStringList[str_replace('com_', '', $option)];
             }
             if ($title[0] != '/') {
                 $title[] = '/';
             }
             // V 1.2.4.q getMenuTitle can now return '/'
             if (count($title) > 0) {
                 // V 1.2.4.q use $shLanguage insted of $lang  (lang name rather than lang code)
                 $string = sef_404::sefGetLocation($string, $title, isset($task) ? @$task : null, isset($limit) ? @$limit : null, isset($limitstart) ? @$limitstart : null, isset($shLanguage) ? @$shLanguage : null);
             }
             break;
     }
     return $string;
 }
예제 #4
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $mainframe =& JFactory::getApplication();
     $this->params =& SEFTools::GetExtParams('com_content');
     $vars = $uri->getQuery(true);
     extract($vars);
     // Do not SEF URLs with exturl variable
     //if( !empty($exturl) )   return $string;
     // Do not SEF edit urls
     if (isset($task) && $task == 'edit') {
         return $uri;
     }
     // Set title.
     $title = array();
     switch (@$view) {
         case 'new':
         case 'edit':
             /*
             $title[] = getMenuTitle($option, $task, $Itemid, $string);
             $title[] = 'new' . $sefConfig->suffix;
             */
             break;
         case 'archive':
             $title[] = JText::_($view);
             if (!empty($year)) {
                 $title[] = $year;
             }
             if (!empty($month)) {
                 $title[] = $month;
             }
             break;
             /*
             case 'archivecategory':
             case 'archivesection': {
             if (eregi($task.".*id=".$id, $_SERVER['REQUEST_URI'])) break;
             }
             */
         /*
         case 'archivecategory':
         case 'archivesection': {
         if (eregi($task.".*id=".$id, $_SERVER['REQUEST_URI'])) break;
         }
         */
         default:
             if (isset($format)) {
                 if ($format == 'pdf') {
                     // wrong ID
                     if (intval($id) == 0) {
                         return $uri;
                     }
                     // create PDF
                     $title = $this->_getContentTitles(!empty($view) ? $view : 'article', $id);
                     if (count($title) === 0) {
                         $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     }
                     // Add Google News number if set to
                     if (@$view == 'article' && $this->params->get('googlenewsnum', '0') != '0') {
                         $i = count($title) - 1;
                         $title[$i] = $this->GoogleNews($title[$i], $id);
                     }
                     $title[] = JText::_('PDF');
                 } elseif ($format == 'feed') {
                     // Create feed
                     if (@$view != 'frontpage') {
                         // wrong ID
                         if (intval($id) == 0) {
                             return $uri;
                         }
                         $title = $this->_getContentTitles(!empty($view) ? $view : 'article', $id);
                         // Add Google News number if set to
                         if (@$view == 'article' && $this->params->get('googlenewsnum', '0') != '0') {
                             $i = count($title) - 1;
                             $title[$i] = $this->GoogleNews($title[$i], $id);
                         }
                     }
                     if (count($title) === 0 && empty($type)) {
                         $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     }
                     if (!empty($type)) {
                         $title[] = $type;
                     }
                 }
             } else {
                 if (isset($id)) {
                     // wrong ID
                     if (intval($id) == 0) {
                         return $uri;
                     }
                     $title = $this->_getContentTitles(@$view, @$id);
                     if (count($title) === 0) {
                         $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     }
                     // Add Google News number if set to
                     if (@$view == 'article' && $this->params->get('googlenewsnum', '0') != '0') {
                         $i = count($title) - 1;
                         $title[$i] = $this->GoogleNews($title[$i], $id);
                     }
                 } else {
                     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     //$title[] = JText::_('Submit');
                 }
                 // Layout
                 $addLayout = $this->params->get('add_layout', '2');
                 if (isset($layout) && !empty($layout) && $addLayout != '0') {
                     if ($addLayout == '2') {
                         $defLayout = $this->params->get('def_layout', 'default');
                         if ($layout != $defLayout) {
                             $title[] = $layout;
                         }
                     } else {
                         $title[] = $layout;
                     }
                 }
                 if (isset($limitstart) && (!$sefConfig->appendNonSef || $this->params->get('pagination', '0') == '0')) {
                     $pagetext = null;
                     if (@$view == 'article') {
                         // Multipage article - get the correct page title
                         $page = $limitstart + 1;
                         if ($this->params->get('multipagetitles', '1') == '1') {
                             $pagetext = $this->_getPageTitle($limitstart);
                         }
                     } else {
                         // Is limit set?
                         if (!isset($limit)) {
                             // Try to get limit from menu parameters
                             $menu =& JSite::getMenu();
                             if (!isset($Itemid)) {
                                 // We need to find Itemid first
                                 $active =& $menu->getActive();
                                 $Itemid = $active->id;
                             }
                             $menuParams =& $menu->getParams($Itemid);
                             $leading = $menuParams->get('num_leading_articles', 1);
                             $intro = $menuParams->get('num_intro_articles', 4);
                             $links = $menuParams->get('num_links', 4);
                             if (isset($layout) && $layout == 'blog') {
                                 $limit = $leading + $intro;
                                 // + $links;
                             } else {
                                 $limit = $menuParams->get('display_num', $mainframe->getCfg('list_limit'));
                                 $limit = $mainframe->getUserStateFromRequest('com_content.' . $uri->getVar('layout', 'default') . '.limit', 'limit', $limit, 'int');
                             }
                         }
                         $page = intval($limitstart / $limit) + 1;
                     }
                     if (is_null($pagetext)) {
                         $pagetext = strval($page);
                         if ($cnfPageText = $sefConfig->getPageText()) {
                             $pagetext = str_replace('%s', $page, $cnfPageText);
                         }
                     }
                     $title = array_merge($title, explode('/', $pagetext));
                     //$title[] = $pagetext;
                 }
                 // show all
                 if (isset($showall) && $showall == 1) {
                     $title[] = JText::_('All Pages');
                 }
                 // print article
                 if (isset($print) && $print == 1) {
                     $title[] = JText::_('Print') . (!empty($page) ? '-' . ($page + 1) : '');
                 }
             }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $metatags = $this->getMetaTags();
         if (isset($this->metatitle)) {
             $metatags['metatitle'] = $this->metatitle;
         }
         $this->_createNonSefVars($uri);
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $metatags, $priority, true, null, $sitemap);
     }
     return $newUri;
 }