summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2014-05-26 20:44:02 +0200
committerGerrit Uitslag <klapinklapin@gmail.com>2014-05-26 20:44:02 +0200
commite5e6f447ba17ba51957a1228e55fe53d8087776a (patch)
treef59213d66fcb910725f8fd34def06e89d88e5241 /inc
parentb66e5840006078112b8da741b2c612e446afd452 (diff)
parent8f2758f6b53b11db38d83ea9ad838ed802a6e635 (diff)
downloadrpg-e5e6f447ba17ba51957a1228e55fe53d8087776a.tar.gz
rpg-e5e6f447ba17ba51957a1228e55fe53d8087776a.tar.bz2
Merge remote-tracking branch 'origin/master' into trailingcolons
Conflicts: inc/lang/cs/lang.php inc/lang/hu/lang.php
Diffstat (limited to 'inc')
-rw-r--r--inc/HTTPClient.php11
-rw-r--r--inc/cache.php1
-rw-r--r--inc/changelog.php47
-rw-r--r--inc/common.php168
-rw-r--r--inc/form.php10
-rw-r--r--inc/lang/cs/lang.php6
-rw-r--r--inc/lang/en/lang.php1
-rw-r--r--inc/lang/fr/lang.php19
-rw-r--r--inc/lang/hu/lang.php9
-rw-r--r--inc/lang/nl/lang.php1
-rw-r--r--inc/pageutils.php73
-rw-r--r--inc/parser/code.php12
-rw-r--r--inc/parser/metadata.php575
-rw-r--r--inc/parser/parser.php5
-rw-r--r--inc/parser/renderer.php765
-rw-r--r--inc/parser/xhtml.php1040
-rw-r--r--inc/subscription.php8
17 files changed, 2023 insertions, 728 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index f8b836753..4352bcb97 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -61,6 +61,9 @@ class DokuHTTPClient extends HTTPClient {
}
+/**
+ * Class HTTPClientException
+ */
class HTTPClientException extends Exception { }
/**
@@ -249,7 +252,6 @@ class HTTPClient {
if (empty($port)) $port = 8080;
}else{
$request_url = $path;
- $server = $server;
if (!isset($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80;
}
@@ -280,7 +282,6 @@ class HTTPClient {
}
}
$headers['Content-Length'] = strlen($data);
- $rmethod = 'POST';
}elseif($method == 'GET'){
$data = ''; //no data allowed on GET requests
}
@@ -343,7 +344,7 @@ class HTTPClient {
try {
//set non-blocking
- stream_set_blocking($socket, false);
+ stream_set_blocking($socket, 0);
// build request
$request = "$method $request_url HTTP/".$this->http.HTTP_NL;
@@ -458,7 +459,7 @@ class HTTPClient {
if ($chunk_size > 0) {
$r_body .= $this->_readData($socket, $chunk_size, 'chunk');
- $byte = $this->_readData($socket, 2, 'chunk'); // read trailing \r\n
+ $this->_readData($socket, 2, 'chunk'); // read trailing \r\n
}
} while ($chunk_size && !$abort);
}elseif(isset($this->resp_headers['content-length']) && !isset($this->resp_headers['transfer-encoding'])){
@@ -480,7 +481,6 @@ class HTTPClient {
$r_body = $this->_readData($socket, $this->max_bodysize, 'response (content-length limited)', true);
}else{
// read entire socket
- $r_size = 0;
while (!feof($socket)) {
$r_body .= $this->_readData($socket, 4096, 'response (unlimited)', true);
}
@@ -509,7 +509,6 @@ class HTTPClient {
if (!$this->keep_alive ||
(isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')) {
// close socket
- $status = socket_get_status($socket);
fclose($socket);
unset(self::$connections[$connectionId]);
}
diff --git a/inc/cache.php b/inc/cache.php
index 7a66049f4..6817e771b 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -178,6 +178,7 @@ class cache_parser extends cache {
public $file = ''; // source file for cache
public $mode = ''; // input mode (represents the processing the input file will undergo)
+ public $page = '';
var $_event = 'PARSER_CACHE_USE';
diff --git a/inc/changelog.php b/inc/changelog.php
index f0788d896..8c14f21b0 100644
--- a/inc/changelog.php
+++ b/inc/changelog.php
@@ -18,6 +18,9 @@ define('DOKU_CHANGE_TYPE_REVERT', 'R');
* parses a changelog line into it's components
*
* @author Ben Coburn <btcoburn@silicodon.net>
+ *
+ * @param string $line changelog line
+ * @return array|bool parsed line or false
*/
function parseChangelogLine($line) {
$tmp = explode("\t", $line);
@@ -43,7 +46,7 @@ function parseChangelogLine($line) {
* @param String $summary Summary of the change
* @param mixed $extra In case of a revert the revision (timestmp) of the reverted page
* @param array $flags Additional flags in a key value array.
- * Availible flags:
+ * Available flags:
* - ExternalEdit - mark as an external edit.
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -116,6 +119,15 @@ function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extr
* @author Andreas Gohr <andi@splitbrain.org>
* @author Esther Brunner <wikidesign@gmail.com>
* @author Ben Coburn <btcoburn@silicodon.net>
+ *
+ * @param int $date Timestamp of the change
+ * @param String $id Name of the affected page
+ * @param String $type Type of the change see DOKU_CHANGE_TYPE_*
+ * @param String $summary Summary of the change
+ * @param mixed $extra In case of a revert the revision (timestmp) of the reverted page
+ * @param array $flags Additional flags in a key value array.
+ * Available flags:
+ * - (none, so far)
*/
function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extra='', $flags=null){
global $conf;
@@ -294,6 +306,12 @@ function getRecentsSince($from,$to=null,$ns='',$flags=0){
* @see getRecents()
* @author Andreas Gohr <andi@splitbrain.org>
* @author Ben Coburn <btcoburn@silicodon.net>
+ *
+ * @param string $line changelog line
+ * @param string $ns restrict to given namespace
+ * @param int $flags flags to control which changes are included
+ * @param array $seen listing of seen pages
+ * @return array|bool false or array with info about a change
*/
function _handleRecent($line,$ns,$flags,&$seen){
if(empty($line)) return false; //skip empty lines
@@ -778,9 +796,9 @@ abstract class ChangeLog {
* Read chunk and return array with lines of given chunck.
* Has no check if $head and $tail are really at a new line
*
- * @param $fp resource filepointer
- * @param $head int start point chunck
- * @param $tail int end point chunck
+ * @param resource $fp resource filepointer
+ * @param int $head start point chunck
+ * @param int $tail end point chunck
* @return array lines read from chunck
*/
protected function readChunk($fp, $head, $tail) {
@@ -804,8 +822,8 @@ abstract class ChangeLog {
/**
* Set pointer to first new line after $finger and return its position
*
- * @param resource $fp filepointer
- * @param $finger int a pointer
+ * @param resource $fp filepointer
+ * @param int $finger a pointer
* @return int pointer
*/
protected function getNewlinepointer($fp, $finger) {
@@ -886,7 +904,7 @@ abstract class ChangeLog {
*/
protected function retrieveRevisionsAround($rev, $max) {
//get lines from changelog
- list($fp, $lines, $starthead, $starttail, $eof) = $this->readloglines($rev);
+ list($fp, $lines, $starthead, $starttail, /* $eof */) = $this->readloglines($rev);
if(empty($lines)) return false;
//parse chunk containing $rev, and read forward more chunks until $max/2 is reached
@@ -1010,7 +1028,7 @@ class MediaChangelog extends ChangeLog {
* @author Kate Arzamastseva <pshns@ukr.net>
*/
function getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false) {
- dbg_deprecated('class PageChangeLog or class MediaChanglog');
+ dbg_deprecated('class PageChangeLog or class MediaChangelog');
if($media) {
$changelog = new MediaChangeLog($id, $chunk_size);
} else {
@@ -1025,10 +1043,6 @@ function getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false) {
* only that a line with the date exists in the changelog.
* By default the current revision is skipped.
*
- * id: the page of interest
- * first: skip the first n changelog lines
- * num: number of revisions to return
- *
* The current revision is automatically skipped when the page exists.
* See $INFO['meta']['last_change'] for the current revision.
*
@@ -1041,9 +1055,16 @@ function getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false) {
*
* @author Ben Coburn <btcoburn@silicodon.net>
* @author Kate Arzamastseva <pshns@ukr.net>
+ *
+ * @param string $id the page of interest
+ * @param int $first skip the first n changelog lines
+ * @param int $num number of revisions to return
+ * @param int $chunk_size
+ * @param bool $media
+ * @return array
*/
function getRevisions($id, $first, $num, $chunk_size = 8192, $media = false) {
- dbg_deprecated('class PageChangeLog or class MediaChanglog');
+ dbg_deprecated('class PageChangeLog or class MediaChangelog');
if($media) {
$changelog = new MediaChangeLog($id, $chunk_size);
} else {
diff --git a/inc/common.php b/inc/common.php
index 84121fd43..0fe33c5b1 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -22,6 +22,9 @@ define('RECENTS_MEDIA_PAGES_MIXED', 32);
*
* @author Andreas Gohr <andi@splitbrain.org>
* @see htmlspecialchars()
+ *
+ * @param string $string the string being converted
+ * @return string converted string
*/
function hsc($string) {
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
@@ -33,6 +36,9 @@ function hsc($string) {
* You can give an indention as optional parameter
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $string line of text
+ * @param int $indent number of spaces indention
*/
function ptln($string, $indent = 0) {
echo str_repeat(' ', $indent)."$string\n";
@@ -42,6 +48,9 @@ function ptln($string, $indent = 0) {
* strips control characters (<32) from the given string
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param $string string being stripped
+ * @return string
*/
function stripctl($string) {
return preg_replace('/[\x00-\x1F]+/s', '', $string);
@@ -63,6 +72,9 @@ function getSecurityToken() {
/**
* Check the secret CSRF token
+ *
+ * @param null|string $token security token or null to read it from request variable
+ * @return bool success if the token matched
*/
function checkSecurityToken($token = null) {
/** @var Input $INPUT */
@@ -81,6 +93,9 @@ function checkSecurityToken($token = null) {
* Print a hidden form field with a secret CSRF token
*
* @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
*/
function formSecurityToken($print = true) {
$ret = '<div class="no"><input type="hidden" name="sectok" value="'.getSecurityToken().'" /></div>'."\n";
@@ -93,6 +108,11 @@ function formSecurityToken($print = true) {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Chris Smith <chris@jalakai.co.uk>
+ *
+ * @param string $id pageid
+ * @param bool $htmlClient add info about whether is mobile browser
+ * @return array with info for a request of $id
+ *
*/
function basicinfo($id, $htmlClient=true){
global $USERINFO;
@@ -139,6 +159,8 @@ function basicinfo($id, $htmlClient=true){
* array.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @return array with info about current document
*/
function pageinfo() {
global $ID;
@@ -246,6 +268,8 @@ function pageinfo() {
/**
* Return information about the current media item as an associative array.
+ *
+ * @return array with info about current media item
*/
function mediainfo(){
global $NS;
@@ -261,6 +285,10 @@ function mediainfo(){
* Build an string of URL parameters
*
* @author Andreas Gohr
+ *
+ * @param array $params array with key-value pairs
+ * @param string $sep series of pairs are separated by this character
+ * @return string query string
*/
function buildURLparams($params, $sep = '&amp;') {
$url = '';
@@ -281,6 +309,10 @@ function buildURLparams($params, $sep = '&amp;') {
* Skips keys starting with '_', values get HTML encoded
*
* @author Andreas Gohr
+ *
+ * @param array $params array with (attribute name-attribute value) pairs
+ * @param bool $skipempty skip empty string values?
+ * @return string
*/
function buildAttributes($params, $skipempty = false) {
$url = '';
@@ -302,6 +334,8 @@ function buildAttributes($params, $skipempty = false) {
* This builds the breadcrumb trail and returns it as array
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @return array(pageid=>name, ... )
*/
function breadcrumbs() {
// we prepare the breadcrumbs early for quick session closing
@@ -361,6 +395,10 @@ function breadcrumbs() {
* Urlencoding is ommitted when the second parameter is false
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id pageid being filtered
+ * @param bool $ue apply urlencoding?
+ * @return string
*/
function idfilter($id, $ue = true) {
global $conf;
@@ -386,10 +424,15 @@ function idfilter($id, $ue = true) {
/**
* This builds a link to a wikipage
*
- * It handles URL rewriting and adds additional parameter if
- * given in $more
+ * It handles URL rewriting and adds additional parameters
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id, defaults to start page
+ * @param string|array $urlParameters URL parameters, associative array recommended
+ * @param bool $absolute request an absolute URL instead of relative
+ * @param string $separator parameter separator
+ * @return string
*/
function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&amp;') {
global $conf;
@@ -431,13 +474,19 @@ function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&amp
* Handles URL rewriting if enabled. Follows the style of wl().
*
* @author Ben Coburn <btcoburn@silicodon.net>
+ * @param string $id page id, defaults to start page
+ * @param string $format the export renderer to use
+ * @param string|array $urlParameters URL parameters, associative array recommended
+ * @param bool $abs request an absolute URL instead of relative
+ * @param string $sep parameter separator
+ * @return string
*/
-function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep = '&amp;') {
+function exportlink($id = '', $format = 'raw', $urlParameters = '', $abs = false, $sep = '&amp;') {
global $conf;
- if(is_array($more)) {
- $more = buildURLparams($more, $sep);
+ if(is_array($urlParameters)) {
+ $urlParameters = buildURLparams($urlParameters, $sep);
} else {
- $more = str_replace(',', $sep, $more);
+ $urlParameters = str_replace(',', $sep, $urlParameters);
}
$format = rawurlencode($format);
@@ -450,13 +499,13 @@ function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep =
if($conf['userewrite'] == 2) {
$xlink .= DOKU_SCRIPT.'/'.$id.'?do=export_'.$format;
- if($more) $xlink .= $sep.$more;
+ if($urlParameters) $xlink .= $sep.$urlParameters;
} elseif($conf['userewrite'] == 1) {
$xlink .= '_export/'.$format.'/'.$id;
- if($more) $xlink .= '?'.$more;
+ if($urlParameters) $xlink .= '?'.$urlParameters;
} else {
$xlink .= DOKU_SCRIPT.'?do=export_'.$format.$sep.'id='.$id;
- if($more) $xlink .= $sep.$more;
+ if($urlParameters) $xlink .= $sep.$urlParameters;
}
return $xlink;
@@ -563,6 +612,8 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
* Consider using wl() instead, unless you absoutely need the doku.php endpoint
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @return string
*/
function script() {
return DOKU_BASE.DOKU_SCRIPT;
@@ -589,6 +640,7 @@ function script() {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Michael Klier <chi@chimeric.de>
+ *
* @param string $text - optional text to check, if not given the globals are used
* @return bool - true if a spam word was found
*/
@@ -657,6 +709,7 @@ function checkwordblock($text = '') {
* headers
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param boolean $single If set only a single IP is returned
* @return string
*/
@@ -728,6 +781,8 @@ function clientIP($single = false) {
* Adapted from the example code at url below
*
* @link http://www.brainhandles.com/2007/10/15/detecting-mobile-browsers/#code
+ *
+ * @return bool if true, client is mobile browser; otherwise false
*/
function clientismobile() {
/* @var Input $INPUT */
@@ -752,6 +807,7 @@ function clientismobile() {
* If $conf['dnslookups'] is disabled it simply returns the input string
*
* @author Glen Harris <astfgl@iamnota.org>
+ *
* @param string $ips comma separated list of IP addresses
* @return string a comma separated list of hostnames
*/
@@ -778,6 +834,9 @@ function gethostsbyaddrs($ips) {
* removes stale lockfiles
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id
+ * @return bool page is locked?
*/
function checklock($id) {
global $conf;
@@ -808,6 +867,8 @@ function checklock($id) {
* Lock a page for editing
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id to lock
*/
function lock($id) {
global $conf;
@@ -830,6 +891,7 @@ function lock($id) {
* Unlock a page if it was locked by the user
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param string $id page id to unlock
* @return bool true if a lock was removed
*/
@@ -855,6 +917,9 @@ function unlock($id) {
*
* @see formText() for 2crlf conversion
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $text
+ * @return string
*/
function cleanText($text) {
$text = preg_replace("/(\015\012)|(\015)/", "\012", $text);
@@ -874,6 +939,9 @@ function cleanText($text) {
*
* @see cleanText() for 2unix conversion
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $text
+ * @return string
*/
function formText($text) {
$text = str_replace("\012", "\015\012", $text);
@@ -884,6 +952,10 @@ function formText($text) {
* Returns the specified local text in raw format
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id
+ * @param string $ext extension of file being read, default 'txt'
+ * @return string
*/
function rawLocale($id, $ext = 'txt') {
return io_readFile(localeFN($id, $ext));
@@ -893,6 +965,10 @@ function rawLocale($id, $ext = 'txt') {
* Returns the raw WikiText
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id
+ * @param string $rev timestamp when a revision of wikitext is desired
+ * @return string
*/
function rawWiki($id, $rev = '') {
return io_readWikiPage(wikiFN($id, $rev), $id, $rev);
@@ -903,6 +979,9 @@ function rawWiki($id, $rev = '') {
*
* @triggers COMMON_PAGETPL_LOAD
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id the id of the page to be created
+ * @return string parsed pagetemplate content
*/
function pageTemplate($id) {
global $conf;
@@ -954,6 +1033,9 @@ function pageTemplate($id) {
* This works on data from COMMON_PAGETPL_LOAD
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $data array with event data
+ * @return string
*/
function parsePageTemplate(&$data) {
/**
@@ -1021,6 +1103,11 @@ function parsePageTemplate(&$data) {
* The returned order is prefix, section and suffix.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $range in form "from-to"
+ * @param string $id page id
+ * @param string $rev optional, the revision timestamp
+ * @return array with three slices
*/
function rawWikiSlices($range, $id, $rev = '') {
$text = io_readWikiPage(wikiFN($id, $rev), $id, $rev);
@@ -1045,6 +1132,12 @@ function rawWikiSlices($range, $id, $rev = '') {
* lines between sections if needed (used on saving).
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $pre prefix
+ * @param string $text text in the middle
+ * @param string $suf suffix
+ * @param bool $pretty add additional empty lines between sections
+ * @return string
*/
function con($pre, $text, $suf, $pretty = false) {
if($pretty) {
@@ -1069,6 +1162,11 @@ function con($pre, $text, $suf, $pretty = false) {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Ben Coburn <btcoburn@silicodon.net>
+ *
+ * @param string $id page id
+ * @param string $text wikitext being saved
+ * @param string $summary summary of text update
+ * @param bool $minor mark this saved version as minor update
*/
function saveWikiText($id, $text, $summary, $minor = false) {
/* Note to developers:
@@ -1173,6 +1271,9 @@ function saveWikiText($id, $text, $summary, $minor = false) {
* revision date
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id
+ * @return int|string revision timestamp
*/
function saveOldRevision($id) {
$oldf = wikiFN($id);
@@ -1192,8 +1293,8 @@ function saveOldRevision($id) {
* @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
- *
* @return bool
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array()) {
@@ -1209,7 +1310,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace =
} elseif($who == 'subscribers') {
if(!actionOK('subscribe')) return false; //subscribers enabled?
if($conf['useacl'] && $INPUT->server->str('REMOTE_USER') && $minor) return false; //skip minors
- $data = array('id' => $id, 'addresslist' => '', 'self' => false);
+ $data = array('id' => $id, 'addresslist' => '', 'self' => false, 'replacements' => $replace);
trigger_event(
'COMMON_NOTIFY_ADDRESSLIST', $data,
array(new Subscription(), 'notifyaddresses')
@@ -1231,6 +1332,8 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace =
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Todd Augsburger <todd@rollerorgans.com>
+ *
+ * @return array|string
*/
function getGoogleQuery() {
/* @var Input $INPUT */
@@ -1272,6 +1375,7 @@ function getGoogleQuery() {
* @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>
* @author Aidan Lister <aidan@php.net>
* @version 1.0.0
@@ -1293,6 +1397,9 @@ function filesize_h($size, $dec = 1) {
* Return the given timestamp as human readable, fuzzy age
*
* @author Andreas Gohr <gohr@cosmocode.de>
+ *
+ * @param int $dt timestamp
+ * @return string
*/
function datetime_h($dt) {
global $lang;
@@ -1327,6 +1434,10 @@ function datetime_h($dt) {
*
* @see datetime_h
* @author Andreas Gohr <gohr@cosmocode.de>
+ *
+ * @param int|null $dt timestamp when given, null will take current timestamp
+ * @param string $format empty default to $conf['dformat'], or provide format as recognized by strftime()
+ * @return string
*/
function dformat($dt = null, $format = '') {
global $conf;
@@ -1344,6 +1455,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
* @return string
*/
@@ -1360,6 +1472,9 @@ function date_iso8601($int_date) {
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Christopher Smith <chris@jalakai.co.uk>
+ *
+ * @param string $email email address
+ * @return string
*/
function obfuscate($email) {
global $conf;
@@ -1387,6 +1502,10 @@ function obfuscate($email) {
* Removes quoting backslashes
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $string
+ * @param string $char backslashed character
+ * @return string
*/
function unslash($string, $char = "'") {
return str_replace('\\'.$char, $char, $string);
@@ -1397,6 +1516,9 @@ function unslash($string, $char = "'") {
*
* @author <gilthans dot NO dot SPAM at gmail dot com>
* @link http://de3.php.net/manual/en/ini.core.php#79564
+ *
+ * @param string $v shorthands
+ * @return int|string
*/
function php_to_byte($v) {
$l = substr($v, -1);
@@ -1414,6 +1536,7 @@ function php_to_byte($v) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'M':
$ret *= 1024;
+ /** @noinspection PhpMissingBreakStatementInspection */
case 'K':
$ret *= 1024;
break;
@@ -1426,6 +1549,9 @@ function php_to_byte($v) {
/**
* Wrapper around preg_quote adding the default delimiter
+ *
+ * @param string $string
+ * @return string
*/
function preg_quote_cb($string) {
return preg_quote($string, '/');
@@ -1459,7 +1585,7 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') {
* Return the users realname or e-mail address for use
* in page footer and recent changes pages
*
- * @param string|bool $username or false when currently logged-in user should be used
+ * @param string|null $username or null when currently logged-in user should be used
* @param bool $textonly true returns only plain text, true allows returning html
* @return string html or plain text(not escaped) of formatted user name
*
@@ -1472,7 +1598,7 @@ function editorinfo($username, $textonly = false) {
/**
* Returns users realname w/o link
*
- * @param string|bool $username or false when currently logged-in user should be used
+ * @param string|null $username or null when currently logged-in user should be used
* @param bool $textonly true returns only plain text, true allows returning html
* @return string html or plain text(not escaped) of formatted user name
*
@@ -1595,6 +1721,7 @@ function userlink($username = null, $textonly = false) {
* When no image exists, returns an empty string
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param string $type - type of image 'badge' or 'button'
* @return string
*/
@@ -1603,7 +1730,6 @@ function license_img($type) {
global $conf;
if(!$conf['license']) return '';
if(!is_array($license[$conf['license']])) return '';
- $lic = $license[$conf['license']];
$try = array();
$try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.png';
$try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.gif';
@@ -1625,9 +1751,8 @@ function license_img($type) {
* @author Filip Oscadal <webmaster@illusionsoftworks.cz>
* @author Andreas Gohr <andi@splitbrain.org>
*
- * @param int $mem Size of memory you want to allocate in bytes
- * @param int $bytes
- * @internal param int $used already allocated memory (see above)
+ * @param int $mem Size of memory you want to allocate in bytes
+ * @param int $bytes already allocated memory (see above)
* @return bool
*/
function is_mem_available($mem, $bytes = 1048576) {
@@ -1658,6 +1783,8 @@ function is_mem_available($mem, $bytes = 1048576) {
*
* @link http://support.microsoft.com/kb/q176113/
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $url url being directed to
*/
function send_redirect($url) {
/* @var Input $INPUT */
@@ -1729,6 +1856,10 @@ function valid_input_set($param, $valid_values, $array, $exc = '') {
/**
* Read a preference from the DokuWiki cookie
* (remembering both keys & values are urlencoded)
+ *
+ * @param string $pref preference key
+ * @param mixed $default value returned when preference not found
+ * @return string preference value
*/
function get_doku_pref($pref, $default) {
$enc_pref = urlencode($pref);
@@ -1747,6 +1878,9 @@ function get_doku_pref($pref, $default) {
/**
* Add a preference to the DokuWiki cookie
* (remembering $_COOKIE['DOKU_PREFS'] is urlencoded)
+ *
+ * @param string $pref preference key
+ * @param string $val preference value
*/
function set_doku_pref($pref, $val) {
global $conf;
diff --git a/inc/form.php b/inc/form.php
index 9cd0491e0..fadc71d3e 100644
--- a/inc/form.php
+++ b/inc/form.php
@@ -131,7 +131,7 @@ class Doku_Form {
* The element can be either a pseudo-tag or string.
* If string, it is printed without escaping special chars. *
*
- * @param string $elem Pseudo-tag or string to add to the form.
+ * @param string|array $elem Pseudo-tag or string to add to the form.
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
function addElement($elem) {
@@ -143,8 +143,8 @@ class Doku_Form {
*
* Inserts a content element at a position.
*
- * @param string $pos 0-based index where the element will be inserted.
- * @param string $elem Pseudo-tag or string to add to the form.
+ * @param string $pos 0-based index where the element will be inserted.
+ * @param string|array $elem Pseudo-tag or string to add to the form.
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
function insertElement($pos, $elem) {
@@ -156,8 +156,8 @@ class Doku_Form {
*
* Replace with NULL to remove an element.
*
- * @param int $pos 0-based index the element will be placed at.
- * @param string $elem Pseudo-tag or string to add to the form.
+ * @param int $pos 0-based index the element will be placed at.
+ * @param string|array $elem Pseudo-tag or string to add to the form.
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
function replaceElement($pos, $elem) {
diff --git a/inc/lang/cs/lang.php b/inc/lang/cs/lang.php
index 0ea1add95..fa0a65044 100644
--- a/inc/lang/cs/lang.php
+++ b/inc/lang/cs/lang.php
@@ -15,8 +15,8 @@
* @author Jakub A. Těšínský (j@kub.cz)
* @author mkucera66@seznam.cz
* @author Zbyněk Křivka <krivka@fit.vutbr.cz>
- * @author Gerrit Uitslag <klapinklapin@gmail.com>
* @author Petr Klíma <qaxi@seznam.cz>
+ * @author Radovan Buroň <radovan@buron.cz>
*/
$lang['encoding'] = 'utf-8';
$lang['direction'] = 'ltr';
@@ -61,6 +61,8 @@ $lang['btn_register'] = 'Registrovat';
$lang['btn_apply'] = 'Použít';
$lang['btn_media'] = 'Správa médií';
$lang['btn_deleteuser'] = 'Odstranit můj účet';
+$lang['btn_img_backto'] = 'Zpět na %s';
+$lang['btn_mediaManager'] = 'Zobrazit ve správě médií';
$lang['loggedinas'] = 'Přihlášen(a) jako:';
$lang['user'] = 'Uživatelské jméno';
$lang['pass'] = 'Heslo';
@@ -248,7 +250,6 @@ $lang['admin_register'] = 'Přidat nového uživatele';
$lang['metaedit'] = 'Upravit Metadata';
$lang['metasaveerr'] = 'Chyba při zápisu metadat';
$lang['metasaveok'] = 'Metadata uložena';
-$lang['btn_img_backto'] = 'Zpět na %s';
$lang['img_title'] = 'Titulek:';
$lang['img_caption'] = 'Popis:';
$lang['img_date'] = 'Datum:';
@@ -261,7 +262,6 @@ $lang['img_camera'] = 'Typ fotoaparátu:';
$lang['img_keywords'] = 'Klíčová slova:';
$lang['img_width'] = 'Šířka:';
$lang['img_height'] = 'Výška:';
-$lang['btn_mediaManager'] = 'Zobrazit ve správě médií';
$lang['subscr_subscribe_success'] = '%s byl přihlášen do seznamu odběratelů %s';
$lang['subscr_subscribe_error'] = 'Došlo k chybě při přihlašování %s do seznamu odběratelů %s';
$lang['subscr_subscribe_noaddress'] = 'K Vašemu loginu neexistuje žádná adresa, nemohl jste být přihlášen do seznamu odběratelů.';
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index 7493c50e6..9c1e5dacd 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -307,6 +307,7 @@ $lang['i_modified'] = 'For security reasons this script will only wor
<a href="http://dokuwiki.org/install">Dokuwiki installation instructions</a>';
$lang['i_funcna'] = 'PHP function <code>%s</code> is not available. Maybe your hosting provider disabled it for some reason?';
$lang['i_phpver'] = 'Your PHP version <code>%s</code> is lower than the needed <code>%s</code>. You need to upgrade your PHP install.';
+$lang['i_mbfuncoverload'] = 'mbstring.func_overload must be disabled in php.ini to run DokuWiki.';
$lang['i_permfail'] = '<code>%s</code> is not writable by DokuWiki. You need to fix the permission settings of this directory!';
$lang['i_confexists'] = '<code>%s</code> already exists';
$lang['i_writeerr'] = 'Unable to create <code>%s</code>. You will need to check directory/file permissions and create the file manually.';
diff --git a/inc/lang/fr/lang.php b/inc/lang/fr/lang.php
index 045e171ff..0f7de46cb 100644
--- a/inc/lang/fr/lang.php
+++ b/inc/lang/fr/lang.php
@@ -32,6 +32,8 @@
* @author Wild <wild.dagger@free.fr>
* @author ggallon <gwenael.gallon@mac.com>
* @author David VANTYGHEM <david.vantyghem@free.fr>
+ * @author Caillot <remicaillot5@gmail.com>
+ * @author Schplurtz le Déboulonné <schplurtz@laposte.net>
*/
$lang['encoding'] = 'utf-8';
$lang['direction'] = 'ltr';
@@ -52,7 +54,7 @@ $lang['btn_newer'] = '<< Plus récent';
$lang['btn_older'] = 'Moins récent >>';
$lang['btn_revs'] = 'Anciennes révisions';
$lang['btn_recent'] = 'Derniers changements';
-$lang['btn_upload'] = 'Envoyer';
+$lang['btn_upload'] = 'Téléverser';
$lang['btn_cancel'] = 'Annuler';
$lang['btn_index'] = 'Plan du site';
$lang['btn_secedit'] = 'Modifier';
@@ -62,7 +64,7 @@ $lang['btn_admin'] = 'Administrer';
$lang['btn_update'] = 'Mettre à jour';
$lang['btn_delete'] = 'Effacer';
$lang['btn_back'] = 'Retour';
-$lang['btn_backlink'] = 'Liens vers cette page';
+$lang['btn_backlink'] = 'Liens de retour';
$lang['btn_backtomedia'] = 'Retour à la sélection du fichier média';
$lang['btn_subscribe'] = 'S\'abonner à cette page';
$lang['btn_profile'] = 'Mettre à jour le profil';
@@ -76,7 +78,7 @@ $lang['btn_register'] = 'Créer un compte';
$lang['btn_apply'] = 'Appliquer';
$lang['btn_media'] = 'Gestionnaire de médias';
$lang['btn_deleteuser'] = 'Supprimer mon compte';
-$lang['btn_img_backto'] = 'Retour à %s';
+$lang['btn_img_backto'] = 'Retour vers %s';
$lang['btn_mediaManager'] = 'Voir dans le gestionnaire de médias';
$lang['loggedinas'] = 'Connecté en tant que :';
$lang['user'] = 'Utilisateur';
@@ -88,20 +90,20 @@ $lang['remember'] = 'Mémoriser';
$lang['fullname'] = 'Nom';
$lang['email'] = 'Adresse de courriel';
$lang['profile'] = 'Profil utilisateur';
-$lang['badlogin'] = 'L\'utilisateur ou le mot de passe est incorrect.';
+$lang['badlogin'] = 'Le nom d\'utilisateur ou le mot de passe est incorrect.';
$lang['badpassconfirm'] = 'Désolé, le mot de passe est erroné';
$lang['minoredit'] = 'Modification mineure';
-$lang['draftdate'] = 'Brouillon enregistré de manière automatique le';
+$lang['draftdate'] = 'Brouillon enregistré automatiquement le';
$lang['nosecedit'] = 'La page a changé entre temps, les informations de la section sont obsolètes ; la page complète a été chargée à la place.';
$lang['regmissing'] = 'Désolé, vous devez remplir tous les champs.';
-$lang['reguexists'] = 'Désolé, ce nom d\'utilisateur est déjà utilisé.';
+$lang['reguexists'] = 'Désolé, ce nom d\'utilisateur est déjà pris.';
$lang['regsuccess'] = 'L\'utilisateur a été créé. Le mot de passe a été expédié par courriel.';
$lang['regsuccess2'] = 'L\'utilisateur a été créé.';
$lang['regmailfail'] = 'On dirait qu\'il y a eu une erreur lors de l\'envoi du mot de passe de messagerie. Veuillez contacter l\'administrateur !';
$lang['regbadmail'] = 'L\'adresse de courriel semble incorrecte. Si vous pensez que c\'est une erreur, contactez l\'administrateur.';
$lang['regbadpass'] = 'Les deux mots de passe fournis sont différents, veuillez recommencez.';
$lang['regpwmail'] = 'Votre mot de passe DokuWiki';
-$lang['reghere'] = 'Vous n\'avez pas encore de compte ? Enregistrez-vous ici ';
+$lang['reghere'] = 'Vous n\'avez pas encore de compte ? Inscrivez-vous';
$lang['profna'] = 'Ce wiki ne permet pas de modifier les profils';
$lang['profnochange'] = 'Pas de modification, rien à faire.';
$lang['profnoempty'] = 'Un nom ou une adresse de courriel vide n\'est pas permis.';
@@ -210,6 +212,8 @@ $lang['diff_side'] = 'Côte à côte';
$lang['diffprevrev'] = 'Révision précédente';
$lang['diffnextrev'] = 'Prochaine révision';
$lang['difflastrev'] = 'Dernière révision';
+$lang['diffbothprevrev'] = 'Les deux révisions précédentes';
+$lang['diffbothnextrev'] = 'Les deux révisions suivantes';
$lang['line'] = 'Ligne';
$lang['breadcrumb'] = 'Piste:';
$lang['youarehere'] = 'Vous êtes ici:';
@@ -305,6 +309,7 @@ $lang['i_problems'] = 'L\'installateur a détecté les problèmes ind
$lang['i_modified'] = 'Pour des raisons de sécurité, ce script ne fonctionne qu\'avec une installation neuve et non modifiée de DokuWiki. Vous devriez ré-extraire les fichiers depuis le paquet téléchargé ou consulter les <a href="http://dokuwiki.org/install">instructions d\'installation de DokuWiki</a>';
$lang['i_funcna'] = 'La fonction PHP <code>%s</code> n\'est pas disponible. Peut-être que votre hébergeur web l\'a désactivée ?';
$lang['i_phpver'] = 'Votre version de PHP (%s) est antérieure à la version requise (%s). Vous devez mettre à jour votre installation de PHP.';
+$lang['i_mbfuncoverload'] = 'Il faut désactiver mbstring.func_overload dans php.ini pour DokuWiki';
$lang['i_permfail'] = '<code>%s</code> n\'est pas accessible en écriture pour DokuWiki. Vous devez corriger les autorisations de ce répertoire !';
$lang['i_confexists'] = '<code>%s</code> existe déjà';
$lang['i_writeerr'] = 'Impossible de créer <code>%s</code>. Vous devez vérifier les autorisations des répertoires/fichiers et créer le fichier manuellement.';
diff --git a/inc/lang/hu/lang.php b/inc/lang/hu/lang.php
index f19c0025b..d7d4ffc32 100644
--- a/inc/lang/hu/lang.php
+++ b/inc/lang/hu/lang.php
@@ -57,6 +57,8 @@ $lang['btn_register'] = 'Regisztráció';
$lang['btn_apply'] = 'Alkalmaz';
$lang['btn_media'] = 'Médiakezelő';
$lang['btn_deleteuser'] = 'Felhasználói fiókom eltávolítása';
+$lang['btn_img_backto'] = 'Vissza %s';
+$lang['btn_mediaManager'] = 'Megtekintés a médiakezelőben';
$lang['loggedinas'] = 'Belépett felhasználó: ';
$lang['user'] = 'Azonosító';
$lang['pass'] = 'Jelszó';
@@ -187,6 +189,11 @@ $lang['difflink'] = 'Összehasonlító nézet linkje';
$lang['diff_type'] = 'Összehasonlítás módja:';
$lang['diff_inline'] = 'Sorok között';
$lang['diff_side'] = 'Egymás mellett';
+$lang['diffprevrev'] = 'Előző változat';
+$lang['diffnextrev'] = 'Következő változat';
+$lang['difflastrev'] = 'Utolsó változat';
+$lang['diffbothprevrev'] = 'Előző változat mindkét oldalon';
+$lang['diffbothnextrev'] = 'Következő változat mindkét oldalon';
$lang['line'] = 'Sor';
$lang['breadcrumb'] = 'Nyomvonal:';
$lang['youarehere'] = 'Itt vagy:';
@@ -243,7 +250,6 @@ $lang['admin_register'] = 'Új felhasználó';
$lang['metaedit'] = 'Metaadatok szerkesztése';
$lang['metasaveerr'] = 'A metaadatok írása nem sikerült';
$lang['metasaveok'] = 'Metaadatok elmentve';
-$lang['btn_img_backto'] = 'Vissza %s';
$lang['img_title'] = 'Cím:';
$lang['img_caption'] = 'Képaláírás:';
$lang['img_date'] = 'Dátum:';
@@ -256,7 +262,6 @@ $lang['img_camera'] = 'Fényképezőgép típusa:';
$lang['img_keywords'] = 'Kulcsszavak:';
$lang['img_width'] = 'Szélesség:';
$lang['img_height'] = 'Magasság:';
-$lang['btn_mediaManager'] = 'Megtekintés a médiakezelőben';
$lang['subscr_subscribe_success'] = '%s hozzáadva az értesítési listához: %s';
$lang['subscr_subscribe_error'] = 'Hiba történt %s hozzáadásakor az értesítési listához: %s';
$lang['subscr_subscribe_noaddress'] = 'Nincs e-mail cím megadva az adataidnál, így a rendszer nem tudott hozzáadni az értesítési listához';
diff --git a/inc/lang/nl/lang.php b/inc/lang/nl/lang.php
index dfdf56532..a9058720c 100644
--- a/inc/lang/nl/lang.php
+++ b/inc/lang/nl/lang.php
@@ -23,6 +23,7 @@
* @author Remon <no@email.local>
* @author gicalle <gicalle@hotmail.com>
* @author Rene <wllywlnt@yahoo.com>
+ * @author Johan Vervloet <johan.vervloet@gmail.com>
*/
$lang['encoding'] = 'utf-8';
$lang['direction'] = 'ltr';
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 8474c5697..5f62926e4 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -17,6 +17,10 @@
* If the second parameter is true (default) the ID is cleaned.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $param the $_REQUEST variable name, default 'id'
+ * @param bool $clean if true, ID is cleaned
+ * @return mixed|string
*/
function getID($param='id',$clean=true){
/** @var Input $INPUT */
@@ -146,6 +150,9 @@ function cleanID($raw_id,$ascii=false){
* Return namespacepart of a wiki ID
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id
+ * @return string|bool the namespace part or false if the given ID has no namespace (root)
*/
function getNS($id){
$pos = strrpos((string)$id,':');
@@ -159,6 +166,9 @@ function getNS($id){
* Returns the ID without the namespace
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id
+ * @return string
*/
function noNS($id) {
$pos = strrpos($id, ':');
@@ -173,6 +183,9 @@ function noNS($id) {
* Returns the current namespace
*
* @author Nathan Fritz <fritzn@crown.edu>
+ *
+ * @param string $id
+ * @return string
*/
function curNS($id) {
return noNS(getNS($id));
@@ -182,6 +195,9 @@ function curNS($id) {
* Returns the ID without the namespace or current namespace for 'start' pages
*
* @author Nathan Fritz <fritzn@crown.edu>
+ *
+ * @param string $id
+ * @return string
*/
function noNSorNS($id) {
global $conf;
@@ -202,6 +218,7 @@ function noNSorNS($id) {
* @param string $title The headline title
* @param array|bool $check Existing IDs (title => number)
* @return string the title
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function sectionID($title,&$check) {
@@ -232,6 +249,11 @@ function sectionID($title,&$check) {
* parameters as for wikiFN
*
* @author Chris Smith <chris@jalakai.co.uk>
+ *
+ * @param string $id page id
+ * @param string|int $rev empty or revision timestamp
+ * @param bool $clean flag indicating that $id should be cleaned (see wikiFN as well)
+ * @return bool exists?
*/
function page_exists($id,$rev='',$clean=true) {
return @file_exists(wikiFN($id,$rev,$clean));
@@ -290,6 +312,9 @@ function wikiFN($raw_id,$rev='',$clean=true){
* Returns the full path to the file for locking the page while editing.
*
* @author Ben Coburn <btcoburn@silicodon.net>
+ *
+ * @param string $id page id
+ * @return string full path
*/
function wikiLockFN($id) {
global $conf;
@@ -301,6 +326,10 @@ function wikiLockFN($id) {
* returns the full path to the meta file specified by ID and extension
*
* @author Steven Danz <steven-danz@kc.rr.com>
+ *
+ * @param string $id page id
+ * @param string $ext file extension
+ * @return string full path
*/
function metaFN($id,$ext){
global $conf;
@@ -314,6 +343,10 @@ function metaFN($id,$ext){
* returns the full path to the media's meta file specified by ID and extension
*
* @author Kate Arzamastseva <pshns@ukr.net>
+ *
+ * @param string $id media id
+ * @param string $ext extension of media
+ * @return string
*/
function mediaMetaFN($id,$ext){
global $conf;
@@ -328,6 +361,9 @@ function mediaMetaFN($id,$ext){
*
* @author Esther Brunner <esther@kaffeehaus.ch>
* @author Michael Hamann <michael@content-space.de>
+ *
+ * @param string $id page id
+ * @return array
*/
function metaFiles($id){
$basename = metaFN($id, '');
@@ -343,6 +379,10 @@ function metaFiles($id){
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Kate Arzamastseva <pshns@ukr.net>
+ *
+ * @param string $id media id
+ * @param string|int $rev empty string or revision timestamp
+ * @return string full path
*/
function mediaFN($id, $rev=''){
global $conf;
@@ -365,6 +405,7 @@ function mediaFN($id, $rev=''){
* @param string $id The id of the local file
* @param string $ext The file extension (usually txt)
* @return string full filepath to localized file
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function localeFN($id,$ext='txt'){
@@ -390,6 +431,11 @@ function localeFN($id,$ext='txt'){
* http://www.php.net/manual/en/function.realpath.php#57016
*
* @author <bart at mediawave dot nl>
+ *
+ * @param string $ns namespace which is context of id
+ * @param string $id relative id
+ * @param bool $clean flag indicating that id should be cleaned
+ * @return mixed|string
*/
function resolve_id($ns,$id,$clean=true){
global $conf;
@@ -435,6 +481,10 @@ function resolve_id($ns,$id,$clean=true){
* Returns a full media id
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $ns namespace which is context of id
+ * @param string &$page (reference) relative media id, updated to resolved id
+ * @param bool &$exists (reference) updated with existance of media
*/
function resolve_mediaid($ns,&$page,&$exists){
$page = resolve_id($ns,$page);
@@ -446,6 +496,10 @@ function resolve_mediaid($ns,&$page,&$exists){
* Returns a full page id
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $ns namespace which is context of id
+ * @param string &$page (reference) relative page id, updated to resolved id
+ * @param bool &$exists (reference) updated with existance of media
*/
function resolve_pageid($ns,&$page,&$exists){
global $conf;
@@ -537,6 +591,9 @@ function getCacheName($data,$ext=''){
* Checks a pageid against $conf['hidepages']
*
* @author Andreas Gohr <gohr@cosmocode.de>
+ *
+ * @param string $id page id
+ * @return bool
*/
function isHiddenPage($id){
$data = array(
@@ -550,7 +607,7 @@ function isHiddenPage($id){
/**
* callback checks if page is hidden
*
- * @param array $data event data see isHiddenPage()
+ * @param array $data event data - see isHiddenPage()
*/
function _isHiddenPage(&$data) {
global $conf;
@@ -569,6 +626,9 @@ function _isHiddenPage(&$data) {
* Reverse of isHiddenPage
*
* @author Andreas Gohr <gohr@cosmocode.de>
+ *
+ * @param string $id page id
+ * @return bool
*/
function isVisiblePage($id){
return !isHiddenPage($id);
@@ -581,8 +641,10 @@ function isVisiblePage($id){
* “*”. Output is escaped.
*
* @author Adrian Lang <lang@cosmocode.de>
+ *
+ * @param string $id page id
+ * @return string
*/
-
function prettyprint_id($id) {
if (!$id || $id === ':') {
return '*';
@@ -605,6 +667,10 @@ function prettyprint_id($id) {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @see urlencode
+ *
+ * @param string $file file name
+ * @param bool $safe if true, only encoded when non ASCII characters detected
+ * @return string
*/
function utf8_encodeFN($file,$safe=true){
global $conf;
@@ -630,6 +696,9 @@ function utf8_encodeFN($file,$safe=true){
*
* @author Andreas Gohr <andi@splitbrain.org>
* @see urldecode
+ *
+ * @param string $file file name
+ * @return string
*/
function utf8_decodeFN($file){
global $conf;
diff --git a/inc/parser/code.php b/inc/parser/code.php
index d77ffd1aa..00b956c27 100644
--- a/inc/parser/code.php
+++ b/inc/parser/code.php
@@ -7,25 +7,25 @@
if(!defined('DOKU_INC')) die('meh.');
class Doku_Renderer_code extends Doku_Renderer {
- var $_codeblock=0;
+ var $_codeblock = 0;
/**
* Send the wanted code block to the browser
*
* When the correct block was found it exits the script.
*/
- function code($text, $language = null, $filename='' ) {
+ function code($text, $language = null, $filename = '') {
global $INPUT;
if(!$language) $language = 'txt';
if(!$filename) $filename = 'snippet.'.$language;
$filename = utf8_basename($filename);
$filename = utf8_stripspecials($filename, '_');
- if($this->_codeblock == $INPUT->str('codeblock')){
+ if($this->_codeblock == $INPUT->str('codeblock')) {
header("Content-Type: text/plain; charset=utf-8");
header("Content-Disposition: attachment; filename=$filename");
header("X-Robots-Tag: noindex");
- echo trim($text,"\r\n");
+ echo trim($text, "\r\n");
exit;
}
@@ -35,7 +35,7 @@ class Doku_Renderer_code extends Doku_Renderer {
/**
* Wraps around code()
*/
- function file($text, $language = null, $filename='') {
+ function file($text, $language = null, $filename = '') {
$this->code($text, $language, $filename);
}
@@ -53,7 +53,7 @@ class Doku_Renderer_code extends Doku_Renderer {
*
* @returns string 'code'
*/
- function getFormat(){
+ function getFormat() {
return 'code';
}
}
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index 82a268fd6..25bf3fe3d 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -6,129 +6,198 @@
*/
if(!defined('DOKU_INC')) die('meh.');
-if ( !defined('DOKU_LF') ) {
+if(!defined('DOKU_LF')) {
// Some whitespace to help View > Source
- define ('DOKU_LF',"\n");
+ define ('DOKU_LF', "\n");
}
-if ( !defined('DOKU_TAB') ) {
+if(!defined('DOKU_TAB')) {
// Some whitespace to help View > Source
- define ('DOKU_TAB',"\t");
+ define ('DOKU_TAB', "\t");
}
/**
- * The Renderer
+ * The MetaData Renderer
+ *
+ * Metadata is additional information about a DokuWiki page that gets extracted mainly from the page's content
+ * but also it's own filesystem data (like the creation time). All metadata is stored in the fields $meta and
+ * $persistent.
+ *
+ * Some simplified rendering to $doc is done to gather the page's (text-only) abstract.
*/
class Doku_Renderer_metadata extends Doku_Renderer {
+ /** the approximate byte lenght to capture for the abstract */
+ const ABSTRACT_LEN = 250;
+
+ /** the maximum UTF8 character length for the abstract */
+ const ABSTRACT_MAX = 500;
+
+ /** @var array transient meta data, will be reset on each rendering */
+ public $meta = array();
+
+ /** @var array persistent meta data, will be kept until explicitly deleted */
+ public $persistent = array();
- var $doc = '';
- var $meta = array();
- var $persistent = array();
+ /** @var array the list of headers used to create unique link ids */
+ protected $headers = array();
- var $headers = array();
- var $capture = true;
- var $store = '';
- var $firstimage = '';
+ /** @var string temporary $doc store */
+ protected $store = '';
- function getFormat(){
+ /** @var string keeps the first image reference */
+ protected $firstimage = '';
+
+ /** @var bool determines if enough data for the abstract was collected, yet */
+ public $capture = true;
+
+ /** @var int number of bytes captured for abstract */
+ protected $captured = 0;
+
+ /**
+ * Returns the format produced by this renderer.
+ *
+ * @return string always 'metadata'
+ */
+ function getFormat() {
return 'metadata';
}
- function document_start(){
+ /**
+ * Initialize the document
+ *
+ * Sets up some of the persistent info about the page if it doesn't exist, yet.
+ */
+ function document_start() {
global $ID;
$this->headers = array();
// external pages are missing create date
- if(!$this->persistent['date']['created']){
+ if(!$this->persistent['date']['created']) {
$this->persistent['date']['created'] = filectime(wikiFN($ID));
}
- if(!isset($this->persistent['user'])){
+ if(!isset($this->persistent['user'])) {
$this->persistent['user'] = '';
}
- if(!isset($this->persistent['creator'])){
+ if(!isset($this->persistent['creator'])) {
$this->persistent['creator'] = '';
}
// reset metadata to persistent values
$this->meta = $this->persistent;
}
- function document_end(){
+ /**
+ * Finalize the document
+ *
+ * Stores collected data in the metadata
+ */
+ function document_end() {
global $ID;
// store internal info in metadata (notoc,nocache)
$this->meta['internal'] = $this->info;
- if (!isset($this->meta['description']['abstract'])){
+ if(!isset($this->meta['description']['abstract'])) {
// cut off too long abstracts
$this->doc = trim($this->doc);
- if (strlen($this->doc) > 500)
- $this->doc = utf8_substr($this->doc, 0, 500).'…';
+ if(strlen($this->doc) > self::ABSTRACT_MAX) {
+ $this->doc = utf8_substr($this->doc, 0, self::ABSTRACT_MAX).'…';
+ }
$this->meta['description']['abstract'] = $this->doc;
}
$this->meta['relation']['firstimage'] = $this->firstimage;
- if(!isset($this->meta['date']['modified'])){
+ if(!isset($this->meta['date']['modified'])) {
$this->meta['date']['modified'] = filemtime(wikiFN($ID));
}
}
+ /**
+ * Render plain text data
+ *
+ * This function takes care of the amount captured data and will stop capturing when
+ * enough abstract data is available
+ *
+ * @param $text
+ */
+ function cdata($text) {
+ if(!$this->capture) return;
+
+ $this->doc .= $text;
+
+ $this->captured += strlen($text);
+ if($this->captured > self::ABSTRACT_LEN) $this->capture = false;
+ }
+
+ /**
+ * Add an item to the TOC
+ *
+ * @param string $id the hash link
+ * @param string $text the text to display
+ * @param int $level the nesting level
+ */
function toc_additem($id, $text, $level) {
global $conf;
//only add items within configured levels
- if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
+ if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) {
// the TOC is one of our standard ul list arrays ;-)
$this->meta['description']['tableofcontents'][] = array(
- 'hid' => $id,
- 'title' => $text,
- 'type' => 'ul',
- 'level' => $level-$conf['toptoclevel']+1
+ 'hid' => $id,
+ 'title' => $text,
+ 'type' => 'ul',
+ 'level' => $level - $conf['toptoclevel'] + 1
);
}
}
+ /**
+ * Render a heading
+ *
+ * @param string $text the text to display
+ * @param int $level header level
+ * @param int $pos byte position in the original source
+ */
function header($text, $level, $pos) {
- if (!isset($this->meta['title'])) $this->meta['title'] = $text;
+ if(!isset($this->meta['title'])) $this->meta['title'] = $text;
// add the header to the TOC
- $hid = $this->_headerToLink($text,'true');
+ $hid = $this->_headerToLink($text, 'true');
$this->toc_additem($hid, $text, $level);
// add to summary
- if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF;
+ $this->cdata(DOKU_LF.$text.DOKU_LF);
}
- function section_open($level){}
- function section_close(){}
-
- function cdata($text){
- if ($this->capture) $this->doc .= $text;
- }
-
- function p_open(){
- if ($this->capture) $this->doc .= DOKU_LF;
+ /**
+ * Open a paragraph
+ */
+ function p_open() {
+ $this->cdata(DOKU_LF);
}
- function p_close(){
- if ($this->capture){
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
+ /**
+ * Close a paragraph
+ */
+ function p_close() {
+ $this->cdata(DOKU_LF);
}
- function linebreak(){
- if ($this->capture) $this->doc .= DOKU_LF;
+ /**
+ * Create a line break
+ */
+ function linebreak() {
+ $this->cdata(DOKU_LF);
}
- function hr(){
- if ($this->capture){
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF.'----------'.DOKU_LF;
- }
+ /**
+ * Create a horizontal line
+ */
+ function hr() {
+ $this->cdata(DOKU_LF.'----------'.DOKU_LF);
}
/**
@@ -141,7 +210,7 @@ class Doku_Renderer_metadata extends Doku_Renderer {
* @author Andreas Gohr <andi@splitbrain.org>
*/
function footnote_open() {
- if ($this->capture){
+ if($this->capture) {
// move current content to store and record footnote
$this->store = $this->doc;
$this->doc = '';
@@ -157,141 +226,214 @@ class Doku_Renderer_metadata extends Doku_Renderer {
* @author Andreas Gohr
*/
function footnote_close() {
- if ($this->capture){
+ if($this->capture) {
// restore old content
- $this->doc = $this->store;
+ $this->doc = $this->store;
$this->store = '';
}
}
- function listu_open(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
-
- function listu_close(){
- if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
- }
-
- function listo_open(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
-
- function listo_close(){
- if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
+ /**
+ * Open an unordered list
+ */
+ function listu_open() {
+ $this->cdata(DOKU_LF);
}
- function listitem_open($level){
- if ($this->capture) $this->doc .= str_repeat(DOKU_TAB, $level).'* ';
+ /**
+ * Open an ordered list
+ */
+ function listo_open() {
+ $this->cdata(DOKU_LF);
}
- function listitem_close(){
- if ($this->capture) $this->doc .= DOKU_LF;
+ /**
+ * Open a list item
+ *
+ * @param int $level the nesting level
+ */
+ function listitem_open($level) {
+ $this->cdata(str_repeat(DOKU_TAB, $level).'* ');
}
- function listcontent_open(){}
- function listcontent_close(){}
-
- function unformatted($text){
- if ($this->capture) $this->doc .= $text;
+ /**
+ * Close a list item
+ */
+ function listitem_close() {
+ $this->cdata(DOKU_LF);
}
- function preformatted($text){
- if ($this->capture) $this->doc .= $text;
+ /**
+ * Output preformatted text
+ *
+ * @param string $text
+ */
+ function preformatted($text) {
+ $this->cdata($text);
}
- function file($text, $lang = null, $file = null){
- if ($this->capture){
- $this->doc .= DOKU_LF.$text;
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
+ /**
+ * Start a block quote
+ */
+ function quote_open() {
+ $this->cdata(DOKU_LF.DOKU_TAB.'"');
}
- function quote_open(){
- if ($this->capture) $this->doc .= DOKU_LF.DOKU_TAB.'"';
+ /**
+ * Stop a block quote
+ */
+ function quote_close() {
+ $this->cdata('"'.DOKU_LF);
}
- function quote_close(){
- if ($this->capture){
- $this->doc .= '"';
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
+ /**
+ * Display text as file content, optionally syntax highlighted
+ *
+ * @param string $text text to show
+ * @param string $lang programming language to use for syntax highlighting
+ * @param string $file file path label
+ */
+ function file($text, $lang = null, $file = null) {
+ $this->cdata(DOKU_LF.$text.DOKU_LF);
}
- function code($text, $language = null, $file = null){
- if ($this->capture){
- $this->doc .= DOKU_LF.$text;
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
+ /**
+ * Display text as code content, optionally syntax highlighted
+ *
+ * @param string $text text to show
+ * @param string $language programming language to use for syntax highlighting
+ * @param string $file file path label
+ */
+ function code($text, $language = null, $file = null) {
+ $this->cdata(DOKU_LF.$text.DOKU_LF);
}
- function acronym($acronym){
- if ($this->capture) $this->doc .= $acronym;
+ /**
+ * Format an acronym
+ *
+ * Uses $this->acronyms
+ *
+ * @param string $acronym
+ */
+ function acronym($acronym) {
+ $this->cdata($acronym);
}
- function smiley($smiley){
- if ($this->capture) $this->doc .= $smiley;
+ /**
+ * Format a smiley
+ *
+ * Uses $this->smiley
+ *
+ * @param string $smiley
+ */
+ function smiley($smiley) {
+ $this->cdata($smiley);
}
- function entity($entity){
- if ($this->capture) $this->doc .= $entity;
+ /**
+ * Format an entity
+ *
+ * Entities are basically small text replacements
+ *
+ * Uses $this->entities
+ *
+ * @param string $entity
+ */
+ function entity($entity) {
+ $this->cdata($entity);
}
- function multiplyentity($x, $y){
- if ($this->capture) $this->doc .= $x.'×'.$y;
+ /**
+ * Typographically format a multiply sign
+ *
+ * Example: ($x=640, $y=480) should result in "640×480"
+ *
+ * @param string|int $x first value
+ * @param string|int $y second value
+ */
+ function multiplyentity($x, $y) {
+ $this->cdata($x.'×'.$y);
}
- function singlequoteopening(){
+ /**
+ * Render an opening single quote char (language specific)
+ */
+ function singlequoteopening() {
global $lang;
- if ($this->capture) $this->doc .= $lang['singlequoteopening'];
+ $this->cdata($lang['singlequoteopening']);
}
- function singlequoteclosing(){
+ /**
+ * Render a closing single quote char (language specific)
+ */
+ function singlequoteclosing() {
global $lang;
- if ($this->capture) $this->doc .= $lang['singlequoteclosing'];
+ $this->cdata($lang['singlequoteclosing']);
}
+ /**
+ * Render an apostrophe char (language specific)
+ */
function apostrophe() {
global $lang;
- if ($this->capture) $this->doc .= $lang['apostrophe'];
+ $this->cdata($lang['apostrophe']);
}
- function doublequoteopening(){
+ /**
+ * Render an opening double quote char (language specific)
+ */
+ function doublequoteopening() {
global $lang;
- if ($this->capture) $this->doc .= $lang['doublequoteopening'];
+ $this->cdata($lang['doublequoteopening']);
}
- function doublequoteclosing(){
+ /**
+ * Render an closinging double quote char (language specific)
+ */
+ function doublequoteclosing() {
global $lang;
- if ($this->capture) $this->doc .= $lang['doublequoteclosing'];
+ $this->cdata($lang['doublequoteclosing']);
}
+ /**
+ * Render a CamelCase link
+ *
+ * @param string $link The link name
+ * @see http://en.wikipedia.org/wiki/CamelCase
+ */
function camelcaselink($link) {
$this->internallink($link, $link);
}
- function locallink($hash, $name = null){
+ /**
+ * Render a page local link
+ *
+ * @param string $hash hash link identifier
+ * @param string $name name for the link
+ */
+ function locallink($hash, $name = null) {
if(is_array($name)) {
$this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ if($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
}
/**
* keep track of internal links in $this->meta['relation']['references']
+ *
+ * @param string $id page ID to link to. eg. 'wiki:syntax'
+ * @param string|array $name name for the link, array for media file
*/
- function internallink($id, $name = null){
+ function internallink($id, $name = null) {
global $ID;
if(is_array($name)) {
$this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ if($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
$parts = explode('?', $id, 2);
- if (count($parts) === 2) {
+ if(count($parts) === 2) {
$id = $parts[0];
}
@@ -299,7 +441,7 @@ class Doku_Renderer_metadata extends Doku_Renderer {
// first resolve and clean up the $id
resolve_pageid(getNS($ID), $id, $exists);
- @list($page, $hash) = explode('#', $id, 2);
+ @list($page) = explode('#', $id, 2);
// set metadata
$this->meta['relation']['references'][$page] = $exists;
@@ -307,84 +449,141 @@ class Doku_Renderer_metadata extends Doku_Renderer {
// p_set_metadata($id, $data);
// add link title to summary
- if ($this->capture){
+ if($this->capture) {
$name = $this->_getLinkTitle($name, $default, $id);
$this->doc .= $name;
}
}
- function externallink($url, $name = null){
+ /**
+ * Render an external link
+ *
+ * @param string $url full URL with scheme
+ * @param string|array $name name for the link, array for media file
+ */
+ function externallink($url, $name = null) {
if(is_array($name)) {
$this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ if($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
- if ($this->capture){
- $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>');
+ if($this->capture) {
+ $this->doc .= $this->_getLinkTitle($name, '<'.$url.'>');
}
}
- function interwikilink($match, $name = null, $wikiName, $wikiUri){
+ /**
+ * Render an interwiki link
+ *
+ * You may want to use $this->_resolveInterWiki() here
+ *
+ * @param string $match original link - probably not much use
+ * @param string|array $name name for the link, array for media file
+ * @param string $wikiName indentifier (shortcut) for the remote wiki
+ * @param string $wikiUri the fragment parsed from the original link
+ */
+ function interwikilink($match, $name = null, $wikiName, $wikiUri) {
if(is_array($name)) {
$this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ if($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
- if ($this->capture){
- list($wikiUri, $hash) = explode('#', $wikiUri, 2);
+ if($this->capture) {
+ list($wikiUri) = explode('#', $wikiUri, 2);
$name = $this->_getLinkTitle($name, $wikiUri);
$this->doc .= $name;
}
}
- function windowssharelink($url, $name = null){
+ /**
+ * Link to windows share
+ *
+ * @param string $url the link
+ * @param string|array $name name for the link, array for media file
+ */
+ function windowssharelink($url, $name = null) {
if(is_array($name)) {
$this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ if($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
- if ($this->capture){
- if ($name) $this->doc .= $name;
+ if($this->capture) {
+ if($name) $this->doc .= $name;
else $this->doc .= '<'.$url.'>';
}
}
- function emaillink($address, $name = null){
+ /**
+ * Render a linked E-Mail Address
+ *
+ * Should honor $conf['mailguard'] setting
+ *
+ * @param string $address Email-Address
+ * @param string|array $name name for the link, array for media file
+ */
+ function emaillink($address, $name = null) {
if(is_array($name)) {
$this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ if($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
- if ($this->capture){
- if ($name) $this->doc .= $name;
+ if($this->capture) {
+ if($name) $this->doc .= $name;
else $this->doc .= '<'.$address.'>';
}
}
- function internalmedia($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $linking=null){
- if ($this->capture && $title) $this->doc .= '['.$title.']';
+ /**
+ * Render an internal media file
+ *
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param string $linking linkonly|detail|nolink
+ */
+ function internalmedia($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $linking = null) {
+ if($this->capture && $title) $this->doc .= '['.$title.']';
$this->_firstimage($src);
$this->_recordMediaUsage($src);
}
- function externalmedia($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $linking=null){
- if ($this->capture && $title) $this->doc .= '['.$title.']';
+ /**
+ * Render an external media file
+ *
+ * @param string $src full media URL
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param string $linking linkonly|detail|nolink
+ */
+ function externalmedia($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $linking = null) {
+ if($this->capture && $title) $this->doc .= '['.$title.']';
$this->_firstimage($src);
}
- function rss($url,$params) {
+ /**
+ * Render the output of an RSS feed
+ *
+ * @param string $url URL of the feed
+ * @param array $params Finetuning of the output
+ */
+ function rss($url, $params) {
$this->meta['relation']['haspart'][$url] = true;
$this->meta['date']['valid']['age'] =
- isset($this->meta['date']['valid']['age']) ?
- min($this->meta['date']['valid']['age'],$params['refresh']) :
- $params['refresh'];
+ isset($this->meta['date']['valid']['age']) ?
+ min($this->meta['date']['valid']['age'], $params['refresh']) :
+ $params['refresh'];
}
- //----------------------------------------------------------
- // Utils
+ #region Utils
/**
* Removes any Namespace from the given name but keeps
@@ -392,35 +591,36 @@ class Doku_Renderer_metadata extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _simpleTitle($name){
+ function _simpleTitle($name) {
global $conf;
if(is_array($name)) return '';
- if($conf['useslash']){
+ if($conf['useslash']) {
$nssep = '[:;/]';
- }else{
+ } else {
$nssep = '[:;]';
}
- $name = preg_replace('!.*'.$nssep.'!','',$name);
+ $name = preg_replace('!.*'.$nssep.'!', '', $name);
//if there is a hash we use the anchor name only
- $name = preg_replace('!.*#!','',$name);
+ $name = preg_replace('!.*#!', '', $name);
return $name;
}
/**
* Creates a linkid from a headline
*
+ * @author Andreas Gohr <andi@splitbrain.org>
* @param string $title The headline title
* @param boolean $create Create a new unique ID?
- * @author Andreas Gohr <andi@splitbrain.org>
+ * @return string
*/
- function _headerToLink($title, $create=false) {
- if($create){
- return sectionID($title,$this->headers);
- }else{
+ function _headerToLink($title, $create = false) {
+ if($create) {
+ return sectionID($title, $this->headers);
+ } else {
$check = false;
- return sectionID($title,$check);
+ return sectionID($title, $check);
}
}
@@ -428,17 +628,22 @@ class Doku_Renderer_metadata extends Doku_Renderer {
* Construct a title and handle images in titles
*
* @author Harry Fuecks <hfuecks@gmail.com>
+ * @param string|array $title either string title or media array
+ * @param string $default default title if nothing else is found
+ * @param null|string $id linked page id (used to extract title from first heading)
+ * @return string title text
*/
- function _getLinkTitle($title, $default, $id=null) {
- global $conf;
-
- $isImage = false;
- if (is_array($title)){
- if($title['title']) return '['.$title['title'].']';
- } else if (is_null($title) || trim($title)==''){
- if (useHeading('content') && $id){
- $heading = p_get_first_heading($id,METADATA_DONT_RENDER);
- if ($heading) return $heading;
+ function _getLinkTitle($title, $default, $id = null) {
+ if(is_array($title)) {
+ if($title['title']) {
+ return '['.$title['title'].']';
+ } else {
+ return $default;
+ }
+ } else if(is_null($title) || trim($title) == '') {
+ if(useHeading('content') && $id) {
+ $heading = p_get_first_heading($id, METADATA_DONT_RENDER);
+ if($heading) return $heading;
}
return $default;
} else {
@@ -446,27 +651,39 @@ class Doku_Renderer_metadata extends Doku_Renderer {
}
}
- function _firstimage($src){
+ /**
+ * Remember first image
+ *
+ * @param string $src image URL or ID
+ */
+ function _firstimage($src) {
if($this->firstimage) return;
global $ID;
- list($src,$hash) = explode('#',$src,2);
- if(!media_isexternal($src)){
- resolve_mediaid(getNS($ID),$src, $exists);
+ list($src) = explode('#', $src, 2);
+ if(!media_isexternal($src)) {
+ resolve_mediaid(getNS($ID), $src, $exists);
}
- if(preg_match('/.(jpe?g|gif|png)$/i',$src)){
+ if(preg_match('/.(jpe?g|gif|png)$/i', $src)) {
$this->firstimage = $src;
}
}
+ /**
+ * Store list of used media files in metadata
+ *
+ * @param string $src media ID
+ */
function _recordMediaUsage($src) {
global $ID;
- list ($src, $hash) = explode('#', $src, 2);
- if (media_isexternal($src)) return;
+ list ($src) = explode('#', $src, 2);
+ if(media_isexternal($src)) return;
resolve_mediaid(getNS($ID), $src, $exists);
$this->meta['relation']['media'][$src] = $exists;
}
+
+ #endregion
}
//Setup VIM: ex: et ts=4 :
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 252bd9170..df01f3302 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -200,6 +200,11 @@ class Doku_Parser_Mode_Plugin extends DokuWiki_Plugin implements Doku_Parser_Mod
var $Lexer;
var $allowedModes = array();
+ /**
+ * Sort for applying this mode
+ *
+ * @return int
+ */
function getSort() {
trigger_error('getSort() not implemented in '.get_class($this), E_USER_WARNING);
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index e92b81bd7..09294539e 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -11,263 +11,748 @@ if(!defined('DOKU_INC')) die('meh.');
* An empty renderer, produces no output
*
* Inherits from DokuWiki_Plugin for giving additional functions to render plugins
+ *
+ * The renderer transforms the syntax instructions created by the parser and handler into the
+ * desired output format. For each instruction a corresponding method defined in this class will
+ * be called. That method needs to produce the desired output for the instruction and add it to the
+ * $doc field. When all instructions are processed, the $doc field contents will be cached by
+ * DokuWiki and sent to the user.
*/
class Doku_Renderer extends DokuWiki_Plugin {
- var $info = array(
+ /** @var array Settings, control the behavior of the renderer */
+ public $info = array(
'cache' => true, // may the rendered result cached?
'toc' => true, // render the TOC?
);
- var $doc = '';
+ /** @var array contains the smiley configuration, set in p_render() */
+ public $smileys = array();
+ /** @var array contains the entity configuration, set in p_render() */
+ public $entities = array();
+ /** @var array contains the acronym configuration, set in p_render() */
+ public $acronyms = array();
+ /** @var array contains the interwiki configuration, set in p_render() */
+ public $interwiki = array();
- // keep some config options
- var $acronyms = array();
- var $smileys = array();
- var $badwords = array();
- var $entities = array();
- var $interwiki = array();
+ /**
+ * @var string the rendered document, this will be cached after the renderer ran through
+ */
+ public $doc = '';
- // allows renderer to be used again, clean out any per-use values
+ /**
+ * clean out any per-use values
+ *
+ * This is called before each use of the renderer object and should be used to
+ * completely reset the state of the renderer to be reused for a new document
+ */
function reset() {
}
- function nocache() {
- $this->info['cache'] = false;
- }
-
- function notoc() {
- $this->info['toc'] = false;
+ /**
+ * Allow the plugin to prevent DokuWiki from reusing an instance
+ *
+ * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
+ * to reinstantiating the renderer here
+ *
+ * @return bool false if the plugin has to be instantiated
+ */
+ function isSingleton() {
+ return false;
}
/**
* Returns the format produced by this renderer.
*
- * Has to be overidden by decendend classes
+ * Has to be overidden by sub classes
+ *
+ * @return string
*/
- function getFormat(){
+ function getFormat() {
trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
+ return '';
}
/**
- * Allow the plugin to prevent DokuWiki from reusing an instance
+ * Disable caching of this renderer's output
+ */
+ function nocache() {
+ $this->info['cache'] = false;
+ }
+
+ /**
+ * Disable TOC generation for this renderer's output
*
- * @return bool false if the plugin has to be instantiated
+ * This might not be used for certain sub renderer
*/
- function isSingleton() {
- return false;
+ function notoc() {
+ $this->info['toc'] = false;
}
/**
- * handle plugin rendering
+ * Handle plugin rendering
+ *
+ * Most likely this needs NOT to be overwritten by sub classes
*
- * @param string $name Plugin name
- * @param mixed $data custom data set by handler
+ * @param string $name Plugin name
+ * @param mixed $data custom data set by handler
* @param string $state matched state if any
* @param string $match raw matched syntax
*/
- function plugin($name,$data,$state='',$match=''){
- $plugin = plugin_load('syntax',$name);
- if($plugin != null){
- $plugin->render($this->getFormat(),$this,$data);
+ function plugin($name, $data, $state = '', $match = '') {
+ /** @var DokuWiki_Syntax_Plugin $plugin */
+ $plugin = plugin_load('syntax', $name);
+ if($plugin != null) {
+ $plugin->render($this->getFormat(), $this, $data);
}
}
/**
* handle nested render instructions
* this method (and nest_close method) should not be overloaded in actual renderer output classes
+ *
+ * @param array $instructions
*/
function nest($instructions) {
-
- foreach ( $instructions as $instruction ) {
+ foreach($instructions as $instruction) {
// execute the callback against ourself
- if (method_exists($this,$instruction[0])) {
+ if(method_exists($this, $instruction[0])) {
call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
}
}
}
- // dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should
- // override this instruction when instantiating Doku_Handler_Nest - however plugins will not
- // be able to - as their instructions require data.
- function nest_close() {}
-
- function document_start() {}
+ /**
+ * dummy closing instruction issued by Doku_Handler_Nest
+ *
+ * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
+ * however plugins will not be able to - as their instructions require data.
+ */
+ function nest_close() {
+ }
- function document_end() {}
+ #region Syntax modes - sub classes will need to implement them to fill $doc
- function render_TOC() { return ''; }
+ /**
+ * Initialize the document
+ */
+ function document_start() {
+ }
- function toc_additem($id, $text, $level) {}
+ /**
+ * Finalize the document
+ */
+ function document_end() {
+ }
- function header($text, $level, $pos) {}
+ /**
+ * Render the Table of Contents
+ *
+ * @return string
+ */
+ function render_TOC() {
+ return '';
+ }
- function section_open($level) {}
+ /**
+ * Add an item to the TOC
+ *
+ * @param string $id the hash link
+ * @param string $text the text to display
+ * @param int $level the nesting level
+ */
+ function toc_additem($id, $text, $level) {
+ }
- function section_close() {}
+ /**
+ * Render a heading
+ *
+ * @param string $text the text to display
+ * @param int $level header level
+ * @param int $pos byte position in the original source
+ */
+ function header($text, $level, $pos) {
+ }
- function cdata($text) {}
+ /**
+ * Open a new section
+ *
+ * @param int $level section level (as determined by the previous header)
+ */
+ function section_open($level) {
+ }
- function p_open() {}
+ /**
+ * Close the current section
+ */
+ function section_close() {
+ }
- function p_close() {}
+ /**
+ * Render plain text data
+ *
+ * @param $text
+ */
+ function cdata($text) {
+ }
- function linebreak() {}
+ /**
+ * Open a paragraph
+ */
+ function p_open() {
+ }
- function hr() {}
+ /**
+ * Close a paragraph
+ */
+ function p_close() {
+ }
- function strong_open() {}
+ /**
+ * Create a line break
+ */
+ function linebreak() {
+ }
- function strong_close() {}
+ /**
+ * Create a horizontal line
+ */
+ function hr() {
+ }
- function emphasis_open() {}
+ /**
+ * Start strong (bold) formatting
+ */
+ function strong_open() {
+ }
- function emphasis_close() {}
+ /**
+ * Stop strong (bold) formatting
+ */
+ function strong_close() {
+ }
- function underline_open() {}
+ /**
+ * Start emphasis (italics) formatting
+ */
+ function emphasis_open() {
+ }
- function underline_close() {}
+ /**
+ * Stop emphasis (italics) formatting
+ */
+ function emphasis_close() {
+ }
- function monospace_open() {}
+ /**
+ * Start underline formatting
+ */
+ function underline_open() {
+ }
- function monospace_close() {}
+ /**
+ * Stop underline formatting
+ */
+ function underline_close() {
+ }
- function subscript_open() {}
+ /**
+ * Start monospace formatting
+ */
+ function monospace_open() {
+ }
- function subscript_close() {}
+ /**
+ * Stop monospace formatting
+ */
+ function monospace_close() {
+ }
- function superscript_open() {}
+ /**
+ * Start a subscript
+ */
+ function subscript_open() {
+ }
- function superscript_close() {}
+ /**
+ * Stop a subscript
+ */
+ function subscript_close() {
+ }
- function deleted_open() {}
+ /**
+ * Start a superscript
+ */
+ function superscript_open() {
+ }
- function deleted_close() {}
+ /**
+ * Stop a superscript
+ */
+ function superscript_close() {
+ }
- function footnote_open() {}
+ /**
+ * Start deleted (strike-through) formatting
+ */
+ function deleted_open() {
+ }
- function footnote_close() {}
+ /**
+ * Stop deleted (strike-through) formatting
+ */
+ function deleted_close() {
+ }
- function listu_open() {}
+ /**
+ * Start a footnote
+ */
+ function footnote_open() {
+ }
- function listu_close() {}
+ /**
+ * Stop a footnote
+ */
+ function footnote_close() {
+ }
- function listo_open() {}
+ /**
+ * Open an unordered list
+ */
+ function listu_open() {
+ }
- function listo_close() {}
+ /**
+ * Close an unordered list
+ */
+ function listu_close() {
+ }
- function listitem_open($level) {}
+ /**
+ * Open an ordered list
+ */
+ function listo_open() {
+ }
- function listitem_close() {}
+ /**
+ * Close an ordered list
+ */
+ function listo_close() {
+ }
- function listcontent_open() {}
+ /**
+ * Open a list item
+ *
+ * @param int $level the nesting level
+ */
+ function listitem_open($level) {
+ }
- function listcontent_close() {}
+ /**
+ * Close a list item
+ */
+ function listitem_close() {
+ }
- function unformatted($text) {}
+ /**
+ * Start the content of a list item
+ */
+ function listcontent_open() {
+ }
- function php($text) {}
+ /**
+ * Stop the content of a list item
+ */
+ function listcontent_close() {
+ }
- function phpblock($text) {}
+ /**
+ * Output unformatted $text
+ *
+ * Defaults to $this->cdata()
+ *
+ * @param string $text
+ */
+ function unformatted($text) {
+ $this->cdata($text);
+ }
- function html($text) {}
+ /**
+ * Output inline PHP code
+ *
+ * If $conf['phpok'] is true this should evaluate the given code and append the result
+ * to $doc
+ *
+ * @param string $text The PHP code
+ */
+ function php($text) {
+ }
- function htmlblock($text) {}
+ /**
+ * Output block level PHP code
+ *
+ * If $conf['phpok'] is true this should evaluate the given code and append the result
+ * to $doc
+ *
+ * @param string $text The PHP code
+ */
+ function phpblock($text) {
+ }
- function preformatted($text) {}
+ /**
+ * Output raw inline HTML
+ *
+ * If $conf['htmlok'] is true this should add the code as is to $doc
+ *
+ * @param string $text The HTML
+ */
+ function html($text) {
+ }
- function quote_open() {}
+ /**
+ * Output raw block-level HTML
+ *
+ * If $conf['htmlok'] is true this should add the code as is to $doc
+ *
+ * @param string $text The HTML
+ */
+ function htmlblock($text) {
+ }
- function quote_close() {}
+ /**
+ * Output preformatted text
+ *
+ * @param string $text
+ */
+ function preformatted($text) {
+ }
- function file($text, $lang = null, $file = null ) {}
+ /**
+ * Start a block quote
+ */
+ function quote_open() {
+ }
- function code($text, $lang = null, $file = null ) {}
+ /**
+ * Stop a block quote
+ */
+ function quote_close() {
+ }
- function acronym($acronym) {}
+ /**
+ * Display text as file content, optionally syntax highlighted
+ *
+ * @param string $text text to show
+ * @param string $lang programming language to use for syntax highlighting
+ * @param string $file file path label
+ */
+ function file($text, $lang = null, $file = null) {
+ }
- function smiley($smiley) {}
+ /**
+ * Display text as code content, optionally syntax highlighted
+ *
+ * @param string $text text to show
+ * @param string $lang programming language to use for syntax highlighting
+ * @param string $file file path label
+ */
+ function code($text, $lang = null, $file = null) {
+ }
- function wordblock($word) {}
+ /**
+ * Format an acronym
+ *
+ * Uses $this->acronyms
+ *
+ * @param string $acronym
+ */
+ function acronym($acronym) {
+ }
- function entity($entity) {}
+ /**
+ * Format a smiley
+ *
+ * Uses $this->smiley
+ *
+ * @param string $smiley
+ */
+ function smiley($smiley) {
+ }
- // 640x480 ($x=640, $y=480)
- function multiplyentity($x, $y) {}
+ /**
+ * Format an entity
+ *
+ * Entities are basically small text replacements
+ *
+ * Uses $this->entities
+ *
+ * @param string $entity
+ */
+ function entity($entity) {
+ }
- function singlequoteopening() {}
+ /**
+ * Typographically format a multiply sign
+ *
+ * Example: ($x=640, $y=480) should result in "640×480"
+ *
+ * @param string|int $x first value
+ * @param string|int $y second value
+ */
+ function multiplyentity($x, $y) {
+ }
- function singlequoteclosing() {}
+ /**
+ * Render an opening single quote char (language specific)
+ */
+ function singlequoteopening() {
+ }
- function apostrophe() {}
+ /**
+ * Render a closing single quote char (language specific)
+ */
+ function singlequoteclosing() {
+ }
- function doublequoteopening() {}
+ /**
+ * Render an apostrophe char (language specific)
+ */
+ function apostrophe() {
+ }
- function doublequoteclosing() {}
+ /**
+ * Render an opening double quote char (language specific)
+ */
+ function doublequoteopening() {
+ }
- // $link like 'SomePage'
- function camelcaselink($link) {}
+ /**
+ * Render an closinging double quote char (language specific)
+ */
+ function doublequoteclosing() {
+ }
- function locallink($hash, $name = null) {}
+ /**
+ * Render a CamelCase link
+ *
+ * @param string $link The link name
+ * @see http://en.wikipedia.org/wiki/CamelCase
+ */
+ function camelcaselink($link) {
+ }
- // $link like 'wiki:syntax', $title could be an array (media)
- function internallink($link, $title = null) {}
+ /**
+ * Render a page local link
+ *
+ * @param string $hash hash link identifier
+ * @param string $name name for the link
+ */
+ function locallink($hash, $name = null) {
+ }
- // $link is full URL with scheme, $title could be an array (media)
- function externallink($link, $title = null) {}
+ /**
+ * Render a wiki internal link
+ *
+ * @param string $link page ID to link to. eg. 'wiki:syntax'
+ * @param string|array $title name for the link, array for media file
+ */
+ function internallink($link, $title = null) {
+ }
- function rss ($url,$params) {}
+ /**
+ * Render an external link
+ *
+ * @param string $link full URL with scheme
+ * @param string|array $title name for the link, array for media file
+ */
+ function externallink($link, $title = null) {
+ }
- // $link is the original link - probably not much use
- // $wikiName is an indentifier for the wiki
- // $wikiUri is the URL fragment to append to some known URL
- function interwikilink($link, $title = null, $wikiName, $wikiUri) {}
+ /**
+ * Render the output of an RSS feed
+ *
+ * @param string $url URL of the feed
+ * @param array $params Finetuning of the output
+ */
+ function rss($url, $params) {
+ }
- // Link to file on users OS, $title could be an array (media)
- function filelink($link, $title = null) {}
+ /**
+ * Render an interwiki link
+ *
+ * You may want to use $this->_resolveInterWiki() here
+ *
+ * @param string $link original link - probably not much use
+ * @param string|array $title name for the link, array for media file
+ * @param string $wikiName indentifier (shortcut) for the remote wiki
+ * @param string $wikiUri the fragment parsed from the original link
+ */
+ function interwikilink($link, $title = null, $wikiName, $wikiUri) {
+ }
- // Link to a Windows share, , $title could be an array (media)
- function windowssharelink($link, $title = null) {}
+ /**
+ * Link to file on users OS
+ *
+ * @param string $link the link
+ * @param string|array $title name for the link, array for media file
+ */
+ function filelink($link, $title = null) {
+ }
-// function email($address, $title = null) {}
- function emaillink($address, $name = null) {}
+ /**
+ * Link to windows share
+ *
+ * @param string $link the link
+ * @param string|array $title name for the link, array for media file
+ */
+ function windowssharelink($link, $title = null) {
+ }
- function internalmedia ($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $linking=null) {}
+ /**
+ * Render a linked E-Mail Address
+ *
+ * Should honor $conf['mailguard'] setting
+ *
+ * @param string $address Email-Address
+ * @param string|array $name name for the link, array for media file
+ */
+ function emaillink($address, $name = null) {
+ }
- function externalmedia ($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $linking=null) {}
+ /**
+ * Render an internal media file
+ *
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param string $linking linkonly|detail|nolink
+ */
+ function internalmedia($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $linking = null) {
+ }
- function internalmedialink (
- $src,$title=null,$align=null,$width=null,$height=null,$cache=null
- ) {}
+ /**
+ * Render an external media file
+ *
+ * @param string $src full media URL
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param string $linking linkonly|detail|nolink
+ */
+ function externalmedia($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $linking = null) {
+ }
- function externalmedialink(
- $src,$title=null,$align=null,$width=null,$height=null,$cache=null
- ) {}
+ /**
+ * Render a link to an internal media file
+ *
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ */
+ function internalmedialink($src, $title = null, $align = null,
+ $width = null, $height = null, $cache = null) {
+ }
- function table_open($maxcols = null, $numrows = null, $pos = null){}
+ /**
+ * Render a link to an external media file
+ *
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ */
+ function externalmedialink($src, $title = null, $align = null,
+ $width = null, $height = null, $cache = null) {
+ }
- function table_close($pos = null){}
+ /**
+ * Start a table
+ *
+ * @param int $maxcols maximum number of columns
+ * @param int $numrows NOT IMPLEMENTED
+ * @param int $pos byte position in the original source
+ */
+ function table_open($maxcols = null, $numrows = null, $pos = null) {
+ }
- function tablethead_open(){}
+ /**
+ * Close a table
+ *
+ * @param int $pos byte position in the original source
+ */
+ function table_close($pos = null) {
+ }
- function tablethead_close(){}
+ /**
+ * Open a table header
+ */
+ function tablethead_open() {
+ }
- function tablerow_open(){}
+ /**
+ * Close a table header
+ */
+ function tablethead_close() {
+ }
- function tablerow_close(){}
+ /**
+ * Open a table row
+ */
+ function tablerow_open() {
+ }
- function tableheader_open($colspan = 1, $align = null, $rowspan = 1){}
+ /**
+ * Close a table row
+ */
+ function tablerow_close() {
+ }
- function tableheader_close(){}
+ /**
+ * Open a table header cell
+ *
+ * @param int $colspan
+ * @param string $align left|center|right
+ * @param int $rowspan
+ */
+ function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
+ }
- function tablecell_open($colspan = 1, $align = null, $rowspan = 1){}
+ /**
+ * Close a table header cell
+ */
+ function tableheader_close() {
+ }
- function tablecell_close(){}
+ /**
+ * Open a table cell
+ *
+ * @param int $colspan
+ * @param string $align left|center|right
+ * @param int $rowspan
+ */
+ function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
+ }
+ /**
+ * Close a table cell
+ */
+ function tablecell_close() {
+ }
- // util functions follow, you probably won't need to reimplement them
+ #endregion
+ #region util functions, you probably won't need to reimplement them
/**
* Removes any Namespace from the given name but keeps
@@ -294,13 +779,13 @@ class Doku_Renderer extends DokuWiki_Plugin {
/**
* Resolve an interwikilink
*/
- function _resolveInterWiki(&$shortcut, $reference, &$exists=null) {
+ function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
//get interwiki URL
if(isset($this->interwiki[$shortcut])) {
$url = $this->interwiki[$shortcut];
} else {
// Default to Google I'm feeling lucky
- $url = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
+ $url = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
$shortcut = 'go';
}
@@ -310,8 +795,8 @@ class Doku_Renderer extends DokuWiki_Plugin {
//replace placeholder
if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
//use placeholders
- $url = str_replace('{URL}', rawurlencode($reference), $url);
- $url = str_replace('{NAME}', $reference, $url);
+ $url = str_replace('{URL}', rawurlencode($reference), $url);
+ $url = str_replace('{NAME}', $reference, $url);
$parsed = parse_url($reference);
if(!$parsed['port']) $parsed['port'] = 80;
$url = str_replace('{SCHEME}', $parsed['scheme'], $url);
@@ -321,18 +806,20 @@ class Doku_Renderer extends DokuWiki_Plugin {
$url = str_replace('{QUERY}', $parsed['query'], $url);
} else {
//default
- $url = $url . rawurlencode($reference);
+ $url = $url.rawurlencode($reference);
}
//handle as wiki links
if($url{0} === ':') {
list($id, $urlparam) = explode('?', $url, 2);
- $url = wl(cleanID($id), $urlparam);
+ $url = wl(cleanID($id), $urlparam);
$exists = page_exists($id);
}
- if($hash) $url .= '#' . rawurlencode($hash);
+ if($hash) $url .= '#'.rawurlencode($hash);
return $url;
}
+
+ #endregion
}
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index cf36a8175..5c0353688 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -7,37 +7,53 @@
*/
if(!defined('DOKU_INC')) die('meh.');
-if ( !defined('DOKU_LF') ) {
+if(!defined('DOKU_LF')) {
// Some whitespace to help View > Source
- define ('DOKU_LF',"\n");
+ define ('DOKU_LF', "\n");
}
-if ( !defined('DOKU_TAB') ) {
+if(!defined('DOKU_TAB')) {
// Some whitespace to help View > Source
- define ('DOKU_TAB',"\t");
+ define ('DOKU_TAB', "\t");
}
/**
- * The Renderer
+ * The XHTML Renderer
+ *
+ * This is DokuWiki's main renderer used to display page content in the wiki
*/
class Doku_Renderer_xhtml extends Doku_Renderer {
+ /** @var array store the table of contents */
+ public $toc = array();
+
+ /** @var array A stack of section edit data */
+ protected $sectionedits = array();
- // @access public
- var $doc = ''; // will contain the whole document
- var $toc = array(); // will contain the Table of Contents
+ /** @var int last section edit id, used by startSectionEdit */
+ protected $lastsecid = 0;
- var $sectionedits = array(); // A stack of section edit data
- private $lastsecid = 0; // last section edit id, used by startSectionEdit
+ /** @var array the list of headers used to create unique link ids */
+ protected $headers = array();
- var $headers = array();
/** @var array a list of footnotes, list starts at 1! */
- var $footnotes = array();
- var $lastlevel = 0;
- var $node = array(0,0,0,0,0);
- var $store = '';
+ protected $footnotes = array();
+
+ /** @var int current section level */
+ protected $lastlevel = 0;
+ /** @var array section node tracker */
+ protected $node = array(0, 0, 0, 0, 0);
+
+ /** @var string temporary $doc store */
+ protected $store = '';
- var $_counter = array(); // used as global counter, introduced for table classes
- var $_codeblock = 0; // counts the code and file blocks, used to provide download links
+ /** @var array global counter, for table classes etc. */
+ protected $_counter = array(); //
+
+ /** @var int counts the code and file blocks, used to provide download links */
+ protected $_codeblock = 0;
+
+ /** @var array list of allowed URL schemes */
+ protected $schemes = null;
/**
* Register a new edit section range
@@ -50,43 +66,53 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*/
public function startSectionEdit($start, $type, $title = null) {
$this->sectionedits[] = array(++$this->lastsecid, $start, $type, $title);
- return 'sectionedit' . $this->lastsecid;
+ return 'sectionedit'.$this->lastsecid;
}
/**
* Finish an edit section range
*
- * @param $end int The byte position for the edit end; null for the rest of
+ * @param $end int The byte position for the edit end; null for the rest of
* the page
* @author Adrian Lang <lang@cosmocode.de>
*/
public function finishSectionEdit($end = null) {
list($id, $start, $type, $title) = array_pop($this->sectionedits);
- if (!is_null($end) && $end <= $start) {
+ if(!is_null($end) && $end <= $start) {
return;
}
- $this->doc .= "<!-- EDIT$id " . strtoupper($type) . ' ';
- if (!is_null($title)) {
- $this->doc .= '"' . str_replace('"', '', $title) . '" ';
+ $this->doc .= "<!-- EDIT$id ".strtoupper($type).' ';
+ if(!is_null($title)) {
+ $this->doc .= '"'.str_replace('"', '', $title).'" ';
}
- $this->doc .= "[$start-" . (is_null($end) ? '' : $end) . '] -->';
+ $this->doc .= "[$start-".(is_null($end) ? '' : $end).'] -->';
}
- function getFormat(){
+ /**
+ * Returns the format produced by this renderer.
+ *
+ * @return string always 'xhtml'
+ */
+ function getFormat() {
return 'xhtml';
}
-
+ /**
+ * Initialize the document
+ */
function document_start() {
//reset some internals
$this->toc = array();
$this->headers = array();
}
+ /**
+ * Finalize the document
+ */
function document_end() {
// Finish open section edits.
- while (count($this->sectionedits) > 0) {
- if ($this->sectionedits[count($this->sectionedits) - 1][1] <= 1) {
+ while(count($this->sectionedits) > 0) {
+ if($this->sectionedits[count($this->sectionedits) - 1][1] <= 1) {
// If there is only one section, do not write a section edit
// marker.
array_pop($this->sectionedits);
@@ -95,12 +121,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
- if ( count ($this->footnotes) > 0 ) {
+ if(count($this->footnotes) > 0) {
$this->doc .= '<div class="footnotes">'.DOKU_LF;
- foreach ( $this->footnotes as $id => $footnote ) {
+ foreach($this->footnotes as $id => $footnote) {
// check its not a placeholder that indicates actual footnote text is elsewhere
- if (substr($footnote, 0, 5) != "@@FNT") {
+ if(substr($footnote, 0, 5) != "@@FNT") {
// open the footnote and set the anchor and backlink
$this->doc .= '<div class="fn">';
@@ -110,8 +136,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// get any other footnotes that use the same markup
$alt = array_keys($this->footnotes, "@@FNT$id");
- if (count($alt)) {
- foreach ($alt as $ref) {
+ if(count($alt)) {
+ foreach($alt as $ref) {
// set anchor and backlink for the other footnotes
$this->doc .= ', <sup><a href="#fnt__'.($ref).'" id="fn__'.($ref).'" class="fn_bot">';
$this->doc .= ($ref).')</a></sup> '.DOKU_LF;
@@ -120,7 +146,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// add footnote markup and close this footnote
$this->doc .= $footnote;
- $this->doc .= '</div>' . DOKU_LF;
+ $this->doc .= '</div>'.DOKU_LF;
}
}
$this->doc .= '</div>'.DOKU_LF;
@@ -128,139 +154,221 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// Prepare the TOC
global $conf;
- if($this->info['toc'] && is_array($this->toc) && $conf['tocminheads'] && count($this->toc) >= $conf['tocminheads']){
+ if($this->info['toc'] && is_array($this->toc) && $conf['tocminheads'] && count($this->toc) >= $conf['tocminheads']) {
global $TOC;
$TOC = $this->toc;
}
// make sure there are no empty paragraphs
- $this->doc = preg_replace('#<p>\s*</p>#','',$this->doc);
+ $this->doc = preg_replace('#<p>\s*</p>#', '', $this->doc);
}
+ /**
+ * Add an item to the TOC
+ *
+ * @param string $id the hash link
+ * @param string $text the text to display
+ * @param int $level the nesting level
+ */
function toc_additem($id, $text, $level) {
global $conf;
//handle TOC
- if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
- $this->toc[] = html_mktocitem($id, $text, $level-$conf['toptoclevel']+1);
+ if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) {
+ $this->toc[] = html_mktocitem($id, $text, $level - $conf['toptoclevel'] + 1);
}
}
+ /**
+ * Render a heading
+ *
+ * @param string $text the text to display
+ * @param int $level header level
+ * @param int $pos byte position in the original source
+ */
function header($text, $level, $pos) {
global $conf;
if(!$text) return; //skip empty headlines
- $hid = $this->_headerToLink($text,true);
+ $hid = $this->_headerToLink($text, true);
//only add items within configured levels
$this->toc_additem($hid, $text, $level);
// adjust $node to reflect hierarchy of levels
- $this->node[$level-1]++;
- if ($level < $this->lastlevel) {
- for ($i = 0; $i < $this->lastlevel-$level; $i++) {
- $this->node[$this->lastlevel-$i-1] = 0;
+ $this->node[$level - 1]++;
+ if($level < $this->lastlevel) {
+ for($i = 0; $i < $this->lastlevel - $level; $i++) {
+ $this->node[$this->lastlevel - $i - 1] = 0;
}
}
$this->lastlevel = $level;
- if ($level <= $conf['maxseclevel'] &&
+ if($level <= $conf['maxseclevel'] &&
count($this->sectionedits) > 0 &&
- $this->sectionedits[count($this->sectionedits) - 1][2] === 'section') {
+ $this->sectionedits[count($this->sectionedits) - 1][2] === 'section'
+ ) {
$this->finishSectionEdit($pos - 1);
}
// write the header
$this->doc .= DOKU_LF.'<h'.$level;
- if ($level <= $conf['maxseclevel']) {
- $this->doc .= ' class="' . $this->startSectionEdit($pos, 'section', $text) . '"';
+ if($level <= $conf['maxseclevel']) {
+ $this->doc .= ' class="'.$this->startSectionEdit($pos, 'section', $text).'"';
}
$this->doc .= ' id="'.$hid.'">';
$this->doc .= $this->_xmlEntities($text);
$this->doc .= "</h$level>".DOKU_LF;
}
+ /**
+ * Open a new section
+ *
+ * @param int $level section level (as determined by the previous header)
+ */
function section_open($level) {
- $this->doc .= '<div class="level' . $level . '">' . DOKU_LF;
+ $this->doc .= '<div class="level'.$level.'">'.DOKU_LF;
}
+ /**
+ * Close the current section
+ */
function section_close() {
$this->doc .= DOKU_LF.'</div>'.DOKU_LF;
}
+ /**
+ * Render plain text data
+ *
+ * @param $text
+ */
function cdata($text) {
$this->doc .= $this->_xmlEntities($text);
}
+ /**
+ * Open a paragraph
+ */
function p_open() {
$this->doc .= DOKU_LF.'<p>'.DOKU_LF;
}
+ /**
+ * Close a paragraph
+ */
function p_close() {
$this->doc .= DOKU_LF.'</p>'.DOKU_LF;
}
+ /**
+ * Create a line break
+ */
function linebreak() {
$this->doc .= '<br/>'.DOKU_LF;
}
+ /**
+ * Create a horizontal line
+ */
function hr() {
$this->doc .= '<hr />'.DOKU_LF;
}
+ /**
+ * Start strong (bold) formatting
+ */
function strong_open() {
$this->doc .= '<strong>';
}
+ /**
+ * Stop strong (bold) formatting
+ */
function strong_close() {
$this->doc .= '</strong>';
}
+ /**
+ * Start emphasis (italics) formatting
+ */
function emphasis_open() {
$this->doc .= '<em>';
}
+ /**
+ * Stop emphasis (italics) formatting
+ */
function emphasis_close() {
$this->doc .= '</em>';
}
+ /**
+ * Start underline formatting
+ */
function underline_open() {
$this->doc .= '<em class="u">';
}
+ /**
+ * Stop underline formatting
+ */
function underline_close() {
$this->doc .= '</em>';
}
+ /**
+ * Start monospace formatting
+ */
function monospace_open() {
$this->doc .= '<code>';
}
+ /**
+ * Stop monospace formatting
+ */
function monospace_close() {
$this->doc .= '</code>';
}
+ /**
+ * Start a subscript
+ */
function subscript_open() {
$this->doc .= '<sub>';
}
+ /**
+ * Stop a subscript
+ */
function subscript_close() {
$this->doc .= '</sub>';
}
+ /**
+ * Start a superscript
+ */
function superscript_open() {
$this->doc .= '<sup>';
}
+ /**
+ * Stop a superscript
+ */
function superscript_close() {
$this->doc .= '</sup>';
}
+ /**
+ * Start deleted (strike-through) formatting
+ */
function deleted_open() {
$this->doc .= '<del>';
}
+ /**
+ * Stop deleted (strike-through) formatting
+ */
function deleted_close() {
$this->doc .= '</del>';
}
@@ -296,14 +404,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$fnid++;
// recover footnote into the stack and restore old content
- $footnote = $this->doc;
- $this->doc = $this->store;
+ $footnote = $this->doc;
+ $this->doc = $this->store;
$this->store = '';
// check to see if this footnote has been seen before
$i = array_search($footnote, $this->footnotes);
- if ($i === false) {
+ if($i === false) {
// its a new footnote, add it to the $footnotes array
$this->footnotes[$fnid] = $footnote;
} else {
@@ -315,38 +423,71 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '<sup><a href="#fn__'.$fnid.'" id="fnt__'.$fnid.'" class="fn_top">'.$fnid.')</a></sup>';
}
+ /**
+ * Open an unordered list
+ */
function listu_open() {
$this->doc .= '<ul>'.DOKU_LF;
}
+ /**
+ * Close an unordered list
+ */
function listu_close() {
$this->doc .= '</ul>'.DOKU_LF;
}
+ /**
+ * Open an ordered list
+ */
function listo_open() {
$this->doc .= '<ol>'.DOKU_LF;
}
+ /**
+ * Close an ordered list
+ */
function listo_close() {
$this->doc .= '</ol>'.DOKU_LF;
}
+ /**
+ * Open a list item
+ *
+ * @param int $level the nesting level
+ */
function listitem_open($level) {
$this->doc .= '<li class="level'.$level.'">';
}
+ /**
+ * Close a list item
+ */
function listitem_close() {
$this->doc .= '</li>'.DOKU_LF;
}
+ /**
+ * Start the content of a list item
+ */
function listcontent_open() {
$this->doc .= '<div class="li">';
}
+ /**
+ * Stop the content of a list item
+ */
function listcontent_close() {
$this->doc .= '</div>'.DOKU_LF;
}
+ /**
+ * Output unformatted $text
+ *
+ * Defaults to $this->cdata()
+ *
+ * @param string $text
+ */
function unformatted($text) {
$this->doc .= $this->_xmlEntities($text);
}
@@ -354,15 +495,15 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Execute PHP code if allowed
*
- * @param string $text PHP code that is either executed or printed
- * @param string $wrapper html element to wrap result if $conf['phpok'] is okff
+ * @param string $text PHP code that is either executed or printed
+ * @param string $wrapper html element to wrap result if $conf['phpok'] is okff
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function php($text, $wrapper='code') {
+ function php($text, $wrapper = 'code') {
global $conf;
- if($conf['phpok']){
+ if($conf['phpok']) {
ob_start();
eval($text);
$this->doc .= ob_get_contents();
@@ -372,6 +513,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
+ /**
+ * Output block level PHP code
+ *
+ * If $conf['phpok'] is true this should evaluate the given code and append the result
+ * to $doc
+ *
+ * @param string $text The PHP code
+ */
function phpblock($text) {
$this->php($text, 'pre');
}
@@ -379,75 +528,110 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Insert HTML if allowed
*
- * @param string $text html text
- * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff
+ * @param string $text html text
+ * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function html($text, $wrapper='code') {
+ function html($text, $wrapper = 'code') {
global $conf;
- if($conf['htmlok']){
+ if($conf['htmlok']) {
$this->doc .= $text;
} else {
$this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper);
}
}
+ /**
+ * Output raw block-level HTML
+ *
+ * If $conf['htmlok'] is true this should add the code as is to $doc
+ *
+ * @param string $text The HTML
+ */
function htmlblock($text) {
$this->html($text, 'pre');
}
+ /**
+ * Start a block quote
+ */
function quote_open() {
$this->doc .= '<blockquote><div class="no">'.DOKU_LF;
}
+ /**
+ * Stop a block quote
+ */
function quote_close() {
$this->doc .= '</div></blockquote>'.DOKU_LF;
}
+ /**
+ * Output preformatted text
+ *
+ * @param string $text
+ */
function preformatted($text) {
- $this->doc .= '<pre class="code">' . trim($this->_xmlEntities($text),"\n\r") . '</pre>'. DOKU_LF;
+ $this->doc .= '<pre class="code">'.trim($this->_xmlEntities($text), "\n\r").'</pre>'.DOKU_LF;
}
- function file($text, $language=null, $filename=null) {
- $this->_highlight('file',$text,$language,$filename);
+ /**
+ * Display text as file content, optionally syntax highlighted
+ *
+ * @param string $text text to show
+ * @param string $language programming language to use for syntax highlighting
+ * @param string $filename file path label
+ */
+ function file($text, $language = null, $filename = null) {
+ $this->_highlight('file', $text, $language, $filename);
}
- function code($text, $language=null, $filename=null) {
- $this->_highlight('code',$text,$language,$filename);
+ /**
+ * Display text as code content, optionally syntax highlighted
+ *
+ * @param string $text text to show
+ * @param string $language programming language to use for syntax highlighting
+ * @param string $filename file path label
+ */
+ function code($text, $language = null, $filename = null) {
+ $this->_highlight('code', $text, $language, $filename);
}
/**
* Use GeSHi to highlight language syntax in code and file blocks
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $type code|file
+ * @param string $text text to show
+ * @param string $language programming language to use for syntax highlighting
+ * @param string $filename file path label
*/
- function _highlight($type, $text, $language=null, $filename=null) {
- global $conf;
+ function _highlight($type, $text, $language = null, $filename = null) {
global $ID;
global $lang;
- if($filename){
+ if($filename) {
// add icon
- list($ext) = mimetype($filename,false);
- $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
+ list($ext) = mimetype($filename, false);
+ $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
$class = 'mediafile mf_'.$class;
$this->doc .= '<dl class="'.$type.'">'.DOKU_LF;
- $this->doc .= '<dt><a href="'.exportlink($ID,'code',array('codeblock'=>$this->_codeblock)).'" title="'.$lang['download'].'" class="'.$class.'">';
+ $this->doc .= '<dt><a href="'.exportlink($ID, 'code', array('codeblock' => $this->_codeblock)).'" title="'.$lang['download'].'" class="'.$class.'">';
$this->doc .= hsc($filename);
$this->doc .= '</a></dt>'.DOKU_LF.'<dd>';
}
- if ($text{0} == "\n") {
+ if($text{0} == "\n") {
$text = substr($text, 1);
}
- if (substr($text, -1) == "\n") {
+ if(substr($text, -1) == "\n") {
$text = substr($text, 0, -1);
}
- if ( is_null($language) ) {
+ if(is_null($language)) {
$this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF;
} else {
$class = 'code'; //we always need the code class to make the syntax highlighting apply
@@ -456,16 +640,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= "<pre class=\"$class $language\">".p_xhtml_cached_geshi($text, $language, '').'</pre>'.DOKU_LF;
}
- if($filename){
+ if($filename) {
$this->doc .= '</dd></dl>'.DOKU_LF;
}
$this->_codeblock++;
}
+ /**
+ * Format an acronym
+ *
+ * Uses $this->acronyms
+ *
+ * @param string $acronym
+ */
function acronym($acronym) {
- if ( array_key_exists($acronym, $this->acronyms) ) {
+ if(array_key_exists($acronym, $this->acronyms)) {
$title = $this->_xmlEntities($this->acronyms[$acronym]);
@@ -477,73 +668,109 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
+ /**
+ * Format a smiley
+ *
+ * Uses $this->smiley
+ *
+ * @param string $smiley
+ */
function smiley($smiley) {
- if ( array_key_exists($smiley, $this->smileys) ) {
- $title = $this->_xmlEntities($this->smileys[$smiley]);
+ if(array_key_exists($smiley, $this->smileys)) {
$this->doc .= '<img src="'.DOKU_BASE.'lib/images/smileys/'.$this->smileys[$smiley].
'" class="icon" alt="'.
- $this->_xmlEntities($smiley).'" />';
+ $this->_xmlEntities($smiley).'" />';
} else {
$this->doc .= $this->_xmlEntities($smiley);
}
}
- /*
- * not used
- function wordblock($word) {
- if ( array_key_exists($word, $this->badwords) ) {
- $this->doc .= '** BLEEP **';
- } else {
- $this->doc .= $this->_xmlEntities($word);
- }
- }
- */
-
+ /**
+ * Format an entity
+ *
+ * Entities are basically small text replacements
+ *
+ * Uses $this->entities
+ *
+ * @param string $entity
+ */
function entity($entity) {
- if ( array_key_exists($entity, $this->entities) ) {
+ if(array_key_exists($entity, $this->entities)) {
$this->doc .= $this->entities[$entity];
} else {
$this->doc .= $this->_xmlEntities($entity);
}
}
+ /**
+ * Typographically format a multiply sign
+ *
+ * Example: ($x=640, $y=480) should result in "640×480"
+ *
+ * @param string|int $x first value
+ * @param string|int $y second value
+ */
function multiplyentity($x, $y) {
$this->doc .= "$x&times;$y";
}
+ /**
+ * Render an opening single quote char (language specific)
+ */
function singlequoteopening() {
global $lang;
$this->doc .= $lang['singlequoteopening'];
}
+ /**
+ * Render a closing single quote char (language specific)
+ */
function singlequoteclosing() {
global $lang;
$this->doc .= $lang['singlequoteclosing'];
}
+ /**
+ * Render an apostrophe char (language specific)
+ */
function apostrophe() {
global $lang;
$this->doc .= $lang['apostrophe'];
}
+ /**
+ * Render an opening double quote char (language specific)
+ */
function doublequoteopening() {
global $lang;
$this->doc .= $lang['doublequoteopening'];
}
+ /**
+ * Render an closinging double quote char (language specific)
+ */
function doublequoteclosing() {
global $lang;
$this->doc .= $lang['doublequoteclosing'];
}
/**
+ * Render a CamelCase link
+ *
+ * @param string $link The link name
+ * @see http://en.wikipedia.org/wiki/CamelCase
*/
function camelcaselink($link) {
- $this->internallink($link,$link);
+ $this->internallink($link, $link);
}
-
- function locallink($hash, $name = null){
+ /**
+ * Render a page local link
+ *
+ * @param string $hash hash link identifier
+ * @param string $name name for the link
+ */
+ function locallink($hash, $name = null) {
global $ID;
$name = $this->_getLinkTitle($name, $hash, $isImage);
$hash = $this->_headerToLink($hash);
@@ -559,23 +786,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* $search,$returnonly & $linktype are not for the renderer but are used
* elsewhere - no need to implement them in other renderers
*
- * @param string $id pageid
- * @param string|null $name link name
- * @param string|null $search adds search url param
- * @param bool $returnonly whether to return html or write to doc attribute
- * @param string $linktype type to set use of headings
- * @return void|string writes to doc attribute or returns html depends on $returnonly
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $id pageid
+ * @param string|null $name link name
+ * @param string|null $search adds search url param
+ * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $linktype type to set use of headings
+ * @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- function internallink($id, $name = null, $search=null,$returnonly=false,$linktype='content') {
+ function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') {
global $conf;
global $ID;
global $INFO;
$params = '';
- $parts = explode('?', $id, 2);
- if (count($parts) === 2) {
- $id = $parts[0];
+ $parts = explode('?', $id, 2);
+ if(count($parts) === 2) {
+ $id = $parts[0];
$params = $parts[1];
}
@@ -583,7 +810,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// We need this check because _simpleTitle needs
// correct $id and resolve_pageid() use cleanID($id)
// (some things could be lost)
- if ($id === '') {
+ if($id === '') {
$id = $ID;
}
@@ -591,22 +818,22 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$default = $this->_simpleTitle($id);
// now first resolve and clean up the $id
- resolve_pageid(getNS($ID),$id,$exists);
+ resolve_pageid(getNS($ID), $id, $exists);
$name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype);
- if ( !$isImage ) {
- if ( $exists ) {
- $class='wikilink1';
+ if(!$isImage) {
+ if($exists) {
+ $class = 'wikilink1';
} else {
- $class='wikilink2';
- $link['rel']='nofollow';
+ $class = 'wikilink2';
+ $link['rel'] = 'nofollow';
}
} else {
- $class='media';
+ $class = 'media';
}
//keep hash anchor
- @list($id,$hash) = explode('#',$id,2);
+ @list($id, $hash) = explode('#', $id, 2);
if(!empty($hash)) $hash = $this->_headerToLink($hash);
//prepare for formating
@@ -615,37 +842,43 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['pre'] = '';
$link['suf'] = '';
// highlight link to current page
- if ($id == $INFO['id']) {
- $link['pre'] = '<span class="curid">';
- $link['suf'] = '</span>';
+ if($id == $INFO['id']) {
+ $link['pre'] = '<span class="curid">';
+ $link['suf'] = '</span>';
}
- $link['more'] = '';
- $link['class'] = $class;
- $link['url'] = wl($id, $params);
- $link['name'] = $name;
- $link['title'] = $id;
+ $link['more'] = '';
+ $link['class'] = $class;
+ $link['url'] = wl($id, $params);
+ $link['name'] = $name;
+ $link['title'] = $id;
//add search string
- if($search){
- ($conf['userewrite']) ? $link['url'].='?' : $link['url'].='&amp;';
- if(is_array($search)){
- $search = array_map('rawurlencode',$search);
- $link['url'] .= 's[]='.join('&amp;s[]=',$search);
- }else{
+ if($search) {
+ ($conf['userewrite']) ? $link['url'] .= '?' : $link['url'] .= '&amp;';
+ if(is_array($search)) {
+ $search = array_map('rawurlencode', $search);
+ $link['url'] .= 's[]='.join('&amp;s[]=', $search);
+ } else {
$link['url'] .= 's='.rawurlencode($search);
}
}
//keep hash
- if($hash) $link['url'].='#'.$hash;
+ if($hash) $link['url'] .= '#'.$hash;
//output formatted
- if($returnonly){
+ if($returnonly) {
return $this->_formatLink($link);
- }else{
+ } else {
$this->doc .= $this->_formatLink($link);
}
}
+ /**
+ * Render an external link
+ *
+ * @param string $url full URL with scheme
+ * @param string|array $name name for the link, array for media file
+ */
function externallink($url, $name = null) {
global $conf;
@@ -653,21 +886,21 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// url might be an attack vector, only allow registered protocols
if(is_null($this->schemes)) $this->schemes = getSchemes();
- list($scheme) = explode('://',$url);
+ list($scheme) = explode('://', $url);
$scheme = strtolower($scheme);
- if(!in_array($scheme,$this->schemes)) $url = '';
+ if(!in_array($scheme, $this->schemes)) $url = '';
// is there still an URL?
- if(!$url){
+ if(!$url) {
$this->doc .= $name;
return;
}
// set class
- if ( !$isImage ) {
- $class='urlextern';
+ if(!$isImage) {
+ $class = 'urlextern';
} else {
- $class='media';
+ $class = 'media';
}
//prepare for formating
@@ -679,8 +912,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['class'] = $class;
$link['url'] = $url;
- $link['name'] = $name;
- $link['title'] = $this->_xmlEntities($url);
+ $link['name'] = $name;
+ $link['title'] = $this->_xmlEntities($url);
if($conf['relnofollow']) $link['more'] .= ' rel="nofollow"';
//output formatted
@@ -688,11 +921,19 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
/**
+ * Render an interwiki link
+ *
+ * You may want to use $this->_resolveInterWiki() here
+ *
+ * @param string $match original link - probably not much use
+ * @param string|array $name name for the link, array for media file
+ * @param string $wikiName indentifier (shortcut) for the remote wiki
+ * @param string $wikiUri the fragment parsed from the original link
*/
function interwikilink($match, $name = null, $wikiName, $wikiUri) {
global $conf;
- $link = array();
+ $link = array();
$link['target'] = $conf['target']['interwiki'];
$link['pre'] = '';
$link['suf'] = '';
@@ -701,10 +942,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//get interwiki URL
$exists = null;
- $url = $this->_resolveInterWiki($wikiName, $wikiUri, $exists);
+ $url = $this->_resolveInterWiki($wikiName, $wikiUri, $exists);
if(!$isImage) {
- $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName);
+ $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName);
$link['class'] = "interwiki iw_$class";
} else {
$link['class'] = 'media';
@@ -723,7 +964,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
- $link['url'] = $url;
+ $link['url'] = $url;
$link['title'] = htmlspecialchars($link['url']);
//output formatted
@@ -731,54 +972,66 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
/**
+ * Link to windows share
+ *
+ * @param string $url the link
+ * @param string|array $name name for the link, array for media file
*/
function windowssharelink($url, $name = null) {
global $conf;
- global $lang;
+
//simple setup
$link['target'] = $conf['target']['windows'];
$link['pre'] = '';
- $link['suf'] = '';
+ $link['suf'] = '';
$link['style'] = '';
$link['name'] = $this->_getLinkTitle($name, $url, $isImage);
- if ( !$isImage ) {
+ if(!$isImage) {
$link['class'] = 'windows';
} else {
$link['class'] = 'media';
}
$link['title'] = $this->_xmlEntities($url);
- $url = str_replace('\\','/',$url);
- $url = 'file:///'.$url;
- $link['url'] = $url;
+ $url = str_replace('\\', '/', $url);
+ $url = 'file:///'.$url;
+ $link['url'] = $url;
//output formatted
$this->doc .= $this->_formatLink($link);
}
+ /**
+ * Render a linked E-Mail Address
+ *
+ * Honors $conf['mailguard'] setting
+ *
+ * @param string $address Email-Address
+ * @param string|array $name name for the link, array for media file
+ */
function emaillink($address, $name = null) {
global $conf;
//simple setup
- $link = array();
+ $link = array();
$link['target'] = '';
$link['pre'] = '';
- $link['suf'] = '';
+ $link['suf'] = '';
$link['style'] = '';
$link['more'] = '';
$name = $this->_getLinkTitle($name, '', $isImage);
- if ( !$isImage ) {
- $link['class']='mail';
+ if(!$isImage) {
+ $link['class'] = 'mail';
} else {
- $link['class']='media';
+ $link['class'] = 'media';
}
$address = $this->_xmlEntities($address);
$address = obfuscate($address);
$title = $address;
- if(empty($name)){
+ if(empty($name)) {
$name = $address;
}
@@ -792,73 +1045,97 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_formatLink($link);
}
- function internalmedia ($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $linking=null, $return=NULL) {
+ /**
+ * Render an internal media file
+ *
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param string $linking linkonly|detail|nolink
+ * @param bool $return return HTML instead of adding to $doc
+ * @return void|string
+ */
+ function internalmedia($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $linking = null, $return = false) {
global $ID;
- list($src,$hash) = explode('#',$src,2);
- resolve_mediaid(getNS($ID),$src, $exists);
+ list($src, $hash) = explode('#', $src, 2);
+ resolve_mediaid(getNS($ID), $src, $exists);
$noLink = false;
$render = ($linking == 'linkonly') ? false : true;
- $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
+ $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
- list($ext,$mime,$dl) = mimetype($src,false);
- if(substr($mime,0,5) == 'image' && $render){
- $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct'));
- }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){
+ list($ext, $mime) = mimetype($src, false);
+ if(substr($mime, 0, 5) == 'image' && $render) {
+ $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), ($linking == 'direct'));
+ } elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render) {
// don't link movies
$noLink = true;
- }else{
+ } else {
// add file icons
- $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
+ $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
$link['class'] .= ' mediafile mf_'.$class;
- $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
- if ($exists) $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))).')';
+ $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), true);
+ if($exists) $link['title'] .= ' ('.filesize_h(filesize(mediaFN($src))).')';
}
if($hash) $link['url'] .= '#'.$hash;
//markup non existing files
- if (!$exists) {
+ if(!$exists) {
$link['class'] .= ' wikilink2';
}
//output formatted
- if ($return) {
- if ($linking == 'nolink' || $noLink) return $link['name'];
+ if($return) {
+ if($linking == 'nolink' || $noLink) return $link['name'];
else return $this->_formatLink($link);
} else {
- if ($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
+ if($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
else $this->doc .= $this->_formatLink($link);
}
}
- function externalmedia ($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $linking=null) {
- list($src,$hash) = explode('#',$src,2);
+ /**
+ * Render an external media file
+ *
+ * @param string $src full media URL
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param string $linking linkonly|detail|nolink
+ */
+ function externalmedia($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $linking = null) {
+ list($src, $hash) = explode('#', $src, 2);
$noLink = false;
$render = ($linking == 'linkonly') ? false : true;
- $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
+ $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
- $link['url'] = ml($src,array('cache'=>$cache));
+ $link['url'] = ml($src, array('cache' => $cache));
- list($ext,$mime,$dl) = mimetype($src,false);
- if(substr($mime,0,5) == 'image' && $render){
+ list($ext, $mime) = mimetype($src, false);
+ if(substr($mime, 0, 5) == 'image' && $render) {
// link only jpeg images
// if ($ext != 'jpg' && $ext != 'jpeg') $noLink = true;
- }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){
+ } elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render) {
// don't link movies
$noLink = true;
- }else{
+ } else {
// add file icons
- $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
+ $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
$link['class'] .= ' mediafile mf_'.$class;
}
if($hash) $link['url'] .= '#'.$hash;
//output formatted
- if ($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
+ if($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
else $this->doc .= $this->_formatLink($link);
}
@@ -867,7 +1144,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function rss ($url,$params){
+ function rss($url, $params) {
global $lang;
global $conf;
@@ -876,17 +1153,21 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$feed->set_feed_url($url);
//disable warning while fetching
- if (!defined('DOKU_E_LEVEL')) { $elvl = error_reporting(E_ERROR); }
+ if(!defined('DOKU_E_LEVEL')) {
+ $elvl = error_reporting(E_ERROR);
+ }
$rc = $feed->init();
- if (!defined('DOKU_E_LEVEL')) { error_reporting($elvl); }
+ if(isset($elvl)) {
+ error_reporting($elvl);
+ }
//decide on start and end
- if($params['reverse']){
- $mod = -1;
- $start = $feed->get_item_quantity()-1;
+ if($params['reverse']) {
+ $mod = -1;
+ $start = $feed->get_item_quantity() - 1;
$end = $start - ($params['max']);
$end = ($end < -1) ? -1 : $end;
- }else{
+ } else {
$mod = 1;
$start = 0;
$end = $feed->get_item_quantity();
@@ -894,36 +1175,38 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
$this->doc .= '<ul class="rss">';
- if($rc){
- for ($x = $start; $x != $end; $x += $mod) {
+ if($rc) {
+ for($x = $start; $x != $end; $x += $mod) {
$item = $feed->get_item($x);
$this->doc .= '<li><div class="li">';
// support feeds without links
$lnkurl = $item->get_permalink();
- if($lnkurl){
+ if($lnkurl) {
// title is escaped by SimplePie, we unescape here because it
// is escaped again in externallink() FS#1705
- $this->externallink($item->get_permalink(),
- html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'));
- }else{
+ $this->externallink(
+ $item->get_permalink(),
+ html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8')
+ );
+ } else {
$this->doc .= ' '.$item->get_title();
}
- if($params['author']){
+ if($params['author']) {
$author = $item->get_author(0);
- if($author){
+ if($author) {
$name = $author->get_name();
if(!$name) $name = $author->get_email();
if($name) $this->doc .= ' '.$lang['by'].' '.$name;
}
}
- if($params['date']){
+ if($params['date']) {
$this->doc .= ' ('.$item->get_local_date($conf['dformat']).')';
}
- if($params['details']){
+ if($params['details']) {
$this->doc .= '<div class="detail">';
- if($conf['htmlok']){
+ if($conf['htmlok']) {
$this->doc .= $item->get_description();
- }else{
+ } else {
$this->doc .= strip_tags($item->get_description());
}
$this->doc .= '</div>';
@@ -931,11 +1214,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '</div></li>';
}
- }else{
+ } else {
$this->doc .= '<li><div class="li">';
$this->doc .= '<em>'.$lang['rssfailed'].'</em>';
$this->externallink($url);
- if($conf['allowdebug']){
+ if($conf['allowdebug']) {
$this->doc .= '<!--'.hsc($feed->error).'-->';
}
$this->doc .= '</div></li>';
@@ -943,89 +1226,130 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '</ul>';
}
- // $numrows not yet implemented
- function table_open($maxcols = null, $numrows = null, $pos = null){
- global $lang;
+ /**
+ * Start a table
+ *
+ * @param int $maxcols maximum number of columns
+ * @param int $numrows NOT IMPLEMENTED
+ * @param int $pos byte position in the original source
+ */
+ function table_open($maxcols = null, $numrows = null, $pos = null) {
// initialize the row counter used for classes
$this->_counter['row_counter'] = 0;
- $class = 'table';
- if ($pos !== null) {
- $class .= ' ' . $this->startSectionEdit($pos, 'table');
+ $class = 'table';
+ if($pos !== null) {
+ $class .= ' '.$this->startSectionEdit($pos, 'table');
}
- $this->doc .= '<div class="' . $class . '"><table class="inline">' .
- DOKU_LF;
+ $this->doc .= '<div class="'.$class.'"><table class="inline">'.
+ DOKU_LF;
}
- function table_close($pos = null){
+ /**
+ * Close a table
+ *
+ * @param int $pos byte position in the original source
+ */
+ function table_close($pos = null) {
$this->doc .= '</table></div>'.DOKU_LF;
- if ($pos !== null) {
+ if($pos !== null) {
$this->finishSectionEdit($pos);
}
}
- function tablethead_open(){
- $this->doc .= DOKU_TAB . '<thead>' . DOKU_LF;
+ /**
+ * Open a table header
+ */
+ function tablethead_open() {
+ $this->doc .= DOKU_TAB.'<thead>'.DOKU_LF;
}
- function tablethead_close(){
- $this->doc .= DOKU_TAB . '</thead>' . DOKU_LF;
+ /**
+ * Close a table header
+ */
+ function tablethead_close() {
+ $this->doc .= DOKU_TAB.'</thead>'.DOKU_LF;
}
- function tablerow_open(){
+ /**
+ * Open a table row
+ */
+ function tablerow_open() {
// initialize the cell counter used for classes
$this->_counter['cell_counter'] = 0;
- $class = 'row' . $this->_counter['row_counter']++;
- $this->doc .= DOKU_TAB . '<tr class="'.$class.'">' . DOKU_LF . DOKU_TAB . DOKU_TAB;
+ $class = 'row'.$this->_counter['row_counter']++;
+ $this->doc .= DOKU_TAB.'<tr class="'.$class.'">'.DOKU_LF.DOKU_TAB.DOKU_TAB;
}
- function tablerow_close(){
- $this->doc .= DOKU_LF . DOKU_TAB . '</tr>' . DOKU_LF;
+ /**
+ * Close a table row
+ */
+ function tablerow_close() {
+ $this->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF;
}
- function tableheader_open($colspan = 1, $align = null, $rowspan = 1){
- $class = 'class="col' . $this->_counter['cell_counter']++;
- if ( !is_null($align) ) {
+ /**
+ * Open a table header cell
+ *
+ * @param int $colspan
+ * @param string $align left|center|right
+ * @param int $rowspan
+ */
+ function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
+ $class = 'class="col'.$this->_counter['cell_counter']++;
+ if(!is_null($align)) {
$class .= ' '.$align.'align';
}
$class .= '"';
- $this->doc .= '<th ' . $class;
- if ( $colspan > 1 ) {
- $this->_counter['cell_counter'] += $colspan-1;
+ $this->doc .= '<th '.$class;
+ if($colspan > 1) {
+ $this->_counter['cell_counter'] += $colspan - 1;
$this->doc .= ' colspan="'.$colspan.'"';
}
- if ( $rowspan > 1 ) {
+ if($rowspan > 1) {
$this->doc .= ' rowspan="'.$rowspan.'"';
}
$this->doc .= '>';
}
- function tableheader_close(){
+ /**
+ * Close a table header cell
+ */
+ function tableheader_close() {
$this->doc .= '</th>';
}
- function tablecell_open($colspan = 1, $align = null, $rowspan = 1){
- $class = 'class="col' . $this->_counter['cell_counter']++;
- if ( !is_null($align) ) {
+ /**
+ * Open a table cell
+ *
+ * @param int $colspan
+ * @param string $align left|center|right
+ * @param int $rowspan
+ */
+ function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
+ $class = 'class="col'.$this->_counter['cell_counter']++;
+ if(!is_null($align)) {
$class .= ' '.$align.'align';
}
$class .= '"';
$this->doc .= '<td '.$class;
- if ( $colspan > 1 ) {
- $this->_counter['cell_counter'] += $colspan-1;
+ if($colspan > 1) {
+ $this->_counter['cell_counter'] += $colspan - 1;
$this->doc .= ' colspan="'.$colspan.'"';
}
- if ( $rowspan > 1 ) {
+ if($rowspan > 1) {
$this->doc .= ' rowspan="'.$rowspan.'"';
}
$this->doc .= '>';
}
- function tablecell_close(){
+ /**
+ * Close a table cell
+ */
+ function tablecell_close() {
$this->doc .= '</td>';
}
- //----------------------------------------------------------
- // Utils
+ #region Utility functions
/**
* Build a link
@@ -1034,29 +1358,29 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _formatLink($link){
+ function _formatLink($link) {
//make sure the url is XHTML compliant (skip mailto)
- if(substr($link['url'],0,7) != 'mailto:'){
- $link['url'] = str_replace('&','&amp;',$link['url']);
- $link['url'] = str_replace('&amp;amp;','&amp;',$link['url']);
+ if(substr($link['url'], 0, 7) != 'mailto:') {
+ $link['url'] = str_replace('&', '&amp;', $link['url']);
+ $link['url'] = str_replace('&amp;amp;', '&amp;', $link['url']);
}
//remove double encodings in titles
- $link['title'] = str_replace('&amp;amp;','&amp;',$link['title']);
+ $link['title'] = str_replace('&amp;amp;', '&amp;', $link['title']);
// be sure there are no bad chars in url or title
// (we can't do this for name because it can contain an img tag)
- $link['url'] = strtr($link['url'],array('>'=>'%3E','<'=>'%3C','"'=>'%22'));
- $link['title'] = strtr($link['title'],array('>'=>'&gt;','<'=>'&lt;','"'=>'&quot;'));
+ $link['url'] = strtr($link['url'], array('>' => '%3E', '<' => '%3C', '"' => '%22'));
+ $link['title'] = strtr($link['title'], array('>' => '&gt;', '<' => '&lt;', '"' => '&quot;'));
- $ret = '';
+ $ret = '';
$ret .= $link['pre'];
$ret .= '<a href="'.$link['url'].'"';
- if(!empty($link['class'])) $ret .= ' class="'.$link['class'].'"';
+ if(!empty($link['class'])) $ret .= ' class="'.$link['class'].'"';
if(!empty($link['target'])) $ret .= ' target="'.$link['target'].'"';
- if(!empty($link['title'])) $ret .= ' title="'.$link['title'].'"';
- if(!empty($link['style'])) $ret .= ' style="'.$link['style'].'"';
- if(!empty($link['rel'])) $ret .= ' rel="'.$link['rel'].'"';
- if(!empty($link['more'])) $ret .= ' '.$link['more'];
+ if(!empty($link['title'])) $ret .= ' title="'.$link['title'].'"';
+ if(!empty($link['style'])) $ret .= ' style="'.$link['style'].'"';
+ if(!empty($link['rel'])) $ret .= ' rel="'.$link['rel'].'"';
+ if(!empty($link['more'])) $ret .= ' '.$link['more'];
$ret .= '>';
$ret .= $link['name'];
$ret .= '</a>';
@@ -1068,102 +1392,112 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* Renders internal and external media
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param bool $render should the media be embedded inline or just linked
+ * @return string
*/
- function _media ($src, $title=null, $align=null, $width=null,
- $height=null, $cache=null, $render = true) {
+ function _media($src, $title = null, $align = null, $width = null,
+ $height = null, $cache = null, $render = true) {
$ret = '';
- list($ext,$mime,$dl) = mimetype($src);
- if(substr($mime,0,5) == 'image'){
+ list($ext, $mime) = mimetype($src);
+ if(substr($mime, 0, 5) == 'image') {
// first get the $title
- if (!is_null($title)) {
- $title = $this->_xmlEntities($title);
- }elseif($ext == 'jpg' || $ext == 'jpeg'){
+ if(!is_null($title)) {
+ $title = $this->_xmlEntities($title);
+ } elseif($ext == 'jpg' || $ext == 'jpeg') {
//try to use the caption from IPTC/EXIF
require_once(DOKU_INC.'inc/JpegMeta.php');
- $jpeg =new JpegMeta(mediaFN($src));
+ $jpeg = new JpegMeta(mediaFN($src));
if($jpeg !== false) $cap = $jpeg->getTitle();
- if($cap){
+ if(!empty($cap)) {
$title = $this->_xmlEntities($cap);
}
}
- if (!$render) {
+ if(!$render) {
// if the picture is not supposed to be rendered
// return the title of the picture
- if (!$title) {
+ if(!$title) {
// just show the sourcename
$title = $this->_xmlEntities(utf8_basename(noNS($src)));
}
return $title;
}
//add image tag
- $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"';
+ $ret .= '<img src="'.ml($src, array('w' => $width, 'h' => $height, 'cache' => $cache)).'"';
$ret .= ' class="media'.$align.'"';
- if ($title) {
- $ret .= ' title="' . $title . '"';
- $ret .= ' alt="' . $title .'"';
- }else{
+ if($title) {
+ $ret .= ' title="'.$title.'"';
+ $ret .= ' alt="'.$title.'"';
+ } else {
$ret .= ' alt=""';
}
- if ( !is_null($width) )
+ if(!is_null($width))
$ret .= ' width="'.$this->_xmlEntities($width).'"';
- if ( !is_null($height) )
+ if(!is_null($height))
$ret .= ' height="'.$this->_xmlEntities($height).'"';
$ret .= ' />';
- }elseif(media_supportedav($mime, 'video') || media_supportedav($mime, 'audio')){
+ } elseif(media_supportedav($mime, 'video') || media_supportedav($mime, 'audio')) {
// first get the $title
$title = !is_null($title) ? $this->_xmlEntities($title) : false;
- if (!$render) {
+ if(!$render) {
// if the file is not supposed to be rendered
// return the title of the file (just the sourcename if there is no title)
return $title ? $title : $this->_xmlEntities(utf8_basename(noNS($src)));
}
- $att = array();
+ $att = array();
$att['class'] = "media$align";
- if ($title) {
+ if($title) {
$att['title'] = $title;
}
- if (media_supportedav($mime, 'video')) {
+ if(media_supportedav($mime, 'video')) {
//add video
$ret .= $this->_video($src, $width, $height, $att);
}
- if (media_supportedav($mime, 'audio')) {
+ if(media_supportedav($mime, 'audio')) {
//add audio
$ret .= $this->_audio($src, $att);
}
- }elseif($mime == 'application/x-shockwave-flash'){
- if (!$render) {
+ } elseif($mime == 'application/x-shockwave-flash') {
+ if(!$render) {
// if the flash is not supposed to be rendered
// return the title of the flash
- if (!$title) {
+ if(!$title) {
// just show the sourcename
$title = utf8_basename(noNS($src));
}
return $this->_xmlEntities($title);
}
- $att = array();
+ $att = array();
$att['class'] = "media$align";
if($align == 'right') $att['align'] = 'right';
- if($align == 'left') $att['align'] = 'left';
- $ret .= html_flashobject(ml($src,array('cache'=>$cache),true,'&'),$width,$height,
- array('quality' => 'high'),
- null,
- $att,
- $this->_xmlEntities($title));
- }elseif($title){
+ if($align == 'left') $att['align'] = 'left';
+ $ret .= html_flashobject(
+ ml($src, array('cache' => $cache), true, '&'), $width, $height,
+ array('quality' => 'high'),
+ null,
+ $att,
+ $this->_xmlEntities($title)
+ );
+ } elseif($title) {
// well at least we have a title to display
$ret .= $this->_xmlEntities($title);
- }else{
+ } else {
// just show the sourcename
$ret .= $this->_xmlEntities(utf8_basename(noNS($src)));
}
@@ -1171,23 +1505,30 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $ret;
}
+ /**
+ * Escape string for output
+ *
+ * @param $string
+ * @return string
+ */
function _xmlEntities($string) {
- return htmlspecialchars($string,ENT_QUOTES,'UTF-8');
+ return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
/**
* Creates a linkid from a headline
*
+ * @author Andreas Gohr <andi@splitbrain.org>
* @param string $title The headline title
* @param boolean $create Create a new unique ID?
- * @author Andreas Gohr <andi@splitbrain.org>
+ * @return string
*/
- function _headerToLink($title,$create=false) {
- if($create){
- return sectionID($title,$this->headers);
- }else{
+ function _headerToLink($title, $create = false) {
+ if($create) {
+ return sectionID($title, $this->headers);
+ } else {
$check = false;
- return sectionID($title,$check);
+ return sectionID($title, $check);
}
}
@@ -1195,18 +1536,22 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* Construct a title and handle images in titles
*
* @author Harry Fuecks <hfuecks@gmail.com>
+ * @param string|array $title either string title or media array
+ * @param string $default default title if nothing else is found
+ * @param bool $isImage will be set to true if it's a media file
+ * @param null|string $id linked page id (used to extract title from first heading)
+ * @param string $linktype content|navigation
+ * @return string HTML of the title, might be full image tag or just escaped text
*/
- function _getLinkTitle($title, $default, & $isImage, $id=null, $linktype='content') {
- global $conf;
-
+ function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') {
$isImage = false;
- if ( is_array($title) ) {
+ if(is_array($title)) {
$isImage = true;
return $this->_imageTitle($title);
- } elseif ( is_null($title) || trim($title)=='') {
- if (useHeading($linktype) && $id) {
+ } elseif(is_null($title) || trim($title) == '') {
+ if(useHeading($linktype) && $id) {
$heading = p_get_first_heading($id);
- if ($heading) {
+ if($heading) {
return $this->_xmlEntities($heading);
}
}
@@ -1217,48 +1562,51 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
/**
- * Returns an HTML code for images used in link titles
+ * Returns HTML code for images used in link titles
*
- * @todo Resolve namespace on internal images
* @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $img
+ * @return string HTML img tag or similar
*/
function _imageTitle($img) {
global $ID;
// some fixes on $img['src']
// see internalmedia() and externalmedia()
- list($img['src'],$hash) = explode('#',$img['src'],2);
- if ($img['type'] == 'internalmedia') {
- resolve_mediaid(getNS($ID),$img['src'],$exists);
+ list($img['src']) = explode('#', $img['src'], 2);
+ if($img['type'] == 'internalmedia') {
+ resolve_mediaid(getNS($ID), $img['src'], $exists);
}
- return $this->_media($img['src'],
- $img['title'],
- $img['align'],
- $img['width'],
- $img['height'],
- $img['cache']);
+ return $this->_media(
+ $img['src'],
+ $img['title'],
+ $img['align'],
+ $img['width'],
+ $img['height'],
+ $img['cache']
+ );
}
/**
- * _getMediaLinkConf is a helperfunction to internalmedia() and externalmedia()
- * which returns a basic link to a media.
+ * helperfunction to return a basic link to a media
+ *
+ * used in internalmedia() and externalmedia()
*
- * @author Pierre Spring <pierre.spring@liip.ch>
- * @param string $src
- * @param string $title
- * @param string $align
- * @param string $width
- * @param string $height
- * @param string $cache
- * @param string $render
- * @access protected
- * @return array
+ * @author Pierre Spring <pierre.spring@liip.ch>
+ * @param string $src media ID
+ * @param string $title descriptive text
+ * @param string $align left|center|right
+ * @param int $width width of media in pixel
+ * @param int $height height of media in pixel
+ * @param string $cache cache|recache|nocache
+ * @param bool $render should the media be embedded inline or just linked
+ * @return array associative array with link config
*/
function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) {
global $conf;
- $link = array();
+ $link = array();
$link['class'] = 'media';
$link['style'] = '';
$link['pre'] = '';
@@ -1271,50 +1619,49 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $link;
}
-
/**
* Embed video(s) in HTML
*
* @author Anika Henke <anika@selfthinker.org>
*
- * @param string $src - ID of video to embed
- * @param int $width - width of the video in pixels
- * @param int $height - height of the video in pixels
- * @param array $atts - additional attributes for the <video> tag
+ * @param string $src - ID of video to embed
+ * @param int $width - width of the video in pixels
+ * @param int $height - height of the video in pixels
+ * @param array $atts - additional attributes for the <video> tag
* @return string
*/
- function _video($src,$width,$height,$atts=null){
+ function _video($src, $width, $height, $atts = null) {
// prepare width and height
if(is_null($atts)) $atts = array();
$atts['width'] = (int) $width;
$atts['height'] = (int) $height;
- if(!$atts['width']) $atts['width'] = 320;
+ if(!$atts['width']) $atts['width'] = 320;
if(!$atts['height']) $atts['height'] = 240;
// prepare alternative formats
- $extensions = array('webm', 'ogv', 'mp4');
+ $extensions = array('webm', 'ogv', 'mp4');
$alternatives = media_alternativefiles($src, $extensions);
- $poster = media_alternativefiles($src, array('jpg', 'png'), true);
- $posterUrl = '';
- if (!empty($poster)) {
- $posterUrl = ml(reset($poster),array('cache'=>$cache),true,'&');
+ $poster = media_alternativefiles($src, array('jpg', 'png'), true);
+ $posterUrl = '';
+ if(!empty($poster)) {
+ $posterUrl = ml(reset($poster), '', true, '&');
}
$out = '';
// open video tag
$out .= '<video '.buildAttributes($atts).' controls="controls"';
- if ($posterUrl) $out .= ' poster="'.hsc($posterUrl).'"';
+ if($posterUrl) $out .= ' poster="'.hsc($posterUrl).'"';
$out .= '>'.NL;
$fallback = '';
// output source for each alternative video format
foreach($alternatives as $mime => $file) {
- $url = ml($file,array('cache'=>$cache),true,'&');
+ $url = ml($file, '', true, '&');
$title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file)));
$out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
// alternative content (just a link to the file)
- $fallback .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly', $return=true);
+ $fallback .= $this->internalmedia($file, $title, null, null, null, $cache = null, $linking = 'linkonly', $return = true);
}
// finish
@@ -1328,14 +1675,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Anika Henke <anika@selfthinker.org>
*
- * @param string $src - ID of audio to embed
- * @param array $atts - additional attributes for the <audio> tag
+ * @param string $src - ID of audio to embed
+ * @param array $atts - additional attributes for the <audio> tag
* @return string
*/
- function _audio($src,$atts=null){
+ function _audio($src, $atts = null) {
// prepare alternative formats
- $extensions = array('ogg', 'mp3', 'wav');
+ $extensions = array('ogg', 'mp3', 'wav');
$alternatives = media_alternativefiles($src, $extensions);
$out = '';
@@ -1345,12 +1692,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// output source for each alternative audio format
foreach($alternatives as $mime => $file) {
- $url = ml($file,array('cache'=>$cache),true,'&');
+ $url = ml($file, '', true, '&');
$title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file)));
$out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
// alternative content (just a link to the file)
- $fallback .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly', $return=true);
+ $fallback .= $this->internalmedia($file, $title, null, null, null, $cache = null, $linking = 'linkonly', $return = true);
}
// finish
@@ -1359,6 +1706,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $out;
}
+ #endregion
}
//Setup VIM: ex: et ts=4 :
diff --git a/inc/subscription.php b/inc/subscription.php
index a6f3dec44..aab6de926 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -650,9 +650,11 @@ class Subscription {
* @todo move the whole functionality into this class, trigger SUBSCRIPTION_NOTIFY_ADDRESSLIST instead,
* use an array for the addresses within it
*
- * @param array &$data Containing $id (the page id), $self (whether the author
- * should be notified, $addresslist (current email address
- * list)
+ * @param array &$data Containing the entries:
+ * - $id (the page id),
+ * - $self (whether the author should be notified,
+ * - $addresslist (current email address list)
+ * - $replacements (array of additional string substitutions, @KEY@ to be replaced by value)
*/
public function notifyaddresses(&$data) {
if(!$this->isenabled()) return;