Example #1
0
 function shGetContactCategory($id, $shLangName)
 {
     $sefConfig =& shRouter::shGetConfig();
     if (empty($sefConfig->insertContactCat)) {
         return '';
     }
     if (empty($id)) {
         return '';
     }
     $cat = sef_404::getcategories($id, $shLangName, 'com_contact_details');
     return $cat;
 }
    if (isset($type)) {
        shRemoveFromGETVarsList('type');
    }
    if (!empty($catid)) {
        shRemoveFromGETVarsList('catid');
    }
    // V 1.2.4.m
    if (isset($showall)) {
        shRemoveFromGETVarsList('showall');
    }
    if (empty($page)) {
        // remove page if not set or 0
        shRemoveFromGETVarsList('page');
    }
    if (isset($print)) {
        shRemoveFromGETVarsList('print');
    }
    if (isset($tmpl) && $tmpl == 'component') {
        // remove if 'component', show otherwise as querystring
        shRemoveFromGETVarsList('tmpl');
    }
    // ------------------  standard plugin finalize function - don't change ---------------------------
    if ($dosef) {
        $string = shFinalizePlugin($string, $title, $shAppendString, $shItemidString, isset($limit) ? $limit : null, isset($limitstart) ? $limitstart : null, isset($shLangName) ? $shLangName : null, isset($showall) ? $showall : null);
    }
    // ------------------  standard plugin finalize function - don't change ---------------------------
} else {
    // this is multipage homepage
    $title[] = '/';
    $string = sef_404::sefGetLocation($string, $title, null, isset($limit) ? $limit : null, isset($limitstart) ? $limitstart : null, isset($shLangName) ? $shLangName : null, isset($showall) ? $showall : null);
}
Example #3
0
 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;
 }
Example #4
0
function is_valid($string)
{
    global $base, $index;
    if (empty($string)) {
        $state = false;
    } elseif ($string == $index | $string == $base . $index) {
        $state = true;
    } else {
        $state = false;
        require_once sh404SEF_FRONT_ABS_PATH . 'sef_ext.php';
        $sef_ext = new sef_404();
        $option = isset($_GET['option']) ? $_GET['option'] : isset($_REQUEST['option']) ? $_REQUEST['option'] : null;
        $vars = array();
        if (is_null($option)) {
            parse_str($string, $vars);
            if (isset($vars['option'])) {
                $option = $vars['option'];
            }
        }
        switch ($option) {
            case is_null($option):
                break;
            case "login":
                /*Beat: makes this also compatible with CommunityBuilder login module*/
            /*Beat: makes this also compatible with CommunityBuilder login module*/
            case "logout":
                $state = true;
                break;
            default:
                if (is_valid_component($option)) {
                    if (!($option == "com_content") | !($option == "content")) {
                        $state = true;
                    } else {
                        $title = $sef_ext->getContentTitles($_REQUEST['view'], $_REQUEST['id'], empty($_REQUEST['layout']) ? '' : $_REQUEST['layout']);
                        if (count($title) > 0) {
                            $state = true;
                        }
                    }
                } else {
                    if (JString::substr($string, 0, 5) == 'lang=') {
                        $state = true;
                    }
                }
                // shumisha end of change
        }
    }
    return $state;
}
Example #5
0
<?php

/**
 * sh404SEF prototype support for Banners component.
 * @author      $Author: shumisha $
 * @copyright   Yannick Gaultier - 2007-2010
 * @package     sh404SEF-15
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version     $Id: com_banners.php 1189 2010-04-04 15:53:21Z silianacom-svn $
 */
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
$sefConfig =& shRouter::shGetConfig();
$shName = shGetComponentPrefix($option);
$title[] = empty($shName) ? 'banners' : $shName;
$title[] = '/';
$title[] = $task . $bid . $sefConfig->suffix;
if (count($title) > 0) {
    $string = sef_404::sefGetLocation($string, $title, null);
}
Example #6
0
     $shCanonicalTag = JRoute::_($nonSef);
 }
 // use regular function to get content titles, as per out specific settings
 $customConfig = clone $sefConfig;
 $customConfig->includeContentCat = $sefConfig->contentTitleIncludeCat;
 $customConfig->UseAlias = $sefConfig->ContentTitleUseAlias;
 $customConfig->useCatAlias = $sefConfig->ContentTitleUseCatAlias;
 $customConfig->LowerCase = false;
 $customConfig->ContentTitleInsertArticleId = false;
 // V 1.2.4.t protect against sef_ext.php not being included
 if (!class_exists('sef_404')) {
     require_once sh404SEF_ABS_PATH . 'components/com_sh404sef/sef_ext.php';
 }
 $layout = isset($layout) ? $layout : null;
 $articleId = shGetArticleIdString($id, $view, $option, $shLangName);
 $title = sef_404::getContentSlugsArray($view, $id, $layout, $Itemid, $shLangName, $customConfig);
 if (!empty($articleId)) {
     $lastBit = array_pop($title);
     $lastBit .= ' [' . $articleId . ']';
     array_push($title, $lastBit);
 }
 $pageNumber = '';
 // V 1.2.4.t try better handling of multipages article (use of mospagebreak)
 if ($view == 'article' && !empty($limitstart)) {
     // this is multipage article
     $shPageTitle = '';
     try {
         $contentElement = ShlDbHelper::selectObject('#__content', array('id', 'fulltext', 'introtext'), array('id' => $id));
     } catch (Exception $e) {
         JError::raise(E_ERROR, 500, $e->getMessage());
     }
Example #7
0
 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;
     }
     $index = str_replace($GLOBALS['shConfigLiveSite'], '', $_SERVER['PHP_SELF']);
     $base = dirname($index);
     $base .= $base == '/' ? '' : '/';
     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
     // Plug-in system.
     $shDoNotOverride = in_array(str_replace('com_', '', $option), $sefConfig->shDoNotOverrideOwnSef);
     // look first in component owndir for a joomla sef router.php file
     if (shFileExists(JPATH_ROOT . DS . 'components' . DS . $option . DS . 'router.php') && ($shDoNotOverride || !$shDoNotOverride && !shFileExists(sh404SEF_ABS_PATH . 'components/com_sh404sef/sef_ext/' . $option . '.php') && !shFileExists(JPATH_ROOT . DS . 'components/' . $option . '/sef_ext/' . $option . '.php'))) {
         // but we don't have a plugin
         // 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);
     } else {
         // look then in component own /sef_ext/ dir for a com_component_name.php plugin file
         if (shFileExists(sh404SEF_ABS_PATH . 'components/' . $option . '/sef_ext/' . $option . '.php')) {
             // Load the plug-in file.
             _log('Loading component own sh404SEF plugin');
             include sh404SEF_ABS_PATH . 'components/' . $option . '/sef_ext/' . $option . '.php';
         } else {
             if (shFileExists(sh404SEF_ABS_PATH . 'components/com_sh404sef/sef_ext/' . $option . '.php')) {
                 _log('Loading built-in plugin');
                 include sh404SEF_ABS_PATH . 'components/com_sh404sef/sef_ext/' . $option . '.php';
             } else {
                 // no plugin found at all, use Joomla 1.0.x sef
                 _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);
                 }
             }
         }
     }
     return $string;
 }
if (!empty($vars['request'])) {
    $request = explode('/', urldecode($vars['request']));
    if (!empty($request)) {
        foreach ($request as $r) {
            if (!empty($r)) {
                $segments[] = $r;
            }
        }
    } else {
        $segments[] = $vars['request'];
    }
} else {
    if ($vars['view'] == 'content' && !empty($vars['layout'])) {
        $segments[] = 'content';
        $segments[] = $vars['layout'];
    }
}
// Add the extra segments
$system = array('Itemid', 'lang', 'option', 'request', 'view', 'layout', 'task');
if (!empty($vars)) {
    foreach ($vars as $name => $value) {
        if (!in_array($name, $system)) {
            $segments[] = "{$name}-{$value}";
        }
    }
}
// Convert the segments into the URL-string
if (count($segments) > 0) {
    $string = sef_404::sefGetLocation($string, $segments, null);
}
// End
Example #9
0
            if ($database->getErrorNum()) {
                JError::raiseError(500, $database->stderr());
            } elseif (@count($rows) > 0) {
                if (!empty($rows[0]->name)) {
                    $title[] = $rows[0]->name;
                }
            }
        } else {
            $title[] = '/';
        }
        // V 1.2.4.s
        break;
    case 'category':
        if (!empty($id)) {
            // V 1.2.4.q
            $title[] = sef_404::getcategories($id, $shLangName);
            $title[] = '/';
        }
        break;
    case 'new':
        $title[] = $sh_LANG[$shLangIso]['COM_SH404SEF_CREATE_NEW_NEWSFEED'] . $sefConfig->suffix;
        break;
    default:
        $title[] = '/';
        // V 1.2.4.s
        break;
}
shRemoveFromGETVarsList('option');
if (!empty($Itemid)) {
    shRemoveFromGETVarsList('Itemid');
}
Example #10
0
                JError::raiseError(500, $database->stderr());
            } elseif (@count($rows) > 0) {
                if (!empty($rows[0]->title)) {
                    $title[] = $rows[0]->title;
                    shMustCreatePageId('set', true);
                }
            }
        } else {
            $title[] = '/';
        }
        // V 1.2.4.s
        break;
    case 'category':
        if (!empty($id)) {
            // V 1.2.4.q
            $arg2[] = sef_404::getcategories($id, $shLangName);
            $title = array_merge($title, $arg2);
            $title[] = '/';
            shMustCreatePageId('set', true);
        }
        break;
    case 'new':
        $title[] = $sh_LANG[$shLangIso]['COM_SH404SEF_CREATE_NEW_LINK'] . $sefConfig->suffix;
        break;
    default:
        $title[] = '/';
        shMustCreatePageId('set', true);
        break;
}
shRemoveFromGETVarsList('option');
if (!empty($Itemid)) {