aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/parser
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/code.php31
-rw-r--r--inc/parser/handler.php625
-rw-r--r--inc/parser/metadata.php175
-rw-r--r--inc/parser/parser.php53
-rw-r--r--inc/parser/renderer.php491
-rw-r--r--inc/parser/xhtml.php1300
-rw-r--r--inc/parser/xhtmlsummary.php56
7 files changed, 1522 insertions, 1209 deletions
diff --git a/inc/parser/code.php b/inc/parser/code.php
index cded87d6d..ac2e136dd 100644
--- a/inc/parser/code.php
+++ b/inc/parser/code.php
@@ -1,10 +1,15 @@
<?php
+
+use dokuwiki\Utf8\Clean;
+use dokuwiki\Utf8\PhpString;
+
/**
* A simple renderer that allows downloading of code and file snippets
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-class Doku_Renderer_code extends Doku_Renderer {
+class Doku_Renderer_code extends Doku_Renderer
+{
protected $_codeblock = 0;
/**
@@ -16,20 +21,21 @@ class Doku_Renderer_code extends Doku_Renderer {
* @param string $language
* @param string $filename
*/
- public function code($text, $language = null, $filename = '') {
+ public function code($text, $language = null, $filename = '')
+ {
global $INPUT;
- if(!$language) $language = 'txt';
+ if (!$language) $language = 'txt';
$language = preg_replace(PREG_PATTERN_VALID_LANGUAGE, '', $language);
- if(!$filename) $filename = 'snippet.'.$language;
- $filename = \dokuwiki\Utf8\PhpString::basename($filename);
- $filename = \dokuwiki\Utf8\Clean::stripspecials($filename, '_');
+ if (!$filename) $filename = 'snippet.' . $language;
+ $filename = PhpString::basename($filename);
+ $filename = Clean::stripspecials($filename, '_');
// send CRLF to Windows clients
- if(strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false) {
+ if (strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false) {
$text = str_replace("\n", "\r\n", $text);
}
- 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");
@@ -47,14 +53,16 @@ class Doku_Renderer_code extends Doku_Renderer {
* @param string $language
* @param string $filename
*/
- public function file($text, $language = null, $filename = '') {
+ public function file($text, $language = null, $filename = '')
+ {
$this->code($text, $language, $filename);
}
/**
* This should never be reached, if it is send a 404
*/
- public function document_end() {
+ public function document_end()
+ {
http_status(404);
echo '404 - Not found';
exit;
@@ -65,7 +73,8 @@ class Doku_Renderer_code extends Doku_Renderer {
*
* @returns string 'code'
*/
- public function getFormat() {
+ public function getFormat()
+ {
return 'code';
}
}
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 1ef9ffdd5..c68190442 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -14,18 +14,19 @@ use dokuwiki\Parsing\Handler\Table;
/**
* Class Doku_Handler
*/
-class Doku_Handler {
+class Doku_Handler
+{
/** @var CallWriterInterface */
- protected $callWriter = null;
+ protected $callWriter;
/** @var array The current CallWriter will write directly to this list of calls, Parser reads it */
- public $calls = array();
+ public $calls = [];
/** @var array internal status holders for some modes */
- protected $status = array(
+ protected $status = [
'section' => false,
- 'doublequote' => 0,
- );
+ 'doublequote' => 0
+ ];
/** @var bool should blocks be rewritten? FIXME seems to always be true */
protected $rewriteBlocks = true;
@@ -38,7 +39,8 @@ class Doku_Handler {
/**
* Doku_Handler constructor.
*/
- public function __construct() {
+ public function __construct()
+ {
$this->callWriter = new CallWriter($this);
}
@@ -47,10 +49,11 @@ class Doku_Handler {
*
* @param string $handler handler method name (see mode handlers below)
* @param mixed $args arguments for this call
- * @param int $pos byte position in the original source file
+ * @param int $pos byte position in the original source file
*/
- public function addCall($handler, $args, $pos) {
- $call = array($handler,$args, $pos);
+ public function addCall($handler, $args, $pos)
+ {
+ $call = [$handler, $args, $pos];
$this->callWriter->writeCall($call);
}
@@ -59,7 +62,8 @@ class Doku_Handler {
*
* @return CallWriterInterface
*/
- public function getCallWriter() {
+ public function getCallWriter()
+ {
return $this->callWriter;
}
@@ -68,7 +72,8 @@ class Doku_Handler {
*
* @param CallWriterInterface $callWriter
*/
- public function setCallWriter($callWriter) {
+ public function setCallWriter($callWriter)
+ {
$this->callWriter = $callWriter;
}
@@ -78,7 +83,8 @@ class Doku_Handler {
* @param string $status
* @return mixed|null
*/
- public function getStatus($status) {
+ public function getStatus($status)
+ {
if (!isset($this->status[$status])) return null;
return $this->status[$status];
}
@@ -89,12 +95,14 @@ class Doku_Handler {
* @param string $status
* @param mixed $value
*/
- public function setStatus($status, $value) {
+ public function setStatus($status, $value)
+ {
$this->status[$status] = $value;
}
/** @deprecated 2019-10-31 use addCall() instead */
- public function _addCall($handler, $args, $pos) {
+ public function _addCall($handler, $args, $pos)
+ {
dbg_deprecated('addCall');
$this->addCall($handler, $args, $pos);
}
@@ -108,8 +116,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @param string $match matched syntax
*/
- public function addPluginCall($plugin, $args, $state, $pos, $match) {
- $call = array('plugin',array($plugin, $args, $state, $match), $pos);
+ public function addPluginCall($plugin, $args, $state, $pos, $match)
+ {
+ $call = ['plugin', [$plugin, $args, $state, $match], $pos];
$this->callWriter->writeCall($call);
}
@@ -121,24 +130,25 @@ class Doku_Handler {
*
* @triggers PARSER_HANDLER_DONE
*/
- public function finalize(){
+ public function finalize()
+ {
$this->callWriter->finalise();
- if ( $this->status['section'] ) {
+ if ($this->status['section']) {
$last_call = end($this->calls);
- array_push($this->calls,array('section_close',array(), $last_call[2]));
+ $this->calls[] = ['section_close', [], $last_call[2]];
}
- if ( $this->rewriteBlocks ) {
+ if ($this->rewriteBlocks) {
$B = new Block();
$this->calls = $B->process($this->calls);
}
- Event::createAndTrigger('PARSER_HANDLER_DONE',$this);
+ Event::createAndTrigger('PARSER_HANDLER_DONE', $this);
- array_unshift($this->calls,array('document_start',array(),0));
+ array_unshift($this->calls, ['document_start', [], 0]);
$last_call = end($this->calls);
- array_push($this->calls,array('document_end',array(),$last_call[2]));
+ $this->calls[] = ['document_end', [], $last_call[2]];
}
/**
@@ -147,9 +157,10 @@ class Doku_Handler {
* @fixme seems to be unused?
* @return bool|mixed
*/
- public function fetch() {
+ public function fetch()
+ {
$call = current($this->calls);
- if($call !== false) {
+ if ($call !== false) {
next($this->calls); //advance the pointer
return $call;
}
@@ -169,8 +180,9 @@ class Doku_Handler {
* @return array|null Array of key-value pairs $array['key'] = 'value';
* or null if no entries found
*/
- protected function parse_highlight_options($options) {
- $result = array();
+ protected function parse_highlight_options($options)
+ {
+ $result = [];
preg_match_all('/(\w+(?:="[^"]*"))|(\w+(?:=[^\s]*))|(\w+[^=\s\]])(?:\s*)/', $options, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$equal_sign = strpos($match [0], '=');
@@ -179,7 +191,7 @@ class Doku_Handler {
$result [$key] = 1;
} else {
$key = substr($match[0], 0, $equal_sign);
- $value = substr($match[0], $equal_sign+1);
+ $value = substr($match[0], $equal_sign + 1);
$value = trim($value, '"');
if (strlen($value) > 0) {
$result [$key] = $value;
@@ -192,34 +204,34 @@ class Doku_Handler {
// Check for supported options
$result = array_intersect_key(
$result,
- array_flip(array(
- 'enable_line_numbers',
- 'start_line_numbers_at',
- 'highlight_lines_extra',
- 'enable_keyword_links')
- )
+ array_flip([
+ 'enable_line_numbers',
+ 'start_line_numbers_at',
+ 'highlight_lines_extra',
+ 'enable_keyword_links'
+ ])
);
// Sanitize values
- if(isset($result['enable_line_numbers'])) {
- if($result['enable_line_numbers'] === 'false') {
+ if (isset($result['enable_line_numbers'])) {
+ if ($result['enable_line_numbers'] === 'false') {
$result['enable_line_numbers'] = false;
}
- $result['enable_line_numbers'] = (bool) $result['enable_line_numbers'];
+ $result['enable_line_numbers'] = (bool)$result['enable_line_numbers'];
}
- if(isset($result['highlight_lines_extra'])) {
+ if (isset($result['highlight_lines_extra'])) {
$result['highlight_lines_extra'] = array_map('intval', explode(',', $result['highlight_lines_extra']));
$result['highlight_lines_extra'] = array_filter($result['highlight_lines_extra']);
$result['highlight_lines_extra'] = array_unique($result['highlight_lines_extra']);
}
- if(isset($result['start_line_numbers_at'])) {
- $result['start_line_numbers_at'] = (int) $result['start_line_numbers_at'];
+ if (isset($result['start_line_numbers_at'])) {
+ $result['start_line_numbers_at'] = (int)$result['start_line_numbers_at'];
}
- if(isset($result['enable_keyword_links'])) {
- if($result['enable_keyword_links'] === 'false') {
+ if (isset($result['enable_keyword_links'])) {
+ if ($result['enable_keyword_links'] === 'false') {
$result['enable_keyword_links'] = false;
}
- $result['enable_keyword_links'] = (bool) $result['enable_keyword_links'];
+ $result['enable_keyword_links'] = (bool)$result['enable_keyword_links'];
}
if (count($result) == 0) {
return null;
@@ -236,16 +248,17 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @param string $name actual mode name
*/
- protected function nestingTag($match, $state, $pos, $name) {
- switch ( $state ) {
+ protected function nestingTag($match, $state, $pos, $name)
+ {
+ switch ($state) {
case DOKU_LEXER_ENTER:
- $this->addCall($name.'_open', array(), $pos);
+ $this->addCall($name . '_open', [], $pos);
break;
case DOKU_LEXER_EXIT:
- $this->addCall($name.'_close', array(), $pos);
+ $this->addCall($name . '_close', [], $pos);
break;
case DOKU_LEXER_UNMATCHED:
- $this->addCall('cdata', array($match), $pos);
+ $this->addCall('cdata', [$match], $pos);
break;
}
}
@@ -268,23 +281,24 @@ class Doku_Handler {
* An additional parameter with the plugin name is passed. The plugin's handle()
* method is called here
*
- * @author Andreas Gohr <andi@splitbrain.org>
- *
* @param string $match matched syntax
* @param int $state a LEXER_STATE_* constant
* @param int $pos byte position in the original source file
* @param string $pluginname name of the plugin
* @return bool mode handled?
+ * @author Andreas Gohr <andi@splitbrain.org>
+ *
*/
- public function plugin($match, $state, $pos, $pluginname){
- $data = array($match);
+ public function plugin($match, $state, $pos, $pluginname)
+ {
+ $data = [$match];
/** @var SyntaxPlugin $plugin */
- $plugin = plugin_load('syntax',$pluginname);
- if($plugin != null){
+ $plugin = plugin_load('syntax', $pluginname);
+ if ($plugin != null) {
$data = $plugin->handle($match, $state, $pos, $this);
}
if ($data !== false) {
- $this->addPluginCall($pluginname,$data,$state,$pos,$match);
+ $this->addPluginCall($pluginname, $data, $state, $pos, $match);
}
return true;
}
@@ -295,12 +309,11 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function base($match, $state, $pos) {
- switch ( $state ) {
- case DOKU_LEXER_UNMATCHED:
- $this->addCall('cdata', array($match), $pos);
- return true;
- break;
+ public function base($match, $state, $pos)
+ {
+ if ($state === DOKU_LEXER_UNMATCHED) {
+ $this->addCall('cdata', [$match], $pos);
+ return true;
}
return false;
}
@@ -311,19 +324,20 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function header($match, $state, $pos) {
+ public function header($match, $state, $pos)
+ {
// get level and title
$title = trim($match);
- $level = 7 - strspn($title,'=');
- if($level < 1) $level = 1;
- $title = trim($title,'=');
+ $level = 7 - strspn($title, '=');
+ if ($level < 1) $level = 1;
+ $title = trim($title, '=');
$title = trim($title);
- if ($this->status['section']) $this->addCall('section_close', array(), $pos);
+ if ($this->status['section']) $this->addCall('section_close', [], $pos);
- $this->addCall('header', array($title, $level, $pos), $pos);
+ $this->addCall('header', [$title, $level, $pos], $pos);
- $this->addCall('section_open', array($level), $pos);
+ $this->addCall('section_open', [$level], $pos);
$this->status['section'] = true;
return true;
}
@@ -334,8 +348,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function notoc($match, $state, $pos) {
- $this->addCall('notoc', array(), $pos);
+ public function notoc($match, $state, $pos)
+ {
+ $this->addCall('notoc', [], $pos);
return true;
}
@@ -345,8 +360,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function nocache($match, $state, $pos) {
- $this->addCall('nocache', array(), $pos);
+ public function nocache($match, $state, $pos)
+ {
+ $this->addCall('nocache', [], $pos);
return true;
}
@@ -356,8 +372,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function linebreak($match, $state, $pos) {
- $this->addCall('linebreak', array(), $pos);
+ public function linebreak($match, $state, $pos)
+ {
+ $this->addCall('linebreak', [], $pos);
return true;
}
@@ -367,8 +384,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function eol($match, $state, $pos) {
- $this->addCall('eol', array(), $pos);
+ public function eol($match, $state, $pos)
+ {
+ $this->addCall('eol', [], $pos);
return true;
}
@@ -378,8 +396,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function hr($match, $state, $pos) {
- $this->addCall('hr', array(), $pos);
+ public function hr($match, $state, $pos)
+ {
+ $this->addCall('hr', [], $pos);
return true;
}
@@ -389,7 +408,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function strong($match, $state, $pos) {
+ public function strong($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'strong');
return true;
}
@@ -400,7 +420,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function emphasis($match, $state, $pos) {
+ public function emphasis($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'emphasis');
return true;
}
@@ -411,7 +432,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function underline($match, $state, $pos) {
+ public function underline($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'underline');
return true;
}
@@ -422,7 +444,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function monospace($match, $state, $pos) {
+ public function monospace($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'monospace');
return true;
}
@@ -433,7 +456,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function subscript($match, $state, $pos) {
+ public function subscript($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'subscript');
return true;
}
@@ -444,7 +468,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function superscript($match, $state, $pos) {
+ public function superscript($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'superscript');
return true;
}
@@ -455,7 +480,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function deleted($match, $state, $pos) {
+ public function deleted($match, $state, $pos)
+ {
$this->nestingTag($match, $state, $pos, 'deleted');
return true;
}
@@ -466,39 +492,40 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function footnote($match, $state, $pos) {
+ public function footnote($match, $state, $pos)
+ {
if (!isset($this->footnote)) $this->footnote = false;
- switch ( $state ) {
+ switch ($state) {
case DOKU_LEXER_ENTER:
// footnotes can not be nested - however due to limitations in lexer it can't be prevented
// we will still enter a new footnote mode, we just do nothing
if ($this->footnote) {
- $this->addCall('cdata', array($match), $pos);
+ $this->addCall('cdata', [$match], $pos);
break;
}
$this->footnote = true;
$this->callWriter = new Nest($this->callWriter, 'footnote_close');
- $this->addCall('footnote_open', array(), $pos);
- break;
+ $this->addCall('footnote_open', [], $pos);
+ break;
case DOKU_LEXER_EXIT:
// check whether we have already exitted the footnote mode, can happen if the modes were nested
if (!$this->footnote) {
- $this->addCall('cdata', array($match), $pos);
+ $this->addCall('cdata', [$match], $pos);
break;
}
$this->footnote = false;
- $this->addCall('footnote_close', array(), $pos);
+ $this->addCall('footnote_close', [], $pos);
/** @var Nest $reWriter */
$reWriter = $this->callWriter;
$this->callWriter = $reWriter->process();
- break;
+ break;
case DOKU_LEXER_UNMATCHED:
- $this->addCall('cdata', array($match), $pos);
- break;
+ $this->addCall('cdata', [$match], $pos);
+ break;
}
return true;
}
@@ -509,24 +536,25 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function listblock($match, $state, $pos) {
- switch ( $state ) {
+ public function listblock($match, $state, $pos)
+ {
+ switch ($state) {
case DOKU_LEXER_ENTER:
$this->callWriter = new Lists($this->callWriter);
- $this->addCall('list_open', array($match), $pos);
- break;
+ $this->addCall('list_open', [$match], $pos);
+ break;
case DOKU_LEXER_EXIT:
- $this->addCall('list_close', array(), $pos);
+ $this->addCall('list_close', [], $pos);
/** @var Lists $reWriter */
$reWriter = $this->callWriter;
$this->callWriter = $reWriter->process();
- break;
+ break;
case DOKU_LEXER_MATCHED:
- $this->addCall('list_item', array($match), $pos);
- break;
+ $this->addCall('list_item', [$match], $pos);
+ break;
case DOKU_LEXER_UNMATCHED:
- $this->addCall('cdata', array($match), $pos);
- break;
+ $this->addCall('cdata', [$match], $pos);
+ break;
}
return true;
}
@@ -537,9 +565,10 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function unformatted($match, $state, $pos) {
- if ( $state == DOKU_LEXER_UNMATCHED ) {
- $this->addCall('unformatted', array($match), $pos);
+ public function unformatted($match, $state, $pos)
+ {
+ if ($state == DOKU_LEXER_UNMATCHED) {
+ $this->addCall('unformatted', [$match], $pos);
}
return true;
}
@@ -550,24 +579,25 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function preformatted($match, $state, $pos) {
- switch ( $state ) {
+ public function preformatted($match, $state, $pos)
+ {
+ switch ($state) {
case DOKU_LEXER_ENTER:
$this->callWriter = new Preformatted($this->callWriter);
- $this->addCall('preformatted_start', array(), $pos);
- break;
+ $this->addCall('preformatted_start', [], $pos);
+ break;
case DOKU_LEXER_EXIT:
- $this->addCall('preformatted_end', array(), $pos);
+ $this->addCall('preformatted_end', [], $pos);
/** @var Preformatted $reWriter */
$reWriter = $this->callWriter;
$this->callWriter = $reWriter->process();
- break;
+ break;
case DOKU_LEXER_MATCHED:
- $this->addCall('preformatted_newline', array(), $pos);
- break;
+ $this->addCall('preformatted_newline', [], $pos);
+ break;
case DOKU_LEXER_UNMATCHED:
- $this->addCall('preformatted_content', array($match), $pos);
- break;
+ $this->addCall('preformatted_content', [$match], $pos);
+ break;
}
return true;
@@ -579,30 +609,29 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function quote($match, $state, $pos) {
-
- switch ( $state ) {
+ public function quote($match, $state, $pos)
+ {
+ switch ($state) {
case DOKU_LEXER_ENTER:
$this->callWriter = new Quote($this->callWriter);
- $this->addCall('quote_start', array($match), $pos);
- break;
+ $this->addCall('quote_start', [$match], $pos);
+ break;
case DOKU_LEXER_EXIT:
- $this->addCall('quote_end', array(), $pos);
+ $this->addCall('quote_end', [], $pos);
/** @var Lists $reWriter */
$reWriter = $this->callWriter;
$this->callWriter = $reWriter->process();
- break;
+ break;
case DOKU_LEXER_MATCHED:
- $this->addCall('quote_newline', array($match), $pos);
- break;
+ $this->addCall('quote_newline', [$match], $pos);
+ break;
case DOKU_LEXER_UNMATCHED:
- $this->addCall('cdata', array($match), $pos);
- break;
-
+ $this->addCall('cdata', [$match], $pos);
+ break;
}
return true;
@@ -614,7 +643,8 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function file($match, $state, $pos) {
+ public function file($match, $state, $pos)
+ {
return $this->code($match, $state, $pos, 'file');
}
@@ -625,22 +655,23 @@ class Doku_Handler {
* @param string $type either 'code' or 'file'
* @return bool mode handled?
*/
- public function code($match, $state, $pos, $type='code') {
- if ( $state == DOKU_LEXER_UNMATCHED ) {
- $matches = sexplode('>',$match,2,'');
+ public function code($match, $state, $pos, $type = 'code')
+ {
+ if ($state == DOKU_LEXER_UNMATCHED) {
+ $matches = sexplode('>', $match, 2, '');
// Cut out variable options enclosed in []
preg_match('/\[.*\]/', $matches[0], $options);
if (!empty($options[0])) {
$matches[0] = str_replace($options[0], '', $matches[0]);
}
$param = preg_split('/\s+/', $matches[0], 2, PREG_SPLIT_NO_EMPTY);
- while(count($param) < 2) array_push($param, null);
+ while (count($param) < 2) $param[] = null;
// We shortcut html here.
if ($param[0] == 'html') $param[0] = 'html4strict';
if ($param[0] == '-') $param[0] = null;
array_unshift($param, $matches[1]);
if (!empty($options[0])) {
- $param [] = $this->parse_highlight_options ($options[0]);
+ $param [] = $this->parse_highlight_options($options[0]);
}
$this->addCall($type, $param, $pos);
}
@@ -653,8 +684,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function acronym($match, $state, $pos) {
- $this->addCall('acronym', array($match), $pos);
+ public function acronym($match, $state, $pos)
+ {
+ $this->addCall('acronym', [$match], $pos);
return true;
}
@@ -664,8 +696,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function smiley($match, $state, $pos) {
- $this->addCall('smiley', array($match), $pos);
+ public function smiley($match, $state, $pos)
+ {
+ $this->addCall('smiley', [$match], $pos);
return true;
}
@@ -675,8 +708,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function wordblock($match, $state, $pos) {
- $this->addCall('wordblock', array($match), $pos);
+ public function wordblock($match, $state, $pos)
+ {
+ $this->addCall('wordblock', [$match], $pos);
return true;
}
@@ -686,8 +720,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function entity($match, $state, $pos) {
- $this->addCall('entity', array($match), $pos);
+ public function entity($match, $state, $pos)
+ {
+ $this->addCall('entity', [$match], $pos);
return true;
}
@@ -697,9 +732,10 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function multiplyentity($match, $state, $pos) {
- preg_match_all('/\d+/',$match,$matches);
- $this->addCall('multiplyentity', array($matches[0][0], $matches[0][1]), $pos);
+ public function multiplyentity($match, $state, $pos)
+ {
+ preg_match_all('/\d+/', $match, $matches);
+ $this->addCall('multiplyentity', [$matches[0][0], $matches[0][1]], $pos);
return true;
}
@@ -709,8 +745,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function singlequoteopening($match, $state, $pos) {
- $this->addCall('singlequoteopening', array(), $pos);
+ public function singlequoteopening($match, $state, $pos)
+ {
+ $this->addCall('singlequoteopening', [], $pos);
return true;
}
@@ -720,8 +757,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function singlequoteclosing($match, $state, $pos) {
- $this->addCall('singlequoteclosing', array(), $pos);
+ public function singlequoteclosing($match, $state, $pos)
+ {
+ $this->addCall('singlequoteclosing', [], $pos);
return true;
}
@@ -731,8 +769,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function apostrophe($match, $state, $pos) {
- $this->addCall('apostrophe', array(), $pos);
+ public function apostrophe($match, $state, $pos)
+ {
+ $this->addCall('apostrophe', [], $pos);
return true;
}
@@ -742,8 +781,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function doublequoteopening($match, $state, $pos) {
- $this->addCall('doublequoteopening', array(), $pos);
+ public function doublequoteopening($match, $state, $pos)
+ {
+ $this->addCall('doublequoteopening', [], $pos);
$this->status['doublequote']++;
return true;
}
@@ -754,11 +794,12 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function doublequoteclosing($match, $state, $pos) {
+ public function doublequoteclosing($match, $state, $pos)
+ {
if ($this->status['doublequote'] <= 0) {
$this->doublequoteopening($match, $state, $pos);
} else {
- $this->addCall('doublequoteclosing', array(), $pos);
+ $this->addCall('doublequoteclosing', [], $pos);
$this->status['doublequote'] = max(0, --$this->status['doublequote']);
}
return true;
@@ -770,8 +811,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function camelcaselink($match, $state, $pos) {
- $this->addCall('camelcaselink', array($match), $pos);
+ public function camelcaselink($match, $state, $pos)
+ {
+ $this->addCall('camelcaselink', [$match], $pos);
return true;
}
@@ -781,15 +823,16 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function internallink($match, $state, $pos) {
+ public function internallink($match, $state, $pos)
+ {
// Strip the opening and closing markup
- $link = preg_replace(array('/^\[\[/','/\]\]$/u'),'',$match);
+ $link = preg_replace(['/^\[\[/', '/\]\]$/u'], '', $match);
// Split title from URL
- $link = sexplode('|',$link,2);
- if ( $link[1] === null ) {
+ $link = sexplode('|', $link, 2);
+ if ($link[1] === null) {
$link[1] = null;
- } else if ( preg_match('/^\{\{[^\}]+\}\}$/',$link[1]) ) {
+ } elseif (preg_match('/^\{\{[^\}]+\}\}$/', $link[1])) {
// If the title is an image, convert it to an array containing the image details
$link[1] = Doku_Handler_Parse_Media($link[1]);
}
@@ -797,49 +840,49 @@ class Doku_Handler {
//decide which kind of link it is
- if ( link_isinterwiki($link[0]) ) {
+ if (link_isinterwiki($link[0])) {
// Interwiki
- $interwiki = sexplode('>',$link[0],2,'');
+ $interwiki = sexplode('>', $link[0], 2, '');
$this->addCall(
'interwikilink',
- array($link[0],$link[1],strtolower($interwiki[0]),$interwiki[1]),
+ [$link[0], $link[1], strtolower($interwiki[0]), $interwiki[1]],
$pos
- );
- }elseif ( preg_match('/^\\\\\\\\[^\\\\]+?\\\\/u',$link[0]) ) {
+ );
+ } elseif (preg_match('/^\\\\\\\\[^\\\\]+?\\\\/u', $link[0])) {
// Windows Share
$this->addCall(
'windowssharelink',
- array($link[0],$link[1]),
+ [$link[0], $link[1]],
$pos
- );
- }elseif ( preg_match('#^([a-z0-9\-\.+]+?)://#i',$link[0]) ) {
+ );
+ } elseif (preg_match('#^([a-z0-9\-\.+]+?)://#i', $link[0])) {
// external link (accepts all protocols)
$this->addCall(
- 'externallink',
- array($link[0],$link[1]),
- $pos
- );
- }elseif ( preg_match('<'.PREG_PATTERN_VALID_EMAIL.'>',$link[0]) ) {
+ 'externallink',
+ [$link[0], $link[1]],
+ $pos
+ );
+ } elseif (preg_match('<' . PREG_PATTERN_VALID_EMAIL . '>', $link[0])) {
// E-Mail (pattern above is defined in inc/mail.php)
$this->addCall(
'emaillink',
- array($link[0],$link[1]),
+ [$link[0], $link[1]],
$pos
- );
- }elseif ( preg_match('!^#.+!',$link[0]) ){
+ );
+ } elseif (preg_match('!^#.+!', $link[0])) {
// local link
$this->addCall(
'locallink',
- array(substr($link[0],1),$link[1]),
+ [substr($link[0], 1), $link[1]],
$pos
- );
- }else{
+ );
+ } else {
// internal link
$this->addCall(
'internallink',
- array($link[0],$link[1]),
+ [$link[0], $link[1]],
$pos
- );
+ );
}
return true;
@@ -851,8 +894,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function filelink($match, $state, $pos) {
- $this->addCall('filelink', array($match, null), $pos);
+ public function filelink($match, $state, $pos)
+ {
+ $this->addCall('filelink', [$match, null], $pos);
return true;
}
@@ -862,8 +906,9 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function windowssharelink($match, $state, $pos) {
- $this->addCall('windowssharelink', array($match, null), $pos);
+ public function windowssharelink($match, $state, $pos)
+ {
+ $this->addCall('windowssharelink', [$match, null], $pos);
return true;
}
@@ -873,15 +918,15 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function media($match, $state, $pos) {
+ public function media($match, $state, $pos)
+ {
$p = Doku_Handler_Parse_Media($match);
$this->addCall(
- $p['type'],
- array($p['src'], $p['title'], $p['align'], $p['width'],
- $p['height'], $p['cache'], $p['linking']),
- $pos
- );
+ $p['type'],
+ [$p['src'], $p['title'], $p['align'], $p['width'], $p['height'], $p['cache'], $p['linking']],
+ $pos
+ );
return true;
}
@@ -891,32 +936,33 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function rss($match, $state, $pos) {
- $link = preg_replace(array('/^\{\{rss>/','/\}\}$/'),'',$match);
+ public function rss($match, $state, $pos)
+ {
+ $link = preg_replace(['/^\{\{rss>/', '/\}\}$/'], '', $match);
// get params
- list($link, $params) = sexplode(' ', $link, 2, '');
+ [$link, $params] = sexplode(' ', $link, 2, '');
- $p = array();
- if(preg_match('/\b(\d+)\b/',$params,$match)){
+ $p = [];
+ if (preg_match('/\b(\d+)\b/', $params, $match)) {
$p['max'] = $match[1];
- }else{
+ } else {
$p['max'] = 8;
}
- $p['reverse'] = (preg_match('/rev/',$params));
- $p['author'] = (preg_match('/\b(by|author)/',$params));
- $p['date'] = (preg_match('/\b(date)/',$params));
- $p['details'] = (preg_match('/\b(desc|detail)/',$params));
- $p['nosort'] = (preg_match('/\b(nosort)\b/',$params));
-
- if (preg_match('/\b(\d+)([dhm])\b/',$params,$match)) {
- $period = array('d' => 86400, 'h' => 3600, 'm' => 60);
- $p['refresh'] = max(600,$match[1]*$period[$match[2]]); // n * period in seconds, minimum 10 minutes
+ $p['reverse'] = (preg_match('/rev/', $params));
+ $p['author'] = (preg_match('/\b(by|author)/', $params));
+ $p['date'] = (preg_match('/\b(date)/', $params));
+ $p['details'] = (preg_match('/\b(desc|detail)/', $params));
+ $p['nosort'] = (preg_match('/\b(nosort)\b/', $params));
+
+ if (preg_match('/\b(\d+)([dhm])\b/', $params, $match)) {
+ $period = ['d' => 86400, 'h' => 3600, 'm' => 60];
+ $p['refresh'] = max(600, $match[1] * $period[$match[2]]); // n * period in seconds, minimum 10 minutes
} else {
$p['refresh'] = 14400; // default to 4 hours
}
- $this->addCall('rss', array($link, $p), $pos);
+ $this->addCall('rss', [$link, $p], $pos);
return true;
}
@@ -926,21 +972,22 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function externallink($match, $state, $pos) {
- $url = $match;
+ public function externallink($match, $state, $pos)
+ {
+ $url = $match;
$title = null;
// add protocol on simple short URLs
- if(substr($url,0,3) == 'ftp' && (substr($url,0,6) != 'ftp://')){
+ if (str_starts_with($url, 'ftp') && !str_starts_with($url, 'ftp://')) {
$title = $url;
- $url = 'ftp://'.$url;
+ $url = 'ftp://' . $url;
}
- if(substr($url,0,3) == 'www' && (substr($url,0,7) != 'http://')){
+ if (str_starts_with($url, 'www')) {
$title = $url;
- $url = 'http://'.$url;
+ $url = 'http://' . $url;
}
- $this->addCall('externallink', array($url, $title), $pos);
+ $this->addCall('externallink', [$url, $title], $pos);
return true;
}
@@ -950,9 +997,10 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function emaillink($match, $state, $pos) {
- $email = preg_replace(array('/^</','/>$/'),'',$match);
- $this->addCall('emaillink', array($email, null), $pos);
+ public function emaillink($match, $state, $pos)
+ {
+ $email = preg_replace(['/^</', '/>$/'], '', $match);
+ $this->addCall('emaillink', [$email, null], $pos);
return true;
}
@@ -962,55 +1010,54 @@ class Doku_Handler {
* @param int $pos byte position in the original source file
* @return bool mode handled?
*/
- public function table($match, $state, $pos) {
- switch ( $state ) {
-
+ public function table($match, $state, $pos)
+ {
+ switch ($state) {
case DOKU_LEXER_ENTER:
-
$this->callWriter = new Table($this->callWriter);
- $this->addCall('table_start', array($pos + 1), $pos);
- if ( trim($match) == '^' ) {
- $this->addCall('tableheader', array(), $pos);
+ $this->addCall('table_start', [$pos + 1], $pos);
+ if (trim($match) == '^') {
+ $this->addCall('tableheader', [], $pos);
} else {
- $this->addCall('tablecell', array(), $pos);
+ $this->addCall('tablecell', [], $pos);
}
- break;
+ break;
case DOKU_LEXER_EXIT:
- $this->addCall('table_end', array($pos), $pos);
+ $this->addCall('table_end', [$pos], $pos);
/** @var Table $reWriter */
$reWriter = $this->callWriter;
$this->callWriter = $reWriter->process();
- break;
+ break;
case DOKU_LEXER_UNMATCHED:
- if ( trim($match) != '' ) {
- $this->addCall('cdata', array($match), $pos);
+ if (trim($match) != '') {
+ $this->addCall('cdata', [$match], $pos);
}
- break;
+ break;
case DOKU_LEXER_MATCHED:
- if ( $match == ' ' ){
- $this->addCall('cdata', array($match), $pos);
- } else if ( preg_match('/:::/',$match) ) {
- $this->addCall('rowspan', array($match), $pos);
- } else if ( preg_match('/\t+/',$match) ) {
- $this->addCall('table_align', array($match), $pos);
- } else if ( preg_match('/ {2,}/',$match) ) {
- $this->addCall('table_align', array($match), $pos);
- } else if ( $match == "\n|" ) {
- $this->addCall('table_row', array(), $pos);
- $this->addCall('tablecell', array(), $pos);
- } else if ( $match == "\n^" ) {
- $this->addCall('table_row', array(), $pos);
- $this->addCall('tableheader', array(), $pos);
- } else if ( $match == '|' ) {
- $this->addCall('tablecell', array(), $pos);
- } else if ( $match == '^' ) {
- $this->addCall('tableheader', array(), $pos);
+ if ($match == ' ') {
+ $this->addCall('cdata', [$match], $pos);
+ } elseif (preg_match('/:::/', $match)) {
+ $this->addCall('rowspan', [$match], $pos);
+ } elseif (preg_match('/\t+/', $match)) {
+ $this->addCall('table_align', [$match], $pos);
+ } elseif (preg_match('/ {2,}/', $match)) {
+ $this->addCall('table_align', [$match], $pos);
+ } elseif ($match == "\n|") {
+ $this->addCall('table_row', [], $pos);
+ $this->addCall('tablecell', [], $pos);
+ } elseif ($match == "\n^") {
+ $this->addCall('table_row', [], $pos);
+ $this->addCall('tableheader', [], $pos);
+ } elseif ($match == '|') {
+ $this->addCall('tablecell', [], $pos);
+ } elseif ($match == '^') {
+ $this->addCall('tableheader', [], $pos);
}
- break;
+ break;
}
return true;
}
@@ -1019,31 +1066,32 @@ class Doku_Handler {
}
//------------------------------------------------------------------------
-function Doku_Handler_Parse_Media($match) {
+function Doku_Handler_Parse_Media($match)
+{
// Strip the opening and closing markup
- $link = preg_replace(array('/^\{\{/','/\}\}$/u'),'',$match);
+ $link = preg_replace(['/^\{\{/', '/\}\}$/u'], '', $match);
// Split title from URL
$link = sexplode('|', $link, 2);
// Check alignment
- $ralign = (bool)preg_match('/^ /',$link[0]);
- $lalign = (bool)preg_match('/ $/',$link[0]);
+ $ralign = (bool)preg_match('/^ /', $link[0]);
+ $lalign = (bool)preg_match('/ $/', $link[0]);
// Logic = what's that ;)...
- if ( $lalign & $ralign ) {
+ if ($lalign & $ralign) {
$align = 'center';
- } else if ( $ralign ) {
+ } elseif ($ralign) {
$align = 'right';
- } else if ( $lalign ) {
+ } elseif ($lalign) {
$align = 'left';
} else {
$align = null;
}
// The title...
- if ( !isset($link[1]) ) {
+ if (!isset($link[1])) {
$link[1] = null;
}
@@ -1052,59 +1100,58 @@ function Doku_Handler_Parse_Media($match) {
//split into src and parameters (using the very last questionmark)
$pos = strrpos($link[0], '?');
- if($pos !== false){
- $src = substr($link[0],0,$pos);
- $param = substr($link[0],$pos+1);
- }else{
- $src = $link[0];
+ if ($pos !== false) {
+ $src = substr($link[0], 0, $pos);
+ $param = substr($link[0], $pos + 1);
+ } else {
+ $src = $link[0];
$param = '';
}
//parse width and height
- if(preg_match('#(\d+)(x(\d+))?#i',$param,$size)){
- !empty($size[1]) ? $w = $size[1] : $w = null;
- !empty($size[3]) ? $h = $size[3] : $h = null;
+ if (preg_match('#(\d+)(x(\d+))?#i', $param, $size)) {
+ $w = empty($size[1]) ? null : $size[1];
+ $h = empty($size[3]) ? null : $size[3];
} else {
$w = null;
$h = null;
}
//get linking command
- if(preg_match('/nolink/i',$param)){
+ if (preg_match('/nolink/i', $param)) {
$linking = 'nolink';
- }else if(preg_match('/direct/i',$param)){
+ } elseif (preg_match('/direct/i', $param)) {
$linking = 'direct';
- }else if(preg_match('/linkonly/i',$param)){
+ } elseif (preg_match('/linkonly/i', $param)) {
$linking = 'linkonly';
- }else{
+ } else {
$linking = 'details';
}
//get caching command
- if (preg_match('/(nocache|recache)/i',$param,$cachemode)){
+ if (preg_match('/(nocache|recache)/i', $param, $cachemode)) {
$cache = $cachemode[1];
- }else{
+ } else {
$cache = 'cache';
}
// Check whether this is a local or remote image or interwiki
- if (media_isexternal($src) || link_isinterwiki($src)){
+ if (media_isexternal($src) || link_isinterwiki($src)) {
$call = 'externalmedia';
} else {
$call = 'internalmedia';
}
- $params = array(
- 'type'=>$call,
- 'src'=>$src,
- 'title'=>$link[1],
- 'align'=>$align,
- 'width'=>$w,
- 'height'=>$h,
- 'cache'=>$cache,
- 'linking'=>$linking,
- );
+ $params = [
+ 'type' => $call,
+ 'src' => $src,
+ 'title' => $link[1],
+ 'align' => $align,
+ 'width' => $w,
+ 'height' => $h,
+ 'cache' => $cache,
+ 'linking' => $linking
+ ];
return $params;
}
-
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index 222b3d065..2d84f5060 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -1,4 +1,9 @@
<?php
+
+use dokuwiki\File\MediaResolver;
+use dokuwiki\File\PageResolver;
+use dokuwiki\Utf8\PhpString;
+
/**
* The MetaData Renderer
*
@@ -13,19 +18,19 @@
class Doku_Renderer_metadata extends Doku_Renderer
{
/** the approximate byte lenght to capture for the abstract */
- const ABSTRACT_LEN = 250;
+ public const ABSTRACT_LEN = 250;
/** the maximum UTF8 character length for the abstract */
- const ABSTRACT_MAX = 500;
+ public const ABSTRACT_MAX = 500;
/** @var array transient meta data, will be reset on each rendering */
- public $meta = array();
+ public $meta = [];
/** @var array persistent meta data, will be kept until explicitly deleted */
- public $persistent = array();
+ public $persistent = [];
/** @var array the list of headers used to create unique link ids */
- protected $headers = array();
+ protected $headers = [];
/** @var string temporary $doc store */
protected $store = '';
@@ -61,7 +66,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
{
global $ID;
- $this->headers = array();
+ $this->headers = [];
// external pages are missing create date
if (!isset($this->persistent['date']['created']) || !$this->persistent['date']['created']) {
@@ -93,7 +98,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
// cut off too long abstracts
$this->doc = trim($this->doc);
if (strlen($this->doc) > self::ABSTRACT_MAX) {
- $this->doc = \dokuwiki\Utf8\PhpString::substr($this->doc, 0, self::ABSTRACT_MAX).'…';
+ $this->doc = PhpString::substr($this->doc, 0, self::ABSTRACT_MAX) . '…';
}
$this->meta['description']['abstract'] = $this->doc;
}
@@ -130,9 +135,9 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* 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
+ * @param string $id the hash link
+ * @param string $text the text to display
+ * @param int $level the nesting level
*/
public function toc_additem($id, $text, $level)
{
@@ -141,21 +146,21 @@ class Doku_Renderer_metadata extends Doku_Renderer
//only add items within configured levels
if ($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) {
// the TOC is one of our standard ul list arrays ;-)
- $this->meta['description']['tableofcontents'][] = array(
- 'hid' => $id,
+ $this->meta['description']['tableofcontents'][] = [
+ 'hid' => $id,
'title' => $text,
- 'type' => 'ul',
+ '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
+ * @param string $text the text to display
+ * @param int $level header level
+ * @param int $pos byte position in the original source
*/
public function header($text, $level, $pos)
{
@@ -168,7 +173,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
$this->toc_additem($hid, $text, $level);
// add to summary
- $this->cdata(DOKU_LF.$text.DOKU_LF);
+ $this->cdata(DOKU_LF . $text . DOKU_LF);
}
/**
@@ -200,7 +205,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
*/
public function hr()
{
- $this->cdata(DOKU_LF.'----------'.DOKU_LF);
+ $this->cdata(DOKU_LF . '----------' . DOKU_LF);
}
/**
@@ -218,7 +223,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
// move current content to store
// this is required to ensure safe behaviour of plugins accessed within footnotes
$this->store = $this->doc;
- $this->doc = '';
+ $this->doc = '';
// disable capturing
$this->capturing = false;
@@ -239,7 +244,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
// re-enable capturing
$this->capturing = true;
// restore previously rendered content
- $this->doc = $this->store;
+ $this->doc = $this->store;
$this->store = '';
}
}
@@ -266,9 +271,9 @@ class Doku_Renderer_metadata extends Doku_Renderer
* @param int $level the nesting level
* @param bool $node true when a node; false when a leaf
*/
- public function listitem_open($level, $node=false)
+ public function listitem_open($level, $node = false)
{
- $this->cdata(str_repeat(DOKU_TAB, $level).'* ');
+ $this->cdata(str_repeat(DOKU_TAB, $level) . '* ');
}
/**
@@ -294,7 +299,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
*/
public function quote_open()
{
- $this->cdata(DOKU_LF.DOKU_TAB.'"');
+ $this->cdata(DOKU_LF . DOKU_TAB . '"');
}
/**
@@ -302,7 +307,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
*/
public function quote_close()
{
- $this->cdata('"'.DOKU_LF);
+ $this->cdata('"' . DOKU_LF);
}
/**
@@ -314,19 +319,19 @@ class Doku_Renderer_metadata extends Doku_Renderer
*/
public function file($text, $lang = null, $file = null)
{
- $this->cdata(DOKU_LF.$text.DOKU_LF);
+ $this->cdata(DOKU_LF . $text . DOKU_LF);
}
/**
* Display text as code content, optionally syntax highlighted
*
- * @param string $text text to show
+ * @param string $text text to show
* @param string $language programming language to use for syntax highlighting
- * @param string $file file path label
+ * @param string $file file path label
*/
public function code($text, $language = null, $file = null)
{
- $this->cdata(DOKU_LF.$text.DOKU_LF);
+ $this->cdata(DOKU_LF . $text . DOKU_LF);
}
/**
@@ -377,7 +382,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
*/
public function multiplyentity($x, $y)
{
- $this->cdata($x.'×'.$y);
+ $this->cdata($x . '×' . $y);
}
/**
@@ -455,7 +460,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* keep track of internal links in $this->meta['relation']['references']
*
- * @param string $id page ID to link to. eg. 'wiki:syntax'
+ * @param string $id page ID to link to. eg. 'wiki:syntax'
* @param string|array|null $name name for the link, array for media file
*/
public function internallink($id, $name = null)
@@ -477,9 +482,9 @@ class Doku_Renderer_metadata extends Doku_Renderer
$default = $this->_simpleTitle($id);
// first resolve and clean up the $id
- $resolver = new \dokuwiki\File\PageResolver($ID);
+ $resolver = new PageResolver($ID);
$id = $resolver->resolveId($id);
- list($page) = sexplode('#', $id, 2);
+ [$page] = sexplode('#', $id, 2);
// set metadata
$this->meta['relation']['references'][$page] = page_exists($page);
@@ -496,7 +501,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* Render an external link
*
- * @param string $url full URL with scheme
+ * @param string $url full URL with scheme
* @param string|array|null $name name for the link, array for media file
*/
public function externallink($url, $name = null)
@@ -509,7 +514,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
}
if ($this->capture) {
- $this->doc .= $this->_getLinkTitle($name, '<'.$url.'>');
+ $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>');
}
}
@@ -518,10 +523,10 @@ class Doku_Renderer_metadata extends Doku_Renderer
*
* 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
+ * @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
*/
public function interwikilink($match, $name, $wikiName, $wikiUri)
{
@@ -533,7 +538,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
}
if ($this->capture) {
- list($wikiUri) = explode('#', $wikiUri, 2);
+ [$wikiUri] = explode('#', $wikiUri, 2);
$name = $this->_getLinkTitle($name, $wikiUri);
$this->doc .= $name;
}
@@ -542,7 +547,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* Link to windows share
*
- * @param string $url the link
+ * @param string $url the link
* @param string|array $name name for the link, array for media file
*/
public function windowssharelink($url, $name = null)
@@ -558,7 +563,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
if ($name) {
$this->doc .= $name;
} else {
- $this->doc .= '<'.$url.'>';
+ $this->doc .= '<' . $url . '>';
}
}
}
@@ -568,8 +573,8 @@ class Doku_Renderer_metadata extends Doku_Renderer
*
* Should honor $conf['mailguard'] setting
*
- * @param string $address Email-Address
- * @param string|array $name name for the link, array for media file
+ * @param string $address Email-Address
+ * @param string|array $name name for the link, array for media file
*/
public function emaillink($address, $name = null)
{
@@ -584,7 +589,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
if ($name) {
$this->doc .= $name;
} else {
- $this->doc .= '<'.$address.'>';
+ $this->doc .= '<' . $address . '>';
}
}
}
@@ -592,19 +597,25 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* 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 $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
*/
- public function internalmedia($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $linking = null)
- {
+ public function internalmedia(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $linking = null
+ ) {
if ($this->capture && $title) {
- $this->doc .= '['.$title.']';
+ $this->doc .= '[' . $title . ']';
}
$this->_firstimage($src);
$this->_recordMediaUsage($src);
@@ -613,19 +624,25 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* 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 $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
*/
- public function externalmedia($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $linking = null)
- {
+ public function externalmedia(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $linking = null
+ ) {
if ($this->capture && $title) {
- $this->doc .= '['.$title.']';
+ $this->doc .= '[' . $title . ']';
}
$this->_firstimage($src);
}
@@ -633,8 +650,8 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* Render the output of an RSS feed
*
- * @param string $url URL of the feed
- * @param array $params Finetuning of the output
+ * @param string $url URL of the feed
+ * @param array $params Finetuning of the output
*/
public function rss($url, $params)
{
@@ -652,11 +669,11 @@ class Doku_Renderer_metadata extends Doku_Renderer
* Removes any Namespace from the given name but keeps
* casing and special chars
*
- * @author Andreas Gohr <andi@splitbrain.org>
- *
* @param string $name
*
* @return mixed|string
+ * @author Andreas Gohr <andi@splitbrain.org>
+ *
*/
public function _simpleTitle($name)
{
@@ -671,7 +688,7 @@ class Doku_Renderer_metadata extends Doku_Renderer
} 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);
return $name;
@@ -680,17 +697,17 @@ class Doku_Renderer_metadata extends Doku_Renderer
/**
* Construct a title and handle images in titles
*
- * @author Harry Fuecks <hfuecks@gmail.com>
- * @param string|array|null $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)
+ * @param string|array|null $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
+ * @author Harry Fuecks <hfuecks@gmail.com>
*/
public function _getLinkTitle($title, $default, $id = null)
{
if (is_array($title)) {
if ($title['title']) {
- return '['.$title['title'].']';
+ return '[' . $title['title'] . ']';
} else {
return $default;
}
@@ -720,9 +737,9 @@ class Doku_Renderer_metadata extends Doku_Renderer
return;
}
- list($src) = explode('#', $src, 2);
+ [$src] = explode('#', $src, 2);
if (!media_isexternal($src)) {
- $src = (new \dokuwiki\File\MediaResolver($ID))->resolveId($src);
+ $src = (new MediaResolver($ID))->resolveId($src);
}
if (preg_match('/.(jpe?g|gif|png|webp|svg)$/i', $src)) {
$this->firstimage = $src;
@@ -738,11 +755,11 @@ class Doku_Renderer_metadata extends Doku_Renderer
{
global $ID;
- list ($src) = explode('#', $src, 2);
+ [$src] = explode('#', $src, 2);
if (media_isexternal($src)) {
return;
}
- $src = (new \dokuwiki\File\MediaResolver($ID))->resolveId($src);
+ $src = (new MediaResolver($ID))->resolveId($src);
$file = mediaFN($src);
$this->meta['relation']['media'][$src] = file_exists($file);
}
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 77f47e3ac..225dee35b 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -1,67 +1,60 @@
<?php
use dokuwiki\Debug\PropertyDeprecationHelper;
+use dokuwiki\Parsing\Parser;
/**
* Define various types of modes used by the parser - they are used to
* populate the list of modes another mode accepts
*/
global $PARSER_MODES;
-$PARSER_MODES = array(
+$PARSER_MODES = [
// containers are complex modes that can contain many other modes
// hr breaks the principle but they shouldn't be used in tables / lists
// so they are put here
- 'container' => array('listblock', 'table', 'quote', 'hr'),
-
+ 'container' => ['listblock', 'table', 'quote', 'hr'],
// some mode are allowed inside the base mode only
- 'baseonly' => array('header'),
-
+ 'baseonly' => ['header'],
// modes for styling text -- footnote behaves similar to styling
- 'formatting' => array(
- 'strong', 'emphasis', 'underline', 'monospace',
- 'subscript', 'superscript', 'deleted', 'footnote'
- ),
-
+ 'formatting' => [
+ 'strong', 'emphasis', 'underline', 'monospace', 'subscript', 'superscript', 'deleted', 'footnote'
+ ],
// modes where the token is simply replaced - they can not contain any
// other modes
- 'substition' => array(
- 'acronym', 'smiley', 'wordblock', 'entity',
- 'camelcaselink', 'internallink', 'media',
- 'externallink', 'linebreak', 'emaillink',
- 'windowssharelink', 'filelink', 'notoc',
- 'nocache', 'multiplyentity', 'quotes', 'rss'
- ),
-
+ 'substition' => [
+ 'acronym', 'smiley', 'wordblock', 'entity', 'camelcaselink', 'internallink', 'media', 'externallink',
+ 'linebreak', 'emaillink', 'windowssharelink', 'filelink', 'notoc', 'nocache', 'multiplyentity', 'quotes', 'rss'
+ ],
// modes which have a start and end token but inside which
// no other modes should be applied
- 'protected' => array('preformatted', 'code', 'file'),
-
+ 'protected' => ['preformatted', 'code', 'file'],
// inside this mode no wiki markup should be applied but lineendings
// and whitespace isn't preserved
- 'disabled' => array('unformatted'),
-
+ 'disabled' => ['unformatted'],
// used to mark paragraph boundaries
- 'paragraphs' => array('eol')
-);
+ 'paragraphs' => ['eol'],
+];
/**
* Class Doku_Parser
*
* @deprecated 2018-05-04
*/
-class Doku_Parser extends \dokuwiki\Parsing\Parser {
+class Doku_Parser extends Parser
+{
use PropertyDeprecationHelper {
__set as protected deprecationHelperMagicSet;
__get as protected deprecationHelperMagicGet;
}
/** @inheritdoc */
- public function __construct(Doku_Handler $handler = null) {
- dbg_deprecated(\dokuwiki\Parsing\Parser::class);
- $this->deprecatePublicProperty('modes', __CLASS__);
- $this->deprecatePublicProperty('connected', __CLASS__);
+ public function __construct(Doku_Handler $handler = null)
+ {
+ dbg_deprecated(Parser::class);
+ $this->deprecatePublicProperty('modes', self::class);
+ $this->deprecatePublicProperty('connected', self::class);
- if ($handler === null) {
+ if (!$handler instanceof \Doku_Handler) {
$handler = new Doku_Handler();
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 14ad5d949..cd43997ef 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Renderer output base class
*
@@ -18,7 +19,7 @@ define('PREG_PATTERN_VALID_LANGUAGE', '#[^a-zA-Z0-9\-_]#');
/**
* An empty renderer, produces no output
*
- * Inherits from dokuwiki\Plugin\DokuWiki_Plugin for giving additional functions to render plugins
+ * Inherits from dokuwiki\Extension\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
@@ -26,26 +27,27 @@ define('PREG_PATTERN_VALID_LANGUAGE', '#[^a-zA-Z0-9\-_]#');
* $doc field. When all instructions are processed, the $doc field contents will be cached by
* DokuWiki and sent to the user.
*/
-abstract class Doku_Renderer extends Plugin {
+abstract class Doku_Renderer extends Plugin
+{
/** @var array Settings, control the behavior of the renderer */
- public $info = array(
+ public $info = [
'cache' => true, // may the rendered result cached?
- 'toc' => true, // render the TOC?
- );
+ 'toc' => true, // render the TOC?
+ ];
/** @var array contains the smiley configuration, set in p_render() */
- public $smileys = array();
+ public $smileys = [];
/** @var array contains the entity configuration, set in p_render() */
- public $entities = array();
+ public $entities = [];
/** @var array contains the acronym configuration, set in p_render() */
- public $acronyms = array();
+ public $acronyms = [];
/** @var array contains the interwiki configuration, set in p_render() */
- public $interwiki = array();
+ public $interwiki = [];
/** @var string|int link pages and media against this revision */
public $date_at = '';
/** @var array the list of headers used to create unique link ids */
- protected $headers = array();
+ protected $headers = [];
/**
* @var string the rendered document, this will be cached after the renderer ran through
@@ -58,11 +60,12 @@ abstract class Doku_Renderer extends Plugin {
* 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
*/
- public function reset(){
- $this->headers = array();
- $this->doc = '';
+ public function reset()
+ {
+ $this->headers = [];
+ $this->doc = '';
$this->info['cache'] = true;
- $this->info['toc'] = true;
+ $this->info['toc'] = true;
}
/**
@@ -73,7 +76,8 @@ abstract class Doku_Renderer extends Plugin {
*
* @return bool false if the plugin has to be instantiated
*/
- public function isSingleton() {
+ public function isSingleton()
+ {
return false;
}
@@ -89,7 +93,8 @@ abstract class Doku_Renderer extends Plugin {
/**
* Disable caching of this renderer's output
*/
- public function nocache() {
+ public function nocache()
+ {
$this->info['cache'] = false;
}
@@ -98,7 +103,8 @@ abstract class Doku_Renderer extends Plugin {
*
* This might not be used for certain sub renderer
*/
- public function notoc() {
+ public function notoc()
+ {
$this->info['toc'] = false;
}
@@ -107,15 +113,16 @@ abstract class Doku_Renderer extends Plugin {
*
* 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
*/
- public function plugin($name, $data, $state = '', $match = '') {
+ public function plugin($name, $data, $state = '', $match = '')
+ {
/** @var SyntaxPlugin $plugin */
$plugin = plugin_load('syntax', $name);
- if($plugin != null) {
+ if ($plugin != null) {
$plugin->render($this->getFormat(), $this, $data);
}
}
@@ -126,11 +133,12 @@ abstract class Doku_Renderer extends Plugin {
*
* @param array $instructions
*/
- public function nest($instructions) {
- foreach($instructions as $instruction) {
+ public function nest($instructions)
+ {
+ foreach ($instructions as $instruction) {
// execute the callback against ourself
- if(method_exists($this, $instruction[0])) {
- call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
+ if (method_exists($this, $instruction[0])) {
+ call_user_func_array([$this, $instruction[0]], $instruction[1] ?: []);
}
}
}
@@ -141,7 +149,8 @@ abstract class Doku_Renderer extends Plugin {
* 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.
*/
- public function nest_close() {
+ public function nest_close()
+ {
}
#region Syntax modes - sub classes will need to implement them to fill $doc
@@ -149,13 +158,15 @@ abstract class Doku_Renderer extends Plugin {
/**
* Initialize the document
*/
- public function document_start() {
+ public function document_start()
+ {
}
/**
* Finalize the document
*/
- public function document_end() {
+ public function document_end()
+ {
}
/**
@@ -163,28 +174,31 @@ abstract class Doku_Renderer extends Plugin {
*
* @return string
*/
- public function render_TOC() {
+ public function render_TOC()
+ {
return '';
}
/**
* 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
+ * @param string $id the hash link
+ * @param string $text the text to display
+ * @param int $level the nesting level
*/
- public function toc_additem($id, $text, $level) {
+ public function toc_additem($id, $text, $level)
+ {
}
/**
* Render a heading
*
- * @param string $text the text to display
- * @param int $level header level
- * @param int $pos byte position in the original source
+ * @param string $text the text to display
+ * @param int $level header level
+ * @param int $pos byte position in the original source
*/
- public function header($text, $level, $pos) {
+ public function header($text, $level, $pos)
+ {
}
/**
@@ -192,13 +206,15 @@ abstract class Doku_Renderer extends Plugin {
*
* @param int $level section level (as determined by the previous header)
*/
- public function section_open($level) {
+ public function section_open($level)
+ {
}
/**
* Close the current section
*/
- public function section_close() {
+ public function section_close()
+ {
}
/**
@@ -206,151 +222,176 @@ abstract class Doku_Renderer extends Plugin {
*
* @param string $text
*/
- public function cdata($text) {
+ public function cdata($text)
+ {
}
/**
* Open a paragraph
*/
- public function p_open() {
+ public function p_open()
+ {
}
/**
* Close a paragraph
*/
- public function p_close() {
+ public function p_close()
+ {
}
/**
* Create a line break
*/
- public function linebreak() {
+ public function linebreak()
+ {
}
/**
* Create a horizontal line
*/
- public function hr() {
+ public function hr()
+ {
}
/**
* Start strong (bold) formatting
*/
- public function strong_open() {
+ public function strong_open()
+ {
}
/**
* Stop strong (bold) formatting
*/
- public function strong_close() {
+ public function strong_close()
+ {
}
/**
* Start emphasis (italics) formatting
*/
- public function emphasis_open() {
+ public function emphasis_open()
+ {
}
/**
* Stop emphasis (italics) formatting
*/
- public function emphasis_close() {
+ public function emphasis_close()
+ {
}
/**
* Start underline formatting
*/
- public function underline_open() {
+ public function underline_open()
+ {
}
/**
* Stop underline formatting
*/
- public function underline_close() {
+ public function underline_close()
+ {
}
/**
* Start monospace formatting
*/
- public function monospace_open() {
+ public function monospace_open()
+ {
}
/**
* Stop monospace formatting
*/
- public function monospace_close() {
+ public function monospace_close()
+ {
}
/**
* Start a subscript
*/
- public function subscript_open() {
+ public function subscript_open()
+ {
}
/**
* Stop a subscript
*/
- public function subscript_close() {
+ public function subscript_close()
+ {
}
/**
* Start a superscript
*/
- public function superscript_open() {
+ public function superscript_open()
+ {
}
/**
* Stop a superscript
*/
- public function superscript_close() {
+ public function superscript_close()
+ {
}
/**
* Start deleted (strike-through) formatting
*/
- public function deleted_open() {
+ public function deleted_open()
+ {
}
/**
* Stop deleted (strike-through) formatting
*/
- public function deleted_close() {
+ public function deleted_close()
+ {
}
/**
* Start a footnote
*/
- public function footnote_open() {
+ public function footnote_open()
+ {
}
/**
* Stop a footnote
*/
- public function footnote_close() {
+ public function footnote_close()
+ {
}
/**
* Open an unordered list
*/
- public function listu_open() {
+ public function listu_open()
+ {
}
/**
* Close an unordered list
*/
- public function listu_close() {
+ public function listu_close()
+ {
}
/**
* Open an ordered list
*/
- public function listo_open() {
+ public function listo_open()
+ {
}
/**
* Close an ordered list
*/
- public function listo_close() {
+ public function listo_close()
+ {
}
/**
@@ -359,25 +400,29 @@ abstract class Doku_Renderer extends Plugin {
* @param int $level the nesting level
* @param bool $node true when a node; false when a leaf
*/
- public function listitem_open($level,$node=false) {
+ public function listitem_open($level, $node = false)
+ {
}
/**
* Close a list item
*/
- public function listitem_close() {
+ public function listitem_close()
+ {
}
/**
* Start the content of a list item
*/
- public function listcontent_open() {
+ public function listcontent_open()
+ {
}
/**
* Stop the content of a list item
*/
- public function listcontent_close() {
+ public function listcontent_close()
+ {
}
/**
@@ -387,7 +432,8 @@ abstract class Doku_Renderer extends Plugin {
*
* @param string $text
*/
- public function unformatted($text) {
+ public function unformatted($text)
+ {
$this->cdata($text);
}
@@ -396,19 +442,22 @@ abstract class Doku_Renderer extends Plugin {
*
* @param string $text
*/
- public function preformatted($text) {
+ public function preformatted($text)
+ {
}
/**
* Start a block quote
*/
- public function quote_open() {
+ public function quote_open()
+ {
}
/**
* Stop a block quote
*/
- public function quote_close() {
+ public function quote_close()
+ {
}
/**
@@ -418,7 +467,8 @@ abstract class Doku_Renderer extends Plugin {
* @param string $lang programming language to use for syntax highlighting
* @param string $file file path label
*/
- public function file($text, $lang = null, $file = null) {
+ public function file($text, $lang = null, $file = null)
+ {
}
/**
@@ -428,7 +478,8 @@ abstract class Doku_Renderer extends Plugin {
* @param string $lang programming language to use for syntax highlighting
* @param string $file file path label
*/
- public function code($text, $lang = null, $file = null) {
+ public function code($text, $lang = null, $file = null)
+ {
}
/**
@@ -438,7 +489,8 @@ abstract class Doku_Renderer extends Plugin {
*
* @param string $acronym
*/
- public function acronym($acronym) {
+ public function acronym($acronym)
+ {
}
/**
@@ -448,7 +500,8 @@ abstract class Doku_Renderer extends Plugin {
*
* @param string $smiley
*/
- public function smiley($smiley) {
+ public function smiley($smiley)
+ {
}
/**
@@ -460,7 +513,8 @@ abstract class Doku_Renderer extends Plugin {
*
* @param string $entity
*/
- public function entity($entity) {
+ public function entity($entity)
+ {
}
/**
@@ -471,37 +525,43 @@ abstract class Doku_Renderer extends Plugin {
* @param string|int $x first value
* @param string|int $y second value
*/
- public function multiplyentity($x, $y) {
+ public function multiplyentity($x, $y)
+ {
}
/**
* Render an opening single quote char (language specific)
*/
- public function singlequoteopening() {
+ public function singlequoteopening()
+ {
}
/**
* Render a closing single quote char (language specific)
*/
- public function singlequoteclosing() {
+ public function singlequoteclosing()
+ {
}
/**
* Render an apostrophe char (language specific)
*/
- public function apostrophe() {
+ public function apostrophe()
+ {
}
/**
* Render an opening double quote char (language specific)
*/
- public function doublequoteopening() {
+ public function doublequoteopening()
+ {
}
/**
* Render an closinging double quote char (language specific)
*/
- public function doublequoteclosing() {
+ public function doublequoteclosing()
+ {
}
/**
@@ -510,7 +570,8 @@ abstract class Doku_Renderer extends Plugin {
* @param string $link The link name
* @see http://en.wikipedia.org/wiki/CamelCase
*/
- public function camelcaselink($link) {
+ public function camelcaselink($link)
+ {
}
/**
@@ -519,34 +580,38 @@ abstract class Doku_Renderer extends Plugin {
* @param string $hash hash link identifier
* @param string $name name for the link
*/
- public function locallink($hash, $name = null) {
+ public function locallink($hash, $name = null)
+ {
}
/**
* Render a wiki internal link
*
- * @param string $link page ID to link to. eg. 'wiki:syntax'
+ * @param string $link page ID to link to. eg. 'wiki:syntax'
* @param string|array $title name for the link, array for media file
*/
- public function internallink($link, $title = null) {
+ public function internallink($link, $title = null)
+ {
}
/**
* Render an external link
*
- * @param string $link full URL with scheme
+ * @param string $link full URL with scheme
* @param string|array $title name for the link, array for media file
*/
- public function externallink($link, $title = null) {
+ public function externallink($link, $title = null)
+ {
}
/**
* Render the output of an RSS feed
*
- * @param string $url URL of the feed
- * @param array $params Finetuning of the output
+ * @param string $url URL of the feed
+ * @param array $params Finetuning of the output
*/
- public function rss($url, $params) {
+ public function rss($url, $params)
+ {
}
/**
@@ -554,30 +619,33 @@ abstract class Doku_Renderer extends Plugin {
*
* 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
+ * @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
*/
- public function interwikilink($link, $title, $wikiName, $wikiUri) {
+ public function interwikilink($link, $title, $wikiName, $wikiUri)
+ {
}
/**
* Link to file on users OS
*
- * @param string $link the link
+ * @param string $link the link
* @param string|array $title name for the link, array for media file
*/
- public function filelink($link, $title = null) {
+ public function filelink($link, $title = null)
+ {
}
/**
* Link to windows share
*
- * @param string $link the link
+ * @param string $link the link
* @param string|array $title name for the link, array for media file
*/
- public function windowssharelink($link, $title = null) {
+ public function windowssharelink($link, $title = null)
+ {
}
/**
@@ -588,65 +656,92 @@ abstract class Doku_Renderer extends Plugin {
* @param string $address Email-Address
* @param string|array $name name for the link, array for media file
*/
- public function emaillink($address, $name = null) {
+ public function emaillink($address, $name = 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 $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
*/
- public function internalmedia($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $linking = null) {
+ public function internalmedia(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $linking = 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 $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
*/
- public function externalmedia($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $linking = null) {
+ public function externalmedia(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $linking = 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
+ * @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
*/
- public function internalmedialink($src, $title = null, $align = null,
- $width = null, $height = null, $cache = null) {
+ public function internalmedialink(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = 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
+ * @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
*/
- public function externalmedialink($src, $title = null, $align = null,
- $width = null, $height = null, $cache = null) {
+ public function externalmedialink(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null
+ ) {
}
/**
@@ -654,9 +749,10 @@ abstract class Doku_Renderer extends Plugin {
*
* @param int $maxcols maximum number of columns
* @param int $numrows NOT IMPLEMENTED
- * @param int $pos byte position in the original source
+ * @param int $pos byte position in the original source
*/
- public function table_open($maxcols = null, $numrows = null, $pos = null) {
+ public function table_open($maxcols = null, $numrows = null, $pos = null)
+ {
}
/**
@@ -664,87 +760,100 @@ abstract class Doku_Renderer extends Plugin {
*
* @param int $pos byte position in the original source
*/
- public function table_close($pos = null) {
+ public function table_close($pos = null)
+ {
}
/**
* Open a table header
*/
- public function tablethead_open() {
+ public function tablethead_open()
+ {
}
/**
* Close a table header
*/
- public function tablethead_close() {
+ public function tablethead_close()
+ {
}
/**
* Open a table body
*/
- public function tabletbody_open() {
+ public function tabletbody_open()
+ {
}
/**
* Close a table body
*/
- public function tabletbody_close() {
+ public function tabletbody_close()
+ {
}
/**
* Open a table footer
*/
- public function tabletfoot_open() {
+ public function tabletfoot_open()
+ {
}
/**
* Close a table footer
*/
- public function tabletfoot_close() {
+ public function tabletfoot_close()
+ {
}
/**
* Open a table row
*/
- public function tablerow_open() {
+ public function tablerow_open()
+ {
}
/**
* Close a table row
*/
- public function tablerow_close() {
+ public function tablerow_close()
+ {
}
/**
* Open a table header cell
*
- * @param int $colspan
+ * @param int $colspan
* @param string $align left|center|right
- * @param int $rowspan
+ * @param int $rowspan
*/
- public function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
+ public function tableheader_open($colspan = 1, $align = null, $rowspan = 1)
+ {
}
/**
* Close a table header cell
*/
- public function tableheader_close() {
+ public function tableheader_close()
+ {
}
/**
* Open a table cell
*
- * @param int $colspan
+ * @param int $colspan
* @param string $align left|center|right
- * @param int $rowspan
+ * @param int $rowspan
*/
- public function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
+ public function tablecell_open($colspan = 1, $align = null, $rowspan = 1)
+ {
}
/**
* Close a table cell
*/
- public function tablecell_close() {
+ public function tablecell_close()
+ {
}
#endregion
@@ -754,13 +863,14 @@ abstract class Doku_Renderer extends Plugin {
/**
* 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?
+ * @param string $title The headline title
+ * @param boolean $create Create a new unique ID?
* @return string
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
- public function _headerToLink($title, $create = false) {
- if($create) {
+ public function _headerToLink($title, $create = false)
+ {
+ if ($create) {
return sectionID($title, $this->headers);
} else {
$check = false;
@@ -772,19 +882,20 @@ abstract class Doku_Renderer extends Plugin {
* Removes any Namespace from the given name but keeps
* casing and special chars
*
- * @author Andreas Gohr <andi@splitbrain.org>
- *
* @param string $name
* @return string
+ * @author Andreas Gohr <andi@splitbrain.org>
+ *
*/
- public function _simpleTitle($name) {
+ public function _simpleTitle($name)
+ {
global $conf;
//if there is a hash we use the ancor name only
- list($name, $hash) = sexplode('#', $name, 2);
- if($hash) return $hash;
+ [$name, $hash] = sexplode('#', $name, 2);
+ if ($hash) return $hash;
- if($conf['useslash']) {
+ if ($conf['useslash']) {
$name = strtr($name, ';/', ';:');
} else {
$name = strtr($name, ';', ':');
@@ -796,69 +907,75 @@ abstract class Doku_Renderer extends Plugin {
/**
* Resolve an interwikilink
*
- * @param string $shortcut identifier for the interwiki link
- * @param string $reference fragment that refers the content
- * @param null|bool $exists reference which returns if an internal page exists
+ * @param string $shortcut identifier for the interwiki link
+ * @param string $reference fragment that refers the content
+ * @param null|bool $exists reference which returns if an internal page exists
* @return string interwikilink
*/
- public function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
+ public function _resolveInterWiki(&$shortcut, $reference, &$exists = null)
+ {
//get interwiki URL
- if(isset($this->interwiki[$shortcut])) {
+ if (isset($this->interwiki[$shortcut])) {
$url = $this->interwiki[$shortcut];
- }elseif(isset($this->interwiki['default'])) {
+ } elseif (isset($this->interwiki['default'])) {
$shortcut = 'default';
$url = $this->interwiki[$shortcut];
- }else{
+ } else {
// not parsable interwiki outputs '' to make sure string manipluation works
$shortcut = '';
- $url = '';
+ $url = '';
}
//split into hash and url part
$hash = strrchr($reference, '#');
- if($hash) {
+ if ($hash) {
$reference = substr($reference, 0, -strlen($hash));
$hash = substr($hash, 1);
}
//replace placeholder
- if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
+ if (preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
//use placeholders
- $url = str_replace('{URL}', rawurlencode($reference), $url);
+ $url = str_replace('{URL}', rawurlencode($reference), $url);
//wiki names will be cleaned next, otherwise urlencode unsafe chars
- $url = str_replace('{NAME}', ($url[0] === ':') ? $reference :
- preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) {
- return rawurlencode($match[0]);
- }, $reference), $url);
+ $url = str_replace(
+ '{NAME}',
+ ($url[0] === ':') ? $reference : preg_replace_callback(
+ '/[[\\\\\]^`{|}#%]/',
+ static fn($match) => rawurlencode($match[0]),
+ $reference
+ ),
+ $url
+ );
$parsed = parse_url($reference);
if (empty($parsed['scheme'])) $parsed['scheme'] = '';
if (empty($parsed['host'])) $parsed['host'] = '';
if (empty($parsed['port'])) $parsed['port'] = 80;
if (empty($parsed['path'])) $parsed['path'] = '';
if (empty($parsed['query'])) $parsed['query'] = '';
- $url = strtr($url,[
+ $url = strtr($url, [
'{SCHEME}' => $parsed['scheme'],
'{HOST}' => $parsed['host'],
'{PORT}' => $parsed['port'],
'{PATH}' => $parsed['path'],
- '{QUERY}' => $parsed['query'] ,
+ '{QUERY}' => $parsed['query'],
]);
- } else if($url != '') {
+ } elseif ($url != '') {
// make sure when no url is defined, we keep it null
// default
- $url = $url.rawurlencode($reference);
+ $url .= rawurlencode($reference);
}
//handle as wiki links
- if($url && $url[0] === ':') {
+ if ($url && $url[0] === ':') {
$urlparam = '';
$id = $url;
if (strpos($url, '?') !== false) {
- list($id, $urlparam) = sexplode('?', $url, 2, '');
+ [$id, $urlparam] = sexplode('?', $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;
}
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index ba7ec51a9..fb8c658e4 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -3,6 +3,8 @@
use dokuwiki\ChangeLog\MediaChangeLog;
use dokuwiki\File\MediaResolver;
use dokuwiki\File\PageResolver;
+use dokuwiki\Utf8\PhpString;
+use SimplePie\Author;
/**
* Renderer for XHTML output
@@ -13,41 +15,42 @@ use dokuwiki\File\PageResolver;
* @author Andreas Gohr <andi@splitbrain.org>
*
*/
-class Doku_Renderer_xhtml extends Doku_Renderer {
+class Doku_Renderer_xhtml extends Doku_Renderer
+{
/** @var array store the table of contents */
- public $toc = array();
+ public $toc = [];
/** @var array A stack of section edit data */
- protected $sectionedits = array();
+ protected $sectionedits = [];
/** @var int last section edit id, used by startSectionEdit */
protected $lastsecid = 0;
/** @var array a list of footnotes, list starts at 1! */
- protected $footnotes = array();
+ protected $footnotes = [];
/** @var int current section level */
protected $lastlevel = 0;
/** @var array section node tracker */
- protected $node = array(0, 0, 0, 0, 0);
+ protected $node = [0, 0, 0, 0, 0];
/** @var string temporary $doc store */
protected $store = '';
/** @var array global counter, for table classes etc. */
- protected $_counter = array(); //
+ protected $_counter = []; //
/** @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;
+ protected $schemes;
/**
* Register a new edit section range
*
- * @param int $start The byte position for the edit start
- * @param array $data Associative array with section data:
+ * @param int $start The byte position for the edit start
+ * @param array $data Associative array with section data:
* Key 'name': the section name/title
* Key 'target': the target for the section edit,
* e.g. 'section' or 'table'
@@ -62,49 +65,52 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Adrian Lang <lang@cosmocode.de>
*/
- public function startSectionEdit($start, $data) {
+ public function startSectionEdit($start, $data)
+ {
if (!is_array($data)) {
msg(
sprintf(
'startSectionEdit: $data "%s" is NOT an array! One of your plugins needs an update.',
- hsc((string) $data)
- ), -1
+ hsc((string)$data)
+ ),
+ -1
);
// @deprecated 2018-04-14, backward compatibility
$args = func_get_args();
- $data = array();
- if(isset($args[1])) $data['target'] = $args[1];
- if(isset($args[2])) $data['name'] = $args[2];
- if(isset($args[3])) $data['hid'] = $args[3];
+ $data = [];
+ if (isset($args[1])) $data['target'] = $args[1];
+ if (isset($args[2])) $data['name'] = $args[2];
+ if (isset($args[3])) $data['hid'] = $args[3];
}
$data['secid'] = ++$this->lastsecid;
$data['start'] = $start;
$this->sectionedits[] = $data;
- return 'sectionedit'.$data['secid'];
+ return 'sectionedit' . $data['secid'];
}
/**
* Finish an edit section range
*
- * @param int $end The byte position for the edit end; null for the rest of the page
+ * @param int $end 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, $hid = null) {
- if(count($this->sectionedits) == 0) {
+ public function finishSectionEdit($end = null, $hid = null)
+ {
+ if (count($this->sectionedits) == 0) {
return;
}
$data = array_pop($this->sectionedits);
- if(!is_null($end) && $end <= $data['start']) {
+ if (!is_null($end) && $end <= $data['start']) {
return;
}
- if(!is_null($hid)) {
+ if (!is_null($hid)) {
$data['hid'] .= $hid;
}
- $data['range'] = $data['start'].'-'.(is_null($end) ? '' : $end);
+ $data['range'] = $data['start'] . '-' . (is_null($end) ? '' : $end);
unset($data['start']);
- $this->doc .= '<!-- EDIT'.hsc(json_encode ($data)).' -->';
+ $this->doc .= '<!-- EDIT' . hsc(json_encode($data, JSON_THROW_ON_ERROR)) . ' -->';
}
/**
@@ -112,25 +118,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @return string always 'xhtml'
*/
- public function getFormat() {
+ public function getFormat()
+ {
return 'xhtml';
}
/**
* Initialize the document
*/
- public function document_start() {
+ public function document_start()
+ {
//reset some internals
- $this->toc = array();
+ $this->toc = [];
}
/**
* Finalize the document
*/
- public function document_end() {
+ public function document_end()
+ {
// Finish open section edits.
- while(count($this->sectionedits) > 0) {
- if($this->sectionedits[count($this->sectionedits) - 1]['start'] <= 1) {
+ while ($this->sectionedits !== []) {
+ if ($this->sectionedits[count($this->sectionedits) - 1]['start'] <= 1) {
// If there is only one section, do not write a section edit
// marker.
array_pop($this->sectionedits);
@@ -139,40 +148,37 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
- if(count($this->footnotes) > 0) {
- $this->doc .= '<div class="footnotes">'.DOKU_LF;
+ if ($this->footnotes !== []) {
+ $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">';
- $this->doc .= '<sup><a href="#fnt__'.$id.'" id="fn__'.$id.'" class="fn_bot">';
- $this->doc .= $id.')</a></sup> '.DOKU_LF;
+ $this->doc .= '<sup><a href="#fnt__' . $id . '" id="fn__' . $id . '" class="fn_bot">';
+ $this->doc .= $id . ')</a></sup> ' . DOKU_LF;
// get any other footnotes that use the same markup
$alt = array_keys($this->footnotes, "@@FNT$id");
- 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;
- }
+ 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;
}
// add footnote markup and close this footnote
- $this->doc .= '<div class="content">'.$footnote.'</div>';
- $this->doc .= '</div>'.DOKU_LF;
+ $this->doc .= '<div class="content">' . $footnote . '</div>';
+ $this->doc .= '</div>' . DOKU_LF;
}
}
- $this->doc .= '</div>'.DOKU_LF;
+ $this->doc .= '</div>' . DOKU_LF;
}
// Prepare the TOC
global $conf;
- if(
+ if (
$this->info['toc'] &&
is_array($this->toc) &&
$conf['tocminheads'] && count($this->toc) >= $conf['tocminheads']
@@ -188,15 +194,16 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* 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
+ * @param string $id the hash link
+ * @param string $text the text to display
+ * @param int $level the nesting level
*/
- public function toc_additem($id, $text, $level) {
+ public function toc_additem($id, $text, $level)
+ {
global $conf;
//handle TOC
- if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) {
+ if ($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) {
$this->toc[] = html_mktocitem($id, $text, $level - $conf['toptoclevel'] + 1);
}
}
@@ -204,16 +211,17 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render a heading
*
- * @param string $text the text to display
- * @param int $level header level
- * @param int $pos byte position in the original source
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $text the text to display
+ * @param int $level header level
+ * @param int $pos byte position in the original source
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- public function header($text, $level, $pos, $returnonly = false) {
+ public function header($text, $level, $pos, $returnonly = false)
+ {
global $conf;
- if(blank($text)) return; //skip empty headlines
+ if (blank($text)) return; //skip empty headlines
$hid = $this->_headerToLink($text, true);
@@ -222,33 +230,34 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// adjust $node to reflect hierarchy of levels
$this->node[$level - 1]++;
- if($level < $this->lastlevel) {
- for($i = 0; $i < $this->lastlevel - $level; $i++) {
+ 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'] &&
- count($this->sectionedits) > 0 &&
+ if (
+ $level <= $conf['maxseclevel'] &&
+ $this->sectionedits !== [] &&
$this->sectionedits[count($this->sectionedits) - 1]['target'] === 'section'
) {
$this->finishSectionEdit($pos - 1);
}
// build the header
- $header = DOKU_LF.'<h'.$level;
- if($level <= $conf['maxseclevel']) {
- $data = array();
+ $header = DOKU_LF . '<h' . $level;
+ if ($level <= $conf['maxseclevel']) {
+ $data = [];
$data['target'] = 'section';
$data['name'] = $text;
$data['hid'] = $hid;
$data['codeblockOffset'] = $this->_codeblock;
- $header .= ' class="'.$this->startSectionEdit($pos, $data).'"';
+ $header .= ' class="' . $this->startSectionEdit($pos, $data) . '"';
}
- $header .= ' id="'.$hid.'">';
+ $header .= ' id="' . $hid . '">';
$header .= $this->_xmlEntities($text);
- $header .= "</h$level>".DOKU_LF;
+ $header .= "</h$level>" . DOKU_LF;
if ($returnonly) {
return $header;
@@ -262,15 +271,17 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param int $level section level (as determined by the previous header)
*/
- public function section_open($level) {
- $this->doc .= '<div class="level'.$level.'">'.DOKU_LF;
+ public function section_open($level)
+ {
+ $this->doc .= '<div class="level' . $level . '">' . DOKU_LF;
}
/**
* Close the current section
*/
- public function section_close() {
- $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
+ public function section_close()
+ {
+ $this->doc .= DOKU_LF . '</div>' . DOKU_LF;
}
/**
@@ -278,133 +289,152 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param $text
*/
- public function cdata($text) {
+ public function cdata($text)
+ {
$this->doc .= $this->_xmlEntities($text);
}
/**
* Open a paragraph
*/
- public function p_open() {
- $this->doc .= DOKU_LF.'<p>'.DOKU_LF;
+ public function p_open()
+ {
+ $this->doc .= DOKU_LF . '<p>' . DOKU_LF;
}
/**
* Close a paragraph
*/
- public function p_close() {
- $this->doc .= DOKU_LF.'</p>'.DOKU_LF;
+ public function p_close()
+ {
+ $this->doc .= DOKU_LF . '</p>' . DOKU_LF;
}
/**
* Create a line break
*/
- public function linebreak() {
- $this->doc .= '<br/>'.DOKU_LF;
+ public function linebreak()
+ {
+ $this->doc .= '<br/>' . DOKU_LF;
}
/**
* Create a horizontal line
*/
- public function hr() {
- $this->doc .= '<hr />'.DOKU_LF;
+ public function hr()
+ {
+ $this->doc .= '<hr />' . DOKU_LF;
}
/**
* Start strong (bold) formatting
*/
- public function strong_open() {
+ public function strong_open()
+ {
$this->doc .= '<strong>';
}
/**
* Stop strong (bold) formatting
*/
- public function strong_close() {
+ public function strong_close()
+ {
$this->doc .= '</strong>';
}
/**
* Start emphasis (italics) formatting
*/
- public function emphasis_open() {
+ public function emphasis_open()
+ {
$this->doc .= '<em>';
}
/**
* Stop emphasis (italics) formatting
*/
- public function emphasis_close() {
+ public function emphasis_close()
+ {
$this->doc .= '</em>';
}
/**
* Start underline formatting
*/
- public function underline_open() {
+ public function underline_open()
+ {
$this->doc .= '<em class="u">';
}
/**
* Stop underline formatting
*/
- public function underline_close() {
+ public function underline_close()
+ {
$this->doc .= '</em>';
}
/**
* Start monospace formatting
*/
- public function monospace_open() {
+ public function monospace_open()
+ {
$this->doc .= '<code>';
}
/**
* Stop monospace formatting
*/
- public function monospace_close() {
+ public function monospace_close()
+ {
$this->doc .= '</code>';
}
/**
* Start a subscript
*/
- public function subscript_open() {
+ public function subscript_open()
+ {
$this->doc .= '<sub>';
}
/**
* Stop a subscript
*/
- public function subscript_close() {
+ public function subscript_close()
+ {
$this->doc .= '</sub>';
}
/**
* Start a superscript
*/
- public function superscript_open() {
+ public function superscript_open()
+ {
$this->doc .= '<sup>';
}
/**
* Stop a superscript
*/
- public function superscript_close() {
+ public function superscript_close()
+ {
$this->doc .= '</sup>';
}
/**
* Start deleted (strike-through) formatting
*/
- public function deleted_open() {
+ public function deleted_open()
+ {
$this->doc .= '<del>';
}
/**
* Stop deleted (strike-through) formatting
*/
- public function deleted_close() {
+ public function deleted_close()
+ {
$this->doc .= '</del>';
}
@@ -417,11 +447,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- public function footnote_open() {
+ public function footnote_open()
+ {
// move current content to store and record footnote
$this->store = $this->doc;
- $this->doc = '';
+ $this->doc = '';
}
/**
@@ -432,30 +463,36 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr
*/
- public function footnote_close() {
+ public function footnote_close()
+ {
/** @var $fnid int takes track of seen footnotes, assures they are unique even across multiple docs FS#2841 */
static $fnid = 0;
// assign new footnote id (we start at 1)
$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 {
// seen this one before, save a placeholder
- $this->footnotes[$fnid] = "@@FNT".($i);
+ $this->footnotes[$fnid] = "@@FNT" . ($i);
}
// output the footnote reference and link
- $this->doc .= '<sup><a href="#fn__'.$fnid.'" id="fnt__'.$fnid.'" class="fn_top">'.$fnid.')</a></sup>';
+ $this->doc .= sprintf(
+ '<sup><a href="#fn__%d" id="fnt__%d" class="fn_top">%d)</a></sup>',
+ $fnid,
+ $fnid,
+ $fnid
+ );
}
/**
@@ -463,20 +500,22 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
*/
- public function listu_open($classes = null) {
+ public function listu_open($classes = null)
+ {
$class = '';
- if($classes !== null) {
- if(is_array($classes)) $classes = join(' ', $classes);
+ if ($classes !== null) {
+ if (is_array($classes)) $classes = implode(' ', $classes);
$class = " class=\"$classes\"";
}
- $this->doc .= "<ul$class>".DOKU_LF;
+ $this->doc .= "<ul$class>" . DOKU_LF;
}
/**
* Close an unordered list
*/
- public function listu_close() {
- $this->doc .= '</ul>'.DOKU_LF;
+ public function listu_close()
+ {
+ $this->doc .= '</ul>' . DOKU_LF;
}
/**
@@ -484,20 +523,22 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
*/
- public function listo_open($classes = null) {
+ public function listo_open($classes = null)
+ {
$class = '';
- if($classes !== null) {
- if(is_array($classes)) $classes = join(' ', $classes);
+ if ($classes !== null) {
+ if (is_array($classes)) $classes = implode(' ', $classes);
$class = " class=\"$classes\"";
}
- $this->doc .= "<ol$class>".DOKU_LF;
+ $this->doc .= "<ol$class>" . DOKU_LF;
}
/**
* Close an ordered list
*/
- public function listo_close() {
- $this->doc .= '</ol>'.DOKU_LF;
+ public function listo_close()
+ {
+ $this->doc .= '</ol>' . DOKU_LF;
}
/**
@@ -506,30 +547,34 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @param int $level the nesting level
* @param bool $node true when a node; false when a leaf
*/
- public function listitem_open($level, $node=false) {
+ public function listitem_open($level, $node = false)
+ {
$branching = $node ? ' node' : '';
- $this->doc .= '<li class="level'.$level.$branching.'">';
+ $this->doc .= '<li class="level' . $level . $branching . '">';
}
/**
* Close a list item
*/
- public function listitem_close() {
- $this->doc .= '</li>'.DOKU_LF;
+ public function listitem_close()
+ {
+ $this->doc .= '</li>' . DOKU_LF;
}
/**
* Start the content of a list item
*/
- public function listcontent_open() {
+ public function listcontent_open()
+ {
$this->doc .= '<div class="li">';
}
/**
* Stop the content of a list item
*/
- public function listcontent_close() {
- $this->doc .= '</div>'.DOKU_LF;
+ public function listcontent_close()
+ {
+ $this->doc .= '</div>' . DOKU_LF;
}
/**
@@ -539,22 +584,25 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string $text
*/
- public function unformatted($text) {
+ public function unformatted($text)
+ {
$this->doc .= $this->_xmlEntities($text);
}
/**
* Start a block quote
*/
- public function quote_open() {
- $this->doc .= '<blockquote><div class="no">'.DOKU_LF;
+ public function quote_open()
+ {
+ $this->doc .= '<blockquote><div class="no">' . DOKU_LF;
}
/**
* Stop a block quote
*/
- public function quote_close() {
- $this->doc .= '</div></blockquote>'.DOKU_LF;
+ public function quote_close()
+ {
+ $this->doc .= '</div></blockquote>' . DOKU_LF;
}
/**
@@ -562,92 +610,96 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string $text
*/
- public function preformatted($text) {
- $this->doc .= '<pre class="code">'.trim($this->_xmlEntities($text), "\n\r").'</pre>'.DOKU_LF;
+ public function preformatted($text)
+ {
+ $this->doc .= '<pre class="code">' . trim($this->_xmlEntities($text), "\n\r") . '</pre>' . DOKU_LF;
}
/**
* Display text as file content, optionally syntax highlighted
*
- * @param string $text text to show
+ * @param string $text text to show
* @param string $language programming language to use for syntax highlighting
* @param string $filename file path label
- * @param array $options assoziative array with additional geshi options
+ * @param array $options assoziative array with additional geshi options
*/
- public function file($text, $language = null, $filename = null, $options=null) {
+ public function file($text, $language = null, $filename = null, $options = null)
+ {
$this->_highlight('file', $text, $language, $filename, $options);
}
/**
* Display text as code content, optionally syntax highlighted
*
- * @param string $text text to show
+ * @param string $text text to show
* @param string $language programming language to use for syntax highlighting
* @param string $filename file path label
- * @param array $options assoziative array with additional geshi options
+ * @param array $options assoziative array with additional geshi options
*/
- public function code($text, $language = null, $filename = null, $options=null) {
+ public function code($text, $language = null, $filename = null, $options = null)
+ {
$this->_highlight('code', $text, $language, $filename, $options);
}
/**
* 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 $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
- * @param array $options assoziative array with additional geshi options
+ * @param array $options assoziative array with additional geshi options
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
- public function _highlight($type, $text, $language = null, $filename = null, $options = null) {
+ public function _highlight($type, $text, $language = null, $filename = null, $options = null)
+ {
global $ID;
global $lang;
global $INPUT;
$language = preg_replace(PREG_PATTERN_VALID_LANGUAGE, '', $language ?? '');
- if($filename) {
+ if ($filename) {
// add icon
- list($ext) = mimetype($filename, false);
+ [$ext] = mimetype($filename, false);
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
- $class = 'mediafile mf_'.$class;
+ $class = 'mediafile mf_' . $class;
$offset = 0;
if ($INPUT->has('codeblockOffset')) {
$offset = $INPUT->str('codeblockOffset');
}
- $this->doc .= '<dl class="'.$type.'">'.DOKU_LF;
+ $this->doc .= '<dl class="' . $type . '">' . DOKU_LF;
$this->doc .= '<dt><a href="' .
exportlink(
$ID,
'code',
- array('codeblock' => $offset + $this->_codeblock)
+ ['codeblock' => $offset + $this->_codeblock]
) . '" title="' . $lang['download'] . '" class="' . $class . '">';
$this->doc .= hsc($filename);
- $this->doc .= '</a></dt>'.DOKU_LF.'<dd>';
+ $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(empty($language)) { // empty is faster than is_null and can prevent '' string
- $this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF;
+ if (empty($language)) { // empty is faster than is_null and can prevent '' string
+ $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
- if($type != 'code') $class .= ' '.$type;
+ if ($type != 'code') $class .= ' ' . $type;
$this->doc .= "<pre class=\"$class $language\">" .
p_xhtml_cached_geshi($text, $language, '', $options) .
'</pre>' . DOKU_LF;
}
- if($filename) {
- $this->doc .= '</dd></dl>'.DOKU_LF;
+ if ($filename) {
+ $this->doc .= '</dd></dl>' . DOKU_LF;
}
$this->_codeblock++;
@@ -660,15 +712,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string $acronym
*/
- public function acronym($acronym) {
-
- if(array_key_exists($acronym, $this->acronyms)) {
+ public function acronym($acronym)
+ {
+ if (array_key_exists($acronym, $this->acronyms)) {
$title = $this->_xmlEntities($this->acronyms[$acronym]);
- $this->doc .= '<abbr title="'.$title
- .'">'.$this->_xmlEntities($acronym).'</abbr>';
-
+ $this->doc .= '<abbr title="' . $title
+ . '">' . $this->_xmlEntities($acronym) . '</abbr>';
} else {
$this->doc .= $this->_xmlEntities($acronym);
}
@@ -681,7 +732,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string $smiley
*/
- public function smiley($smiley) {
+ public function smiley($smiley)
+ {
if (isset($this->smileys[$smiley])) {
$this->doc .= '<img src="' . DOKU_BASE . 'lib/images/smileys/' . $this->smileys[$smiley] .
'" class="icon smiley" alt="' . $this->_xmlEntities($smiley) . '" />';
@@ -699,8 +751,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string $entity
*/
- public function entity($entity) {
- if(array_key_exists($entity, $this->entities)) {
+ public function entity($entity)
+ {
+ if (array_key_exists($entity, $this->entities)) {
$this->doc .= $this->entities[$entity];
} else {
$this->doc .= $this->_xmlEntities($entity);
@@ -715,14 +768,16 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @param string|int $x first value
* @param string|int $y second value
*/
- public function multiplyentity($x, $y) {
+ public function multiplyentity($x, $y)
+ {
$this->doc .= "$x&times;$y";
}
/**
* Render an opening single quote char (language specific)
*/
- public function singlequoteopening() {
+ public function singlequoteopening()
+ {
global $lang;
$this->doc .= $lang['singlequoteopening'];
}
@@ -730,7 +785,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render a closing single quote char (language specific)
*/
- public function singlequoteclosing() {
+ public function singlequoteclosing()
+ {
global $lang;
$this->doc .= $lang['singlequoteclosing'];
}
@@ -738,7 +794,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render an apostrophe char (language specific)
*/
- public function apostrophe() {
+ public function apostrophe()
+ {
global $lang;
$this->doc .= $lang['apostrophe'];
}
@@ -746,7 +803,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render an opening double quote char (language specific)
*/
- public function doublequoteopening() {
+ public function doublequoteopening()
+ {
global $lang;
$this->doc .= $lang['doublequoteopening'];
}
@@ -754,7 +812,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render an closinging double quote char (language specific)
*/
- public function doublequoteclosing() {
+ public function doublequoteclosing()
+ {
global $lang;
$this->doc .= $lang['doublequoteclosing'];
}
@@ -762,42 +821,44 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render a CamelCase link
*
- * @param string $link The link name
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $link The link name
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*
* @see http://en.wikipedia.org/wiki/CamelCase
*/
- public function camelcaselink($link, $returnonly = false) {
- if($returnonly) {
- return $this->internallink($link, $link, null, true);
+ public function camelcaselink($link, $returnonly = false)
+ {
+ if ($returnonly) {
+ return $this->internallink($link, $link, null, true);
} else {
- $this->internallink($link, $link);
+ $this->internallink($link, $link);
}
}
/**
* Render a page local link
*
- * @param string $hash hash link identifier
- * @param string $name name for the link
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $hash hash link identifier
+ * @param string $name name for the link
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- public function locallink($hash, $name = null, $returnonly = false) {
+ public function locallink($hash, $name = null, $returnonly = false)
+ {
global $ID;
- $name = $this->_getLinkTitle($name, $hash, $isImage);
- $hash = $this->_headerToLink($hash);
- $title = $ID.' ↵';
+ $name = $this->_getLinkTitle($name, $hash, $isImage);
+ $hash = $this->_headerToLink($hash);
+ $title = $ID . ' ↵';
- $doc = '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
+ $doc = '<a href="#' . $hash . '" title="' . $title . '" class="wikilink1">';
$doc .= $name;
$doc .= '</a>';
- if($returnonly) {
- return $doc;
+ if ($returnonly) {
+ return $doc;
} else {
- $this->doc .= $doc;
+ $this->doc .= $doc;
}
}
@@ -807,23 +868,24 @@ 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
*
- * @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
+ * @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>
*/
- public function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') {
+ public 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];
}
@@ -831,7 +893,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;
}
@@ -842,13 +904,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$id = (new PageResolver($ID))->resolveId($id, $this->date_at, true);
$exists = page_exists($id, $this->date_at, false, true);
- $link = array();
+ $link = [];
$name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype);
- if(!$isImage) {
- if($exists) {
+ if (!$isImage) {
+ if ($exists) {
$class = 'wikilink1';
} else {
- $class = 'wikilink2';
+ $class = 'wikilink2';
$link['rel'] = 'nofollow';
}
} else {
@@ -856,38 +918,38 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
//keep hash anchor
- list($id, $hash) = sexplode('#', $id, 2);
- if(!empty($hash)) $hash = $this->_headerToLink($hash);
+ [$id, $hash] = sexplode('#', $id, 2);
+ if (!empty($hash)) $hash = $this->_headerToLink($hash);
//prepare for formating
$link['target'] = $conf['target']['wiki'];
- $link['style'] = '';
- $link['pre'] = '';
- $link['suf'] = '';
- $link['more'] = 'data-wiki-id="'.$id.'"'; // id is already cleaned
- $link['class'] = $class;
- if($this->date_at) {
- $params = $params.'&at='.rawurlencode($this->date_at);
- }
- $link['url'] = wl($id, $params);
- $link['name'] = $name;
- $link['title'] = $id;
+ $link['style'] = '';
+ $link['pre'] = '';
+ $link['suf'] = '';
+ $link['more'] = 'data-wiki-id="' . $id . '"'; // id is already cleaned
+ $link['class'] = $class;
+ if ($this->date_at) {
+ $params = $params . '&at=' . rawurlencode($this->date_at);
+ }
+ $link['url'] = wl($id, $params);
+ $link['name'] = $name;
+ $link['title'] = $id;
//add search string
- if($search) {
+ if ($search) {
($conf['userewrite']) ? $link['url'] .= '?' : $link['url'] .= '&amp;';
- if(is_array($search)) {
+ if (is_array($search)) {
$search = array_map('rawurlencode', $search);
- $link['url'] .= 's[]='.join('&amp;s[]=', $search);
+ $link['url'] .= 's[]=' . implode('&amp;s[]=', $search);
} else {
- $link['url'] .= 's='.rawurlencode($search);
+ $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 {
$this->doc .= $this->_formatLink($link);
@@ -897,25 +959,26 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render an external link
*
- * @param string $url full URL with scheme
- * @param string|array $name name for the link, array for media file
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $url full URL with scheme
+ * @param string|array $name name for the link, array for media file
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- public function externallink($url, $name = null, $returnonly = false) {
+ public function externallink($url, $name = null, $returnonly = false)
+ {
global $conf;
$name = $this->_getLinkTitle($name, $url, $isImage);
// url might be an attack vector, only allow registered protocols
- if(is_null($this->schemes)) $this->schemes = getSchemes();
- list($scheme) = explode('://', $url);
+ if (is_null($this->schemes)) $this->schemes = getSchemes();
+ [$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($returnonly) {
+ if (!$url) {
+ if ($returnonly) {
return $name;
} else {
$this->doc .= $name;
@@ -924,30 +987,30 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
// set class
- if(!$isImage) {
+ if (!$isImage) {
$class = 'urlextern';
} else {
$class = 'media';
}
//prepare for formating
- $link = array();
+ $link = [];
$link['target'] = $conf['target']['extern'];
- $link['style'] = '';
- $link['pre'] = '';
- $link['suf'] = '';
- $link['more'] = '';
- $link['class'] = $class;
- $link['url'] = $url;
- $link['rel'] = '';
-
- $link['name'] = $name;
+ $link['style'] = '';
+ $link['pre'] = '';
+ $link['suf'] = '';
+ $link['more'] = '';
+ $link['class'] = $class;
+ $link['url'] = $url;
+ $link['rel'] = '';
+
+ $link['name'] = $name;
$link['title'] = $this->_xmlEntities($url);
- if($conf['relnofollow']) $link['rel'] .= ' ugc nofollow';
- if($conf['target']['extern']) $link['rel'] .= ' noopener';
+ if ($conf['relnofollow']) $link['rel'] .= ' ugc nofollow';
+ if ($conf['target']['extern']) $link['rel'] .= ' noopener';
//output formatted
- if($returnonly) {
+ if ($returnonly) {
return $this->_formatLink($link);
} else {
$this->doc .= $this->_formatLink($link);
@@ -959,94 +1022,95 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* 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
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @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
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- public function interwikilink($match, $name, $wikiName, $wikiUri, $returnonly = false) {
+ public function interwikilink($match, $name, $wikiName, $wikiUri, $returnonly = false)
+ {
global $conf;
- $link = array();
+ $link = [];
$link['target'] = $conf['target']['interwiki'];
- $link['pre'] = '';
- $link['suf'] = '';
- $link['more'] = '';
- $link['name'] = $this->_getLinkTitle($name, $wikiUri, $isImage);
- $link['rel'] = '';
+ $link['pre'] = '';
+ $link['suf'] = '';
+ $link['more'] = '';
+ $link['name'] = $this->_getLinkTitle($name, $wikiUri, $isImage);
+ $link['rel'] = '';
//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);
+ if (!$isImage) {
+ $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName);
$link['class'] = "interwiki iw_$class";
} else {
$link['class'] = 'media';
}
//do we stay at the same server? Use local target
- if(strpos($url, DOKU_URL) === 0 OR strpos($url, DOKU_BASE) === 0) {
+ if (strpos($url, DOKU_URL) === 0 || strpos($url, DOKU_BASE) === 0) {
$link['target'] = $conf['target']['wiki'];
}
- if($exists !== null && !$isImage) {
- if($exists) {
+ if ($exists !== null && !$isImage) {
+ if ($exists) {
$link['class'] .= ' wikilink1';
} else {
$link['class'] .= ' wikilink2';
$link['rel'] .= ' nofollow';
}
}
- if($conf['target']['interwiki']) $link['rel'] .= ' noopener';
+ if ($conf['target']['interwiki']) $link['rel'] .= ' noopener';
- $link['url'] = $url;
+ $link['url'] = $url;
$link['title'] = $this->_xmlEntities($link['url']);
// output formatted
- if($returnonly) {
- if($url == '') return $link['name'];
+ if ($returnonly) {
+ if ($url == '') return $link['name'];
return $this->_formatLink($link);
- } else {
- if($url == '') $this->doc .= $link['name'];
- else $this->doc .= $this->_formatLink($link);
- }
+ } elseif ($url == '') {
+ $this->doc .= $link['name'];
+ } else $this->doc .= $this->_formatLink($link);
}
/**
* Link to windows share
*
- * @param string $url the link
- * @param string|array $name name for the link, array for media file
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $url the link
+ * @param string|array $name name for the link, array for media file
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- public function windowssharelink($url, $name = null, $returnonly = false) {
+ public function windowssharelink($url, $name = null, $returnonly = false)
+ {
global $conf;
//simple setup
- $link = array();
+ $link = [];
$link['target'] = $conf['target']['windows'];
- $link['pre'] = '';
- $link['suf'] = '';
- $link['style'] = '';
+ $link['pre'] = '';
+ $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
- if($returnonly) {
+ if ($returnonly) {
return $this->_formatLink($link);
} else {
$this->doc .= $this->_formatLink($link);
@@ -1058,23 +1122,24 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* Honors $conf['mailguard'] setting
*
- * @param string $address Email-Address
- * @param string|array $name name for the link, array for media file
- * @param bool $returnonly whether to return html or write to doc attribute
+ * @param string $address Email-Address
+ * @param string|array $name name for the link, array for media file
+ * @param bool $returnonly whether to return html or write to doc attribute
* @return void|string writes to doc attribute or returns html depends on $returnonly
*/
- public function emaillink($address, $name = null, $returnonly = false) {
+ public function emaillink($address, $name = null, $returnonly = false)
+ {
global $conf;
//simple setup
- $link = array();
+ $link = [];
$link['target'] = '';
- $link['pre'] = '';
- $link['suf'] = '';
- $link['style'] = '';
- $link['more'] = '';
+ $link['pre'] = '';
+ $link['suf'] = '';
+ $link['style'] = '';
+ $link['more'] = '';
$name = $this->_getLinkTitle($name, '', $isImage);
- if(!$isImage) {
+ if (!$isImage) {
$link['class'] = 'mail';
} else {
$link['class'] = 'media';
@@ -1082,20 +1147,21 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$address = $this->_xmlEntities($address);
$address = obfuscate($address);
- $title = $address;
- if(empty($name)) {
+ $title = $address;
+
+ if (empty($name)) {
$name = $address;
}
- if($conf['mailguard'] == 'visible') $address = rawurlencode($address);
+ if ($conf['mailguard'] == 'visible') $address = rawurlencode($address);
- $link['url'] = 'mailto:'.$address;
- $link['name'] = $name;
+ $link['url'] = 'mailto:' . $address;
+ $link['name'] = $name;
$link['title'] = $title;
//output formatted
- if($returnonly) {
+ if ($returnonly) {
return $this->_formatLink($link);
} else {
$this->doc .= $this->_formatLink($link);
@@ -1105,179 +1171,199 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* 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
+ * @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 writes to doc attribute or returns html depends on $return
*/
- public function internalmedia($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $linking = null, $return = false) {
+ public function internalmedia(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $linking = null,
+ $return = false
+ ) {
global $ID;
if (strpos($src, '#') !== false) {
- list($src, $hash) = sexplode('#', $src, 2);
+ [$src, $hash] = sexplode('#', $src, 2);
}
- $src = (new MediaResolver($ID))->resolveId($src,$this->date_at,true);
+ $src = (new MediaResolver($ID))->resolveId($src, $this->date_at, true);
$exists = media_exists($src);
$noLink = false;
- $render = ($linking == 'linkonly') ? false : true;
- $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
+ $render = $linking != 'linkonly';
+ $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
- list($ext, $mime) = mimetype($src, false);
- if(substr($mime, 0, 5) == 'image' && $render) {
+ [$ext, $mime] = mimetype($src, false);
+ if (substr($mime, 0, 5) == 'image' && $render) {
$link['url'] = ml(
$src,
- array(
+ [
'id' => $ID,
'cache' => $cache,
'rev' => $this->_getLastMediaRevisionAt($src)
- ),
+ ],
($linking == 'direct')
);
- } 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 {
// add file icons
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
- $link['class'] .= ' mediafile mf_'.$class;
+ $link['class'] .= ' mediafile mf_' . $class;
$link['url'] = ml(
$src,
- array(
+ [
'id' => $ID,
'cache' => $cache,
'rev' => $this->_getLastMediaRevisionAt($src)
- ),
+ ],
true
);
- if($exists) $link['title'] .= ' ('.filesize_h(filesize(mediaFN($src))).')';
+ if ($exists) $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))) . ')';
}
- if (!empty($hash)) $link['url'] .= '#'.$hash;
+ if (!empty($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'];
- else return $this->_formatLink($link);
+ if ($return) {
+ if ($linking == 'nolink' || $noLink) {
+ return $link['name'];
+ } else {
+ return $this->_formatLink($link);
+ }
+ } elseif ($linking == 'nolink' || $noLink) {
+ $this->doc .= $link['name'];
} else {
- if($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
- else $this->doc .= $this->_formatLink($link);
+ $this->doc .= $this->_formatLink($link);
}
}
/**
* 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 $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
- * @param bool $return return HTML instead of adding to $doc
+ * @param bool $return return HTML instead of adding to $doc
* @return void|string writes to doc attribute or returns html depends on $return
*/
- public function externalmedia($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $linking = null, $return = false) {
- if(link_isinterwiki($src)){
- list($shortcut, $reference) = sexplode('>', $src, 2, '');
+ public function externalmedia(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $linking = null,
+ $return = false
+ ) {
+ if (link_isinterwiki($src)) {
+ [$shortcut, $reference] = sexplode('>', $src, 2, '');
$exists = null;
$src = $this->_resolveInterWiki($shortcut, $reference, $exists);
- if($src == '' && empty($title)){
+ if ($src == '' && empty($title)) {
// make sure at least something will be shown in this case
$title = $reference;
}
}
- list($src, $hash) = sexplode('#', $src, 2);
+ [$src, $hash] = sexplode('#', $src, 2);
$noLink = false;
- if($src == '') {
+ if ($src == '') {
// only output plaintext without link if there is no src
$noLink = true;
}
- $render = ($linking == 'linkonly') ? false : true;
- $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
+ $render = $linking != 'linkonly';
+ $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
- $link['url'] = ml($src, array('cache' => $cache));
+ $link['url'] = ml($src, ['cache' => $cache]);
- list($ext, $mime) = mimetype($src, false);
- if(substr($mime, 0, 5) == 'image' && $render) {
+ [$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 {
// add file icons
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
- $link['class'] .= ' mediafile mf_'.$class;
+ $link['class'] .= ' mediafile mf_' . $class;
}
- if($hash) $link['url'] .= '#'.$hash;
+ if ($hash) $link['url'] .= '#' . $hash;
//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'];
- else $this->doc .= $this->_formatLink($link);
- }
+ } elseif ($linking == 'nolink' || $noLink) {
+ $this->doc .= $link['name'];
+ } else $this->doc .= $this->_formatLink($link);
}
/**
* Renders an RSS feed
*
- * @param string $url URL of the feed
- * @param array $params Finetuning of the output
+ * @param string $url URL of the feed
+ * @param array $params Finetuning of the output
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- public function rss($url, $params) {
+ public function rss($url, $params)
+ {
global $lang;
global $conf;
- require_once(DOKU_INC.'inc/FeedParser.php');
+ require_once(DOKU_INC . 'inc/FeedParser.php');
$feed = new FeedParser();
$feed->set_feed_url($url);
//disable warning while fetching
- if(!defined('DOKU_E_LEVEL')) {
+ if (!defined('DOKU_E_LEVEL')) {
$elvl = error_reporting(E_ERROR);
}
$rc = $feed->init();
- if(isset($elvl)) {
+ if (isset($elvl)) {
error_reporting($elvl);
}
- if($params['nosort']) $feed->enable_order_by_date(false);
+ if ($params['nosort']) $feed->enable_order_by_date(false);
//decide on start and end
- if($params['reverse']) {
- $mod = -1;
+ if ($params['reverse']) {
+ $mod = -1;
$start = $feed->get_item_quantity() - 1;
- $end = $start - ($params['max']);
- $end = ($end < -1) ? -1 : $end;
+ $end = $start - ($params['max']);
+ $end = ($end < -1) ? -1 : $end;
} else {
- $mod = 1;
+ $mod = 1;
$start = 0;
- $end = $feed->get_item_quantity();
- $end = ($end > $params['max']) ? $params['max'] : $end;
+ $end = $feed->get_item_quantity();
+ $end = ($end > $params['max']) ? $params['max'] : $end;
}
$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">';
@@ -1285,23 +1371,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$title = html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8');
// support feeds without links
- if($lnkurl) {
+ if ($lnkurl) {
$this->externallink($item->get_permalink(), $title);
} else {
- $this->doc .= ' '.hsc($item->get_title());
+ $this->doc .= ' ' . hsc($item->get_title());
}
- if($params['author']) {
+ if ($params['author']) {
$author = $item->get_author(0);
- if($author) {
+ if ($author instanceof Author) {
$name = $author->get_name();
- if(!$name) $name = $author->get_email();
- if($name) $this->doc .= ' '.$lang['by'].' '.hsc($name);
+ if (!$name) $name = $author->get_email();
+ if ($name) $this->doc .= ' ' . $lang['by'] . ' ' . hsc($name);
}
}
- if($params['date']) {
- $this->doc .= ' ('.$item->get_local_date($conf['dformat']).')';
+ if ($params['date']) {
+ $this->doc .= ' (' . $item->get_local_date($conf['dformat']) . ')';
}
- if($params['details']) {
+ if ($params['details']) {
$desc = $item->get_description();
$desc = strip_tags($desc);
$desc = html_entity_decode($desc, ENT_QUOTES, 'UTF-8');
@@ -1314,10 +1400,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
} else {
$this->doc .= '<li><div class="li">';
- $this->doc .= '<em>'.$lang['rssfailed'].'</em>';
+ $this->doc .= '<em>' . $lang['rssfailed'] . '</em>';
$this->externallink($url);
- if($conf['allowdebug']) {
- $this->doc .= '<!--'.hsc($feed->error).'-->';
+ if ($conf['allowdebug']) {
+ $this->doc .= '<!--' . hsc($feed->error) . '-->';
}
$this->doc .= '</div></li>';
}
@@ -1332,23 +1418,24 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @param int $pos byte position in the original source
* @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
*/
- public function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) {
+ public function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null)
+ {
// initialize the row counter used for classes
$this->_counter['row_counter'] = 0;
- $class = 'table';
- if($classes !== null) {
- if(is_array($classes)) $classes = join(' ', $classes);
+ $class = 'table';
+ if ($classes !== null) {
+ if (is_array($classes)) $classes = implode(' ', $classes);
$class .= ' ' . $classes;
}
- if($pos !== null) {
+ if ($pos !== null) {
$hid = $this->_headerToLink($class, true);
- $data = array();
+ $data = [];
$data['target'] = 'table';
$data['name'] = '';
$data['hid'] = $hid;
- $class .= ' '.$this->startSectionEdit($pos, $data);
+ $class .= ' ' . $this->startSectionEdit($pos, $data);
}
- $this->doc .= '<div class="'.$class.'"><table class="inline">'.
+ $this->doc .= '<div class="' . $class . '"><table class="inline">' .
DOKU_LF;
}
@@ -1357,9 +1444,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param int $pos byte position in the original source
*/
- public function table_close($pos = null) {
- $this->doc .= '</table></div>'.DOKU_LF;
- if($pos !== null) {
+ public function table_close($pos = null)
+ {
+ $this->doc .= '</table></div>' . DOKU_LF;
+ if ($pos !== null) {
$this->finishSectionEdit($pos);
}
}
@@ -1367,43 +1455,49 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Open a table header
*/
- public function tablethead_open() {
- $this->doc .= DOKU_TAB.'<thead>'.DOKU_LF;
+ public function tablethead_open()
+ {
+ $this->doc .= DOKU_TAB . '<thead>' . DOKU_LF;
}
/**
* Close a table header
*/
- public function tablethead_close() {
- $this->doc .= DOKU_TAB.'</thead>'.DOKU_LF;
+ public function tablethead_close()
+ {
+ $this->doc .= DOKU_TAB . '</thead>' . DOKU_LF;
}
/**
* Open a table body
*/
- public function tabletbody_open() {
- $this->doc .= DOKU_TAB.'<tbody>'.DOKU_LF;
+ public function tabletbody_open()
+ {
+ $this->doc .= DOKU_TAB . '<tbody>' . DOKU_LF;
}
/**
* Close a table body
*/
- public function tabletbody_close() {
- $this->doc .= DOKU_TAB.'</tbody>'.DOKU_LF;
+ public function tabletbody_close()
+ {
+ $this->doc .= DOKU_TAB . '</tbody>' . DOKU_LF;
}
/**
* Open a table footer
*/
- public function tabletfoot_open() {
- $this->doc .= DOKU_TAB.'<tfoot>'.DOKU_LF;
+ public function tabletfoot_open()
+ {
+ $this->doc .= DOKU_TAB . '<tfoot>' . DOKU_LF;
}
/**
* Close a table footer
*/
- public function tabletfoot_close() {
- $this->doc .= DOKU_TAB.'</tfoot>'.DOKU_LF;
+ public function tabletfoot_close()
+ {
+ $this->doc .= DOKU_TAB . '</tfoot>' . DOKU_LF;
}
/**
@@ -1411,49 +1505,52 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
*/
- public function tablerow_open($classes = null) {
+ public function tablerow_open($classes = null)
+ {
// initialize the cell counter used for classes
$this->_counter['cell_counter'] = 0;
- $class = 'row'.$this->_counter['row_counter']++;
- if($classes !== null) {
- if(is_array($classes)) $classes = join(' ', $classes);
+ $class = 'row' . $this->_counter['row_counter']++;
+ if ($classes !== null) {
+ if (is_array($classes)) $classes = implode(' ', $classes);
$class .= ' ' . $classes;
}
- $this->doc .= DOKU_TAB.'<tr class="'.$class.'">'.DOKU_LF.DOKU_TAB.DOKU_TAB;
+ $this->doc .= DOKU_TAB . '<tr class="' . $class . '">' . DOKU_LF . DOKU_TAB . DOKU_TAB;
}
/**
* Close a table row
*/
- public function tablerow_close() {
- $this->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF;
+ public function tablerow_close()
+ {
+ $this->doc .= DOKU_LF . DOKU_TAB . '</tr>' . DOKU_LF;
}
/**
* Open a table header cell
*
- * @param int $colspan
+ * @param int $colspan
* @param string $align left|center|right
- * @param int $rowspan
+ * @param int $rowspan
* @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
*/
- public function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) {
- $class = 'class="col'.$this->_counter['cell_counter']++;
- if(!is_null($align)) {
- $class .= ' '.$align.'align';
+ public function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null)
+ {
+ $class = 'class="col' . $this->_counter['cell_counter']++;
+ if (!is_null($align)) {
+ $class .= ' ' . $align . 'align';
}
- if($classes !== null) {
- if(is_array($classes)) $classes = join(' ', $classes);
+ if ($classes !== null) {
+ if (is_array($classes)) $classes = implode(' ', $classes);
$class .= ' ' . $classes;
}
$class .= '"';
- $this->doc .= '<th '.$class;
- if($colspan > 1) {
+ $this->doc .= '<th ' . $class;
+ if ($colspan > 1) {
$this->_counter['cell_counter'] += $colspan - 1;
- $this->doc .= ' colspan="'.$colspan.'"';
+ $this->doc .= ' colspan="' . $colspan . '"';
}
- if($rowspan > 1) {
- $this->doc .= ' rowspan="'.$rowspan.'"';
+ if ($rowspan > 1) {
+ $this->doc .= ' rowspan="' . $rowspan . '"';
}
$this->doc .= '>';
}
@@ -1461,35 +1558,37 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Close a table header cell
*/
- public function tableheader_close() {
+ public function tableheader_close()
+ {
$this->doc .= '</th>';
}
/**
* Open a table cell
*
- * @param int $colspan
- * @param string $align left|center|right
- * @param int $rowspan
- * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
+ * @param int $colspan
+ * @param string $align left|center|right
+ * @param int $rowspan
+ * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input
*/
- public function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) {
- $class = 'class="col'.$this->_counter['cell_counter']++;
- if(!is_null($align)) {
- $class .= ' '.$align.'align';
+ public function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null)
+ {
+ $class = 'class="col' . $this->_counter['cell_counter']++;
+ if (!is_null($align)) {
+ $class .= ' ' . $align . 'align';
}
- if($classes !== null) {
- if(is_array($classes)) $classes = join(' ', $classes);
+ if ($classes !== null) {
+ if (is_array($classes)) $classes = implode(' ', $classes);
$class .= ' ' . $classes;
}
$class .= '"';
- $this->doc .= '<td '.$class;
- if($colspan > 1) {
+ $this->doc .= '<td ' . $class;
+ if ($colspan > 1) {
$this->_counter['cell_counter'] += $colspan - 1;
- $this->doc .= ' colspan="'.$colspan.'"';
+ $this->doc .= ' colspan="' . $colspan . '"';
}
- if($rowspan > 1) {
- $this->doc .= ' rowspan="'.$rowspan.'"';
+ if ($rowspan > 1) {
+ $this->doc .= ' rowspan="' . $rowspan . '"';
}
$this->doc .= '>';
}
@@ -1497,7 +1596,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Close a table cell
*/
- public function tablecell_close() {
+ public function tablecell_close()
+ {
$this->doc .= '</td>';
}
@@ -1507,7 +1607,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @return int The current header level
*/
- public function getLastlevel() {
+ public function getLastlevel()
+ {
return $this->lastlevel;
}
@@ -1523,9 +1624,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- public function _formatLink($link) {
+ public function _formatLink($link)
+ {
//make sure the url is XHTML compliant (skip mailto)
- if(substr($link['url'], 0, 7) != 'mailto:') {
+ if (substr($link['url'], 0, 7) != 'mailto:') {
$link['url'] = str_replace('&', '&amp;', $link['url']);
$link['url'] = str_replace('&amp;amp;', '&amp;', $link['url']);
}
@@ -1534,18 +1636,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// 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'], ['>' => '%3E', '<' => '%3C', '"' => '%22']);
+ $link['title'] = strtr($link['title'], ['>' => '&gt;', '<' => '&lt;', '"' => '&quot;']);
$ret = '';
$ret .= $link['pre'];
- $ret .= '<a href="'.$link['url'].'"';
- 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="'.trim($link['rel']).'"';
- if(!empty($link['more'])) $ret .= ' '.$link['more'];
+ $ret .= '<a href="' . $link['url'] . '"';
+ 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="' . trim($link['rel']) . '"';
+ if (!empty($link['more'])) $ret .= ' ' . $link['more'];
$ret .= '>';
$ret .= $link['name'];
$ret .= '</a>';
@@ -1556,123 +1658,133 @@ 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
+ * @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
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
- public function _media($src, $title = null, $align = null, $width = null,
- $height = null, $cache = null, $render = true) {
+ public function _media(
+ $src,
+ $title = null,
+ $align = null,
+ $width = null,
+ $height = null,
+ $cache = null,
+ $render = true
+ ) {
$ret = '';
- list($ext, $mime) = mimetype($src);
- if(substr($mime, 0, 5) == 'image') {
+ [$ext, $mime] = mimetype($src);
+ if (substr($mime, 0, 5) == 'image') {
// first get the $title
- if(!is_null($title)) {
+ if (!is_null($title)) {
$title = $this->_xmlEntities($title);
- } elseif($ext == 'jpg' || $ext == 'jpeg') {
+ } elseif ($ext == 'jpg' || $ext == 'jpeg') {
//try to use the caption from IPTC/EXIF
- require_once(DOKU_INC.'inc/JpegMeta.php');
+ require_once(DOKU_INC . 'inc/JpegMeta.php');
$jpeg = new JpegMeta(mediaFN($src));
- if($jpeg !== false) $cap = $jpeg->getTitle();
- if(!empty($cap)) {
+ $cap = $jpeg->getTitle();
+ 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 === null || $title === "") {
+ if ($title === null || $title === "") {
// just show the sourcename
- $title = $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($src)));
+ $title = $this->_xmlEntities(PhpString::basename(noNS($src)));
}
return $title;
}
//add image tag
$ret .= '<img src="' . ml(
- $src,
- array(
- 'w' => $width, 'h' => $height,
+ $src,
+ [
+ 'w' => $width,
+ 'h' => $height,
'cache' => $cache,
'rev' => $this->_getLastMediaRevisionAt($src)
- )
- ) . '"';
- $ret .= ' class="media'.$align.'"';
+ ]
+ ) . '"';
+ $ret .= ' class="media' . $align . '"';
$ret .= ' loading="lazy"';
- if($title) {
- $ret .= ' title="'.$title.'"';
- $ret .= ' alt="'.$title.'"';
+ if ($title) {
+ $ret .= ' title="' . $title . '"';
+ $ret .= ' alt="' . $title . '"';
} else {
$ret .= ' alt=""';
}
- if(!is_null($width))
- $ret .= ' width="'.$this->_xmlEntities($width).'"';
+ if (!is_null($width)) {
+ $ret .= ' width="' . $this->_xmlEntities($width) . '"';
+ }
- if(!is_null($height))
- $ret .= ' height="'.$this->_xmlEntities($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) ? $title : false;
- if(!$render) {
+ $title ??= false;
+ 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 $this->_xmlEntities($title ? $title : \dokuwiki\Utf8\PhpString::basename(noNS($src)));
+ return $this->_xmlEntities($title ?: PhpString::basename(noNS($src)));
}
- $att = array();
+ $att = [];
$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 = \dokuwiki\Utf8\PhpString::basename(noNS($src));
+ $title = PhpString::basename(noNS($src));
}
return $this->_xmlEntities($title);
}
- $att = array();
+ $att = [];
$att['class'] = "media$align";
- if($align == 'right') $att['align'] = 'right';
- if($align == 'left') $att['align'] = 'left';
+ 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'),
+ ml($src, ['cache' => $cache], true, '&'),
+ $width,
+ $height,
+ ['quality' => 'high'],
null,
$att,
$this->_xmlEntities($title)
);
- } elseif($title) {
+ } elseif ($title) {
// well at least we have a title to display
$ret .= $this->_xmlEntities($title);
} else {
// just show the sourcename
- $ret .= $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($src)));
+ $ret .= $this->_xmlEntities(PhpString::basename(noNS($src)));
}
return $ret;
@@ -1684,32 +1796,33 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @param $string
* @return string
*/
- public function _xmlEntities($string) {
+ public function _xmlEntities($string)
+ {
return hsc($string);
}
-
/**
* 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
+ * @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
+ * @author Harry Fuecks <hfuecks@gmail.com>
*/
- public function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') {
+ public 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(!blank($heading)) {
+ if (!blank($heading)) {
return $this->_xmlEntities($heading);
}
}
@@ -1722,17 +1835,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Returns HTML code for images used in link titles
*
- * @author Andreas Gohr <andi@splitbrain.org>
* @param array $img
* @return string HTML img tag or similar
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
- public function _imageTitle($img) {
+ public function _imageTitle($img)
+ {
global $ID;
// some fixes on $img['src']
// see internalmedia() and externalmedia()
- list($img['src']) = explode('#', $img['src'], 2);
- if($img['type'] == 'internalmedia') {
+ [$img['src']] = explode('#', $img['src'], 2);
+ if ($img['type'] == 'internalmedia') {
$img['src'] = (new MediaResolver($ID))->resolveId($img['src'], $this->date_at, true);
}
@@ -1751,29 +1865,30 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* used in internalmedia() and externalmedia()
*
- * @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
+ * @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
+ * @author Pierre Spring <pierre.spring@liip.ch>
*/
- public function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) {
+ public function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render)
+ {
global $conf;
- $link = array();
- $link['class'] = 'media';
- $link['style'] = '';
- $link['pre'] = '';
- $link['suf'] = '';
- $link['more'] = '';
+ $link = [];
+ $link['class'] = 'media';
+ $link['style'] = '';
+ $link['pre'] = '';
+ $link['suf'] = '';
+ $link['more'] = '';
$link['target'] = $conf['target']['media'];
- if($conf['target']['media']) $link['rel'] = 'noopener';
- $link['title'] = $this->_xmlEntities($src);
- $link['name'] = $this->_media($src, $title, $align, $width, $height, $cache, $render);
+ if ($conf['target']['media']) $link['rel'] = 'noopener';
+ $link['title'] = $this->_xmlEntities($src);
+ $link['name'] = $this->_media($src, $title, $align, $width, $height, $cache, $render);
return $link;
}
@@ -1781,52 +1896,53 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* 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
+ * @return string
* @author Schplurtz le Déboulonné <Schplurtz@laposte.net>
*
- * @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
+ * @author Anika Henke <anika@selfthinker.org>
*/
- public function _video($src, $width, $height, $atts = null) {
+ public 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['height']) $atts['height'] = 240;
+ if (is_null($atts)) $atts = [];
+ $atts['width'] = (int)$width;
+ $atts['height'] = (int)$height;
+ if (!$atts['width']) $atts['width'] = 320;
+ if (!$atts['height']) $atts['height'] = 240;
$posterUrl = '';
- $files = array();
- $tracks = array();
+ $files = [];
+ $tracks = [];
$isExternal = media_isexternal($src);
if ($isExternal) {
// take direct source for external files
- list(/*ext*/, $srcMime) = mimetype($src);
+ [/* ext */, $srcMime] = mimetype($src);
$files[$srcMime] = $src;
} else {
// prepare alternative formats
- $extensions = array('webm', 'ogv', 'mp4');
- $files = media_alternativefiles($src, $extensions);
- $poster = media_alternativefiles($src, array('jpg', 'png'));
- $tracks = media_trackfiles($src);
- if(!empty($poster)) {
+ $extensions = ['webm', 'ogv', 'mp4'];
+ $files = media_alternativefiles($src, $extensions);
+ $poster = media_alternativefiles($src, ['jpg', 'png']);
+ $tracks = media_trackfiles($src);
+ if (!empty($poster)) {
$posterUrl = ml(reset($poster), '', true, '&');
}
}
$out = '';
// open video tag
- $out .= '<video '.buildAttributes($atts).' controls="controls"';
- if($posterUrl) $out .= ' poster="'.hsc($posterUrl).'"';
- $out .= '>'.NL;
+ $out .= '<video ' . buildAttributes($atts) . ' controls="controls"';
+ if ($posterUrl) $out .= ' poster="' . hsc($posterUrl) . '"';
+ $out .= '>' . NL;
$fallback = '';
// output source for each alternative video format
- foreach($files as $mime => $file) {
+ foreach ($files as $mime => $file) {
if ($isExternal) {
$url = $file;
$linkType = 'externalmedia';
@@ -1834,11 +1950,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$url = ml($file, '', true, '&');
$linkType = 'internalmedia';
}
- $title = !empty($atts['title'])
- ? $atts['title']
- : $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($file)));
+ $title = empty($atts['title'])
+ ? $this->_xmlEntities(PhpString::basename(noNS($file)))
+ : $atts['title'];
- $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
+ $out .= '<source src="' . hsc($url) . '" type="' . $mime . '" />' . NL;
// alternative content (just a link to the file)
$fallback .= $this->$linkType(
$file,
@@ -1853,49 +1969,50 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
// output each track if any
- foreach( $tracks as $trackid => $info ) {
- list( $kind, $srclang ) = array_map( 'hsc', $info );
+ foreach ($tracks as $trackid => $info) {
+ [$kind, $srclang] = array_map('hsc', $info);
$out .= "<track kind=\"$kind\" srclang=\"$srclang\" ";
$out .= "label=\"$srclang\" ";
- $out .= 'src="'.ml($trackid, '', true).'">'.NL;
+ $out .= 'src="' . ml($trackid, '', true) . '">' . NL;
}
// finish
$out .= $fallback;
- $out .= '</video>'.NL;
+ $out .= '</video>' . NL;
return $out;
}
/**
* Embed audio in HTML
*
+ * @param string $src - ID of audio to embed
+ * @param array $atts - additional attributes for the <audio> tag
+ * @return string
* @author Anika Henke <anika@selfthinker.org>
*
- * @param string $src - ID of audio to embed
- * @param array $atts - additional attributes for the <audio> tag
- * @return string
*/
- public function _audio($src, $atts = array()) {
- $files = array();
+ public function _audio($src, $atts = [])
+ {
+ $files = [];
$isExternal = media_isexternal($src);
if ($isExternal) {
// take direct source for external files
- list(/*ext*/, $srcMime) = mimetype($src);
+ [/* ext */, $srcMime] = mimetype($src);
$files[$srcMime] = $src;
} else {
// prepare alternative formats
- $extensions = array('ogg', 'mp3', 'wav');
- $files = media_alternativefiles($src, $extensions);
+ $extensions = ['ogg', 'mp3', 'wav'];
+ $files = media_alternativefiles($src, $extensions);
}
$out = '';
// open audio tag
- $out .= '<audio '.buildAttributes($atts).' controls="controls">'.NL;
+ $out .= '<audio ' . buildAttributes($atts) . ' controls="controls">' . NL;
$fallback = '';
// output source for each alternative audio format
- foreach($files as $mime => $file) {
+ foreach ($files as $mime => $file) {
if ($isExternal) {
$url = $file;
$linkType = 'externalmedia';
@@ -1903,9 +2020,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$url = ml($file, '', true, '&');
$linkType = 'internalmedia';
}
- $title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($file)));
+ $title = $atts['title'] ?: $this->_xmlEntities(PhpString::basename(noNS($file)));
- $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
+ $out .= '<source src="' . hsc($url) . '" type="' . $mime . '" />' . NL;
// alternative content (just a link to the file)
$fallback .= $this->$linkType(
$file,
@@ -1921,7 +2038,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// finish
$out .= $fallback;
- $out .= '</audio>'.NL;
+ $out .= '</audio>' . NL;
return $out;
}
@@ -1929,12 +2046,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media()
* which returns an existing media revision less or equal to rev or date_at
*
- * @author lisps
* @param string $media_id
* @access protected
* @return string revision ('' for current)
+ * @author lisps
*/
- protected function _getLastMediaRevisionAt($media_id) {
+ protected function _getLastMediaRevisionAt($media_id)
+ {
if (!$this->date_at || media_isexternal($media_id)) return '';
$changelog = new MediaChangeLog($media_id);
return $changelog->getLastRevisionAt($this->date_at);
diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php
index 4641bf836..1b73d1368 100644
--- a/inc/parser/xhtmlsummary.php
+++ b/inc/parser/xhtmlsummary.php
@@ -1,4 +1,5 @@
<?php
+
/**
* The summary XHTML form selects either up to the first two paragraphs
* it find in a page or the first section (whichever comes first)
@@ -14,8 +15,8 @@
* @author Harry Fuecks <hfuecks@gmail.com>
* @todo Is this currently used anywhere? Should it?
*/
-class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
-
+class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml
+{
// Namespace these variables to
// avoid clashes with parent classes
protected $sum_paragraphs = 0;
@@ -25,59 +26,70 @@ class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
protected $sum_pageTitle = false;
/** @inheritdoc */
- public function document_start() {
- $this->doc .= DOKU_LF.'<div>'.DOKU_LF;
+ public function document_start()
+ {
+ $this->doc .= DOKU_LF . '<div>' . DOKU_LF;
}
/** @inheritdoc */
- public function document_end() {
+ public function document_end()
+ {
$this->doc = $this->sum_summary;
- $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
+ $this->doc .= DOKU_LF . '</div>' . DOKU_LF;
}
- /** @inheritdoc */
- public function header($text, $level, $pos) {
- if ( !$this->sum_pageTitle ) {
+ /** @inheritdoc
+ * @param string $text
+ * @param int $level
+ * @param int $pos
+ * @param false $returnonly
+ */
+ public function header($text, $level, $pos, $returnonly = false)
+ {
+ if (!$this->sum_pageTitle) {
$this->info['sum_pagetitle'] = $text;
$this->sum_pageTitle = true;
}
- $this->doc .= DOKU_LF.'<h'.$level.'>';
+ $this->doc .= DOKU_LF . '<h' . $level . '>';
$this->doc .= $this->_xmlEntities($text);
- $this->doc .= "</h$level>".DOKU_LF;
+ $this->doc .= "</h$level>" . DOKU_LF;
}
/** @inheritdoc */
- public function section_open($level) {
- if ( $this->sum_capture ) {
+ public function section_open($level)
+ {
+ if ($this->sum_capture) {
$this->sum_inSection = true;
}
}
/** @inheritdoc */
- public function section_close() {
- if ( $this->sum_capture && $this->sum_inSection ) {
+ public function section_close()
+ {
+ if ($this->sum_capture && $this->sum_inSection) {
$this->sum_summary .= $this->doc;
$this->sum_capture = false;
}
}
/** @inheritdoc */
- public function p_open() {
- if ( $this->sum_capture && $this->sum_paragraphs < 2 ) {
+ public function p_open()
+ {
+ if ($this->sum_capture && $this->sum_paragraphs < 2) {
$this->sum_paragraphs++;
}
- parent :: p_open();
+ parent::p_open();
}
/** @inheritdoc */
- public function p_close() {
- parent :: p_close();
- if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) {
+ public function p_close()
+ {
+ parent::p_close();
+ if ($this->sum_capture && $this->sum_paragraphs >= 2) {
$this->sum_summary .= $this->doc;
$this->sum_capture = false;
}
}
-
}