summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/common.php14
-rw-r--r--inc/html.php12
-rw-r--r--inc/pageutils.php39
3 files changed, 56 insertions, 9 deletions
diff --git a/inc/common.php b/inc/common.php
index 8cfe4eea8..84c6bded4 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -183,6 +183,9 @@ function idfilter($id,$ue=true){
/**
* This builds a link to a wikipage
*
+ * It handles URL rewriting and adds additional parameter if
+ * given in $more
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function wl($id='',$more='',$abs=false){
@@ -196,12 +199,15 @@ function wl($id='',$more='',$abs=false){
$xlink = DOKU_BASE;
}
- if(!$conf['userewrite']){
- $xlink .= DOKU_SCRIPT.'?id='.$id;
- if($more) $xlink .= '&amp;'.$more;
- }else{
+ if($conf['userewrite'] == 2){
+ $xlink .= DOKU_SCRIPT.'/'.$id;
+ if($more) $xlink .= '?'.$more;
+ }elseif($conf['userewrite']){
$xlink .= $id;
if($more) $xlink .= '?'.$more;
+ }else{
+ $xlink .= DOKU_SCRIPT.'?id='.$id;
+ if($more) $xlink .= '&amp;'.$more;
}
return $xlink;
diff --git a/inc/html.php b/inc/html.php
index 7e60cad34..3f6306dc1 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -186,14 +186,16 @@ function html_btn($name,$id,$akey,$params,$method='get'){
//filter id (without urlencoding)
$id = idfilter($id,false);
- //make nice URLs even for buttons
- if(!$conf['userewrite']){
+ //make nice URLs even for buttons
+ if($conf['userewrite'] == 2){
+ $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
+ }elseif($conf['userewrite']){
+ $script = DOKU_BASE.$id;
+ }else{
$script = DOKU_BASE.DOKU_SCRIPT;
$params['id'] = $id;
- }else{
- $script = DOKU_BASE.$id;
}
-
+
$ret .= '<form class="button" method="'.$method.'" action="'.$script.'" onsubmit="return svchk()">';
reset($params);
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 9a255ec2e..724514982 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -6,6 +6,45 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
+/**
+ * Fetch the pageid
+ *
+ * Uses either standard $_REQUEST variable or extracts it from
+ * the full request URI when userewrite is set to 2
+ *
+ * Returns $conf['start'] if no id was found.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function getID(){
+ global $conf;
+
+ $id = cleanID($_REQUEST['id']);
+
+ //construct page id from request URI
+ if(empty($id) && $conf['userewrite'] == 2){
+ //get the script URL
+ if($conf['basedir']){
+ $script = $conf['basedir'].DOKU_SCRIPT;
+ }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){
+ $script = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','',
+ $_SERVER['SCRIPT_FILENAME']);
+ $script = '/'.$script;
+ }else{
+ $script = $_SERVER['SCRIPT_NAME'];
+ }
+
+ //remove script URL and Querystring to gain the id
+ if(preg_match('/^'.preg_quote($script,'/').'(.*)/',
+ $_SERVER['REQUEST_URI'], $match)){
+ $id = preg_replace ('/\?.*/','',$match[1]);
+ }
+ $id = cleanID($id);
+ }
+ if(empty($id)) $id = $conf['start'];
+
+ return $id;
+}
/**
* Remove unwanted chars from ID