summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.htaccess.dist1
-rw-r--r--inc/common.php37
-rw-r--r--inc/template.php4
3 files changed, 40 insertions, 2 deletions
diff --git a/.htaccess.dist b/.htaccess.dist
index 77a4b9579..268144d8a 100644
--- a/.htaccess.dist
+++ b/.htaccess.dist
@@ -16,6 +16,7 @@
#RewriteEngine on
#RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L]
#RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L]
+#RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L]
#RewriteRule ^$ doku.php [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
diff --git a/inc/common.php b/inc/common.php
index 8af63002c..ca05bd3e7 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -315,6 +315,43 @@ function wl($id='',$more='',$abs=false,$sep='&'){
}
/**
+ * This builds a link to an alternate page format
+ *
+ * Handles URL rewriting if enabled. Follows the style of wl().
+ *
+ * @author Ben Coburn <btcoburn@silicodon.net>
+ */
+function exportlink($id='',$format='raw',$more='',$abs=false,$sep='&amp;'){
+ global $conf;
+ if(is_array($more)){
+ $more = buildURLparams($more,$sep);
+ }else{
+ $more = str_replace(',',$sep,$more);
+ }
+
+ $format = rawurlencode($format);
+ $id = idfilter($id);
+ if($abs){
+ $xlink = DOKU_URL;
+ }else{
+ $xlink = DOKU_BASE;
+ }
+
+ if($conf['userewrite'] == 2){
+ $xlink .= DOKU_SCRIPT.'/'.$id.'?do=export_'.$format;
+ if($more) $xlink .= $sep.$more;
+ }elseif($conf['userewrite'] == 1){
+ $xlink .= '_export/'.$format.'/'.$id;
+ if($more) $xlink .= '?'.$more;
+ }else{
+ $xlink .= DOKU_SCRIPT.'?do=export_'.$format.$sep.'id='.$id;
+ if($more) $xlink .= $sep.$more;
+ }
+
+ return $xlink;
+}
+
+/**
* Build a link to a media file
*
* Will return a link to the detail page if $direct is false
diff --git a/inc/template.php b/inc/template.php
index bda0a7e4b..c1848dd79 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -161,8 +161,8 @@ function tpl_metaheaders($alt=true){
if($alt){
ptln('<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="'.DOKU_BASE.'feed.php" />',$it);
ptln('<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="'.DOKU_BASE.'feed.php?mode=list&amp;ns='.$INFO['namespace'].'" />',$it);
- ptln('<link rel="alternate" type="text/html" title="Plain HTML" href="'.wl($ID,'do=export_xhtml').'" />',$it);
- ptln('<link rel="alternate" type="text/plain" title="Wiki Markup" href="'.wl($ID, 'do=export_raw').'" />',$it);
+ ptln('<link rel="alternate" type="text/html" title="Plain HTML" href="'.exportlink($ID, 'xhtml').'" />',$it);
+ ptln('<link rel="alternate" type="text/plain" title="Wiki Markup" href="'.exportlink($ID, 'raw').'" />',$it);
}
// setup robot tags apropriate for different modes