xref: /dokuwiki/inc/parser/renderer.php (revision abaaba9a28aaa461b6b6e0a9de7b1de1d3012f3b)
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() {
55*abaaba9aSSatoshi Sahara        $this->doc           = '';
56*abaaba9aSSatoshi Sahara        $this->info['cache'] = true;
57*abaaba9aSSatoshi Sahara        $this->info['toc']   = true;
585f70445dSAndreas Gohr    }
595f70445dSAndreas Gohr
60f6ec8df8SAdrian Lang    /**
61f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
62f6ec8df8SAdrian Lang     *
63cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
64cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
65cfa2b40eSAndreas Gohr     *
66f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
67f6ec8df8SAdrian Lang     */
68f6ec8df8SAdrian Lang    function isSingleton() {
69f6ec8df8SAdrian Lang        return false;
70f6ec8df8SAdrian Lang    }
71f6ec8df8SAdrian Lang
728cc41db0SAndreas Gohr    /**
73cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
74cfa2b40eSAndreas Gohr     *
75cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
76cfa2b40eSAndreas Gohr     *
77cfa2b40eSAndreas Gohr     * @return string
78cfa2b40eSAndreas Gohr     */
79cfa2b40eSAndreas Gohr    function getFormat() {
80cfa2b40eSAndreas Gohr        trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
81cfa2b40eSAndreas Gohr        return '';
82cfa2b40eSAndreas Gohr    }
83cfa2b40eSAndreas Gohr
84cfa2b40eSAndreas Gohr    /**
85cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
86cfa2b40eSAndreas Gohr     */
87cfa2b40eSAndreas Gohr    function nocache() {
88cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
89cfa2b40eSAndreas Gohr    }
90cfa2b40eSAndreas Gohr
91cfa2b40eSAndreas Gohr    /**
92cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
93cfa2b40eSAndreas Gohr     *
94cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
95cfa2b40eSAndreas Gohr     */
96cfa2b40eSAndreas Gohr    function notoc() {
97cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
98cfa2b40eSAndreas Gohr    }
99cfa2b40eSAndreas Gohr
100cfa2b40eSAndreas Gohr    /**
101cfa2b40eSAndreas Gohr     * Handle plugin rendering
102cfa2b40eSAndreas Gohr     *
103cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
1048cc41db0SAndreas Gohr     *
1058cc41db0SAndreas Gohr     * @param string $name  Plugin name
1068cc41db0SAndreas Gohr     * @param mixed  $data  custom data set by handler
1078cc41db0SAndreas Gohr     * @param string $state matched state if any
1088cc41db0SAndreas Gohr     * @param string $match raw matched syntax
1098cc41db0SAndreas Gohr     */
1108cc41db0SAndreas Gohr    function plugin($name, $data, $state = '', $match = '') {
111cfa2b40eSAndreas Gohr        /** @var DokuWiki_Syntax_Plugin $plugin */
112e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
11361faf446Schris        if($plugin != null) {
1145f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
11561faf446Schris        }
11661faf446Schris    }
11761faf446Schris
1185587e44cSchris    /**
1195587e44cSchris     * handle nested render instructions
1205587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
121cfa2b40eSAndreas Gohr     *
122cfa2b40eSAndreas Gohr     * @param array $instructions
1235587e44cSchris     */
1245587e44cSchris    function nest($instructions) {
1255587e44cSchris        foreach($instructions as $instruction) {
1265587e44cSchris            // execute the callback against ourself
127c2122b83SChristopher Smith            if(method_exists($this, $instruction[0])) {
128d6a1a955SAndreas Gohr                call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
129c2122b83SChristopher Smith            }
1305587e44cSchris        }
1315587e44cSchris    }
1325587e44cSchris
133cfa2b40eSAndreas Gohr    /**
134cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
135cfa2b40eSAndreas Gohr     *
136cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
137cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
138cfa2b40eSAndreas Gohr     */
1392c2835c2SAndreas Gohr    function nest_close() {
1402c2835c2SAndreas Gohr    }
1415587e44cSchris
142cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
143cfa2b40eSAndreas Gohr
144cfa2b40eSAndreas Gohr    /**
145cfa2b40eSAndreas Gohr     * Initialize the document
146cfa2b40eSAndreas Gohr     */
1472c2835c2SAndreas Gohr    function document_start() {
1482c2835c2SAndreas Gohr    }
1490cecf9d5Sandi
150cfa2b40eSAndreas Gohr    /**
151cfa2b40eSAndreas Gohr     * Finalize the document
152cfa2b40eSAndreas Gohr     */
1532c2835c2SAndreas Gohr    function document_end() {
1542c2835c2SAndreas Gohr    }
1550cecf9d5Sandi
156cfa2b40eSAndreas Gohr    /**
157cfa2b40eSAndreas Gohr     * Render the Table of Contents
158cfa2b40eSAndreas Gohr     *
159cfa2b40eSAndreas Gohr     * @return string
160cfa2b40eSAndreas Gohr     */
1612c2835c2SAndreas Gohr    function render_TOC() {
1622c2835c2SAndreas Gohr        return '';
1632c2835c2SAndreas Gohr    }
1640cecf9d5Sandi
165cfa2b40eSAndreas Gohr    /**
166cfa2b40eSAndreas Gohr     * Add an item to the TOC
167cfa2b40eSAndreas Gohr     *
168cfa2b40eSAndreas Gohr     * @param string $id       the hash link
169cfa2b40eSAndreas Gohr     * @param string $text     the text to display
170cfa2b40eSAndreas Gohr     * @param int    $level    the nesting level
171cfa2b40eSAndreas Gohr     */
1722c2835c2SAndreas Gohr    function toc_additem($id, $text, $level) {
1732c2835c2SAndreas Gohr    }
174e7856beaSchris
175cfa2b40eSAndreas Gohr    /**
176cfa2b40eSAndreas Gohr     * Render a heading
177cfa2b40eSAndreas Gohr     *
178cfa2b40eSAndreas Gohr     * @param string $text  the text to display
179cfa2b40eSAndreas Gohr     * @param int    $level header level
180cfa2b40eSAndreas Gohr     * @param int    $pos   byte position in the original source
181cfa2b40eSAndreas Gohr     */
1822c2835c2SAndreas Gohr    function header($text, $level, $pos) {
1832c2835c2SAndreas Gohr    }
1840cecf9d5Sandi
185cfa2b40eSAndreas Gohr    /**
186cfa2b40eSAndreas Gohr     * Open a new section
187cfa2b40eSAndreas Gohr     *
188cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
189cfa2b40eSAndreas Gohr     */
1902c2835c2SAndreas Gohr    function section_open($level) {
1912c2835c2SAndreas Gohr    }
1920cecf9d5Sandi
193cfa2b40eSAndreas Gohr    /**
194cfa2b40eSAndreas Gohr     * Close the current section
195cfa2b40eSAndreas Gohr     */
1962c2835c2SAndreas Gohr    function section_close() {
1972c2835c2SAndreas Gohr    }
1980cecf9d5Sandi
199cfa2b40eSAndreas Gohr    /**
200cfa2b40eSAndreas Gohr     * Render plain text data
201cfa2b40eSAndreas Gohr     *
20242ea7f44SGerrit Uitslag     * @param string $text
203cfa2b40eSAndreas Gohr     */
2042c2835c2SAndreas Gohr    function cdata($text) {
2052c2835c2SAndreas Gohr    }
2060cecf9d5Sandi
207cfa2b40eSAndreas Gohr    /**
208cfa2b40eSAndreas Gohr     * Open a paragraph
209cfa2b40eSAndreas Gohr     */
2102c2835c2SAndreas Gohr    function p_open() {
2112c2835c2SAndreas Gohr    }
2120cecf9d5Sandi
213cfa2b40eSAndreas Gohr    /**
214cfa2b40eSAndreas Gohr     * Close a paragraph
215cfa2b40eSAndreas Gohr     */
2162c2835c2SAndreas Gohr    function p_close() {
2172c2835c2SAndreas Gohr    }
2180cecf9d5Sandi
219cfa2b40eSAndreas Gohr    /**
2203dd5c225SAndreas Gohr     * Create a line break
221cfa2b40eSAndreas Gohr     */
2222c2835c2SAndreas Gohr    function linebreak() {
2232c2835c2SAndreas Gohr    }
2240cecf9d5Sandi
225cfa2b40eSAndreas Gohr    /**
226cfa2b40eSAndreas Gohr     * Create a horizontal line
227cfa2b40eSAndreas Gohr     */
2282c2835c2SAndreas Gohr    function hr() {
2292c2835c2SAndreas Gohr    }
2300cecf9d5Sandi
231cfa2b40eSAndreas Gohr    /**
232cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
233cfa2b40eSAndreas Gohr     */
2342c2835c2SAndreas Gohr    function strong_open() {
2352c2835c2SAndreas Gohr    }
2360cecf9d5Sandi
237cfa2b40eSAndreas Gohr    /**
238cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
239cfa2b40eSAndreas Gohr     */
2402c2835c2SAndreas Gohr    function strong_close() {
2412c2835c2SAndreas Gohr    }
2420cecf9d5Sandi
243cfa2b40eSAndreas Gohr    /**
244cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
245cfa2b40eSAndreas Gohr     */
2462c2835c2SAndreas Gohr    function emphasis_open() {
2472c2835c2SAndreas Gohr    }
2480cecf9d5Sandi
249cfa2b40eSAndreas Gohr    /**
250cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
251cfa2b40eSAndreas Gohr     */
2522c2835c2SAndreas Gohr    function emphasis_close() {
2532c2835c2SAndreas Gohr    }
2540cecf9d5Sandi
255cfa2b40eSAndreas Gohr    /**
256cfa2b40eSAndreas Gohr     * Start underline formatting
257cfa2b40eSAndreas Gohr     */
2582c2835c2SAndreas Gohr    function underline_open() {
2592c2835c2SAndreas Gohr    }
2600cecf9d5Sandi
261cfa2b40eSAndreas Gohr    /**
262cfa2b40eSAndreas Gohr     * Stop underline formatting
263cfa2b40eSAndreas Gohr     */
2642c2835c2SAndreas Gohr    function underline_close() {
2652c2835c2SAndreas Gohr    }
2660cecf9d5Sandi
267cfa2b40eSAndreas Gohr    /**
268cfa2b40eSAndreas Gohr     * Start monospace formatting
269cfa2b40eSAndreas Gohr     */
2702c2835c2SAndreas Gohr    function monospace_open() {
2712c2835c2SAndreas Gohr    }
2720cecf9d5Sandi
273cfa2b40eSAndreas Gohr    /**
274cfa2b40eSAndreas Gohr     * Stop monospace formatting
275cfa2b40eSAndreas Gohr     */
2762c2835c2SAndreas Gohr    function monospace_close() {
2772c2835c2SAndreas Gohr    }
2780cecf9d5Sandi
279cfa2b40eSAndreas Gohr    /**
280cfa2b40eSAndreas Gohr     * Start a subscript
281cfa2b40eSAndreas Gohr     */
2822c2835c2SAndreas Gohr    function subscript_open() {
2832c2835c2SAndreas Gohr    }
2840cecf9d5Sandi
285cfa2b40eSAndreas Gohr    /**
286cfa2b40eSAndreas Gohr     * Stop a subscript
287cfa2b40eSAndreas Gohr     */
2882c2835c2SAndreas Gohr    function subscript_close() {
2892c2835c2SAndreas Gohr    }
2900cecf9d5Sandi
291cfa2b40eSAndreas Gohr    /**
292cfa2b40eSAndreas Gohr     * Start a superscript
293cfa2b40eSAndreas Gohr     */
2942c2835c2SAndreas Gohr    function superscript_open() {
2952c2835c2SAndreas Gohr    }
2960cecf9d5Sandi
297cfa2b40eSAndreas Gohr    /**
298cfa2b40eSAndreas Gohr     * Stop a superscript
299cfa2b40eSAndreas Gohr     */
3002c2835c2SAndreas Gohr    function superscript_close() {
3012c2835c2SAndreas Gohr    }
3020cecf9d5Sandi
303cfa2b40eSAndreas Gohr    /**
304cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
305cfa2b40eSAndreas Gohr     */
3062c2835c2SAndreas Gohr    function deleted_open() {
3072c2835c2SAndreas Gohr    }
3080cecf9d5Sandi
309cfa2b40eSAndreas Gohr    /**
310cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
311cfa2b40eSAndreas Gohr     */
3122c2835c2SAndreas Gohr    function deleted_close() {
3132c2835c2SAndreas Gohr    }
3140cecf9d5Sandi
315cfa2b40eSAndreas Gohr    /**
316cfa2b40eSAndreas Gohr     * Start a footnote
317cfa2b40eSAndreas Gohr     */
3182c2835c2SAndreas Gohr    function footnote_open() {
3192c2835c2SAndreas Gohr    }
3200cecf9d5Sandi
321cfa2b40eSAndreas Gohr    /**
322cfa2b40eSAndreas Gohr     * Stop a footnote
323cfa2b40eSAndreas Gohr     */
3242c2835c2SAndreas Gohr    function footnote_close() {
3252c2835c2SAndreas Gohr    }
3260cecf9d5Sandi
327cfa2b40eSAndreas Gohr    /**
328cfa2b40eSAndreas Gohr     * Open an unordered list
329cfa2b40eSAndreas Gohr     */
3302c2835c2SAndreas Gohr    function listu_open() {
3312c2835c2SAndreas Gohr    }
3320cecf9d5Sandi
333cfa2b40eSAndreas Gohr    /**
334cfa2b40eSAndreas Gohr     * Close an unordered list
335cfa2b40eSAndreas Gohr     */
3362c2835c2SAndreas Gohr    function listu_close() {
3372c2835c2SAndreas Gohr    }
3380cecf9d5Sandi
339cfa2b40eSAndreas Gohr    /**
340cfa2b40eSAndreas Gohr     * Open an ordered list
341cfa2b40eSAndreas Gohr     */
3422c2835c2SAndreas Gohr    function listo_open() {
3432c2835c2SAndreas Gohr    }
3440cecf9d5Sandi
345cfa2b40eSAndreas Gohr    /**
346cfa2b40eSAndreas Gohr     * Close an ordered list
347cfa2b40eSAndreas Gohr     */
3482c2835c2SAndreas Gohr    function listo_close() {
3492c2835c2SAndreas Gohr    }
3500cecf9d5Sandi
351cfa2b40eSAndreas Gohr    /**
352cfa2b40eSAndreas Gohr     * Open a list item
353cfa2b40eSAndreas Gohr     *
354cfa2b40eSAndreas Gohr     * @param int $level the nesting level
355e3a24861SChristopher Smith     * @param bool $node true when a node; false when a leaf
356cfa2b40eSAndreas Gohr     */
357e3a24861SChristopher Smith    function listitem_open($level,$node=false) {
3582c2835c2SAndreas Gohr    }
3590cecf9d5Sandi
360cfa2b40eSAndreas Gohr    /**
361cfa2b40eSAndreas Gohr     * Close a list item
362cfa2b40eSAndreas Gohr     */
3632c2835c2SAndreas Gohr    function listitem_close() {
3642c2835c2SAndreas Gohr    }
3650cecf9d5Sandi
366cfa2b40eSAndreas Gohr    /**
367cfa2b40eSAndreas Gohr     * Start the content of a list item
368cfa2b40eSAndreas Gohr     */
3692c2835c2SAndreas Gohr    function listcontent_open() {
3702c2835c2SAndreas Gohr    }
3710cecf9d5Sandi
372cfa2b40eSAndreas Gohr    /**
373cfa2b40eSAndreas Gohr     * Stop the content of a list item
374cfa2b40eSAndreas Gohr     */
3752c2835c2SAndreas Gohr    function listcontent_close() {
3762c2835c2SAndreas Gohr    }
3770cecf9d5Sandi
378cfa2b40eSAndreas Gohr    /**
379cfa2b40eSAndreas Gohr     * Output unformatted $text
380cfa2b40eSAndreas Gohr     *
381cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
382cfa2b40eSAndreas Gohr     *
383cfa2b40eSAndreas Gohr     * @param string $text
384cfa2b40eSAndreas Gohr     */
3852c2835c2SAndreas Gohr    function unformatted($text) {
386cfa2b40eSAndreas Gohr        $this->cdata($text);
3872c2835c2SAndreas Gohr    }
3880cecf9d5Sandi
389cfa2b40eSAndreas Gohr    /**
390cfa2b40eSAndreas Gohr     * Output inline PHP code
391cfa2b40eSAndreas Gohr     *
392cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
393cfa2b40eSAndreas Gohr     * to $doc
394cfa2b40eSAndreas Gohr     *
395cfa2b40eSAndreas Gohr     * @param string $text The PHP code
396cfa2b40eSAndreas Gohr     */
3972c2835c2SAndreas Gohr    function php($text) {
3982c2835c2SAndreas Gohr    }
3990cecf9d5Sandi
400cfa2b40eSAndreas Gohr    /**
401cfa2b40eSAndreas Gohr     * Output block level PHP code
402cfa2b40eSAndreas Gohr     *
403cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
404cfa2b40eSAndreas Gohr     * to $doc
405cfa2b40eSAndreas Gohr     *
406cfa2b40eSAndreas Gohr     * @param string $text The PHP code
407cfa2b40eSAndreas Gohr     */
4082c2835c2SAndreas Gohr    function phpblock($text) {
4092c2835c2SAndreas Gohr    }
41007f89c3cSAnika Henke
411cfa2b40eSAndreas Gohr    /**
412cfa2b40eSAndreas Gohr     * Output raw inline HTML
413cfa2b40eSAndreas Gohr     *
414cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
415cfa2b40eSAndreas Gohr     *
416cfa2b40eSAndreas Gohr     * @param string $text The HTML
417cfa2b40eSAndreas Gohr     */
4182c2835c2SAndreas Gohr    function html($text) {
4192c2835c2SAndreas Gohr    }
4200cecf9d5Sandi
421cfa2b40eSAndreas Gohr    /**
422cfa2b40eSAndreas Gohr     * Output raw block-level HTML
423cfa2b40eSAndreas Gohr     *
424cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
425cfa2b40eSAndreas Gohr     *
426cfa2b40eSAndreas Gohr     * @param string $text The HTML
427cfa2b40eSAndreas Gohr     */
4282c2835c2SAndreas Gohr    function htmlblock($text) {
4292c2835c2SAndreas Gohr    }
43007f89c3cSAnika Henke
431cfa2b40eSAndreas Gohr    /**
432cfa2b40eSAndreas Gohr     * Output preformatted text
433cfa2b40eSAndreas Gohr     *
434cfa2b40eSAndreas Gohr     * @param string $text
435cfa2b40eSAndreas Gohr     */
4362c2835c2SAndreas Gohr    function preformatted($text) {
4372c2835c2SAndreas Gohr    }
4380cecf9d5Sandi
439cfa2b40eSAndreas Gohr    /**
440cfa2b40eSAndreas Gohr     * Start a block quote
441cfa2b40eSAndreas Gohr     */
4422c2835c2SAndreas Gohr    function quote_open() {
4432c2835c2SAndreas Gohr    }
4440cecf9d5Sandi
445cfa2b40eSAndreas Gohr    /**
446cfa2b40eSAndreas Gohr     * Stop a block quote
447cfa2b40eSAndreas Gohr     */
4482c2835c2SAndreas Gohr    function quote_close() {
4492c2835c2SAndreas Gohr    }
4500cecf9d5Sandi
451cfa2b40eSAndreas Gohr    /**
452cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
453cfa2b40eSAndreas Gohr     *
454cfa2b40eSAndreas Gohr     * @param string $text text to show
455cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
456cfa2b40eSAndreas Gohr     * @param string $file file path label
457cfa2b40eSAndreas Gohr     */
4582c2835c2SAndreas Gohr    function file($text, $lang = null, $file = null) {
4592c2835c2SAndreas Gohr    }
4603d491f75SAndreas Gohr
461cfa2b40eSAndreas Gohr    /**
462cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
463cfa2b40eSAndreas Gohr     *
464cfa2b40eSAndreas Gohr     * @param string $text text to show
465cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
466cfa2b40eSAndreas Gohr     * @param string $file file path label
467cfa2b40eSAndreas Gohr     */
4682c2835c2SAndreas Gohr    function code($text, $lang = null, $file = null) {
4692c2835c2SAndreas Gohr    }
4700cecf9d5Sandi
471cfa2b40eSAndreas Gohr    /**
472cfa2b40eSAndreas Gohr     * Format an acronym
473cfa2b40eSAndreas Gohr     *
474cfa2b40eSAndreas Gohr     * Uses $this->acronyms
475cfa2b40eSAndreas Gohr     *
476cfa2b40eSAndreas Gohr     * @param string $acronym
477cfa2b40eSAndreas Gohr     */
4782c2835c2SAndreas Gohr    function acronym($acronym) {
4792c2835c2SAndreas Gohr    }
4800cecf9d5Sandi
481cfa2b40eSAndreas Gohr    /**
482cfa2b40eSAndreas Gohr     * Format a smiley
483cfa2b40eSAndreas Gohr     *
484cfa2b40eSAndreas Gohr     * Uses $this->smiley
485cfa2b40eSAndreas Gohr     *
486cfa2b40eSAndreas Gohr     * @param string $smiley
487cfa2b40eSAndreas Gohr     */
4882c2835c2SAndreas Gohr    function smiley($smiley) {
4892c2835c2SAndreas Gohr    }
4900cecf9d5Sandi
491cfa2b40eSAndreas Gohr    /**
492cfa2b40eSAndreas Gohr     * Format an entity
493cfa2b40eSAndreas Gohr     *
494cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
495cfa2b40eSAndreas Gohr     *
496cfa2b40eSAndreas Gohr     * Uses $this->entities
497cfa2b40eSAndreas Gohr     *
498cfa2b40eSAndreas Gohr     * @param string $entity
499cfa2b40eSAndreas Gohr     */
5002c2835c2SAndreas Gohr    function entity($entity) {
5012c2835c2SAndreas Gohr    }
5020cecf9d5Sandi
503cfa2b40eSAndreas Gohr    /**
504cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
505cfa2b40eSAndreas Gohr     *
506cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
507cfa2b40eSAndreas Gohr     *
508cfa2b40eSAndreas Gohr     * @param string|int $x first value
509cfa2b40eSAndreas Gohr     * @param string|int $y second value
510cfa2b40eSAndreas Gohr     */
5112c2835c2SAndreas Gohr    function multiplyentity($x, $y) {
5122c2835c2SAndreas Gohr    }
5130cecf9d5Sandi
514cfa2b40eSAndreas Gohr    /**
515cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
516cfa2b40eSAndreas Gohr     */
5172c2835c2SAndreas Gohr    function singlequoteopening() {
5182c2835c2SAndreas Gohr    }
5190cecf9d5Sandi
520cfa2b40eSAndreas Gohr    /**
521cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
522cfa2b40eSAndreas Gohr     */
5232c2835c2SAndreas Gohr    function singlequoteclosing() {
5242c2835c2SAndreas Gohr    }
5250cecf9d5Sandi
526cfa2b40eSAndreas Gohr    /**
527cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
528cfa2b40eSAndreas Gohr     */
5292c2835c2SAndreas Gohr    function apostrophe() {
5302c2835c2SAndreas Gohr    }
53157d757d1SAndreas Gohr
532cfa2b40eSAndreas Gohr    /**
533cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
534cfa2b40eSAndreas Gohr     */
5352c2835c2SAndreas Gohr    function doublequoteopening() {
5362c2835c2SAndreas Gohr    }
5370cecf9d5Sandi
538cfa2b40eSAndreas Gohr    /**
539cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
540cfa2b40eSAndreas Gohr     */
5412c2835c2SAndreas Gohr    function doublequoteclosing() {
5422c2835c2SAndreas Gohr    }
5430cecf9d5Sandi
544cfa2b40eSAndreas Gohr    /**
545cfa2b40eSAndreas Gohr     * Render a CamelCase link
546cfa2b40eSAndreas Gohr     *
547cfa2b40eSAndreas Gohr     * @param string $link The link name
548cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
549cfa2b40eSAndreas Gohr     */
5502c2835c2SAndreas Gohr    function camelcaselink($link) {
5512c2835c2SAndreas Gohr    }
5520cecf9d5Sandi
553cfa2b40eSAndreas Gohr    /**
554cfa2b40eSAndreas Gohr     * Render a page local link
555cfa2b40eSAndreas Gohr     *
556cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
557cfa2b40eSAndreas Gohr     * @param string $name name for the link
558cfa2b40eSAndreas Gohr     */
5592c2835c2SAndreas Gohr    function locallink($hash, $name = null) {
5602c2835c2SAndreas Gohr    }
561a939d432SAndreas Gohr
562cfa2b40eSAndreas Gohr    /**
563cfa2b40eSAndreas Gohr     * Render a wiki internal link
564cfa2b40eSAndreas Gohr     *
565cfa2b40eSAndreas Gohr     * @param string       $link  page ID to link to. eg. 'wiki:syntax'
566cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
567cfa2b40eSAndreas Gohr     */
5682c2835c2SAndreas Gohr    function internallink($link, $title = null) {
5692c2835c2SAndreas Gohr    }
5700cecf9d5Sandi
571cfa2b40eSAndreas Gohr    /**
572cfa2b40eSAndreas Gohr     * Render an external link
573cfa2b40eSAndreas Gohr     *
574cfa2b40eSAndreas Gohr     * @param string       $link  full URL with scheme
575cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
576cfa2b40eSAndreas Gohr     */
5772c2835c2SAndreas Gohr    function externallink($link, $title = null) {
5782c2835c2SAndreas Gohr    }
5790cecf9d5Sandi
580cfa2b40eSAndreas Gohr    /**
581cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
582cfa2b40eSAndreas Gohr     *
583cfa2b40eSAndreas Gohr     * @param string $url    URL of the feed
584cfa2b40eSAndreas Gohr     * @param array  $params Finetuning of the output
585cfa2b40eSAndreas Gohr     */
5862c2835c2SAndreas Gohr    function rss($url, $params) {
5872c2835c2SAndreas Gohr    }
588c5cfca61SAndreas Gohr
589cfa2b40eSAndreas Gohr    /**
590cfa2b40eSAndreas Gohr     * Render an interwiki link
591cfa2b40eSAndreas Gohr     *
592cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
593cfa2b40eSAndreas Gohr     *
594cfa2b40eSAndreas Gohr     * @param string       $link     original link - probably not much use
595cfa2b40eSAndreas Gohr     * @param string|array $title    name for the link, array for media file
596cfa2b40eSAndreas Gohr     * @param string       $wikiName indentifier (shortcut) for the remote wiki
597cfa2b40eSAndreas Gohr     * @param string       $wikiUri  the fragment parsed from the original link
598cfa2b40eSAndreas Gohr     */
5992c2835c2SAndreas Gohr    function interwikilink($link, $title = null, $wikiName, $wikiUri) {
6002c2835c2SAndreas Gohr    }
6010cecf9d5Sandi
602cfa2b40eSAndreas Gohr    /**
603cfa2b40eSAndreas Gohr     * Link to file on users OS
604cfa2b40eSAndreas Gohr     *
605cfa2b40eSAndreas Gohr     * @param string       $link  the link
606cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
607cfa2b40eSAndreas Gohr     */
6082c2835c2SAndreas Gohr    function filelink($link, $title = null) {
6092c2835c2SAndreas Gohr    }
6100cecf9d5Sandi
611cfa2b40eSAndreas Gohr    /**
612cfa2b40eSAndreas Gohr     * Link to windows share
613cfa2b40eSAndreas Gohr     *
614cfa2b40eSAndreas Gohr     * @param string       $link  the link
615cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
616cfa2b40eSAndreas Gohr     */
6172c2835c2SAndreas Gohr    function windowssharelink($link, $title = null) {
6182c2835c2SAndreas Gohr    }
6190cecf9d5Sandi
620cfa2b40eSAndreas Gohr    /**
621cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
622cfa2b40eSAndreas Gohr     *
623cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
624cfa2b40eSAndreas Gohr     *
625cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6263dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
627cfa2b40eSAndreas Gohr     */
6282c2835c2SAndreas Gohr    function emaillink($address, $name = null) {
6292c2835c2SAndreas Gohr    }
6300cecf9d5Sandi
631cfa2b40eSAndreas Gohr    /**
632cfa2b40eSAndreas Gohr     * Render an internal media file
633cfa2b40eSAndreas Gohr     *
634cfa2b40eSAndreas Gohr     * @param string $src     media ID
635cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
636cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
637cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
638cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
639cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
640cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
641cfa2b40eSAndreas Gohr     */
6420ea51e63SMatt Perry    function internalmedia($src, $title = null, $align = null, $width = null,
6432c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6442c2835c2SAndreas Gohr    }
645a939d432SAndreas Gohr
646cfa2b40eSAndreas Gohr    /**
647cfa2b40eSAndreas Gohr     * Render an external media file
648cfa2b40eSAndreas Gohr     *
649cfa2b40eSAndreas Gohr     * @param string $src     full media URL
650cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
651cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
652cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
653cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
654cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
655cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
656cfa2b40eSAndreas Gohr     */
6570ea51e63SMatt Perry    function externalmedia($src, $title = null, $align = null, $width = null,
6582c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6592c2835c2SAndreas Gohr    }
660a939d432SAndreas Gohr
661cfa2b40eSAndreas Gohr    /**
662cfa2b40eSAndreas Gohr     * Render a link to an internal media file
663cfa2b40eSAndreas Gohr     *
664cfa2b40eSAndreas Gohr     * @param string $src     media ID
665cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
666cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
667cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
668cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
669cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
670cfa2b40eSAndreas Gohr     */
671cfa2b40eSAndreas Gohr    function internalmedialink($src, $title = null, $align = null,
672cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6732c2835c2SAndreas Gohr    }
6740cecf9d5Sandi
675cfa2b40eSAndreas Gohr    /**
676cfa2b40eSAndreas Gohr     * Render a link to an external media file
677cfa2b40eSAndreas Gohr     *
678cfa2b40eSAndreas Gohr     * @param string $src     media ID
679cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
680cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
681cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
682cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
683cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
684cfa2b40eSAndreas Gohr     */
685cfa2b40eSAndreas Gohr    function externalmedialink($src, $title = null, $align = null,
686cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6872c2835c2SAndreas Gohr    }
6880cecf9d5Sandi
689cfa2b40eSAndreas Gohr    /**
690cfa2b40eSAndreas Gohr     * Start a table
691cfa2b40eSAndreas Gohr     *
692cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
693cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
694cfa2b40eSAndreas Gohr     * @param int $pos     byte position in the original source
695cfa2b40eSAndreas Gohr     */
6962c2835c2SAndreas Gohr    function table_open($maxcols = null, $numrows = null, $pos = null) {
6972c2835c2SAndreas Gohr    }
6980cecf9d5Sandi
699cfa2b40eSAndreas Gohr    /**
700cfa2b40eSAndreas Gohr     * Close a table
701cfa2b40eSAndreas Gohr     *
702cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
703cfa2b40eSAndreas Gohr     */
7042c2835c2SAndreas Gohr    function table_close($pos = null) {
7052c2835c2SAndreas Gohr    }
7060cecf9d5Sandi
707cfa2b40eSAndreas Gohr    /**
708cfa2b40eSAndreas Gohr     * Open a table header
709cfa2b40eSAndreas Gohr     */
7102c2835c2SAndreas Gohr    function tablethead_open() {
7112c2835c2SAndreas Gohr    }
712f05a1cc5SGerrit Uitslag
713cfa2b40eSAndreas Gohr    /**
714cfa2b40eSAndreas Gohr     * Close a table header
715cfa2b40eSAndreas Gohr     */
7162c2835c2SAndreas Gohr    function tablethead_close() {
7172c2835c2SAndreas Gohr    }
718f05a1cc5SGerrit Uitslag
719cfa2b40eSAndreas Gohr    /**
7205a93f869SAnika Henke     * Open a table body
7215a93f869SAnika Henke     */
7225a93f869SAnika Henke    function tabletbody_open() {
7235a93f869SAnika Henke    }
7245a93f869SAnika Henke
7255a93f869SAnika Henke    /**
7265a93f869SAnika Henke     * Close a table body
7275a93f869SAnika Henke     */
7285a93f869SAnika Henke    function tabletbody_close() {
7295a93f869SAnika Henke    }
7305a93f869SAnika Henke
7315a93f869SAnika Henke    /**
732d2a99739SAndreas Gohr     * Open a table footer
733d2a99739SAndreas Gohr     */
734d2a99739SAndreas Gohr    function tabletfoot_open() {
735d2a99739SAndreas Gohr    }
736d2a99739SAndreas Gohr
737d2a99739SAndreas Gohr    /**
738d2a99739SAndreas Gohr     * Close a table footer
739d2a99739SAndreas Gohr     */
740d2a99739SAndreas Gohr    function tabletfoot_close() {
741d2a99739SAndreas Gohr    }
742d2a99739SAndreas Gohr
743d2a99739SAndreas Gohr    /**
744cfa2b40eSAndreas Gohr     * Open a table row
745cfa2b40eSAndreas Gohr     */
7462c2835c2SAndreas Gohr    function tablerow_open() {
7472c2835c2SAndreas Gohr    }
7480cecf9d5Sandi
749cfa2b40eSAndreas Gohr    /**
750cfa2b40eSAndreas Gohr     * Close a table row
751cfa2b40eSAndreas Gohr     */
7522c2835c2SAndreas Gohr    function tablerow_close() {
7532c2835c2SAndreas Gohr    }
7540cecf9d5Sandi
755cfa2b40eSAndreas Gohr    /**
756cfa2b40eSAndreas Gohr     * Open a table header cell
757cfa2b40eSAndreas Gohr     *
758cfa2b40eSAndreas Gohr     * @param int    $colspan
759cfa2b40eSAndreas Gohr     * @param string $align left|center|right
760cfa2b40eSAndreas Gohr     * @param int    $rowspan
761cfa2b40eSAndreas Gohr     */
7622c2835c2SAndreas Gohr    function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
7632c2835c2SAndreas Gohr    }
7640cecf9d5Sandi
765cfa2b40eSAndreas Gohr    /**
766cfa2b40eSAndreas Gohr     * Close a table header cell
767cfa2b40eSAndreas Gohr     */
7682c2835c2SAndreas Gohr    function tableheader_close() {
7692c2835c2SAndreas Gohr    }
7700cecf9d5Sandi
771cfa2b40eSAndreas Gohr    /**
772cfa2b40eSAndreas Gohr     * Open a table cell
773cfa2b40eSAndreas Gohr     *
774cfa2b40eSAndreas Gohr     * @param int    $colspan
775cfa2b40eSAndreas Gohr     * @param string $align left|center|right
776cfa2b40eSAndreas Gohr     * @param int    $rowspan
777cfa2b40eSAndreas Gohr     */
7782c2835c2SAndreas Gohr    function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
7792c2835c2SAndreas Gohr    }
7800cecf9d5Sandi
781cfa2b40eSAndreas Gohr    /**
782cfa2b40eSAndreas Gohr     * Close a table cell
783cfa2b40eSAndreas Gohr     */
7842c2835c2SAndreas Gohr    function tablecell_close() {
7852c2835c2SAndreas Gohr    }
7862ea4044fSAndreas Gohr
787cfa2b40eSAndreas Gohr    #endregion
788cfa2b40eSAndreas Gohr
789cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
7902ea4044fSAndreas Gohr
7912ea4044fSAndreas Gohr    /**
7922ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
7932ea4044fSAndreas Gohr     * casing and special chars
7942ea4044fSAndreas Gohr     *
7952ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
79642ea7f44SGerrit Uitslag     *
79742ea7f44SGerrit Uitslag     * @param string $name
79842ea7f44SGerrit Uitslag     * @return string
7992ea4044fSAndreas Gohr     */
8002ea4044fSAndreas Gohr    function _simpleTitle($name) {
8012ea4044fSAndreas Gohr        global $conf;
8022ea4044fSAndreas Gohr
8032ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
8046d2af55dSChristopher Smith        @list($name, $hash) = explode('#', $name, 2);
8052ea4044fSAndreas Gohr        if($hash) return $hash;
8062ea4044fSAndreas Gohr
8072ea4044fSAndreas Gohr        if($conf['useslash']) {
8083755fc25STom N Harris            $name = strtr($name, ';/', ';:');
8093755fc25STom N Harris        } else {
8103755fc25STom N Harris            $name = strtr($name, ';', ':');
8112ea4044fSAndreas Gohr        }
8122ea4044fSAndreas Gohr
8139708106bSAdrian Lang        return noNSorNS($name);
8142ea4044fSAndreas Gohr    }
8152ea4044fSAndreas Gohr
8161f82fabeSAndreas Gohr    /**
8171f82fabeSAndreas Gohr     * Resolve an interwikilink
81842ea7f44SGerrit Uitslag     *
81942ea7f44SGerrit Uitslag     * @param string    $shortcut  identifier for the interwiki link
82042ea7f44SGerrit Uitslag     * @param string    $reference fragment that refers the content
82142ea7f44SGerrit Uitslag     * @param null|bool $exists    reference which returns if an internal page exists
82242ea7f44SGerrit Uitslag     * @return string interwikilink
8231f82fabeSAndreas Gohr     */
8246496c33fSGerrit Uitslag    function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
8251f82fabeSAndreas Gohr        //get interwiki URL
8261f82fabeSAndreas Gohr        if(isset($this->interwiki[$shortcut])) {
8271f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
8281f82fabeSAndreas Gohr        } else {
8291f82fabeSAndreas Gohr            // Default to Google I'm feeling lucky
830ccee93d9SPatrick Brown            $url      = 'https://www.google.com/search?q={URL}&amp;btnI=lucky';
8311f82fabeSAndreas Gohr            $shortcut = 'go';
8321f82fabeSAndreas Gohr        }
8332ea4044fSAndreas Gohr
8341f82fabeSAndreas Gohr        //split into hash and url part
83517e17ae2SPatrick Brown        $hash = strrchr($reference, '#');
83617e17ae2SPatrick Brown        if($hash) {
83717e17ae2SPatrick Brown            $reference = substr($reference, 0, -strlen($hash));
83817e17ae2SPatrick Brown            $hash = substr($hash, 1);
83917e17ae2SPatrick Brown        }
8401f82fabeSAndreas Gohr
8411f82fabeSAndreas Gohr        //replace placeholder
8421f82fabeSAndreas Gohr        if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
8431f82fabeSAndreas Gohr            //use placeholders
8441f82fabeSAndreas Gohr            $url    = str_replace('{URL}', rawurlencode($reference), $url);
84517e17ae2SPatrick Brown            //wiki names will be cleaned next, otherwise urlencode unsafe chars
84617e17ae2SPatrick Brown            $url    = str_replace('{NAME}', ($url{0} === ':') ? $reference :
84717e17ae2SPatrick Brown                                  preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) {
84817e17ae2SPatrick Brown                                    return rawurlencode($match[0]);
84917e17ae2SPatrick Brown                                  }, $reference), $url);
8501f82fabeSAndreas Gohr            $parsed = parse_url($reference);
8518f34cf3dSMichael Große            if (empty($parsed['scheme'])) $parsed['scheme'] = '';
8528f34cf3dSMichael Große            if (empty($parsed['host'])) $parsed['host'] = '';
8538f34cf3dSMichael Große            if (empty($parsed['port'])) $parsed['port'] = 80;
8548f34cf3dSMichael Große            if (empty($parsed['path'])) $parsed['path'] = '';
8558f34cf3dSMichael Große            if (empty($parsed['query'])) $parsed['query'] = '';
8568f34cf3dSMichael Große            $url = strtr($url,[
8578f34cf3dSMichael Große                '{SCHEME}' => $parsed['scheme'],
8588f34cf3dSMichael Große                '{HOST}' => $parsed['host'],
8598f34cf3dSMichael Große                '{PORT}' => $parsed['port'],
8608f34cf3dSMichael Große                '{PATH}' => $parsed['path'],
8618f34cf3dSMichael Große                '{QUERY}' => $parsed['query'] ,
8628f34cf3dSMichael Große            ]);
8631f82fabeSAndreas Gohr        } else {
8641f82fabeSAndreas Gohr            //default
8651f82fabeSAndreas Gohr            $url = $url.rawurlencode($reference);
8661f82fabeSAndreas Gohr        }
867f379edc2SGerrit Uitslag        //handle as wiki links
8686496c33fSGerrit Uitslag        if($url{0} === ':') {
869c55b109cSMichael Große            $urlparam = null;
870c55b109cSMichael Große            $id = $url;
871c55b109cSMichael Große            if (strpos($url, '?') !== false) {
8726496c33fSGerrit Uitslag                list($id, $urlparam) = explode('?', $url, 2);
873c55b109cSMichael Große            }
8746496c33fSGerrit Uitslag            $url    = wl(cleanID($id), $urlparam);
8756496c33fSGerrit Uitslag            $exists = page_exists($id);
8762345e871SGerrit Uitslag        }
8771f82fabeSAndreas Gohr        if($hash) $url .= '#'.rawurlencode($hash);
8781f82fabeSAndreas Gohr
8791f82fabeSAndreas Gohr        return $url;
8801f82fabeSAndreas Gohr    }
881cfa2b40eSAndreas Gohr
882cfa2b40eSAndreas Gohr    #endregion
8830cecf9d5Sandi}
8840cecf9d5Sandi
885340756e4Sandi
886e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
887