summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-08-14 12:18:34 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-08-14 12:18:34 +0200
commit6de3759a1b7a74492845c76e1f0bd1078e2220c7 (patch)
tree96975cbac21a72f29934013e1e6bd6f4711f60d7 /inc/common.php
parent706882dcf32358de6c9300ced7b5fcfa9ba28771 (diff)
downloadrpg-6de3759a1b7a74492845c76e1f0bd1078e2220c7.tar.gz
rpg-6de3759a1b7a74492845c76e1f0bd1078e2220c7.tar.bz2
URL rewriting for media files
This patch adds nicer URLs for media files (for fetch.php and detail.php) !IMPORTANT! Users of rewrite mode 1 need to adjust their .htaccess See .htaccess.dist for an example darcs-hash:20050814101834-7ad00-37ef1dea00affc9d808d9ee1289fa7454199cd24.gz
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php68
1 files changed, 67 insertions, 1 deletions
diff --git a/inc/common.php b/inc/common.php
index b0d7c4c10..891601357 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -238,7 +238,11 @@ function idfilter($id,$ue=true){
*/
function wl($id='',$more='',$abs=false){
global $conf;
- $more = str_replace(',','&amp;',$more);
+ if(is_array($more)){
+ $more = buildURLparams($more);
+ }else{
+ $more = str_replace(',','&amp;',$more);
+ }
$id = idfilter($id);
if($abs){
@@ -262,6 +266,68 @@ function wl($id='',$more='',$abs=false){
}
/**
+ * Build a link to a media file
+ *
+ * Will return a link to the detail page if $direct is false
+ */
+function ml($id='',$more='',$direct=true){
+ global $conf;
+ if(is_array($more)){
+ $more = buildURLparams($more);
+ }else{
+ $more = str_replace(',','&amp;',$more);
+ }
+
+ $xlink = DOKU_BASE;
+
+ // external URLs are always direct without rewriting
+ if(preg_match('#^(https?|ftp)://#i',$id)){
+ $xlink .= 'lib/exe/fetch.php';
+ if($more){
+ $xlink .= '?'.$more;
+ $xlink .= '&amp;media='.$id;
+ }else{
+ $xlink .= '?media='.$id;
+ }
+ return $xlink;
+ }
+
+ $id = idfilter($id);
+
+ // decide on scriptname
+ if($direct){
+ if($conf['userewrite'] == 1){
+ $script = '_media';
+ }else{
+ $script = 'lib/exe/fetch.php';
+ }
+ }else{
+ if($conf['userewrite'] == 1){
+ $script = '_detail';
+ }else{
+ $script = 'lib/exe/detail.php';
+ }
+ }
+
+ // build URL based on rewrite mode
+ if($conf['userewrite']){
+ $xlink .= $script.'/'.$id;
+ if($more) $xlink .= '?'.$more;
+ }else{
+ if($more){
+ $xlink .= '?'.$more;
+ $xlink .= '&amp;media='.$id;
+ }else{
+ $xlink .= '?media='.$id;
+ }
+ }
+
+ return $xlink;
+}
+
+
+
+/**
* Just builds a link to a script
*
* @todo maybe obsolete