aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/parser/renderer.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser/renderer.php')
-rw-r--r--inc/parser/renderer.php491
1 files changed, 304 insertions, 187 deletions
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;
}