summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/cache.php2
-rw-r--r--inc/fulltext.php2
-rw-r--r--inc/html.php4
-rw-r--r--inc/indexer.php2
-rw-r--r--inc/pageutils.php33
-rw-r--r--inc/template.php2
6 files changed, 29 insertions, 16 deletions
diff --git a/inc/cache.php b/inc/cache.php
index 2c43da5ff..3c5dc058e 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -233,7 +233,7 @@ class cache_renderer extends cache_parser {
if (!empty($links)) {
foreach ($links as $id => $exists) {
- if ($exists != @file_exists(wikiFN($id,'',false))) return false;
+ if ($exists != page_exists($id,'',false)) return false;
}
}
}
diff --git a/inc/fulltext.php b/inc/fulltext.php
index fd83a8c05..3131b7433 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -170,7 +170,7 @@ function ft_pageLookup($id,$pageonly=true){
continue;
}
}
- if(!@file_exists(wikiFN($pages[$i]))){
+ if(!page_exists($pages[$i])){
unset($pages[$i]);
continue;
}
diff --git a/inc/html.php b/inc/html.php
index 74ec1cd64..3c7f8e2b1 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -446,9 +446,7 @@ function html_revisions($first=0){
foreach($revisions as $rev){
$date = date($conf['dformat'],$rev);
$info = getRevisionInfo($ID,$rev,true);
- $exists = @file_exists(wikiFN($ID,$rev));
-
-
+ $exists = page_exists($ID,$rev);
print ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
print '<div class="li">';
diff --git a/inc/indexer.php b/inc/indexer.php
index 54d57611a..0b4e60b13 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -523,7 +523,7 @@ function idx_parseIndexLine(&$page_idx,$line){
$doc = trim($page_idx[$doc]);
if(!$doc) continue;
// make sure the document still exists
- if(!@file_exists(wikiFN($doc,'',false))) continue;
+ if(!page_exists($doc,'',false)) continue;
$result[$doc] = $cnt;
}
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 4b4ad216c..4229c60cd 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -55,13 +55,13 @@ function getID($param='id',$clean=true){
// Namespace autolinking from URL
if(substr($id,-1) == ':' || ($conf['useslash'] && substr($id,-1) == '/')){
- if(@file_exists(wikiFN($id.$conf['start']))){
+ if(page_exists($id.$conf['start'])){
// start page inside namespace
$id = $id.$conf['start'];
- }elseif(@file_exists(wikiFN($id.noNS(cleanID($id))))){
+ }elseif(page_exists($id.noNS(cleanID($id)))){
// page named like the NS inside the NS
$id = $id.noNS(cleanID($id));
- }elseif(@file_exists(wikiFN($id))){
+ }elseif(page_exists($id)){
// page like namespace exists
$id = substr($id,0,-1);
}else{
@@ -188,11 +188,26 @@ function noNSorNS($id) {
}
/**
- * returns the full path to the datafile specified by ID and
- * optional revision
+ * Wiki page existence check
+ *
+ * parameters as for wikiFN
+ *
+ * @author Chris Smith <chris@jalakai.co.uk>
+ */
+function page_exists($id,$rev='',$clean=true) {
+ return @file_exists(wikiFN($id,$rev,$clean));
+}
+
+/**
+ * returns the full path to the datafile specified by ID and optional revision
*
* The filename is URL encoded to protect Unicode chars
*
+ * @param $raw_id string id of wikipage
+ * @param $rev string page revision, empty string for current
+ * @param $clean bool flag indicating that $raw_id should be cleaned. Only set to false
+ * when $id is guaranteed to have been cleaned already.
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function wikiFN($raw_id,$rev='',$clean=true){
@@ -394,15 +409,15 @@ function resolve_pageid($ns,&$page,&$exists){
// if ends with colon or slash we have a namespace link
if(substr($page,-1) == ':' || ($conf['useslash'] && substr($page,-1) == '/')){
- if(@file_exists(wikiFN($page.$conf['start']))){
+ if(page_exists($page.$conf['start'])){
// start page inside namespace
$page = $page.$conf['start'];
$exists = true;
- }elseif(@file_exists(wikiFN($page.noNS(cleanID($page))))){
+ }elseif(page_exists($page.noNS(cleanID($page)))){
// page named like the NS inside the NS
$page = $page.noNS(cleanID($page));
$exists = true;
- }elseif(@file_exists(wikiFN($page))){
+ }elseif(page_exists($page)){
// page like namespace exists
$page = $page;
$exists = true;
@@ -419,7 +434,7 @@ function resolve_pageid($ns,&$page,&$exists){
}else{
$try = $page.'s';
}
- if(@file_exists(wikiFN($try))){
+ if(page_exists($try)){
$page = $try;
$exists = true;
}
diff --git a/inc/template.php b/inc/template.php
index 5879d98db..d84aad8db 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -812,7 +812,7 @@ function tpl_youarehere($sep=' &raquo; '){
$page = $part.$parts[$i];
if($page == $conf['start']) return;
echo $sep;
- if(@file_exists(wikiFN($page))){
+ if(page_exists($page)){
$title = p_get_first_heading($page);
if(!$title) $title = $parts[$i];
tpl_link(wl($page),hsc($title),'title="'.$page.'"');