de wrote:
Predator wrote:
Where are the limits? The first 3 POints can be done with an sef_ext.php last point have to check.
Any documentation/secification available?
As far as I know the sef_ext.php was introduced with SEF Advanced and it is also implemented by 404 SEF (for example)... I did not hear any complains about the implementation of it in 404 SEF but know that it was not really possible with it... For example when I set to use a ".html" extension that this extension was added always. The other limitiation seemed true there too.
Depends where you set the extensions, so it's upto how the sef_ext.php is made, you can create the links as you like the limit is the coding skill.
Here a quick sef_ext.php is did for DOCMan is not perfect and can befinetuned, but as a hint URl will be created directly without forced to store in a database.
I'm currently working on a port of OpenSEF to Joomla! 1.1 which will give me more ideas to rework the Advanced SEF, as you suggested for multisites ;)
Code:
class sef_docman {
/**
* Creates the SEF advance URL out of the Joomla! request
**/
function create ($string) {
global $database, $sefConfig, $sufix,$longurl;
if (empty($sefConfig)) {
$ext_suffix = $sufix;
$ext_url = $longurl;
} else {
$ext_suffix = $sefConfig->encode_page_suffix;
$ext_url = $sefConfig->category_title_field;
}
$sefstring ='';
$string = str_replace( '&', '&', $string );
if (eregi("&task=doc_details",$string) ||
eregi("&task=doc_edit",$string) ||
eregi("&task=doc_checkout",$string) ||
eregi("&task=doc_checkin",$string) ||
eregi("&task=doc_reset",$string) ||
eregi("&task=doc_move",$string) ||
eregi("&task=doc_delete",$string) ||
eregi("&task=doc_update",$string) ||
eregi("&task=doc_unpublish",$string) ||
eregi("&task=doc_publish",$string) &&
eregi("&gid=",$string)) {
if (eregi("&task=",$string)) {
$temp = split("&task=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
}
if (eregi("&gid=",$string)) {
$temp = split("&gid=", $string);
$temp = split("&", $temp[1]);
$database->setQuery("SELECT dmname FROM #__docman WHERE id=".$temp[0]);
$sefstring .= docman_sefencode($database->loadResult());
}
return $sefstring.$ext_suffix;
} elseif (eregi("&task=upload",$string) OR eregi("&task=search_form",$string)) {
$temp = split("&task=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
return $sefstring;
} elseif (eregi("&task=license_result",$string) && eregi("&gid=",$string)) {
$temp = split("&task=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
$temp = split("&gid=", $string);
$temp = split("&", $temp[1]);
$database->setQuery("SELECT dmname FROM #__docman WHERE id=".$temp[0]);
$sefstring .= docman_sefencode($database->loadResult())."/";
$temp = split("&bid=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
return $sefstring;
} elseif (eregi("&task=doc_download",$string)) {
$temp = split("\?option=com_docman", $string);
$temp = split('&', $temp[1]);
foreach($temp as $key => $value) {
$sefstring .= $value.'/';
}
$string = str_replace( '=', ',', $sefstring );
return $string;
}
elseif (eregi("&gid=",$string)) {
$temp = split("&gid=", $string);
$temp = split("&", $temp[1]);
$database->setQuery("SELECT $ext_url FROM #__categories WHERE id=".$temp[0]);
$sefstring .= docman_sefencode($database->loadResult());
return $sefstring.$ext_suffix;
}
}
/**
* Reverts to the Joomla query string out of the SEF advance URL
**/
function revert ($url_array, $pos) {
// define all variables you pass as globals
global $database, $sefConfig, $longurl;
if (empty($sefConfig)) {
$ext_url = $longurl;
} else {
$ext_url = $sefConfig->category_title_field;
}
// Examine the SEF advance URL and extract the variables building the query string
$QUERY_STRING = "";
$database->setQuery("SELECT id "
."FROM #__menu "
."WHERE link='index.php?option=com_docman'");
$Itemid = $database->loadResult();
$_GET['Itemid'] = $Itemid;
$_REQUEST['Itemid'] = $Itemid;
$QUERY_STRING .= "option=com_docman&Itemid=$Itemid";
$pos=0;
if (isset($url_array[$pos+2]) && $url_array[$pos+2] !="" &&
($url_array[$pos+2] == "search_form" ||
$url_array[$pos+2] == "upload")) {
$task = $url_array[$pos+2];
$_GET['task'] = $task;
$_REQUEST['task'] = $task;
$QUERY_STRING .= "&task=$task";
return $QUERY_STRING;
}
elseif (isset($url_array[$pos+2]) && $url_array[$pos+2] !="" &&
($url_array[$pos+2] == "task,doc_download")) {
$temp = explode(',', $url_array[2]);
$task = $temp[1];
$_GET['task'] = $task;
$_REQUEST['task'] = $task;
$temp2 = explode(',', $url_array[3]);
$gid = $temp2[1];
$_GET['gid'] = $gid;
$_REQUEST['gid'] = $gid;
$QUERY_STRING .= "&task=$task&gid=$gid";
return $QUERY_STRING;
}
elseif (isset($url_array[$pos+2]) && $url_array[$pos+2] !="" &&
($url_array[$pos+2] == "license_result")) {
$task = $url_array[$pos+2];
$_GET['task'] = $task;
$_REQUEST['task'] = $task;
$dmname = docman_sefdecode($url_array[$pos+3]);
$database->setQuery("SELECT id "
."FROM #__docman "
."WHERE dmname='$dmname'");
$gid = $database->loadResult();
$_GET['gid'] = $gid;
$_REQUEST['gid'] = $gid;
$bid = $url_array[$pos+4];
$_GET['bid'] = $bid;
$_REQUEST['bid'] = $bid;
$QUERY_STRING .= "&task=$task&gid=$gid&Itemid=$Itemid&bid=$bid";
return $QUERY_STRING;
}
elseif (isset($url_array[$pos+2]) && $url_array[$pos+2] !="" &&
($url_array[$pos+2] == "doc_details" ||
$url_array[$pos+2] == "doc_edit" ||
$url_array[$pos+2] == "doc_checkout" ||
$url_array[$pos+2] == "doc_checkin" ||
$url_array[$pos+2] == "doc_reset" ||
$url_array[$pos+2] == "doc_move" ||
$url_array[$pos+2] == "doc_delete" ||
$url_array[$pos+2] == "doc_update" ||
$url_array[$pos+2] == "doc_unpublish" ||
$url_array[$pos+2] == "doc_publish")) {
$dmname = docman_sefdecode($url_array[$pos+3]);
$database->setQuery("SELECT id "
."FROM #__docman "
."WHERE dmname='$dmname'");
$gid = $database->loadResult();
$task = $url_array[$pos+2];
$_GET['task'] = $task;
$_REQUEST['task'] = $task;
$QUERY_STRING .= "&task=$task";
$_GET['gid'] = $gid;
$_REQUEST['gid'] = $gid;
$QUERY_STRING .= "&task=$task&gid=$gid";
return $QUERY_STRING;
}
elseif (isset($url_array[$pos+2]) && $url_array[$pos+2]!="" ) {
$catname = docman_sefdecode($url_array[$pos+2]);
$database->setQuery("SELECT id "
."FROM #__categories "
."WHERE $ext_url='$catname'");
$gid = $database->loadResult();
$_GET['gid'] = $gid;
$_REQUEST['gid'] = $gid;
$QUERY_STRING .= "&gid=$gid";
return $QUERY_STRING;
}
}
}
/**
* Get new string with new space filler etc...
*
* @param string $string
* @return encoded string
*/
function docman_sefencode($string) {
global $sefConfig, $sufix, $lowercase,$url_exception;
if (empty($sefConfig)) {
$ext_suffix = $sufix;
$ext_space = _SEF_SPACE;
$ext_lower = $lowercase;
$ext_strip = $url_exception;
} else {
$ext_suffix = $sefConfig->encode_page_suffix;
$ext_space = $sefConfig->encode_space_char;
$ext_lower = $sefConfig->encode_lowercase;
$ext_strip = array($sefConfig->encode_strip_chars);
}
$string = urlencode($string);
$string = eregi_replace("%2F", "%10", $string);
$string = eregi_replace($ext_space, "%11", $string);
$string = eregi_replace("\+", $ext_space, $string);
foreach ($ext_strip as $value) {
$string = ereg_replace(urlencode($value), $value, $string);
}
if ($ext_lower) {
$string = strtolower($string);
}
return $string;
}
/**
* Get back to original string
*
* @param string $string
* @return decoded string
*/
function docman_sefdecode($string) {
global $sefConfig, $sufix;
if (empty($sefConfig)) {
$ext_suffix = $sufix;
$ext_space = _SEF_SPACE;
} else {
$ext_suffix = $sefConfig->encode_page_suffix;
$ext_space = $sefConfig->encode_space_char;
}
$string = eregi_replace($ext_suffix, "", $string);
$string = eregi_replace($ext_space, "%20", $string);
$string = eregi_replace("%11", $ext_space, $string);
$string = eregi_replace("%10", "%2F", $string);
$string = urldecode($string);
$string = addslashes($string);
return $string;
}
_________________
The "Humor, Fun and Games" forum has more than 2500 Posts, so why not build a "Humor, Fun and Games Working" Group?
.....
Malicious tongues say we have this WG right from the start, they call it core team
