xref: /dokuwiki/inc/parser/renderer.php (revision c55b109ca57d471075e2a5b094ebd41815953d8e)
10cecf9d5Sandi<?php
261faf446Schris/**
35587e44cSchris * Renderer output base class
461faf446Schris *
561faf446Schris * @author Harry Fuecks <hfuecks@gmail.com>
661faf446Schris * @author Andreas Gohr <andi@splitbrain.org>
761faf446Schris */
8fa8adffeSAndreas Gohrif(!defined('DOKU_INC')) die('meh.');
961faf446Schris
10863befa1SAndreas Gohr/**
1156bd9509SPhy * Allowed chars in $language for code highlighting
1256bd9509SPhy * @see GeSHi::set_language()
1356bd9509SPhy */
1456bd9509SPhydefine('PREG_PATTERN_VALID_LANGUAGE', '#[^a-zA-Z0-9\-_]#');
1556bd9509SPhy
1656bd9509SPhy/**
17863befa1SAndreas Gohr * An empty renderer, produces no output
18863befa1SAndreas Gohr *
19863befa1SAndreas Gohr * Inherits from DokuWiki_Plugin for giving additional functions to render plugins
208e3a5477SAndreas Gohr *
218e3a5477SAndreas Gohr * The renderer transforms the syntax instructions created by the parser and handler into the
228e3a5477SAndreas Gohr * desired output format. For each instruction a corresponding method defined in this class will
238e3a5477SAndreas Gohr * be called. That method needs to produce the desired output for the instruction and add it to the
248e3a5477SAndreas Gohr * $doc field. When all instructions are processed, the $doc field contents will be cached by
258e3a5477SAndreas Gohr * DokuWiki and sent to the user.
26863befa1SAndreas Gohr */
27863befa1SAndreas Gohrclass Doku_Renderer extends DokuWiki_Plugin {
28cfa2b40eSAndreas Gohr    /** @var array Settings, control the behavior of the renderer */
29cfa2b40eSAndreas Gohr    public $info = array(
3044881bd0Shenning.noren        'cache' => true, // may the rendered result cached?
3144881bd0Shenning.noren        'toc'   => true, // render the TOC?
329dc2c2afSandi    );
339dc2c2afSandi
34cfa2b40eSAndreas Gohr    /** @var array contains the smiley configuration, set in p_render() */
35cfa2b40eSAndreas Gohr    public $smileys = array();
36cfa2b40eSAndreas Gohr    /** @var array contains the entity configuration, set in p_render() */
37cfa2b40eSAndreas Gohr    public $entities = array();
38cfa2b40eSAndreas Gohr    /** @var array contains the acronym configuration, set in p_render() */
39cfa2b40eSAndreas Gohr    public $acronyms = array();
40cfa2b40eSAndreas Gohr    /** @var array contains the interwiki configuration, set in p_render() */
41cfa2b40eSAndreas Gohr    public $interwiki = array();
42e41c4da9SAndreas Gohr
435f70445dSAndreas Gohr    /**
44cfa2b40eSAndreas Gohr     * @var string the rendered document, this will be cached after the renderer ran through
455f70445dSAndreas Gohr     */
46cfa2b40eSAndreas Gohr    public $doc = '';
47cfa2b40eSAndreas Gohr
48cfa2b40eSAndreas Gohr    /**
49cfa2b40eSAndreas Gohr     * clean out any per-use values
50cfa2b40eSAndreas Gohr     *
51cfa2b40eSAndreas Gohr     * This is called before each use of the renderer object and should be used to
52cfa2b40eSAndreas Gohr     * completely reset the state of the renderer to be reused for a new document
53cfa2b40eSAndreas Gohr     */
54cfa2b40eSAndreas Gohr    function reset() {
555f70445dSAndreas Gohr    }
565f70445dSAndreas Gohr
57f6ec8df8SAdrian Lang    /**
58f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
59f6ec8df8SAdrian Lang     *
60cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
61cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
62cfa2b40eSAndreas Gohr     *
63f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
64f6ec8df8SAdrian Lang     */
65f6ec8df8SAdrian Lang    function isSingleton() {
66f6ec8df8SAdrian Lang        return false;
67f6ec8df8SAdrian Lang    }
68f6ec8df8SAdrian Lang
698cc41db0SAndreas Gohr    /**
70cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
71cfa2b40eSAndreas Gohr     *
72cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
73cfa2b40eSAndreas Gohr     *
74cfa2b40eSAndreas Gohr     * @return string
75cfa2b40eSAndreas Gohr     */
76cfa2b40eSAndreas Gohr    function getFormat() {
77cfa2b40eSAndreas Gohr        trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
78cfa2b40eSAndreas Gohr        return '';
79cfa2b40eSAndreas Gohr    }
80cfa2b40eSAndreas Gohr
81cfa2b40eSAndreas Gohr    /**
82cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
83cfa2b40eSAndreas Gohr     */
84cfa2b40eSAndreas Gohr    function nocache() {
85cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
86cfa2b40eSAndreas Gohr    }
87cfa2b40eSAndreas Gohr
88cfa2b40eSAndreas Gohr    /**
89cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
90cfa2b40eSAndreas Gohr     *
91cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
92cfa2b40eSAndreas Gohr     */
93cfa2b40eSAndreas Gohr    function notoc() {
94cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
95cfa2b40eSAndreas Gohr    }
96cfa2b40eSAndreas Gohr
97cfa2b40eSAndreas Gohr    /**
98cfa2b40eSAndreas Gohr     * Handle plugin rendering
99cfa2b40eSAndreas Gohr     *
100cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
1018cc41db0SAndreas Gohr     *
1028cc41db0SAndreas Gohr     * @param string $name  Plugin name
1038cc41db0SAndreas Gohr     * @param mixed  $data  custom data set by handler
1048cc41db0SAndreas Gohr     * @param string $state matched state if any
1058cc41db0SAndreas Gohr     * @param string $match raw matched syntax
1068cc41db0SAndreas Gohr     */
1078cc41db0SAndreas Gohr    function plugin($name, $data, $state = '', $match = '') {
108cfa2b40eSAndreas Gohr        /** @var DokuWiki_Syntax_Plugin $plugin */
109e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
11061faf446Schris        if($plugin != null) {
1115f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
11261faf446Schris        }
11361faf446Schris    }
11461faf446Schris
1155587e44cSchris    /**
1165587e44cSchris     * handle nested render instructions
1175587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
118cfa2b40eSAndreas Gohr     *
119cfa2b40eSAndreas Gohr     * @param array $instructions
1205587e44cSchris     */
1215587e44cSchris    function nest($instructions) {
1225587e44cSchris        foreach($instructions as $instruction) {
1235587e44cSchris            // execute the callback against ourself
124c2122b83SChristopher Smith            if(method_exists($this, $instruction[0])) {
125d6a1a955SAndreas Gohr                call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
126c2122b83SChristopher Smith            }
1275587e44cSchris        }
1285587e44cSchris    }
1295587e44cSchris
130cfa2b40eSAndreas Gohr    /**
131cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
132cfa2b40eSAndreas Gohr     *
133cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
134cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
135cfa2b40eSAndreas Gohr     */
1362c2835c2SAndreas Gohr    function nest_close() {
1372c2835c2SAndreas Gohr    }
1385587e44cSchris
139cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
140cfa2b40eSAndreas Gohr
141cfa2b40eSAndreas Gohr    /**
142cfa2b40eSAndreas Gohr     * Initialize the document
143cfa2b40eSAndreas Gohr     */
1442c2835c2SAndreas Gohr    function document_start() {
1452c2835c2SAndreas Gohr    }
1460cecf9d5Sandi
147cfa2b40eSAndreas Gohr    /**
148cfa2b40eSAndreas Gohr     * Finalize the document
149cfa2b40eSAndreas Gohr     */
1502c2835c2SAndreas Gohr    function document_end() {
1512c2835c2SAndreas Gohr    }
1520cecf9d5Sandi
153cfa2b40eSAndreas Gohr    /**
154cfa2b40eSAndreas Gohr     * Render the Table of Contents
155cfa2b40eSAndreas Gohr     *
156cfa2b40eSAndreas Gohr     * @return string
157cfa2b40eSAndreas Gohr     */
1582c2835c2SAndreas Gohr    function render_TOC() {
1592c2835c2SAndreas Gohr        return '';
1602c2835c2SAndreas Gohr    }
1610cecf9d5Sandi
162cfa2b40eSAndreas Gohr    /**
163cfa2b40eSAndreas Gohr     * Add an item to the TOC
164cfa2b40eSAndreas Gohr     *
165cfa2b40eSAndreas Gohr     * @param string $id       the hash link
166cfa2b40eSAndreas Gohr     * @param string $text     the text to display
167cfa2b40eSAndreas Gohr     * @param int    $level    the nesting level
168cfa2b40eSAndreas Gohr     */
1692c2835c2SAndreas Gohr    function toc_additem($id, $text, $level) {
1702c2835c2SAndreas Gohr    }
171e7856beaSchris
172cfa2b40eSAndreas Gohr    /**
173cfa2b40eSAndreas Gohr     * Render a heading
174cfa2b40eSAndreas Gohr     *
175cfa2b40eSAndreas Gohr     * @param string $text  the text to display
176cfa2b40eSAndreas Gohr     * @param int    $level header level
177cfa2b40eSAndreas Gohr     * @param int    $pos   byte position in the original source
178cfa2b40eSAndreas Gohr     */
1792c2835c2SAndreas Gohr    function header($text, $level, $pos) {
1802c2835c2SAndreas Gohr    }
1810cecf9d5Sandi
182cfa2b40eSAndreas Gohr    /**
183cfa2b40eSAndreas Gohr     * Open a new section
184cfa2b40eSAndreas Gohr     *
185cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
186cfa2b40eSAndreas Gohr     */
1872c2835c2SAndreas Gohr    function section_open($level) {
1882c2835c2SAndreas Gohr    }
1890cecf9d5Sandi
190cfa2b40eSAndreas Gohr    /**
191cfa2b40eSAndreas Gohr     * Close the current section
192cfa2b40eSAndreas Gohr     */
1932c2835c2SAndreas Gohr    function section_close() {
1942c2835c2SAndreas Gohr    }
1950cecf9d5Sandi
196cfa2b40eSAndreas Gohr    /**
197cfa2b40eSAndreas Gohr     * Render plain text data
198cfa2b40eSAndreas Gohr     *
19942ea7f44SGerrit Uitslag     * @param string $text
200cfa2b40eSAndreas Gohr     */
2012c2835c2SAndreas Gohr    function cdata($text) {
2022c2835c2SAndreas Gohr    }
2030cecf9d5Sandi
204cfa2b40eSAndreas Gohr    /**
205cfa2b40eSAndreas Gohr     * Open a paragraph
206cfa2b40eSAndreas Gohr     */
2072c2835c2SAndreas Gohr    function p_open() {
2082c2835c2SAndreas Gohr    }
2090cecf9d5Sandi
210cfa2b40eSAndreas Gohr    /**
211cfa2b40eSAndreas Gohr     * Close a paragraph
212cfa2b40eSAndreas Gohr     */
2132c2835c2SAndreas Gohr    function p_close() {
2142c2835c2SAndreas Gohr    }
2150cecf9d5Sandi
216cfa2b40eSAndreas Gohr    /**
2173dd5c225SAndreas Gohr     * Create a line break
218cfa2b40eSAndreas Gohr     */
2192c2835c2SAndreas Gohr    function linebreak() {
2202c2835c2SAndreas Gohr    }
2210cecf9d5Sandi
222cfa2b40eSAndreas Gohr    /**
223cfa2b40eSAndreas Gohr     * Create a horizontal line
224cfa2b40eSAndreas Gohr     */
2252c2835c2SAndreas Gohr    function hr() {
2262c2835c2SAndreas Gohr    }
2270cecf9d5Sandi
228cfa2b40eSAndreas Gohr    /**
229cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
230cfa2b40eSAndreas Gohr     */
2312c2835c2SAndreas Gohr    function strong_open() {
2322c2835c2SAndreas Gohr    }
2330cecf9d5Sandi
234cfa2b40eSAndreas Gohr    /**
235cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
236cfa2b40eSAndreas Gohr     */
2372c2835c2SAndreas Gohr    function strong_close() {
2382c2835c2SAndreas Gohr    }
2390cecf9d5Sandi
240cfa2b40eSAndreas Gohr    /**
241cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
242cfa2b40eSAndreas Gohr     */
2432c2835c2SAndreas Gohr    function emphasis_open() {
2442c2835c2SAndreas Gohr    }
2450cecf9d5Sandi
246cfa2b40eSAndreas Gohr    /**
247cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
248cfa2b40eSAndreas Gohr     */
2492c2835c2SAndreas Gohr    function emphasis_close() {
2502c2835c2SAndreas Gohr    }
2510cecf9d5Sandi
252cfa2b40eSAndreas Gohr    /**
253cfa2b40eSAndreas Gohr     * Start underline formatting
254cfa2b40eSAndreas Gohr     */
2552c2835c2SAndreas Gohr    function underline_open() {
2562c2835c2SAndreas Gohr    }
2570cecf9d5Sandi
258cfa2b40eSAndreas Gohr    /**
259cfa2b40eSAndreas Gohr     * Stop underline formatting
260cfa2b40eSAndreas Gohr     */
2612c2835c2SAndreas Gohr    function underline_close() {
2622c2835c2SAndreas Gohr    }
2630cecf9d5Sandi
264cfa2b40eSAndreas Gohr    /**
265cfa2b40eSAndreas Gohr     * Start monospace formatting
266cfa2b40eSAndreas Gohr     */
2672c2835c2SAndreas Gohr    function monospace_open() {
2682c2835c2SAndreas Gohr    }
2690cecf9d5Sandi
270cfa2b40eSAndreas Gohr    /**
271cfa2b40eSAndreas Gohr     * Stop monospace formatting
272cfa2b40eSAndreas Gohr     */
2732c2835c2SAndreas Gohr    function monospace_close() {
2742c2835c2SAndreas Gohr    }
2750cecf9d5Sandi
276cfa2b40eSAndreas Gohr    /**
277cfa2b40eSAndreas Gohr     * Start a subscript
278cfa2b40eSAndreas Gohr     */
2792c2835c2SAndreas Gohr    function subscript_open() {
2802c2835c2SAndreas Gohr    }
2810cecf9d5Sandi
282cfa2b40eSAndreas Gohr    /**
283cfa2b40eSAndreas Gohr     * Stop a subscript
284cfa2b40eSAndreas Gohr     */
2852c2835c2SAndreas Gohr    function subscript_close() {
2862c2835c2SAndreas Gohr    }
2870cecf9d5Sandi
288cfa2b40eSAndreas Gohr    /**
289cfa2b40eSAndreas Gohr     * Start a superscript
290cfa2b40eSAndreas Gohr     */
2912c2835c2SAndreas Gohr    function superscript_open() {
2922c2835c2SAndreas Gohr    }
2930cecf9d5Sandi
294cfa2b40eSAndreas Gohr    /**
295cfa2b40eSAndreas Gohr     * Stop a superscript
296cfa2b40eSAndreas Gohr     */
2972c2835c2SAndreas Gohr    function superscript_close() {
2982c2835c2SAndreas Gohr    }
2990cecf9d5Sandi
300cfa2b40eSAndreas Gohr    /**
301cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
302cfa2b40eSAndreas Gohr     */
3032c2835c2SAndreas Gohr    function deleted_open() {
3042c2835c2SAndreas Gohr    }
3050cecf9d5Sandi
306cfa2b40eSAndreas Gohr    /**
307cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
308cfa2b40eSAndreas Gohr     */
3092c2835c2SAndreas Gohr    function deleted_close() {
3102c2835c2SAndreas Gohr    }
3110cecf9d5Sandi
312cfa2b40eSAndreas Gohr    /**
313cfa2b40eSAndreas Gohr     * Start a footnote
314cfa2b40eSAndreas Gohr     */
3152c2835c2SAndreas Gohr    function footnote_open() {
3162c2835c2SAndreas Gohr    }
3170cecf9d5Sandi
318cfa2b40eSAndreas Gohr    /**
319cfa2b40eSAndreas Gohr     * Stop a footnote
320cfa2b40eSAndreas Gohr     */
3212c2835c2SAndreas Gohr    function footnote_close() {
3222c2835c2SAndreas Gohr    }
3230cecf9d5Sandi
324cfa2b40eSAndreas Gohr    /**
325cfa2b40eSAndreas Gohr     * Open an unordered list
326cfa2b40eSAndreas Gohr     */
3272c2835c2SAndreas Gohr    function listu_open() {
3282c2835c2SAndreas Gohr    }
3290cecf9d5Sandi
330cfa2b40eSAndreas Gohr    /**
331cfa2b40eSAndreas Gohr     * Close an unordered list
332cfa2b40eSAndreas Gohr     */
3332c2835c2SAndreas Gohr    function listu_close() {
3342c2835c2SAndreas Gohr    }
3350cecf9d5Sandi
336cfa2b40eSAndreas Gohr    /**
337cfa2b40eSAndreas Gohr     * Open an ordered list
338cfa2b40eSAndreas Gohr     */
3392c2835c2SAndreas Gohr    function listo_open() {
3402c2835c2SAndreas Gohr    }
3410cecf9d5Sandi
342cfa2b40eSAndreas Gohr    /**
343cfa2b40eSAndreas Gohr     * Close an ordered list
344cfa2b40eSAndreas Gohr     */
3452c2835c2SAndreas Gohr    function listo_close() {
3462c2835c2SAndreas Gohr    }
3470cecf9d5Sandi
348cfa2b40eSAndreas Gohr    /**
349cfa2b40eSAndreas Gohr     * Open a list item
350cfa2b40eSAndreas Gohr     *
351cfa2b40eSAndreas Gohr     * @param int $level the nesting level
352e3a24861SChristopher Smith     * @param bool $node true when a node; false when a leaf
353cfa2b40eSAndreas Gohr     */
354e3a24861SChristopher Smith    function listitem_open($level,$node=false) {
3552c2835c2SAndreas Gohr    }
3560cecf9d5Sandi
357cfa2b40eSAndreas Gohr    /**
358cfa2b40eSAndreas Gohr     * Close a list item
359cfa2b40eSAndreas Gohr     */
3602c2835c2SAndreas Gohr    function listitem_close() {
3612c2835c2SAndreas Gohr    }
3620cecf9d5Sandi
363cfa2b40eSAndreas Gohr    /**
364cfa2b40eSAndreas Gohr     * Start the content of a list item
365cfa2b40eSAndreas Gohr     */
3662c2835c2SAndreas Gohr    function listcontent_open() {
3672c2835c2SAndreas Gohr    }
3680cecf9d5Sandi
369cfa2b40eSAndreas Gohr    /**
370cfa2b40eSAndreas Gohr     * Stop the content of a list item
371cfa2b40eSAndreas Gohr     */
3722c2835c2SAndreas Gohr    function listcontent_close() {
3732c2835c2SAndreas Gohr    }
3740cecf9d5Sandi
375cfa2b40eSAndreas Gohr    /**
376cfa2b40eSAndreas Gohr     * Output unformatted $text
377cfa2b40eSAndreas Gohr     *
378cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
379cfa2b40eSAndreas Gohr     *
380cfa2b40eSAndreas Gohr     * @param string $text
381cfa2b40eSAndreas Gohr     */
3822c2835c2SAndreas Gohr    function unformatted($text) {
383cfa2b40eSAndreas Gohr        $this->cdata($text);
3842c2835c2SAndreas Gohr    }
3850cecf9d5Sandi
386cfa2b40eSAndreas Gohr    /**
387cfa2b40eSAndreas Gohr     * Output inline PHP code
388cfa2b40eSAndreas Gohr     *
389cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
390cfa2b40eSAndreas Gohr     * to $doc
391cfa2b40eSAndreas Gohr     *
392cfa2b40eSAndreas Gohr     * @param string $text The PHP code
393cfa2b40eSAndreas Gohr     */
3942c2835c2SAndreas Gohr    function php($text) {
3952c2835c2SAndreas Gohr    }
3960cecf9d5Sandi
397cfa2b40eSAndreas Gohr    /**
398cfa2b40eSAndreas Gohr     * Output block level PHP code
399cfa2b40eSAndreas Gohr     *
400cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
401cfa2b40eSAndreas Gohr     * to $doc
402cfa2b40eSAndreas Gohr     *
403cfa2b40eSAndreas Gohr     * @param string $text The PHP code
404cfa2b40eSAndreas Gohr     */
4052c2835c2SAndreas Gohr    function phpblock($text) {
4062c2835c2SAndreas Gohr    }
40707f89c3cSAnika Henke
408cfa2b40eSAndreas Gohr    /**
409cfa2b40eSAndreas Gohr     * Output raw inline HTML
410cfa2b40eSAndreas Gohr     *
411cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
412cfa2b40eSAndreas Gohr     *
413cfa2b40eSAndreas Gohr     * @param string $text The HTML
414cfa2b40eSAndreas Gohr     */
4152c2835c2SAndreas Gohr    function html($text) {
4162c2835c2SAndreas Gohr    }
4170cecf9d5Sandi
418cfa2b40eSAndreas Gohr    /**
419cfa2b40eSAndreas Gohr     * Output raw block-level HTML
420cfa2b40eSAndreas Gohr     *
421cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
422cfa2b40eSAndreas Gohr     *
423cfa2b40eSAndreas Gohr     * @param string $text The HTML
424cfa2b40eSAndreas Gohr     */
4252c2835c2SAndreas Gohr    function htmlblock($text) {
4262c2835c2SAndreas Gohr    }
42707f89c3cSAnika Henke
428cfa2b40eSAndreas Gohr    /**
429cfa2b40eSAndreas Gohr     * Output preformatted text
430cfa2b40eSAndreas Gohr     *
431cfa2b40eSAndreas Gohr     * @param string $text
432cfa2b40eSAndreas Gohr     */
4332c2835c2SAndreas Gohr    function preformatted($text) {
4342c2835c2SAndreas Gohr    }
4350cecf9d5Sandi
436cfa2b40eSAndreas Gohr    /**
437cfa2b40eSAndreas Gohr     * Start a block quote
438cfa2b40eSAndreas Gohr     */
4392c2835c2SAndreas Gohr    function quote_open() {
4402c2835c2SAndreas Gohr    }
4410cecf9d5Sandi
442cfa2b40eSAndreas Gohr    /**
443cfa2b40eSAndreas Gohr     * Stop a block quote
444cfa2b40eSAndreas Gohr     */
4452c2835c2SAndreas Gohr    function quote_close() {
4462c2835c2SAndreas Gohr    }
4470cecf9d5Sandi
448cfa2b40eSAndreas Gohr    /**
449cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
450cfa2b40eSAndreas Gohr     *
451cfa2b40eSAndreas Gohr     * @param string $text text to show
452cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
453cfa2b40eSAndreas Gohr     * @param string $file file path label
454cfa2b40eSAndreas Gohr     */
4552c2835c2SAndreas Gohr    function file($text, $lang = null, $file = null) {
4562c2835c2SAndreas Gohr    }
4573d491f75SAndreas Gohr
458cfa2b40eSAndreas Gohr    /**
459cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
460cfa2b40eSAndreas Gohr     *
461cfa2b40eSAndreas Gohr     * @param string $text text to show
462cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
463cfa2b40eSAndreas Gohr     * @param string $file file path label
464cfa2b40eSAndreas Gohr     */
4652c2835c2SAndreas Gohr    function code($text, $lang = null, $file = null) {
4662c2835c2SAndreas Gohr    }
4670cecf9d5Sandi
468cfa2b40eSAndreas Gohr    /**
469cfa2b40eSAndreas Gohr     * Format an acronym
470cfa2b40eSAndreas Gohr     *
471cfa2b40eSAndreas Gohr     * Uses $this->acronyms
472cfa2b40eSAndreas Gohr     *
473cfa2b40eSAndreas Gohr     * @param string $acronym
474cfa2b40eSAndreas Gohr     */
4752c2835c2SAndreas Gohr    function acronym($acronym) {
4762c2835c2SAndreas Gohr    }
4770cecf9d5Sandi
478cfa2b40eSAndreas Gohr    /**
479cfa2b40eSAndreas Gohr     * Format a smiley
480cfa2b40eSAndreas Gohr     *
481cfa2b40eSAndreas Gohr     * Uses $this->smiley
482cfa2b40eSAndreas Gohr     *
483cfa2b40eSAndreas Gohr     * @param string $smiley
484cfa2b40eSAndreas Gohr     */
4852c2835c2SAndreas Gohr    function smiley($smiley) {
4862c2835c2SAndreas Gohr    }
4870cecf9d5Sandi
488cfa2b40eSAndreas Gohr    /**
489cfa2b40eSAndreas Gohr     * Format an entity
490cfa2b40eSAndreas Gohr     *
491cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
492cfa2b40eSAndreas Gohr     *
493cfa2b40eSAndreas Gohr     * Uses $this->entities
494cfa2b40eSAndreas Gohr     *
495cfa2b40eSAndreas Gohr     * @param string $entity
496cfa2b40eSAndreas Gohr     */
4972c2835c2SAndreas Gohr    function entity($entity) {
4982c2835c2SAndreas Gohr    }
4990cecf9d5Sandi
500cfa2b40eSAndreas Gohr    /**
501cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
502cfa2b40eSAndreas Gohr     *
503cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
504cfa2b40eSAndreas Gohr     *
505cfa2b40eSAndreas Gohr     * @param string|int $x first value
506cfa2b40eSAndreas Gohr     * @param string|int $y second value
507cfa2b40eSAndreas Gohr     */
5082c2835c2SAndreas Gohr    function multiplyentity($x, $y) {
5092c2835c2SAndreas Gohr    }
5100cecf9d5Sandi
511cfa2b40eSAndreas Gohr    /**
512cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
513cfa2b40eSAndreas Gohr     */
5142c2835c2SAndreas Gohr    function singlequoteopening() {
5152c2835c2SAndreas Gohr    }
5160cecf9d5Sandi
517cfa2b40eSAndreas Gohr    /**
518cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
519cfa2b40eSAndreas Gohr     */
5202c2835c2SAndreas Gohr    function singlequoteclosing() {
5212c2835c2SAndreas Gohr    }
5220cecf9d5Sandi
523cfa2b40eSAndreas Gohr    /**
524cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
525cfa2b40eSAndreas Gohr     */
5262c2835c2SAndreas Gohr    function apostrophe() {
5272c2835c2SAndreas Gohr    }
52857d757d1SAndreas Gohr
529cfa2b40eSAndreas Gohr    /**
530cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
531cfa2b40eSAndreas Gohr     */
5322c2835c2SAndreas Gohr    function doublequoteopening() {
5332c2835c2SAndreas Gohr    }
5340cecf9d5Sandi
535cfa2b40eSAndreas Gohr    /**
536cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
537cfa2b40eSAndreas Gohr     */
5382c2835c2SAndreas Gohr    function doublequoteclosing() {
5392c2835c2SAndreas Gohr    }
5400cecf9d5Sandi
541cfa2b40eSAndreas Gohr    /**
542cfa2b40eSAndreas Gohr     * Render a CamelCase link
543cfa2b40eSAndreas Gohr     *
544cfa2b40eSAndreas Gohr     * @param string $link The link name
545cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
546cfa2b40eSAndreas Gohr     */
5472c2835c2SAndreas Gohr    function camelcaselink($link) {
5482c2835c2SAndreas Gohr    }
5490cecf9d5Sandi
550cfa2b40eSAndreas Gohr    /**
551cfa2b40eSAndreas Gohr     * Render a page local link
552cfa2b40eSAndreas Gohr     *
553cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
554cfa2b40eSAndreas Gohr     * @param string $name name for the link
555cfa2b40eSAndreas Gohr     */
5562c2835c2SAndreas Gohr    function locallink($hash, $name = null) {
5572c2835c2SAndreas Gohr    }
558a939d432SAndreas Gohr
559cfa2b40eSAndreas Gohr    /**
560cfa2b40eSAndreas Gohr     * Render a wiki internal link
561cfa2b40eSAndreas Gohr     *
562cfa2b40eSAndreas Gohr     * @param string       $link  page ID to link to. eg. 'wiki:syntax'
563cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
564cfa2b40eSAndreas Gohr     */
5652c2835c2SAndreas Gohr    function internallink($link, $title = null) {
5662c2835c2SAndreas Gohr    }
5670cecf9d5Sandi
568cfa2b40eSAndreas Gohr    /**
569cfa2b40eSAndreas Gohr     * Render an external link
570cfa2b40eSAndreas Gohr     *
571cfa2b40eSAndreas Gohr     * @param string       $link  full URL with scheme
572cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
573cfa2b40eSAndreas Gohr     */
5742c2835c2SAndreas Gohr    function externallink($link, $title = null) {
5752c2835c2SAndreas Gohr    }
5760cecf9d5Sandi
577cfa2b40eSAndreas Gohr    /**
578cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
579cfa2b40eSAndreas Gohr     *
580cfa2b40eSAndreas Gohr     * @param string $url    URL of the feed
581cfa2b40eSAndreas Gohr     * @param array  $params Finetuning of the output
582cfa2b40eSAndreas Gohr     */
5832c2835c2SAndreas Gohr    function rss($url, $params) {
5842c2835c2SAndreas Gohr    }
585c5cfca61SAndreas Gohr
586cfa2b40eSAndreas Gohr    /**
587cfa2b40eSAndreas Gohr     * Render an interwiki link
588cfa2b40eSAndreas Gohr     *
589cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
590cfa2b40eSAndreas Gohr     *
591cfa2b40eSAndreas Gohr     * @param string       $link     original link - probably not much use
592cfa2b40eSAndreas Gohr     * @param string|array $title    name for the link, array for media file
593cfa2b40eSAndreas Gohr     * @param string       $wikiName indentifier (shortcut) for the remote wiki
594cfa2b40eSAndreas Gohr     * @param string       $wikiUri  the fragment parsed from the original link
595cfa2b40eSAndreas Gohr     */
5962c2835c2SAndreas Gohr    function interwikilink($link, $title = null, $wikiName, $wikiUri) {
5972c2835c2SAndreas Gohr    }
5980cecf9d5Sandi
599cfa2b40eSAndreas Gohr    /**
600cfa2b40eSAndreas Gohr     * Link to file on users OS
601cfa2b40eSAndreas Gohr     *
602cfa2b40eSAndreas Gohr     * @param string       $link  the link
603cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
604cfa2b40eSAndreas Gohr     */
6052c2835c2SAndreas Gohr    function filelink($link, $title = null) {
6062c2835c2SAndreas Gohr    }
6070cecf9d5Sandi
608cfa2b40eSAndreas Gohr    /**
609cfa2b40eSAndreas Gohr     * Link to windows share
610cfa2b40eSAndreas Gohr     *
611cfa2b40eSAndreas Gohr     * @param string       $link  the link
612cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
613cfa2b40eSAndreas Gohr     */
6142c2835c2SAndreas Gohr    function windowssharelink($link, $title = null) {
6152c2835c2SAndreas Gohr    }
6160cecf9d5Sandi
617cfa2b40eSAndreas Gohr    /**
618cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
619cfa2b40eSAndreas Gohr     *
620cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
621cfa2b40eSAndreas Gohr     *
622cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6233dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
624cfa2b40eSAndreas Gohr     */
6252c2835c2SAndreas Gohr    function emaillink($address, $name = null) {
6262c2835c2SAndreas Gohr    }
6270cecf9d5Sandi
628cfa2b40eSAndreas Gohr    /**
629cfa2b40eSAndreas Gohr     * Render an internal media file
630cfa2b40eSAndreas Gohr     *
631cfa2b40eSAndreas Gohr     * @param string $src     media ID
632cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
633cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
634cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
635cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
636cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
637cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
638cfa2b40eSAndreas Gohr     */
6390ea51e63SMatt Perry    function internalmedia($src, $title = null, $align = null, $width = null,
6402c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6412c2835c2SAndreas Gohr    }
642a939d432SAndreas Gohr
643cfa2b40eSAndreas Gohr    /**
644cfa2b40eSAndreas Gohr     * Render an external media file
645cfa2b40eSAndreas Gohr     *
646cfa2b40eSAndreas Gohr     * @param string $src     full media URL
647cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
648cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
649cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
650cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
651cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
652cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
653cfa2b40eSAndreas Gohr     */
6540ea51e63SMatt Perry    function externalmedia($src, $title = null, $align = null, $width = null,
6552c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6562c2835c2SAndreas Gohr    }
657a939d432SAndreas Gohr
658cfa2b40eSAndreas Gohr    /**
659cfa2b40eSAndreas Gohr     * Render a link to an internal media file
660cfa2b40eSAndreas Gohr     *
661cfa2b40eSAndreas Gohr     * @param string $src     media ID
662cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
663cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
664cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
665cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
666cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
667cfa2b40eSAndreas Gohr     */
668cfa2b40eSAndreas Gohr    function internalmedialink($src, $title = null, $align = null,
669cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6702c2835c2SAndreas Gohr    }
6710cecf9d5Sandi
672cfa2b40eSAndreas Gohr    /**
673cfa2b40eSAndreas Gohr     * Render a link to an external media file
674cfa2b40eSAndreas Gohr     *
675cfa2b40eSAndreas Gohr     * @param string $src     media ID
676cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
677cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
678cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
679cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
680cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
681cfa2b40eSAndreas Gohr     */
682cfa2b40eSAndreas Gohr    function externalmedialink($src, $title = null, $align = null,
683cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6842c2835c2SAndreas Gohr    }
6850cecf9d5Sandi
686cfa2b40eSAndreas Gohr    /**
687cfa2b40eSAndreas Gohr     * Start a table
688cfa2b40eSAndreas Gohr     *
689cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
690cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
691cfa2b40eSAndreas Gohr     * @param int $pos     byte position in the original source
692cfa2b40eSAndreas Gohr     */
6932c2835c2SAndreas Gohr    function table_open($maxcols = null, $numrows = null, $pos = null) {
6942c2835c2SAndreas Gohr    }
6950cecf9d5Sandi
696cfa2b40eSAndreas Gohr    /**
697cfa2b40eSAndreas Gohr     * Close a table
698cfa2b40eSAndreas Gohr     *
699cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
700cfa2b40eSAndreas Gohr     */
7012c2835c2SAndreas Gohr    function table_close($pos = null) {
7022c2835c2SAndreas Gohr    }
7030cecf9d5Sandi
704cfa2b40eSAndreas Gohr    /**
705cfa2b40eSAndreas Gohr     * Open a table header
706cfa2b40eSAndreas Gohr     */
7072c2835c2SAndreas Gohr    function tablethead_open() {
7082c2835c2SAndreas Gohr    }
709f05a1cc5SGerrit Uitslag
710cfa2b40eSAndreas Gohr    /**
711cfa2b40eSAndreas Gohr     * Close a table header
712cfa2b40eSAndreas Gohr     */
7132c2835c2SAndreas Gohr    function tablethead_close() {
7142c2835c2SAndreas Gohr    }
715f05a1cc5SGerrit Uitslag
716cfa2b40eSAndreas Gohr    /**
7175a93f869SAnika Henke     * Open a table body
7185a93f869SAnika Henke     */
7195a93f869SAnika Henke    function tabletbody_open() {
7205a93f869SAnika Henke    }
7215a93f869SAnika Henke
7225a93f869SAnika Henke    /**
7235a93f869SAnika Henke     * Close a table body
7245a93f869SAnika Henke     */
7255a93f869SAnika Henke    function tabletbody_close() {
7265a93f869SAnika Henke    }
7275a93f869SAnika Henke
7285a93f869SAnika Henke    /**
729d2a99739SAndreas Gohr     * Open a table footer
730d2a99739SAndreas Gohr     */
731d2a99739SAndreas Gohr    function tabletfoot_open() {
732d2a99739SAndreas Gohr    }
733d2a99739SAndreas Gohr
734d2a99739SAndreas Gohr    /**
735d2a99739SAndreas Gohr     * Close a table footer
736d2a99739SAndreas Gohr     */
737d2a99739SAndreas Gohr    function tabletfoot_close() {
738d2a99739SAndreas Gohr    }
739d2a99739SAndreas Gohr
740d2a99739SAndreas Gohr    /**
741cfa2b40eSAndreas Gohr     * Open a table row
742cfa2b40eSAndreas Gohr     */
7432c2835c2SAndreas Gohr    function tablerow_open() {
7442c2835c2SAndreas Gohr    }
7450cecf9d5Sandi
746cfa2b40eSAndreas Gohr    /**
747cfa2b40eSAndreas Gohr     * Close a table row
748cfa2b40eSAndreas Gohr     */
7492c2835c2SAndreas Gohr    function tablerow_close() {
7502c2835c2SAndreas Gohr    }
7510cecf9d5Sandi
752cfa2b40eSAndreas Gohr    /**
753cfa2b40eSAndreas Gohr     * Open a table header cell
754cfa2b40eSAndreas Gohr     *
755cfa2b40eSAndreas Gohr     * @param int    $colspan
756cfa2b40eSAndreas Gohr     * @param string $align left|center|right
757cfa2b40eSAndreas Gohr     * @param int    $rowspan
758cfa2b40eSAndreas Gohr     */
7592c2835c2SAndreas Gohr    function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
7602c2835c2SAndreas Gohr    }
7610cecf9d5Sandi
762cfa2b40eSAndreas Gohr    /**
763cfa2b40eSAndreas Gohr     * Close a table header cell
764cfa2b40eSAndreas Gohr     */
7652c2835c2SAndreas Gohr    function tableheader_close() {
7662c2835c2SAndreas Gohr    }
7670cecf9d5Sandi
768cfa2b40eSAndreas Gohr    /**
769cfa2b40eSAndreas Gohr     * Open a table cell
770cfa2b40eSAndreas Gohr     *
771cfa2b40eSAndreas Gohr     * @param int    $colspan
772cfa2b40eSAndreas Gohr     * @param string $align left|center|right
773cfa2b40eSAndreas Gohr     * @param int    $rowspan
774cfa2b40eSAndreas Gohr     */
7752c2835c2SAndreas Gohr    function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
7762c2835c2SAndreas Gohr    }
7770cecf9d5Sandi
778cfa2b40eSAndreas Gohr    /**
779cfa2b40eSAndreas Gohr     * Close a table cell
780cfa2b40eSAndreas Gohr     */
7812c2835c2SAndreas Gohr    function tablecell_close() {
7822c2835c2SAndreas Gohr    }
7832ea4044fSAndreas Gohr
784cfa2b40eSAndreas Gohr    #endregion
785cfa2b40eSAndreas Gohr
786cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
7872ea4044fSAndreas Gohr
7882ea4044fSAndreas Gohr    /**
7892ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
7902ea4044fSAndreas Gohr     * casing and special chars
7912ea4044fSAndreas Gohr     *
7922ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
79342ea7f44SGerrit Uitslag     *
79442ea7f44SGerrit Uitslag     * @param string $name
79542ea7f44SGerrit Uitslag     * @return string
7962ea4044fSAndreas Gohr     */
7972ea4044fSAndreas Gohr    function _simpleTitle($name) {
7982ea4044fSAndreas Gohr        global $conf;
7992ea4044fSAndreas Gohr
8002ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
8016d2af55dSChristopher Smith        @list($name, $hash) = explode('#', $name, 2);
8022ea4044fSAndreas Gohr        if($hash) return $hash;
8032ea4044fSAndreas Gohr
8042ea4044fSAndreas Gohr        if($conf['useslash']) {
8053755fc25STom N Harris            $name = strtr($name, ';/', ';:');
8063755fc25STom N Harris        } else {
8073755fc25STom N Harris            $name = strtr($name, ';', ':');
8082ea4044fSAndreas Gohr        }
8092ea4044fSAndreas Gohr
8109708106bSAdrian Lang        return noNSorNS($name);
8112ea4044fSAndreas Gohr    }
8122ea4044fSAndreas Gohr
8131f82fabeSAndreas Gohr    /**
8141f82fabeSAndreas Gohr     * Resolve an interwikilink
81542ea7f44SGerrit Uitslag     *
81642ea7f44SGerrit Uitslag     * @param string    $shortcut  identifier for the interwiki link
81742ea7f44SGerrit Uitslag     * @param string    $reference fragment that refers the content
81842ea7f44SGerrit Uitslag     * @param null|bool $exists    reference which returns if an internal page exists
81942ea7f44SGerrit Uitslag     * @return string interwikilink
8201f82fabeSAndreas Gohr     */
8216496c33fSGerrit Uitslag    function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
8221f82fabeSAndreas Gohr        //get interwiki URL
8231f82fabeSAndreas Gohr        if(isset($this->interwiki[$shortcut])) {
8241f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
8251f82fabeSAndreas Gohr        } else {
8261f82fabeSAndreas Gohr            // Default to Google I'm feeling lucky
827ccee93d9SPatrick Brown            $url      = 'https://www.google.com/search?q={URL}&amp;btnI=lucky';
8281f82fabeSAndreas Gohr            $shortcut = 'go';
8291f82fabeSAndreas Gohr        }
8302ea4044fSAndreas Gohr
8311f82fabeSAndreas Gohr        //split into hash and url part
83217e17ae2SPatrick Brown        $hash = strrchr($reference, '#');
83317e17ae2SPatrick Brown        if($hash) {
83417e17ae2SPatrick Brown            $reference = substr($reference, 0, -strlen($hash));
83517e17ae2SPatrick Brown            $hash = substr($hash, 1);
83617e17ae2SPatrick Brown        }
8371f82fabeSAndreas Gohr
8381f82fabeSAndreas Gohr        //replace placeholder
8391f82fabeSAndreas Gohr        if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
8401f82fabeSAndreas Gohr            //use placeholders
8411f82fabeSAndreas Gohr            $url    = str_replace('{URL}', rawurlencode($reference), $url);
84217e17ae2SPatrick Brown            //wiki names will be cleaned next, otherwise urlencode unsafe chars
84317e17ae2SPatrick Brown            $url    = str_replace('{NAME}', ($url{0} === ':') ? $reference :
84417e17ae2SPatrick Brown                                  preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) {
84517e17ae2SPatrick Brown                                    return rawurlencode($match[0]);
84617e17ae2SPatrick Brown                                  }, $reference), $url);
8471f82fabeSAndreas Gohr            $parsed = parse_url($reference);
8488f34cf3dSMichael Große            if (empty($parsed['scheme'])) $parsed['scheme'] = '';
8498f34cf3dSMichael Große            if (empty($parsed['host'])) $parsed['host'] = '';
8508f34cf3dSMichael Große            if (empty($parsed['port'])) $parsed['port'] = 80;
8518f34cf3dSMichael Große            if (empty($parsed['path'])) $parsed['path'] = '';
8528f34cf3dSMichael Große            if (empty($parsed['query'])) $parsed['query'] = '';
8538f34cf3dSMichael Große            $url = strtr($url,[
8548f34cf3dSMichael Große                '{SCHEME}' => $parsed['scheme'],
8558f34cf3dSMichael Große                '{HOST}' => $parsed['host'],
8568f34cf3dSMichael Große                '{PORT}' => $parsed['port'],
8578f34cf3dSMichael Große                '{PATH}' => $parsed['path'],
8588f34cf3dSMichael Große                '{QUERY}' => $parsed['query'] ,
8598f34cf3dSMichael Große            ]);
8601f82fabeSAndreas Gohr        } else {
8611f82fabeSAndreas Gohr            //default
8621f82fabeSAndreas Gohr            $url = $url.rawurlencode($reference);
8631f82fabeSAndreas Gohr        }
864f379edc2SGerrit Uitslag        //handle as wiki links
8656496c33fSGerrit Uitslag        if($url{0} === ':') {
866*c55b109cSMichael Große            $urlparam = null;
867*c55b109cSMichael Große            $id = $url;
868*c55b109cSMichael Große            if (strpos($url, '?') !== false) {
8696496c33fSGerrit Uitslag                list($id, $urlparam) = explode('?', $url, 2);
870*c55b109cSMichael Große            }
8716496c33fSGerrit Uitslag            $url    = wl(cleanID($id), $urlparam);
8726496c33fSGerrit Uitslag            $exists = page_exists($id);
8732345e871SGerrit Uitslag        }
8741f82fabeSAndreas Gohr        if($hash) $url .= '#'.rawurlencode($hash);
8751f82fabeSAndreas Gohr
8761f82fabeSAndreas Gohr        return $url;
8771f82fabeSAndreas Gohr    }
878cfa2b40eSAndreas Gohr
879cfa2b40eSAndreas Gohr    #endregion
8800cecf9d5Sandi}
8810cecf9d5Sandi
882340756e4Sandi
883e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
884