예제 #1
0
 /**
  * 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)
 {
     // $string == "index.php?option=com_example&Itemid=$Itemid&var1=$var1&var2=$var2"
     $sefstring = '';
     if (eregi('&var1=', $string)) {
         $temp = explode('&var1=', $string);
         $temp = explode('&', $temp[1]);
         $sefstring .= sefencode($temp[0]) . '/';
     }
     if (eregi('&var2=', $string)) {
         $temp = explode('&var2=', $string);
         $temp = explode('&', $temp[1]);
         $sefstring .= sefencode($temp[0]) . "/";
     }
     // $sefstring == "$var1/$var2/"
     return $sefstring;
 }
예제 #2
0
 /**
  * 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;
 }