/** * Creates the SEF Advance URL out of the request * Input: $string, string, The request URL (index.php?option=com_example&Itemid=$Itemid) * Output: $sefstring, string, SEF Advance URL ($var1/$var2/) **/ function create($string) { global $database; if (empty($database)) { // Joomla! 1.5 native $database = EasyBlogHelper::db(); } // $string == "index.php?option=com_mydir&Itemid=$Itemid // &catid=$catid&id=$id" $sefstring = ''; // $itemid = ''; // if (preg_match('/&Itemid=/i',$string)) // { // $temp = explode('&Itemid=', $string); // $temp = explode('&', $temp[1]); // $itemid = $temp[0]; // } $config = EasyBlogHelper::getConfig(); if (preg_match('/&view=/i', $string)) { $temp = explode('&view=', $string); $temp = explode('&', $temp[1]); $view = $temp[0]; if ($view != 'entry' || $config->get('main_sef') != 'simple') { $sefstring .= sefencode($view) . '/'; } } if (preg_match('/&id=/i', $string)) { $id = sef_easyblog::getVarValue('id', $string); JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'tables'); $idname = ''; if (!empty($id) && isset($view)) { switch ($view) { case 'entry': $idname = EasyBlogRouter::getBlogSefPermalink($id); break; case 'blogger': $idname = EasyBlogRouter::getBloggerPermalink($id); break; case 'categories': $idname = EasyBlogRouter::getCategoryPermalink($id); break; case 'tags': $idname = EasyBlogRouter::getTagPermalink($id); break; case 'teamblog': $idname = EasyBlogRouter::getTeamBlogPermalink($id); break; default: $idname = ''; } } $idname = empty($idname) ? $id : $idname; } if (preg_match('/&controller=/i', $string)) { $temp = explode('&controller=', $string); $temp = explode('&', $temp[1]); $controller = $temp[0]; $sefstring .= '?controller=' . $controller; if (preg_match('/&task=/i', $string)) { $temp = explode('&task=', $string); $temp = explode('&', $temp[1]); $task = $temp[0]; $sefstring .= '&task=' . $task; } if (preg_match('/&tmpl=/i', $string)) { $temp = explode('&tmpl=', $string); $temp = explode('&', $temp[1]); $tmpl = $temp[0]; $sefstring .= '&tmpl=' . $tmpl; } if (preg_match('/&browse=/i', $string)) { $temp = explode('&browse=', $string); $temp = explode('&', $temp[1]); $browse = $temp[0]; $sefstring .= '&browse=' . $browse; } if (preg_match('/&from=/i', $string)) { $temp = explode('&from=', $string); $temp = explode('&', $temp[1]); $from = $temp[0]; $sefstring .= '&from=' . $from; } if (preg_match('/&status=/i', $string)) { $temp = explode('&status=', $string); $temp = explode('&', $temp[1]); $from = $temp[0]; $sefstring .= '&status=' . $from; } if (preg_match('/&blogId=/i', $string)) { $temp = explode('&blogId=', $string); $temp = explode('&', $temp[1]); $from = $temp[0]; $sefstring .= '&blogId=' . $from; } } $add_idname = true; if (preg_match('/&layout=/i', $string)) { $temp = explode('&layout=', $string); $temp = explode('&', $temp[1]); $layout = $temp[0]; if ($layout == 'statistic') { if (!empty($idname)) { $sefstring .= $idname . '/'; $add_idname = false; } $sefstring .= sefencode($layout) . '/'; if (preg_match('/&stat=/i', $string)) { $stat = sef_easyblog::getVarValue('stat', $string); $sefstring .= sefencode($stat) . '/'; } if (preg_match('/&catid=/i', $string)) { $catid = sef_easyblog::getVarValue('catid', $string); $sefstring .= EasyBlogRouter::getCategoryPermalink($catid) . '/'; } if (preg_match('/&tagid=/i', $string)) { $tagid = sef_easyblog::getVarValue('tagid', $string); $sefstring .= EasyBlogRouter::getTagPermalink($tagid) . '/'; } } else { $sefstring .= sefencode($layout) . '/'; } } if (preg_match('/&id=/i', $string) && $add_idname) { $sefstring .= $idname . '/'; } if (preg_match('/&blogid=/', $string)) { $temp = explode('&blogid=', $string); $temp = explode('&', $temp[1]); $blogid = $temp[0]; $sefstring .= 'blogid-' . $blogid . '/'; } if (preg_match('/&format=/i', $string)) { $temp = explode('&format=', $string); if ($temp[1] == 'rss') { $temp = explode('&', $temp[2]); } else { $temp = explode('&', $temp[1]); } $format = $temp[0]; $sefstring .= sefencode($format) . '/'; } if (preg_match('/&type=/i', $string)) { $temp = explode('&type=', $string); $temp = explode('&', $temp[1]); $type = $temp[0]; $sefstring .= sefencode($type) . '/'; } if (preg_match('/&limitstart=/i', $string)) { if (preg_match('/&limit=/i', $string)) { $temp = explode('&limit=', $string); $temp = explode('&', $temp[1]); $sefstring .= '/limit-' . $temp[0]; } // category pagination $temp = explode('&limitstart=', $string); $temp = explode('&', $temp[1]); if ($temp[0] != 0 || preg_match('/&limit=/i', $string)) { $sefstring .= '/limitstart-' . $temp[0]; } } return $sefstring; }
$language = JFactory::getLanguage(); $language->load('com_easyblog', JPATH_ROOT); // start by inserting the menu element title (just an idea, this is not required at all) $task = isset($task) ? @$task : null; $Itemid = isset($Itemid) ? @$Itemid : null; if (!empty($view) && file_exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'router.php')) { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php'; require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'router.php'; if (!empty($id)) { JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'tables'); switch ($view) { case 'entry': $idname = EasyBlogRouter::getBlogSefPermalink($id); break; case 'blogger': $idname = EasyBlogRouter::getBloggerPermalink($id); break; case 'categories': $idname = EasyBlogRouter::getCategoryPermalink($id); break; case 'tags': $idname = EasyBlogRouter::getTagPermalink($id); break; case 'teamblog': $idname = EasyBlogRouter::getTeamBlogPermalink($id); break; default: $idname = ''; } } if (empty($Itemid)) {
function EasyBlogBuildRoute(&$query) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $segments = array(); $config = EasyBlogHelper::getConfig(); if (isset($query['view']) && $query['view'] == 'entry' && isset($query['id'])) { if ($config->get('main_sef') != 'simple') { $segments[] = EasyBlogSEFTranslation::_($query['view']); } $segments[] = EasyBlogRouter::getBlogSefPermalink($query['id']); unset($query['id']); unset($query['view']); } if (isset($query['view']) && $query['view'] == 'categories' && isset($query['id'])) { $segments[] = EasyBlogSEFTranslation::_($query['view']); if ($config->get('main_sef') != 'simple') { if (isset($query['layout'])) { $segments[] = EasyBlogSEFTranslation::_($query['layout']); } } $segments[] = EasyBlogRouter::getCategoryPermalink($query['id']); unset($query['id']); unset($query['view']); unset($query['layout']); } if (isset($query['view']) && $query['view'] == 'tags' && isset($query['id']) && isset($query['layout'])) { $segments[] = EasyBlogSEFTranslation::_($query['view']); $segments[] = EasyBlogSEFTranslation::_($query['layout']); $segments[] = EasyBlogRouter::getTagPermalink($query['id']); unset($query['id']); unset($query['view']); unset($query['layout']); } if (isset($query['view']) && $query['view'] == 'teamblog' && isset($query['id'])) { $segments[] = EasyBlogSEFTranslation::_($query['view']); if (isset($query['layout'])) { if ($query['layout'] == "statistic") { $segments[] = EasyBlogRouter::getTeamBlogPermalink($query['id']); $segments[] = EasyBlogSEFTranslation::_($query['layout']); $segments[] = EasyBlogSEFTranslation::_($query['stat']); if ($query['stat'] == 'category') { $segments[] = EasyBlogRouter::getCategoryPermalink($query['catid']); unset($query['catid']); } if ($query['stat'] == 'tag') { $segments[] = EasyBlogRouter::getTagPermalink($query['tagid']); unset($query['tagid']); } } else { $segments[] = EasyBlogSEFTranslation::_($query['layout']); $segments[] = EasyBlogRouter::getTeamBlogPermalink($query['id']); } } else { $segments[] = EasyBlogRouter::getTeamBlogPermalink($query['id']); } unset($query['id']); unset($query['stat']); unset($query['layout']); unset($query['view']); } if (isset($query['view']) && $query['view'] == 'blogger' && isset($query['id'])) { $segments[] = EasyBlogSEFTranslation::_($query['view']); if (isset($query['layout'])) { if ($query['layout'] == "statistic") { $segments[] = EasyBlogRouter::getBloggerPermalink($query['id']); $segments[] = EasyBlogSEFTranslation::_($query['layout']); $segments[] = $query['stat']; if ($query['stat'] == 'category') { $segments[] = EasyBlogRouter::getCategoryPermalink($query['catid']); unset($query['catid']); } if ($query['stat'] == 'tag') { $segments[] = EasyBlogRouter::getTagPermalink($query['tagid']); unset($query['tagid']); } } else { $segments[] = EasyBlogSEFTranslation::_($query['layout']); $segments[] = EasyBlogRouter::getBloggerPermalink($query['id']); } } else { $segments[] = EasyBlogRouter::getBloggerPermalink($query['id']); } unset($query['id']); unset($query['stat']); unset($query['view']); unset($query['layout']); } if (isset($query['view']) && $query['view'] == 'dashboard' && isset($query['layout'])) { $segments[] = EasyBlogSEFTranslation::_($query['view']); $segments[] = EasyBlogSEFTranslation::_($query['layout']); if (isset($query['filter'])) { $segments[] = $query['filter']; unset($query['filter']); } if (isset($query['postType'])) { $segments[] = $query['postType']; unset($query['postType']); } unset($query['view']); unset($query['layout']); } /** * Route for archive links **/ if (isset($query['view']) && $query['view'] == 'archive') { $segments[] = EasyBlogSEFTranslation::_($query['view']); unset($query['view']); if (isset($query['layout'])) { $segments[] = $query['layout']; unset($query['layout']); } if (isset($query['archiveyear'])) { $segments[] = $query['archiveyear']; unset($query['archiveyear']); } if (isset($query['archivemonth'])) { $segments[] = $query['archivemonth']; unset($query['archivemonth']); } if (isset($query['archiveday'])) { $segments[] = $query['archiveday']; unset($query['archiveday']); } } if (isset($query['view']) && $query['view'] == 'search') { $segments[] = EasyBlogSEFTranslation::_($query['view']); unset($query['view']); if (isset($query['layout'])) { $segments[] = $query['layout']; unset($query['layout']); } if (isset($query['query'])) { $segments[] = $query['query']; unset($query['query']); } } if (isset($query['view']) && $query['view'] != 'images') { $segments[] = EasyBlogSEFTranslation::_($query['view']); unset($query['view']); } if (isset($query['type'])) { if (!isset($query['format']) && !isset($query['controller'])) { $segments[] = $query['type']; unset($query['type']); } } if (!isset($query['Itemid'])) { $query['Itemid'] = EasyBlogRouter::getItemId(); } return $segments; }