xref: /dokuwiki/inc/parser/renderer.php (revision 2401f18d305c5060bd60ef150d62bbf916c4e7c1)
10cecf9d5Sandi<?php
261faf446Schris/**
35587e44cSchris * Renderer output base class
461faf446Schris *
561faf446Schris * @author Harry Fuecks <hfuecks@gmail.com>
661faf446Schris * @author Andreas Gohr <andi@splitbrain.org>
761faf446Schris */
861faf446Schris
9e1d9dcc8SAndreas Gohruse dokuwiki\Extension\Plugin;
10e1d9dcc8SAndreas Gohruse dokuwiki\Extension\SyntaxPlugin;
11e1d9dcc8SAndreas Gohr
12863befa1SAndreas Gohr/**
1356bd9509SPhy * Allowed chars in $language for code highlighting
1456bd9509SPhy * @see GeSHi::set_language()
1556bd9509SPhy */
1656bd9509SPhydefine('PREG_PATTERN_VALID_LANGUAGE', '#[^a-zA-Z0-9\-_]#');
1756bd9509SPhy
1856bd9509SPhy/**
19863befa1SAndreas Gohr * An empty renderer, produces no output
20863befa1SAndreas Gohr *
21e1d9dcc8SAndreas Gohr * Inherits from dokuwiki\Plugin\DokuWiki_Plugin for giving additional functions to render plugins
228e3a5477SAndreas Gohr *
238e3a5477SAndreas Gohr * The renderer transforms the syntax instructions created by the parser and handler into the
248e3a5477SAndreas Gohr * desired output format. For each instruction a corresponding method defined in this class will
258e3a5477SAndreas Gohr * be called. That method needs to produce the desired output for the instruction and add it to the
268e3a5477SAndreas Gohr * $doc field. When all instructions are processed, the $doc field contents will be cached by
278e3a5477SAndreas Gohr * DokuWiki and sent to the user.
28863befa1SAndreas Gohr */
29e1d9dcc8SAndreas Gohrabstract class Doku_Renderer extends Plugin {
30cfa2b40eSAndreas Gohr    /** @var array Settings, control the behavior of the renderer */
31cfa2b40eSAndreas Gohr    public $info = array(
3244881bd0Shenning.noren        'cache' => true, // may the rendered result cached?
3344881bd0Shenning.noren        'toc'   => true, // render the TOC?
349dc2c2afSandi    );
359dc2c2afSandi
36cfa2b40eSAndreas Gohr    /** @var array contains the smiley configuration, set in p_render() */
37cfa2b40eSAndreas Gohr    public $smileys = array();
38cfa2b40eSAndreas Gohr    /** @var array contains the entity configuration, set in p_render() */
39cfa2b40eSAndreas Gohr    public $entities = array();
40cfa2b40eSAndreas Gohr    /** @var array contains the acronym configuration, set in p_render() */
41cfa2b40eSAndreas Gohr    public $acronyms = array();
42cfa2b40eSAndreas Gohr    /** @var array contains the interwiki configuration, set in p_render() */
43cfa2b40eSAndreas Gohr    public $interwiki = array();
44e41c4da9SAndreas Gohr
45de369923SAndreas Gohr    /** @var array the list of headers used to create unique link ids */
46de369923SAndreas Gohr    protected $headers = array();
47de369923SAndreas Gohr
485f70445dSAndreas Gohr    /**
49cfa2b40eSAndreas Gohr     * @var string the rendered document, this will be cached after the renderer ran through
505f70445dSAndreas Gohr     */
51cfa2b40eSAndreas Gohr    public $doc = '';
52cfa2b40eSAndreas Gohr
53cfa2b40eSAndreas Gohr    /**
54cfa2b40eSAndreas Gohr     * clean out any per-use values
55cfa2b40eSAndreas Gohr     *
56cfa2b40eSAndreas Gohr     * This is called before each use of the renderer object and should be used to
57cfa2b40eSAndreas Gohr     * completely reset the state of the renderer to be reused for a new document
58cfa2b40eSAndreas Gohr     */
59de369923SAndreas Gohr    public function reset(){
60de369923SAndreas Gohr        $this->headers = array();
61abaaba9aSSatoshi Sahara        $this->doc           = '';
62abaaba9aSSatoshi Sahara        $this->info['cache'] = true;
63abaaba9aSSatoshi Sahara        $this->info['toc']   = true;
645f70445dSAndreas Gohr    }
655f70445dSAndreas Gohr
66f6ec8df8SAdrian Lang    /**
67f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
68f6ec8df8SAdrian Lang     *
69cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
70cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
71cfa2b40eSAndreas Gohr     *
72f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
73f6ec8df8SAdrian Lang     */
74de369923SAndreas Gohr    public function isSingleton() {
75f6ec8df8SAdrian Lang        return false;
76f6ec8df8SAdrian Lang    }
77f6ec8df8SAdrian Lang
788cc41db0SAndreas Gohr    /**
79cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
80cfa2b40eSAndreas Gohr     *
81cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
82cfa2b40eSAndreas Gohr     *
83cfa2b40eSAndreas Gohr     * @return string
84cfa2b40eSAndreas Gohr     */
85de369923SAndreas Gohr    abstract public function getFormat();
86cfa2b40eSAndreas Gohr
87cfa2b40eSAndreas Gohr    /**
88cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
89cfa2b40eSAndreas Gohr     */
90e1cdd96cSAndreas Gohr    public function nocache() {
91cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
92cfa2b40eSAndreas Gohr    }
93cfa2b40eSAndreas Gohr
94cfa2b40eSAndreas Gohr    /**
95cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
96cfa2b40eSAndreas Gohr     *
97cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
98cfa2b40eSAndreas Gohr     */
99e1cdd96cSAndreas Gohr    public function notoc() {
100cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
101cfa2b40eSAndreas Gohr    }
102cfa2b40eSAndreas Gohr
103cfa2b40eSAndreas Gohr    /**
104cfa2b40eSAndreas Gohr     * Handle plugin rendering
105cfa2b40eSAndreas Gohr     *
106cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
1078cc41db0SAndreas Gohr     *
1088cc41db0SAndreas Gohr     * @param string $name  Plugin name
1098cc41db0SAndreas Gohr     * @param mixed  $data  custom data set by handler
1108cc41db0SAndreas Gohr     * @param string $state matched state if any
1118cc41db0SAndreas Gohr     * @param string $match raw matched syntax
1128cc41db0SAndreas Gohr     */
113de369923SAndreas Gohr    public function plugin($name, $data, $state = '', $match = '') {
114e1d9dcc8SAndreas Gohr        /** @var SyntaxPlugin $plugin */
115e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
11661faf446Schris        if($plugin != null) {
1175f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
11861faf446Schris        }
11961faf446Schris    }
12061faf446Schris
1215587e44cSchris    /**
1225587e44cSchris     * handle nested render instructions
1235587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
124cfa2b40eSAndreas Gohr     *
125cfa2b40eSAndreas Gohr     * @param array $instructions
1265587e44cSchris     */
127de369923SAndreas Gohr    public function nest($instructions) {
1285587e44cSchris        foreach($instructions as $instruction) {
1295587e44cSchris            // execute the callback against ourself
130c2122b83SChristopher Smith            if(method_exists($this, $instruction[0])) {
131d6a1a955SAndreas Gohr                call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
132c2122b83SChristopher Smith            }
1335587e44cSchris        }
1345587e44cSchris    }
1355587e44cSchris
136cfa2b40eSAndreas Gohr    /**
137cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
138cfa2b40eSAndreas Gohr     *
139cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
140cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
141cfa2b40eSAndreas Gohr     */
142de369923SAndreas Gohr    public function nest_close() {
1432c2835c2SAndreas Gohr    }
1445587e44cSchris
145cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
146cfa2b40eSAndreas Gohr
147cfa2b40eSAndreas Gohr    /**
148cfa2b40eSAndreas Gohr     * Initialize the document
149cfa2b40eSAndreas Gohr     */
150de369923SAndreas Gohr    public function document_start() {
1512c2835c2SAndreas Gohr    }
1520cecf9d5Sandi
153cfa2b40eSAndreas Gohr    /**
154cfa2b40eSAndreas Gohr     * Finalize the document
155cfa2b40eSAndreas Gohr     */
156de369923SAndreas Gohr    public function document_end() {
1572c2835c2SAndreas Gohr    }
1580cecf9d5Sandi
159cfa2b40eSAndreas Gohr    /**
160cfa2b40eSAndreas Gohr     * Render the Table of Contents
161cfa2b40eSAndreas Gohr     *
162cfa2b40eSAndreas Gohr     * @return string
163cfa2b40eSAndreas Gohr     */
164de369923SAndreas Gohr    public function render_TOC() {
1652c2835c2SAndreas Gohr        return '';
1662c2835c2SAndreas Gohr    }
1670cecf9d5Sandi
168cfa2b40eSAndreas Gohr    /**
169cfa2b40eSAndreas Gohr     * Add an item to the TOC
170cfa2b40eSAndreas Gohr     *
171cfa2b40eSAndreas Gohr     * @param string $id       the hash link
172cfa2b40eSAndreas Gohr     * @param string $text     the text to display
173cfa2b40eSAndreas Gohr     * @param int    $level    the nesting level
174cfa2b40eSAndreas Gohr     */
175de369923SAndreas Gohr    public function toc_additem($id, $text, $level) {
1762c2835c2SAndreas Gohr    }
177e7856beaSchris
178cfa2b40eSAndreas Gohr    /**
179cfa2b40eSAndreas Gohr     * Render a heading
180cfa2b40eSAndreas Gohr     *
181cfa2b40eSAndreas Gohr     * @param string $text  the text to display
182cfa2b40eSAndreas Gohr     * @param int    $level header level
183cfa2b40eSAndreas Gohr     * @param int    $pos   byte position in the original source
184cfa2b40eSAndreas Gohr     */
185de369923SAndreas Gohr    public function header($text, $level, $pos) {
1862c2835c2SAndreas Gohr    }
1870cecf9d5Sandi
188cfa2b40eSAndreas Gohr    /**
189cfa2b40eSAndreas Gohr     * Open a new section
190cfa2b40eSAndreas Gohr     *
191cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
192cfa2b40eSAndreas Gohr     */
193de369923SAndreas Gohr    public function section_open($level) {
1942c2835c2SAndreas Gohr    }
1950cecf9d5Sandi
196cfa2b40eSAndreas Gohr    /**
197cfa2b40eSAndreas Gohr     * Close the current section
198cfa2b40eSAndreas Gohr     */
199de369923SAndreas Gohr    public function section_close() {
2002c2835c2SAndreas Gohr    }
2010cecf9d5Sandi
202cfa2b40eSAndreas Gohr    /**
203cfa2b40eSAndreas Gohr     * Render plain text data
204cfa2b40eSAndreas Gohr     *
20542ea7f44SGerrit Uitslag     * @param string $text
206cfa2b40eSAndreas Gohr     */
207de369923SAndreas Gohr    public function cdata($text) {
2082c2835c2SAndreas Gohr    }
2090cecf9d5Sandi
210cfa2b40eSAndreas Gohr    /**
211cfa2b40eSAndreas Gohr     * Open a paragraph
212cfa2b40eSAndreas Gohr     */
213de369923SAndreas Gohr    public function p_open() {
2142c2835c2SAndreas Gohr    }
2150cecf9d5Sandi
216cfa2b40eSAndreas Gohr    /**
217cfa2b40eSAndreas Gohr     * Close a paragraph
218cfa2b40eSAndreas Gohr     */
219de369923SAndreas Gohr    public function p_close() {
2202c2835c2SAndreas Gohr    }
2210cecf9d5Sandi
222cfa2b40eSAndreas Gohr    /**
2233dd5c225SAndreas Gohr     * Create a line break
224cfa2b40eSAndreas Gohr     */
225de369923SAndreas Gohr    public function linebreak() {
2262c2835c2SAndreas Gohr    }
2270cecf9d5Sandi
228cfa2b40eSAndreas Gohr    /**
229cfa2b40eSAndreas Gohr     * Create a horizontal line
230cfa2b40eSAndreas Gohr     */
231de369923SAndreas Gohr    public function hr() {
2322c2835c2SAndreas Gohr    }
2330cecf9d5Sandi
234cfa2b40eSAndreas Gohr    /**
235cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
236cfa2b40eSAndreas Gohr     */
237de369923SAndreas Gohr    public function strong_open() {
2382c2835c2SAndreas Gohr    }
2390cecf9d5Sandi
240cfa2b40eSAndreas Gohr    /**
241cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
242cfa2b40eSAndreas Gohr     */
243de369923SAndreas Gohr    public function strong_close() {
2442c2835c2SAndreas Gohr    }
2450cecf9d5Sandi
246cfa2b40eSAndreas Gohr    /**
247cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
248cfa2b40eSAndreas Gohr     */
249de369923SAndreas Gohr    public function emphasis_open() {
2502c2835c2SAndreas Gohr    }
2510cecf9d5Sandi
252cfa2b40eSAndreas Gohr    /**
253cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
254cfa2b40eSAndreas Gohr     */
255de369923SAndreas Gohr    public function emphasis_close() {
2562c2835c2SAndreas Gohr    }
2570cecf9d5Sandi
258cfa2b40eSAndreas Gohr    /**
259cfa2b40eSAndreas Gohr     * Start underline formatting
260cfa2b40eSAndreas Gohr     */
261de369923SAndreas Gohr    public function underline_open() {
2622c2835c2SAndreas Gohr    }
2630cecf9d5Sandi
264cfa2b40eSAndreas Gohr    /**
265cfa2b40eSAndreas Gohr     * Stop underline formatting
266cfa2b40eSAndreas Gohr     */
267de369923SAndreas Gohr    public function underline_close() {
2682c2835c2SAndreas Gohr    }
2690cecf9d5Sandi
270cfa2b40eSAndreas Gohr    /**
271cfa2b40eSAndreas Gohr     * Start monospace formatting
272cfa2b40eSAndreas Gohr     */
273de369923SAndreas Gohr    public function monospace_open() {
2742c2835c2SAndreas Gohr    }
2750cecf9d5Sandi
276cfa2b40eSAndreas Gohr    /**
277cfa2b40eSAndreas Gohr     * Stop monospace formatting
278cfa2b40eSAndreas Gohr     */
279de369923SAndreas Gohr    public function monospace_close() {
2802c2835c2SAndreas Gohr    }
2810cecf9d5Sandi
282cfa2b40eSAndreas Gohr    /**
283cfa2b40eSAndreas Gohr     * Start a subscript
284cfa2b40eSAndreas Gohr     */
285de369923SAndreas Gohr    public function subscript_open() {
2862c2835c2SAndreas Gohr    }
2870cecf9d5Sandi
288cfa2b40eSAndreas Gohr    /**
289cfa2b40eSAndreas Gohr     * Stop a subscript
290cfa2b40eSAndreas Gohr     */
291de369923SAndreas Gohr    public function subscript_close() {
2922c2835c2SAndreas Gohr    }
2930cecf9d5Sandi
294cfa2b40eSAndreas Gohr    /**
295cfa2b40eSAndreas Gohr     * Start a superscript
296cfa2b40eSAndreas Gohr     */
297de369923SAndreas Gohr    public function superscript_open() {
2982c2835c2SAndreas Gohr    }
2990cecf9d5Sandi
300cfa2b40eSAndreas Gohr    /**
301cfa2b40eSAndreas Gohr     * Stop a superscript
302cfa2b40eSAndreas Gohr     */
303de369923SAndreas Gohr    public function superscript_close() {
3042c2835c2SAndreas Gohr    }
3050cecf9d5Sandi
306cfa2b40eSAndreas Gohr    /**
307cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
308cfa2b40eSAndreas Gohr     */
309de369923SAndreas Gohr    public function deleted_open() {
3102c2835c2SAndreas Gohr    }
3110cecf9d5Sandi
312cfa2b40eSAndreas Gohr    /**
313cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
314cfa2b40eSAndreas Gohr     */
315de369923SAndreas Gohr    public function deleted_close() {
3162c2835c2SAndreas Gohr    }
3170cecf9d5Sandi
318cfa2b40eSAndreas Gohr    /**
319cfa2b40eSAndreas Gohr     * Start a footnote
320cfa2b40eSAndreas Gohr     */
321de369923SAndreas Gohr    public function footnote_open() {
3222c2835c2SAndreas Gohr    }
3230cecf9d5Sandi
324cfa2b40eSAndreas Gohr    /**
325cfa2b40eSAndreas Gohr     * Stop a footnote
326cfa2b40eSAndreas Gohr     */
327de369923SAndreas Gohr    public function footnote_close() {
3282c2835c2SAndreas Gohr    }
3290cecf9d5Sandi
330cfa2b40eSAndreas Gohr    /**
331cfa2b40eSAndreas Gohr     * Open an unordered list
332cfa2b40eSAndreas Gohr     */
333de369923SAndreas Gohr    public function listu_open() {
3342c2835c2SAndreas Gohr    }
3350cecf9d5Sandi
336cfa2b40eSAndreas Gohr    /**
337cfa2b40eSAndreas Gohr     * Close an unordered list
338cfa2b40eSAndreas Gohr     */
339de369923SAndreas Gohr    public function listu_close() {
3402c2835c2SAndreas Gohr    }
3410cecf9d5Sandi
342cfa2b40eSAndreas Gohr    /**
343cfa2b40eSAndreas Gohr     * Open an ordered list
344cfa2b40eSAndreas Gohr     */
345de369923SAndreas Gohr    public function listo_open() {
3462c2835c2SAndreas Gohr    }
3470cecf9d5Sandi
348cfa2b40eSAndreas Gohr    /**
349cfa2b40eSAndreas Gohr     * Close an ordered list
350cfa2b40eSAndreas Gohr     */
351de369923SAndreas Gohr    public function listo_close() {
3522c2835c2SAndreas Gohr    }
3530cecf9d5Sandi
354cfa2b40eSAndreas Gohr    /**
355cfa2b40eSAndreas Gohr     * Open a list item
356cfa2b40eSAndreas Gohr     *
357cfa2b40eSAndreas Gohr     * @param int $level the nesting level
358e3a24861SChristopher Smith     * @param bool $node true when a node; false when a leaf
359cfa2b40eSAndreas Gohr     */
360de369923SAndreas Gohr    public function listitem_open($level,$node=false) {
3612c2835c2SAndreas Gohr    }
3620cecf9d5Sandi
363cfa2b40eSAndreas Gohr    /**
364cfa2b40eSAndreas Gohr     * Close a list item
365cfa2b40eSAndreas Gohr     */
366de369923SAndreas Gohr    public function listitem_close() {
3672c2835c2SAndreas Gohr    }
3680cecf9d5Sandi
369cfa2b40eSAndreas Gohr    /**
370cfa2b40eSAndreas Gohr     * Start the content of a list item
371cfa2b40eSAndreas Gohr     */
372de369923SAndreas Gohr    public function listcontent_open() {
3732c2835c2SAndreas Gohr    }
3740cecf9d5Sandi
375cfa2b40eSAndreas Gohr    /**
376cfa2b40eSAndreas Gohr     * Stop the content of a list item
377cfa2b40eSAndreas Gohr     */
378de369923SAndreas Gohr    public function listcontent_close() {
3792c2835c2SAndreas Gohr    }
3800cecf9d5Sandi
381cfa2b40eSAndreas Gohr    /**
382cfa2b40eSAndreas Gohr     * Output unformatted $text
383cfa2b40eSAndreas Gohr     *
384cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
385cfa2b40eSAndreas Gohr     *
386cfa2b40eSAndreas Gohr     * @param string $text
387cfa2b40eSAndreas Gohr     */
388de369923SAndreas Gohr    public function unformatted($text) {
389cfa2b40eSAndreas Gohr        $this->cdata($text);
3902c2835c2SAndreas Gohr    }
3910cecf9d5Sandi
392cfa2b40eSAndreas Gohr    /**
393cfa2b40eSAndreas Gohr     * Output inline PHP code
394cfa2b40eSAndreas Gohr     *
395cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
396cfa2b40eSAndreas Gohr     * to $doc
397cfa2b40eSAndreas Gohr     *
398cfa2b40eSAndreas Gohr     * @param string $text The PHP code
399cfa2b40eSAndreas Gohr     */
400de369923SAndreas Gohr    public function php($text) {
4012c2835c2SAndreas Gohr    }
4020cecf9d5Sandi
403cfa2b40eSAndreas Gohr    /**
404cfa2b40eSAndreas Gohr     * Output block level PHP code
405cfa2b40eSAndreas Gohr     *
406cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
407cfa2b40eSAndreas Gohr     * to $doc
408cfa2b40eSAndreas Gohr     *
409cfa2b40eSAndreas Gohr     * @param string $text The PHP code
410cfa2b40eSAndreas Gohr     */
411de369923SAndreas Gohr    public function phpblock($text) {
4122c2835c2SAndreas Gohr    }
41307f89c3cSAnika Henke
414cfa2b40eSAndreas Gohr    /**
415cfa2b40eSAndreas Gohr     * Output raw inline HTML
416cfa2b40eSAndreas Gohr     *
417cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
418cfa2b40eSAndreas Gohr     *
419cfa2b40eSAndreas Gohr     * @param string $text The HTML
420cfa2b40eSAndreas Gohr     */
421de369923SAndreas Gohr    public function html($text) {
4222c2835c2SAndreas Gohr    }
4230cecf9d5Sandi
424cfa2b40eSAndreas Gohr    /**
425cfa2b40eSAndreas Gohr     * Output raw block-level HTML
426cfa2b40eSAndreas Gohr     *
427cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
428cfa2b40eSAndreas Gohr     *
429cfa2b40eSAndreas Gohr     * @param string $text The HTML
430cfa2b40eSAndreas Gohr     */
431de369923SAndreas Gohr    public function htmlblock($text) {
4322c2835c2SAndreas Gohr    }
43307f89c3cSAnika Henke
434cfa2b40eSAndreas Gohr    /**
435cfa2b40eSAndreas Gohr     * Output preformatted text
436cfa2b40eSAndreas Gohr     *
437cfa2b40eSAndreas Gohr     * @param string $text
438cfa2b40eSAndreas Gohr     */
439de369923SAndreas Gohr    public function preformatted($text) {
4402c2835c2SAndreas Gohr    }
4410cecf9d5Sandi
442cfa2b40eSAndreas Gohr    /**
443cfa2b40eSAndreas Gohr     * Start a block quote
444cfa2b40eSAndreas Gohr     */
445de369923SAndreas Gohr    public function quote_open() {
4462c2835c2SAndreas Gohr    }
4470cecf9d5Sandi
448cfa2b40eSAndreas Gohr    /**
449cfa2b40eSAndreas Gohr     * Stop a block quote
450cfa2b40eSAndreas Gohr     */
451de369923SAndreas Gohr    public function quote_close() {
4522c2835c2SAndreas Gohr    }
4530cecf9d5Sandi
454cfa2b40eSAndreas Gohr    /**
455cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
456cfa2b40eSAndreas Gohr     *
457cfa2b40eSAndreas Gohr     * @param string $text text to show
458cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
459cfa2b40eSAndreas Gohr     * @param string $file file path label
460cfa2b40eSAndreas Gohr     */
461de369923SAndreas Gohr    public function file($text, $lang = null, $file = null) {
4622c2835c2SAndreas Gohr    }
4633d491f75SAndreas Gohr
464cfa2b40eSAndreas Gohr    /**
465cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
466cfa2b40eSAndreas Gohr     *
467cfa2b40eSAndreas Gohr     * @param string $text text to show
468cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
469cfa2b40eSAndreas Gohr     * @param string $file file path label
470cfa2b40eSAndreas Gohr     */
471de369923SAndreas Gohr    public function code($text, $lang = null, $file = null) {
4722c2835c2SAndreas Gohr    }
4730cecf9d5Sandi
474cfa2b40eSAndreas Gohr    /**
475cfa2b40eSAndreas Gohr     * Format an acronym
476cfa2b40eSAndreas Gohr     *
477cfa2b40eSAndreas Gohr     * Uses $this->acronyms
478cfa2b40eSAndreas Gohr     *
479cfa2b40eSAndreas Gohr     * @param string $acronym
480cfa2b40eSAndreas Gohr     */
481de369923SAndreas Gohr    public function acronym($acronym) {
4822c2835c2SAndreas Gohr    }
4830cecf9d5Sandi
484cfa2b40eSAndreas Gohr    /**
485cfa2b40eSAndreas Gohr     * Format a smiley
486cfa2b40eSAndreas Gohr     *
487cfa2b40eSAndreas Gohr     * Uses $this->smiley
488cfa2b40eSAndreas Gohr     *
489cfa2b40eSAndreas Gohr     * @param string $smiley
490cfa2b40eSAndreas Gohr     */
491de369923SAndreas Gohr    public function smiley($smiley) {
4922c2835c2SAndreas Gohr    }
4930cecf9d5Sandi
494cfa2b40eSAndreas Gohr    /**
495cfa2b40eSAndreas Gohr     * Format an entity
496cfa2b40eSAndreas Gohr     *
497cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
498cfa2b40eSAndreas Gohr     *
499cfa2b40eSAndreas Gohr     * Uses $this->entities
500cfa2b40eSAndreas Gohr     *
501cfa2b40eSAndreas Gohr     * @param string $entity
502cfa2b40eSAndreas Gohr     */
503de369923SAndreas Gohr    public function entity($entity) {
5042c2835c2SAndreas Gohr    }
5050cecf9d5Sandi
506cfa2b40eSAndreas Gohr    /**
507cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
508cfa2b40eSAndreas Gohr     *
509cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
510cfa2b40eSAndreas Gohr     *
511cfa2b40eSAndreas Gohr     * @param string|int $x first value
512cfa2b40eSAndreas Gohr     * @param string|int $y second value
513cfa2b40eSAndreas Gohr     */
514de369923SAndreas Gohr    public function multiplyentity($x, $y) {
5152c2835c2SAndreas Gohr    }
5160cecf9d5Sandi
517cfa2b40eSAndreas Gohr    /**
518cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
519cfa2b40eSAndreas Gohr     */
520de369923SAndreas Gohr    public function singlequoteopening() {
5212c2835c2SAndreas Gohr    }
5220cecf9d5Sandi
523cfa2b40eSAndreas Gohr    /**
524cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
525cfa2b40eSAndreas Gohr     */
526de369923SAndreas Gohr    public function singlequoteclosing() {
5272c2835c2SAndreas Gohr    }
5280cecf9d5Sandi
529cfa2b40eSAndreas Gohr    /**
530cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
531cfa2b40eSAndreas Gohr     */
532de369923SAndreas Gohr    public function apostrophe() {
5332c2835c2SAndreas Gohr    }
53457d757d1SAndreas Gohr
535cfa2b40eSAndreas Gohr    /**
536cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
537cfa2b40eSAndreas Gohr     */
538de369923SAndreas Gohr    public function doublequoteopening() {
5392c2835c2SAndreas Gohr    }
5400cecf9d5Sandi
541cfa2b40eSAndreas Gohr    /**
542cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
543cfa2b40eSAndreas Gohr     */
544de369923SAndreas Gohr    public function doublequoteclosing() {
5452c2835c2SAndreas Gohr    }
5460cecf9d5Sandi
547cfa2b40eSAndreas Gohr    /**
548cfa2b40eSAndreas Gohr     * Render a CamelCase link
549cfa2b40eSAndreas Gohr     *
550cfa2b40eSAndreas Gohr     * @param string $link The link name
551cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
552cfa2b40eSAndreas Gohr     */
553de369923SAndreas Gohr    public function camelcaselink($link) {
5542c2835c2SAndreas Gohr    }
5550cecf9d5Sandi
556cfa2b40eSAndreas Gohr    /**
557cfa2b40eSAndreas Gohr     * Render a page local link
558cfa2b40eSAndreas Gohr     *
559cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
560cfa2b40eSAndreas Gohr     * @param string $name name for the link
561cfa2b40eSAndreas Gohr     */
562de369923SAndreas Gohr    public function locallink($hash, $name = null) {
5632c2835c2SAndreas Gohr    }
564a939d432SAndreas Gohr
565cfa2b40eSAndreas Gohr    /**
566cfa2b40eSAndreas Gohr     * Render a wiki internal link
567cfa2b40eSAndreas Gohr     *
568cfa2b40eSAndreas Gohr     * @param string       $link  page ID to link to. eg. 'wiki:syntax'
569cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
570cfa2b40eSAndreas Gohr     */
571de369923SAndreas Gohr    public function internallink($link, $title = null) {
5722c2835c2SAndreas Gohr    }
5730cecf9d5Sandi
574cfa2b40eSAndreas Gohr    /**
575cfa2b40eSAndreas Gohr     * Render an external link
576cfa2b40eSAndreas Gohr     *
577cfa2b40eSAndreas Gohr     * @param string       $link  full URL with scheme
578cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
579cfa2b40eSAndreas Gohr     */
580de369923SAndreas Gohr    public function externallink($link, $title = null) {
5812c2835c2SAndreas Gohr    }
5820cecf9d5Sandi
583cfa2b40eSAndreas Gohr    /**
584cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
585cfa2b40eSAndreas Gohr     *
586cfa2b40eSAndreas Gohr     * @param string $url    URL of the feed
587cfa2b40eSAndreas Gohr     * @param array  $params Finetuning of the output
588cfa2b40eSAndreas Gohr     */
589de369923SAndreas Gohr    public function rss($url, $params) {
5902c2835c2SAndreas Gohr    }
591c5cfca61SAndreas Gohr
592cfa2b40eSAndreas Gohr    /**
593cfa2b40eSAndreas Gohr     * Render an interwiki link
594cfa2b40eSAndreas Gohr     *
595cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
596cfa2b40eSAndreas Gohr     *
597cfa2b40eSAndreas Gohr     * @param string       $link     original link - probably not much use
598cfa2b40eSAndreas Gohr     * @param string|array $title    name for the link, array for media file
599cfa2b40eSAndreas Gohr     * @param string       $wikiName indentifier (shortcut) for the remote wiki
600cfa2b40eSAndreas Gohr     * @param string       $wikiUri  the fragment parsed from the original link
601cfa2b40eSAndreas Gohr     */
602de369923SAndreas Gohr    public function interwikilink($link, $title, $wikiName, $wikiUri) {
6032c2835c2SAndreas Gohr    }
6040cecf9d5Sandi
605cfa2b40eSAndreas Gohr    /**
606cfa2b40eSAndreas Gohr     * Link to file on users OS
607cfa2b40eSAndreas Gohr     *
608cfa2b40eSAndreas Gohr     * @param string       $link  the link
609cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
610cfa2b40eSAndreas Gohr     */
611de369923SAndreas Gohr    public function filelink($link, $title = null) {
6122c2835c2SAndreas Gohr    }
6130cecf9d5Sandi
614cfa2b40eSAndreas Gohr    /**
615cfa2b40eSAndreas Gohr     * Link to windows share
616cfa2b40eSAndreas Gohr     *
617cfa2b40eSAndreas Gohr     * @param string       $link  the link
618cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
619cfa2b40eSAndreas Gohr     */
620de369923SAndreas Gohr    public function windowssharelink($link, $title = null) {
6212c2835c2SAndreas Gohr    }
6220cecf9d5Sandi
623cfa2b40eSAndreas Gohr    /**
624cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
625cfa2b40eSAndreas Gohr     *
626cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
627cfa2b40eSAndreas Gohr     *
628cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6293dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
630cfa2b40eSAndreas Gohr     */
631de369923SAndreas Gohr    public function emaillink($address, $name = null) {
6322c2835c2SAndreas Gohr    }
6330cecf9d5Sandi
634cfa2b40eSAndreas Gohr    /**
635cfa2b40eSAndreas Gohr     * Render an internal media file
636cfa2b40eSAndreas Gohr     *
637cfa2b40eSAndreas Gohr     * @param string $src     media ID
638cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
639cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
640cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
641cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
642cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
643cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
644cfa2b40eSAndreas Gohr     */
645de369923SAndreas Gohr    public function internalmedia($src, $title = null, $align = null, $width = null,
6462c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6472c2835c2SAndreas Gohr    }
648a939d432SAndreas Gohr
649cfa2b40eSAndreas Gohr    /**
650cfa2b40eSAndreas Gohr     * Render an external media file
651cfa2b40eSAndreas Gohr     *
652cfa2b40eSAndreas Gohr     * @param string $src     full media URL
653cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
654cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
655cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
656cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
657cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
658cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
659cfa2b40eSAndreas Gohr     */
660de369923SAndreas Gohr    public function externalmedia($src, $title = null, $align = null, $width = null,
6612c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6622c2835c2SAndreas Gohr    }
663a939d432SAndreas Gohr
664cfa2b40eSAndreas Gohr    /**
665cfa2b40eSAndreas Gohr     * Render a link to an internal media file
666cfa2b40eSAndreas Gohr     *
667cfa2b40eSAndreas Gohr     * @param string $src     media ID
668cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
669cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
670cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
671cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
672cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
673cfa2b40eSAndreas Gohr     */
674de369923SAndreas Gohr    public function internalmedialink($src, $title = null, $align = null,
675cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6762c2835c2SAndreas Gohr    }
6770cecf9d5Sandi
678cfa2b40eSAndreas Gohr    /**
679cfa2b40eSAndreas Gohr     * Render a link to an external media file
680cfa2b40eSAndreas Gohr     *
681cfa2b40eSAndreas Gohr     * @param string $src     media ID
682cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
683cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
684cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
685cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
686cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
687cfa2b40eSAndreas Gohr     */
688de369923SAndreas Gohr    public function externalmedialink($src, $title = null, $align = null,
689cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6902c2835c2SAndreas Gohr    }
6910cecf9d5Sandi
692cfa2b40eSAndreas Gohr    /**
693cfa2b40eSAndreas Gohr     * Start a table
694cfa2b40eSAndreas Gohr     *
695cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
696cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
697cfa2b40eSAndreas Gohr     * @param int $pos     byte position in the original source
698cfa2b40eSAndreas Gohr     */
699de369923SAndreas Gohr    public function table_open($maxcols = null, $numrows = null, $pos = null) {
7002c2835c2SAndreas Gohr    }
7010cecf9d5Sandi
702cfa2b40eSAndreas Gohr    /**
703cfa2b40eSAndreas Gohr     * Close a table
704cfa2b40eSAndreas Gohr     *
705cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
706cfa2b40eSAndreas Gohr     */
707de369923SAndreas Gohr    public function table_close($pos = null) {
7082c2835c2SAndreas Gohr    }
7090cecf9d5Sandi
710cfa2b40eSAndreas Gohr    /**
711cfa2b40eSAndreas Gohr     * Open a table header
712cfa2b40eSAndreas Gohr     */
713de369923SAndreas Gohr    public function tablethead_open() {
7142c2835c2SAndreas Gohr    }
715f05a1cc5SGerrit Uitslag
716cfa2b40eSAndreas Gohr    /**
717cfa2b40eSAndreas Gohr     * Close a table header
718cfa2b40eSAndreas Gohr     */
719de369923SAndreas Gohr    public function tablethead_close() {
7202c2835c2SAndreas Gohr    }
721f05a1cc5SGerrit Uitslag
722cfa2b40eSAndreas Gohr    /**
7235a93f869SAnika Henke     * Open a table body
7245a93f869SAnika Henke     */
725de369923SAndreas Gohr    public function tabletbody_open() {
7265a93f869SAnika Henke    }
7275a93f869SAnika Henke
7285a93f869SAnika Henke    /**
7295a93f869SAnika Henke     * Close a table body
7305a93f869SAnika Henke     */
731de369923SAndreas Gohr    public function tabletbody_close() {
7325a93f869SAnika Henke    }
7335a93f869SAnika Henke
7345a93f869SAnika Henke    /**
735d2a99739SAndreas Gohr     * Open a table footer
736d2a99739SAndreas Gohr     */
737de369923SAndreas Gohr    public function tabletfoot_open() {
738d2a99739SAndreas Gohr    }
739d2a99739SAndreas Gohr
740d2a99739SAndreas Gohr    /**
741d2a99739SAndreas Gohr     * Close a table footer
742d2a99739SAndreas Gohr     */
743de369923SAndreas Gohr    public function tabletfoot_close() {
744d2a99739SAndreas Gohr    }
745d2a99739SAndreas Gohr
746d2a99739SAndreas Gohr    /**
747cfa2b40eSAndreas Gohr     * Open a table row
748cfa2b40eSAndreas Gohr     */
749de369923SAndreas Gohr    public function tablerow_open() {
7502c2835c2SAndreas Gohr    }
7510cecf9d5Sandi
752cfa2b40eSAndreas Gohr    /**
753cfa2b40eSAndreas Gohr     * Close a table row
754cfa2b40eSAndreas Gohr     */
755de369923SAndreas Gohr    public function tablerow_close() {
7562c2835c2SAndreas Gohr    }
7570cecf9d5Sandi
758cfa2b40eSAndreas Gohr    /**
759cfa2b40eSAndreas Gohr     * Open a table header cell
760cfa2b40eSAndreas Gohr     *
761cfa2b40eSAndreas Gohr     * @param int    $colspan
762cfa2b40eSAndreas Gohr     * @param string $align left|center|right
763cfa2b40eSAndreas Gohr     * @param int    $rowspan
764cfa2b40eSAndreas Gohr     */
765de369923SAndreas Gohr    public function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
7662c2835c2SAndreas Gohr    }
7670cecf9d5Sandi
768cfa2b40eSAndreas Gohr    /**
769cfa2b40eSAndreas Gohr     * Close a table header cell
770cfa2b40eSAndreas Gohr     */
771de369923SAndreas Gohr    public function tableheader_close() {
7722c2835c2SAndreas Gohr    }
7730cecf9d5Sandi
774cfa2b40eSAndreas Gohr    /**
775cfa2b40eSAndreas Gohr     * Open a table cell
776cfa2b40eSAndreas Gohr     *
777cfa2b40eSAndreas Gohr     * @param int    $colspan
778cfa2b40eSAndreas Gohr     * @param string $align left|center|right
779cfa2b40eSAndreas Gohr     * @param int    $rowspan
780cfa2b40eSAndreas Gohr     */
781de369923SAndreas Gohr    public function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
7822c2835c2SAndreas Gohr    }
7830cecf9d5Sandi
784cfa2b40eSAndreas Gohr    /**
785cfa2b40eSAndreas Gohr     * Close a table cell
786cfa2b40eSAndreas Gohr     */
787de369923SAndreas Gohr    public function tablecell_close() {
7882c2835c2SAndreas Gohr    }
7892ea4044fSAndreas Gohr
790cfa2b40eSAndreas Gohr    #endregion
791cfa2b40eSAndreas Gohr
792cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
7932ea4044fSAndreas Gohr
7942ea4044fSAndreas Gohr    /**
795de369923SAndreas Gohr     * Creates a linkid from a headline
796de369923SAndreas Gohr     *
797de369923SAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
798de369923SAndreas Gohr     * @param string  $title   The headline title
799de369923SAndreas Gohr     * @param boolean $create  Create a new unique ID?
800de369923SAndreas Gohr     * @return string
801de369923SAndreas Gohr     */
802de369923SAndreas Gohr    public function _headerToLink($title, $create = false) {
803de369923SAndreas Gohr        if($create) {
804de369923SAndreas Gohr            return sectionID($title, $this->headers);
805de369923SAndreas Gohr        } else {
806de369923SAndreas Gohr            $check = false;
807de369923SAndreas Gohr            return sectionID($title, $check);
808de369923SAndreas Gohr        }
809de369923SAndreas Gohr    }
810de369923SAndreas Gohr
811de369923SAndreas Gohr    /**
8122ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
8132ea4044fSAndreas Gohr     * casing and special chars
8142ea4044fSAndreas Gohr     *
8152ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
81642ea7f44SGerrit Uitslag     *
81742ea7f44SGerrit Uitslag     * @param string $name
81842ea7f44SGerrit Uitslag     * @return string
8192ea4044fSAndreas Gohr     */
820de369923SAndreas Gohr    protected function _simpleTitle($name) {
8212ea4044fSAndreas Gohr        global $conf;
8222ea4044fSAndreas Gohr
8232ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
8246d2af55dSChristopher Smith        @list($name, $hash) = explode('#', $name, 2);
8252ea4044fSAndreas Gohr        if($hash) return $hash;
8262ea4044fSAndreas Gohr
8272ea4044fSAndreas Gohr        if($conf['useslash']) {
8283755fc25STom N Harris            $name = strtr($name, ';/', ';:');
8293755fc25STom N Harris        } else {
8303755fc25STom N Harris            $name = strtr($name, ';', ':');
8312ea4044fSAndreas Gohr        }
8322ea4044fSAndreas Gohr
8339708106bSAdrian Lang        return noNSorNS($name);
8342ea4044fSAndreas Gohr    }
8352ea4044fSAndreas Gohr
8361f82fabeSAndreas Gohr    /**
8371f82fabeSAndreas Gohr     * Resolve an interwikilink
83842ea7f44SGerrit Uitslag     *
83942ea7f44SGerrit Uitslag     * @param string    $shortcut  identifier for the interwiki link
84042ea7f44SGerrit Uitslag     * @param string    $reference fragment that refers the content
84142ea7f44SGerrit Uitslag     * @param null|bool $exists    reference which returns if an internal page exists
84242ea7f44SGerrit Uitslag     * @return string interwikilink
8431f82fabeSAndreas Gohr     */
844de369923SAndreas Gohr    public function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
8451f82fabeSAndreas Gohr        //get interwiki URL
8461f82fabeSAndreas Gohr        if(isset($this->interwiki[$shortcut])) {
8471f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
8481f82fabeSAndreas Gohr        } else {
8491f82fabeSAndreas Gohr            // Default to Google I'm feeling lucky
850ccee93d9SPatrick Brown            $url      = 'https://www.google.com/search?q={URL}&amp;btnI=lucky';
8511f82fabeSAndreas Gohr            $shortcut = 'go';
8521f82fabeSAndreas Gohr        }
8532ea4044fSAndreas Gohr
8541f82fabeSAndreas Gohr        //split into hash and url part
85517e17ae2SPatrick Brown        $hash = strrchr($reference, '#');
85617e17ae2SPatrick Brown        if($hash) {
85717e17ae2SPatrick Brown            $reference = substr($reference, 0, -strlen($hash));
85817e17ae2SPatrick Brown            $hash = substr($hash, 1);
85917e17ae2SPatrick Brown        }
8601f82fabeSAndreas Gohr
8611f82fabeSAndreas Gohr        //replace placeholder
8621f82fabeSAndreas Gohr        if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
8631f82fabeSAndreas Gohr            //use placeholders
8641f82fabeSAndreas Gohr            $url    = str_replace('{URL}', rawurlencode($reference), $url);
86517e17ae2SPatrick Brown            //wiki names will be cleaned next, otherwise urlencode unsafe chars
866*2401f18dSSyntaxseed            $url    = str_replace('{NAME}', ($url[0] === ':') ? $reference :
86717e17ae2SPatrick Brown                                  preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) {
86817e17ae2SPatrick Brown                                    return rawurlencode($match[0]);
86917e17ae2SPatrick Brown                                  }, $reference), $url);
8701f82fabeSAndreas Gohr            $parsed = parse_url($reference);
8718f34cf3dSMichael Große            if (empty($parsed['scheme'])) $parsed['scheme'] = '';
8728f34cf3dSMichael Große            if (empty($parsed['host'])) $parsed['host'] = '';
8738f34cf3dSMichael Große            if (empty($parsed['port'])) $parsed['port'] = 80;
8748f34cf3dSMichael Große            if (empty($parsed['path'])) $parsed['path'] = '';
8758f34cf3dSMichael Große            if (empty($parsed['query'])) $parsed['query'] = '';
8768f34cf3dSMichael Große            $url = strtr($url,[
8778f34cf3dSMichael Große                '{SCHEME}' => $parsed['scheme'],
8788f34cf3dSMichael Große                '{HOST}' => $parsed['host'],
8798f34cf3dSMichael Große                '{PORT}' => $parsed['port'],
8808f34cf3dSMichael Große                '{PATH}' => $parsed['path'],
8818f34cf3dSMichael Große                '{QUERY}' => $parsed['query'] ,
8828f34cf3dSMichael Große            ]);
8831f82fabeSAndreas Gohr        } else {
8841f82fabeSAndreas Gohr            //default
8851f82fabeSAndreas Gohr            $url = $url.rawurlencode($reference);
8861f82fabeSAndreas Gohr        }
887f379edc2SGerrit Uitslag        //handle as wiki links
888*2401f18dSSyntaxseed        if($url[0] === ':') {
889c55b109cSMichael Große            $urlparam = null;
890c55b109cSMichael Große            $id = $url;
891c55b109cSMichael Große            if (strpos($url, '?') !== false) {
8926496c33fSGerrit Uitslag                list($id, $urlparam) = explode('?', $url, 2);
893c55b109cSMichael Große            }
8946496c33fSGerrit Uitslag            $url    = wl(cleanID($id), $urlparam);
8956496c33fSGerrit Uitslag            $exists = page_exists($id);
8962345e871SGerrit Uitslag        }
8971f82fabeSAndreas Gohr        if($hash) $url .= '#'.rawurlencode($hash);
8981f82fabeSAndreas Gohr
8991f82fabeSAndreas Gohr        return $url;
9001f82fabeSAndreas Gohr    }
901cfa2b40eSAndreas Gohr
902cfa2b40eSAndreas Gohr    #endregion
9030cecf9d5Sandi}
9040cecf9d5Sandi
905340756e4Sandi
906e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
907