summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorKlap-in <klapinklapin@gmail.com>2013-07-21 23:10:32 +0200
committerKlap-in <klapinklapin@gmail.com>2013-07-21 23:10:32 +0200
commitb1ffadaa6963bbf83e61917c31e04c04c421ce9e (patch)
treef9a1391d2ee6536473b1672e249c1b11a67a5b0e /inc/common.php
parentfa3ed26bfbafa4d05ec77a799259d4a46baadd9a (diff)
parentfbd8067eeeb9f424981aad8b283e17f734c738c3 (diff)
downloadrpg-b1ffadaa6963bbf83e61917c31e04c04c421ce9e.tar.gz
rpg-b1ffadaa6963bbf83e61917c31e04c04c421ce9e.tar.bz2
Merge remote-tracking branch 'origin/master' into fetchimagetokexternal
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php79
1 files changed, 56 insertions, 23 deletions
diff --git a/inc/common.php b/inc/common.php
index 59ceb0c0d..1b4d9e8e4 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -86,32 +86,20 @@ function formSecurityToken($print = true) {
}
/**
- * Return info about the current document as associative
- * array.
+ * Determine basic information for a request of $id
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @author Chris Smith <chris@jalakai.co.uk>
*/
-function pageinfo() {
- global $ID;
- global $REV;
- global $RANGE;
+function basicinfo($id, $htmlClient=true){
global $USERINFO;
- global $lang;
-
- // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml
- // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary
- $info['id'] = $ID;
- $info['rev'] = $REV;
// set info about manager/admin status.
$info['isadmin'] = false;
$info['ismanager'] = false;
if(isset($_SERVER['REMOTE_USER'])) {
- $sub = new Subscription();
-
$info['userinfo'] = $USERINFO;
- $info['perm'] = auth_quickaclcheck($ID);
- $info['subscribed'] = $sub->user_subscription();
+ $info['perm'] = auth_quickaclcheck($id);
$info['client'] = $_SERVER['REMOTE_USER'];
if($info['perm'] == AUTH_ADMIN) {
@@ -127,12 +115,46 @@ function pageinfo() {
}
} else {
- $info['perm'] = auth_aclcheck($ID, '', null);
- $info['subscribed'] = false;
+ $info['perm'] = auth_aclcheck($id, '', null);
$info['client'] = clientIP(true);
}
- $info['namespace'] = getNS($ID);
+ $info['namespace'] = getNS($id);
+
+ // mobile detection
+ if ($htmlClient) {
+ $info['ismobile'] = clientismobile();
+ }
+
+ return $info;
+ }
+
+/**
+ * Return info about the current document as associative
+ * array.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function pageinfo() {
+ global $ID;
+ global $REV;
+ global $RANGE;
+ global $lang;
+
+ $info = basicinfo($ID);
+
+ // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml
+ // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary
+ $info['id'] = $ID;
+ $info['rev'] = $REV;
+
+ if(isset($_SERVER['REMOTE_USER'])) {
+ $sub = new Subscription();
+ $info['subscribed'] = $sub->user_subscription();
+ } else {
+ $info['subscribed'] = false;
+ }
+
$info['locked'] = checklock($ID);
$info['filepath'] = fullpath(wikiFN($ID));
$info['exists'] = @file_exists($info['filepath']);
@@ -210,8 +232,18 @@ function pageinfo() {
}
}
- // mobile detection
- $info['ismobile'] = clientismobile();
+ return $info;
+}
+
+/**
+ * Return information about the current media item as an associative array.
+ */
+function mediainfo(){
+ global $NS;
+ global $IMG;
+
+ $info = basicinfo("$NS:*");
+ $info['image'] = $IMG;
return $info;
}
@@ -435,7 +467,7 @@ function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep =
*/
function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false) {
global $conf;
- $isexternalimage = preg_match('#^(https?|ftp)://#i', $id);
+ $isexternalimage = media_isexternal($id);
if(!$isexternalimage) {
$id = cleanID($id);
}
@@ -557,12 +589,13 @@ function checkwordblock($text = '') {
global $TEXT;
global $PRE;
global $SUF;
+ global $SUM;
global $conf;
global $INFO;
if(!$conf['usewordblock']) return false;
- if(!$text) $text = "$PRE $TEXT $SUF";
+ if(!$text) $text = "$PRE $TEXT $SUF $SUM";
// we prepare the text a tiny bit to prevent spammers circumventing URL checks
$text = preg_replace('!(\b)(www\.[\w.:?\-;,]+?\.[\w.:?\-;,]+?[\w/\#~:.?+=&%@\!\-.:?\-;,]+?)([.:?\-;,]*[^\w/\#~:.?+=&%@\!\-.:?\-;,])!i', '\1http://\2 \2\3', $text);