summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php59
1 files changed, 33 insertions, 26 deletions
diff --git a/inc/common.php b/inc/common.php
index 8c9956018..2c9359a0c 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -49,7 +49,7 @@ function ptln($string, $indent = 0) {
*
* @author Andreas Gohr <andi@splitbrain.org>
*
- * @param $string string being stripped
+ * @param string $string being stripped
* @return string
*/
function stripctl($string) {
@@ -62,6 +62,7 @@ function stripctl($string) {
* @author Andreas Gohr <andi@splitbrain.org>
* @link http://en.wikipedia.org/wiki/Cross-site_request_forgery
* @link http://christ1an.blogspot.com/2007/04/preventing-csrf-efficiently.html
+ *
* @return string
*/
function getSecurityToken() {
@@ -95,7 +96,7 @@ function checkSecurityToken($token = null) {
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param bool $print if true print the field, otherwise html of the field is returned
- * @return void|string html of hidden form field
+ * @return string html of hidden form field
*/
function formSecurityToken($print = true) {
$ret = '<div class="no"><input type="hidden" name="sectok" value="'.getSecurityToken().'" /></div>'."\n";
@@ -120,6 +121,7 @@ function basicinfo($id, $htmlClient=true){
global $INPUT;
// set info about manager/admin status.
+ $info = array();
$info['isadmin'] = false;
$info['ismanager'] = false;
if($INPUT->server->has('REMOTE_USER')) {
@@ -335,7 +337,7 @@ function buildAttributes($params, $skipempty = false) {
*
* @author Andreas Gohr <andi@splitbrain.org>
*
- * @return array(pageid=>name, ... )
+ * @return string[] with the data: array(pageid=>name, ... )
*/
function breadcrumbs() {
// we prepare the breadcrumbs early for quick session closing
@@ -438,6 +440,8 @@ function idfilter($id, $ue = true) {
function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&amp;') {
global $conf;
if(is_array($urlParameters)) {
+ if(isset($urlParameters['rev']) && !$urlParameters['rev']) unset($urlParameters['rev']);
+ if(isset($urlParameters['at']) && $conf['date_at_format']) $urlParameters['at'] = date($conf['date_at_format'],$urlParameters['at']);
$urlParameters = buildURLparams($urlParameters, $separator);
} else {
$urlParameters = str_replace(',', $separator, $urlParameters);
@@ -544,6 +548,7 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
if(empty($more['w'])) unset($more['w']);
if(empty($more['h'])) unset($more['h']);
if(isset($more['id']) && $direct) unset($more['id']);
+ if(isset($more['rev']) && !$more['rev']) unset($more['rev']);
$more = buildURLparams($more, $sep);
} else {
$matches = array();
@@ -685,6 +690,7 @@ function checkwordblock($text = '') {
}
if(count($re) && preg_match('#('.join('|', $re).')#si', $text, $matches)) {
// prepare event data
+ $data = array();
$data['matches'] = $matches;
$data['userinfo']['ip'] = $INPUT->server->str('REMOTE_ADDR');
if($INPUT->server->str('REMOTE_USER')) {
@@ -968,7 +974,7 @@ function rawLocale($id, $ext = 'txt') {
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string $id page id
- * @param string $rev timestamp when a revision of wikitext is desired
+ * @param string|int $rev timestamp when a revision of wikitext is desired
* @return string
*/
function rawWiki($id, $rev = '') {
@@ -1108,7 +1114,7 @@ function parsePageTemplate(&$data) {
* @param string $range in form "from-to"
* @param string $id page id
* @param string $rev optional, the revision timestamp
- * @return array with three slices
+ * @return string[] with three slices
*/
function rawWikiSlices($range, $id, $rev = '') {
$text = io_readWikiPage(wikiFN($id, $rev), $id, $rev);
@@ -1119,6 +1125,7 @@ function rawWikiSlices($range, $id, $rev = '') {
$from = !$from ? 0 : ($from - 1);
$to = !$to ? strlen($text) : ($to - 1);
+ $slices = array();
$slices[0] = substr($text, 0, $from);
$slices[1] = substr($text, $from, $to - $from);
$slices[2] = substr($text, $to);
@@ -1293,7 +1300,7 @@ function saveOldRevision($id) {
* @param int|string $rev Old page revision
* @param string $summary What changed
* @param boolean $minor Is this a minor edit?
- * @param array $replace Additional string substitutions, @KEY@ to be replaced by value
+ * @param string[] $replace Additional string substitutions, @KEY@ to be replaced by value
* @return bool
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -1373,8 +1380,8 @@ function getGoogleQuery() {
/**
* Return the human readable size of a file
*
- * @param int $size A file size
- * @param int $dec A number of decimal places
+ * @param int $size A file size
+ * @param int $dec A number of decimal places
* @return string human readable size
*
* @author Martin Benjamin <b.martin@cybernet.ch>
@@ -1457,7 +1464,7 @@ function dformat($dt = null, $format = '') {
* @author <ungu at terong dot com>
* @link http://www.php.net/manual/en/function.date.php#54072
*
- * @param int $int_date: current date in UNIX timestamp
+ * @param int $int_date current date in UNIX timestamp
* @return string
*/
function date_iso8601($int_date) {
@@ -1583,7 +1590,7 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') {
}
/**
- * Return the users realname or e-mail address for use
+ * Return the users real name or e-mail address for use
* in page footer and recent changes pages
*
* @param string|null $username or null when currently logged-in user should be used
@@ -1641,22 +1648,20 @@ function userlink($username = null, $textonly = false) {
$evt = new Doku_Event('COMMON_USER_LINK', $data);
if($evt->advise_before(true)) {
if(empty($data['name'])) {
- if($conf['showuseras'] == 'loginname') {
- $data['name'] = $textonly ? $data['username'] : hsc($data['username']);
- } else {
- if($auth) $info = $auth->getUserData($username);
- if(isset($info) && $info) {
- switch($conf['showuseras']) {
- case 'username':
- case 'username_link':
- $data['name'] = $textonly ? $info['name'] : hsc($info['name']);
- break;
- case 'email':
- case 'email_link':
- $data['name'] = obfuscate($info['mail']);
- break;
- }
+ if($auth) $info = $auth->getUserData($username);
+ if($conf['showuseras'] != 'loginname' && isset($info) && $info) {
+ switch($conf['showuseras']) {
+ case 'username':
+ case 'username_link':
+ $data['name'] = $textonly ? $info['name'] : hsc($info['name']);
+ break;
+ case 'email':
+ case 'email_link':
+ $data['name'] = obfuscate($info['mail']);
+ break;
}
+ } else {
+ $data['name'] = $textonly ? $data['username'] : hsc($data['username']);
}
}
@@ -1823,6 +1828,8 @@ function send_redirect($url) {
} else {
header('Location: '.$url);
}
+
+ if(defined('DOKU_UNITTEST')) return; // no exits during unit tests
exit;
}
@@ -1913,7 +1920,7 @@ function set_doku_pref($pref, $val) {
/**
* Strips source mapping declarations from given text #601
*
- * @param &string $text reference to the CSS or JavaScript code to clean
+ * @param string &$text reference to the CSS or JavaScript code to clean
*/
function stripsourcemaps(&$text){
$text = preg_replace('/^(\/\/|\/\*)[@#]\s+sourceMappingURL=.*?(\*\/)?$/im', '\\1\\2', $text);