xref: /dokuwiki/inc/parser/renderer.php (revision fb0213561a32c69cec2ffedf6be207a1c7aae4e6)
10cecf9d5Sandi<?php
295078f23SAndreas Gohr
361faf446Schris/**
45587e44cSchris * Renderer output base class
561faf446Schris *
661faf446Schris * @author Harry Fuecks <hfuecks@gmail.com>
761faf446Schris * @author Andreas Gohr <andi@splitbrain.org>
861faf446Schris */
961faf446Schris
10e1d9dcc8SAndreas Gohruse dokuwiki\Extension\Plugin;
11e1d9dcc8SAndreas Gohruse dokuwiki\Extension\SyntaxPlugin;
12e1d9dcc8SAndreas Gohr
13863befa1SAndreas Gohr/**
1456bd9509SPhy * Allowed chars in $language for code highlighting
1556bd9509SPhy * @see GeSHi::set_language()
1656bd9509SPhy */
1756bd9509SPhydefine('PREG_PATTERN_VALID_LANGUAGE', '#[^a-zA-Z0-9\-_]#');
1856bd9509SPhy
1956bd9509SPhy/**
20863befa1SAndreas Gohr * An empty renderer, produces no output
21863befa1SAndreas Gohr *
2251ee2399SGerrit Uitslag * Inherits from dokuwiki\Extension\Plugin for giving additional functions to render plugins
238e3a5477SAndreas Gohr *
248e3a5477SAndreas Gohr * The renderer transforms the syntax instructions created by the parser and handler into the
258e3a5477SAndreas Gohr * desired output format. For each instruction a corresponding method defined in this class will
268e3a5477SAndreas Gohr * be called. That method needs to produce the desired output for the instruction and add it to the
278e3a5477SAndreas Gohr * $doc field. When all instructions are processed, the $doc field contents will be cached by
288e3a5477SAndreas Gohr * DokuWiki and sent to the user.
29863befa1SAndreas Gohr */
30faf3f01bSAndreas Gohrabstract class Doku_Renderer extends Plugin
31faf3f01bSAndreas Gohr{
32cfa2b40eSAndreas Gohr    /** @var array Settings, control the behavior of the renderer */
33faf3f01bSAndreas Gohr    public $info = [
34749bc7f1SAndreas Gohr        'cache' => true, // may the rendered result cached?
35749bc7f1SAndreas Gohr        'toc' => true, // render the TOC?
36faf3f01bSAndreas Gohr    ];
379dc2c2afSandi
38cfa2b40eSAndreas Gohr    /** @var array contains the smiley configuration, set in p_render() */
39faf3f01bSAndreas Gohr    public $smileys = [];
40cfa2b40eSAndreas Gohr    /** @var array contains the entity configuration, set in p_render() */
41faf3f01bSAndreas Gohr    public $entities = [];
42cfa2b40eSAndreas Gohr    /** @var array contains the acronym configuration, set in p_render() */
43faf3f01bSAndreas Gohr    public $acronyms = [];
44cfa2b40eSAndreas Gohr    /** @var array contains the interwiki configuration, set in p_render() */
45faf3f01bSAndreas Gohr    public $interwiki = [];
4678b498a7SAndreas Gohr    /** @var string|int link pages and media against this revision */
4778b498a7SAndreas Gohr    public $date_at = '';
48e41c4da9SAndreas Gohr
49de369923SAndreas Gohr    /** @var array the list of headers used to create unique link ids */
50faf3f01bSAndreas Gohr    protected $headers = [];
51de369923SAndreas Gohr
525f70445dSAndreas Gohr    /**
53cfa2b40eSAndreas Gohr     * @var string the rendered document, this will be cached after the renderer ran through
545f70445dSAndreas Gohr     */
55cfa2b40eSAndreas Gohr    public $doc = '';
56cfa2b40eSAndreas Gohr
57cfa2b40eSAndreas Gohr    /**
58cfa2b40eSAndreas Gohr     * clean out any per-use values
59cfa2b40eSAndreas Gohr     *
60cfa2b40eSAndreas Gohr     * This is called before each use of the renderer object and should be used to
61cfa2b40eSAndreas Gohr     * completely reset the state of the renderer to be reused for a new document
62cfa2b40eSAndreas Gohr     */
63faf3f01bSAndreas Gohr    public function reset()
64faf3f01bSAndreas Gohr    {
65faf3f01bSAndreas Gohr        $this->headers = [];
66abaaba9aSSatoshi Sahara        $this->doc = '';
67abaaba9aSSatoshi Sahara        $this->info['cache'] = true;
68abaaba9aSSatoshi Sahara        $this->info['toc'] = true;
695f70445dSAndreas Gohr    }
705f70445dSAndreas Gohr
71f6ec8df8SAdrian Lang    /**
72f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
73f6ec8df8SAdrian Lang     *
74cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
75cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
76cfa2b40eSAndreas Gohr     *
77f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
78f6ec8df8SAdrian Lang     */
79faf3f01bSAndreas Gohr    public function isSingleton()
80faf3f01bSAndreas Gohr    {
81f6ec8df8SAdrian Lang        return false;
82f6ec8df8SAdrian Lang    }
83f6ec8df8SAdrian Lang
848cc41db0SAndreas Gohr    /**
85cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
86cfa2b40eSAndreas Gohr     *
87cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
88cfa2b40eSAndreas Gohr     *
89cfa2b40eSAndreas Gohr     * @return string
90cfa2b40eSAndreas Gohr     */
91de369923SAndreas Gohr    abstract public function getFormat();
92cfa2b40eSAndreas Gohr
93cfa2b40eSAndreas Gohr    /**
94cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
95cfa2b40eSAndreas Gohr     */
96faf3f01bSAndreas Gohr    public function nocache()
97faf3f01bSAndreas Gohr    {
98cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
99cfa2b40eSAndreas Gohr    }
100cfa2b40eSAndreas Gohr
101cfa2b40eSAndreas Gohr    /**
102cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
103cfa2b40eSAndreas Gohr     *
104cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
105cfa2b40eSAndreas Gohr     */
106faf3f01bSAndreas Gohr    public function notoc()
107faf3f01bSAndreas Gohr    {
108cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
109cfa2b40eSAndreas Gohr    }
110cfa2b40eSAndreas Gohr
111cfa2b40eSAndreas Gohr    /**
112cfa2b40eSAndreas Gohr     * Handle plugin rendering
113cfa2b40eSAndreas Gohr     *
114cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
1158cc41db0SAndreas Gohr     *
1168cc41db0SAndreas Gohr     * @param string $name Plugin name
1178cc41db0SAndreas Gohr     * @param mixed $data custom data set by handler
1188cc41db0SAndreas Gohr     * @param string $state matched state if any
1198cc41db0SAndreas Gohr     * @param string $match raw matched syntax
1208cc41db0SAndreas Gohr     */
121faf3f01bSAndreas Gohr    public function plugin($name, $data, $state = '', $match = '')
122faf3f01bSAndreas Gohr    {
123e1d9dcc8SAndreas Gohr        /** @var SyntaxPlugin $plugin */
124e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
12561faf446Schris        if ($plugin != null) {
1265f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
12761faf446Schris        }
12861faf446Schris    }
12961faf446Schris
1305587e44cSchris    /**
1315587e44cSchris     * handle nested render instructions
1325587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
133cfa2b40eSAndreas Gohr     *
134cfa2b40eSAndreas Gohr     * @param array $instructions
1355587e44cSchris     */
136faf3f01bSAndreas Gohr    public function nest($instructions)
137faf3f01bSAndreas Gohr    {
1385587e44cSchris        foreach ($instructions as $instruction) {
1395587e44cSchris            // execute the callback against ourself
140c2122b83SChristopher Smith            if (method_exists($this, $instruction[0])) {
141faf3f01bSAndreas Gohr                call_user_func_array([$this, $instruction[0]], $instruction[1] ?: []);
142c2122b83SChristopher Smith            }
1435587e44cSchris        }
1445587e44cSchris    }
1455587e44cSchris
146cfa2b40eSAndreas Gohr    /**
147cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
148cfa2b40eSAndreas Gohr     *
149cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
150cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
151cfa2b40eSAndreas Gohr     */
152faf3f01bSAndreas Gohr    public function nest_close()
153faf3f01bSAndreas Gohr    {
1542c2835c2SAndreas Gohr    }
1555587e44cSchris
156cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
157cfa2b40eSAndreas Gohr
158cfa2b40eSAndreas Gohr    /**
159cfa2b40eSAndreas Gohr     * Initialize the document
160cfa2b40eSAndreas Gohr     */
161faf3f01bSAndreas Gohr    public function document_start()
162faf3f01bSAndreas Gohr    {
1632c2835c2SAndreas Gohr    }
1640cecf9d5Sandi
165cfa2b40eSAndreas Gohr    /**
166cfa2b40eSAndreas Gohr     * Finalize the document
167cfa2b40eSAndreas Gohr     */
168faf3f01bSAndreas Gohr    public function document_end()
169faf3f01bSAndreas Gohr    {
1702c2835c2SAndreas Gohr    }
1710cecf9d5Sandi
172cfa2b40eSAndreas Gohr    /**
173cfa2b40eSAndreas Gohr     * Render the Table of Contents
174cfa2b40eSAndreas Gohr     *
175cfa2b40eSAndreas Gohr     * @return string
176cfa2b40eSAndreas Gohr     */
177faf3f01bSAndreas Gohr    public function render_TOC()
178faf3f01bSAndreas Gohr    {
1792c2835c2SAndreas Gohr        return '';
1802c2835c2SAndreas Gohr    }
1810cecf9d5Sandi
182cfa2b40eSAndreas Gohr    /**
183cfa2b40eSAndreas Gohr     * Add an item to the TOC
184cfa2b40eSAndreas Gohr     *
185cfa2b40eSAndreas Gohr     * @param string $id the hash link
186cfa2b40eSAndreas Gohr     * @param string $text the text to display
187cfa2b40eSAndreas Gohr     * @param int $level the nesting level
188cfa2b40eSAndreas Gohr     */
189faf3f01bSAndreas Gohr    public function toc_additem($id, $text, $level)
190faf3f01bSAndreas Gohr    {
1912c2835c2SAndreas Gohr    }
192e7856beaSchris
193cfa2b40eSAndreas Gohr    /**
194cfa2b40eSAndreas Gohr     * Render a heading
195cfa2b40eSAndreas Gohr     *
196cfa2b40eSAndreas Gohr     * @param string $text the text to display
197cfa2b40eSAndreas Gohr     * @param int $level header level
198cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
199cfa2b40eSAndreas Gohr     */
200faf3f01bSAndreas Gohr    public function header($text, $level, $pos)
201faf3f01bSAndreas Gohr    {
2022c2835c2SAndreas Gohr    }
2030cecf9d5Sandi
204cfa2b40eSAndreas Gohr    /**
205cfa2b40eSAndreas Gohr     * Open a new section
206cfa2b40eSAndreas Gohr     *
207cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
208cfa2b40eSAndreas Gohr     */
209faf3f01bSAndreas Gohr    public function section_open($level)
210faf3f01bSAndreas Gohr    {
2112c2835c2SAndreas Gohr    }
2120cecf9d5Sandi
213cfa2b40eSAndreas Gohr    /**
214cfa2b40eSAndreas Gohr     * Close the current section
215cfa2b40eSAndreas Gohr     */
216faf3f01bSAndreas Gohr    public function section_close()
217faf3f01bSAndreas Gohr    {
2182c2835c2SAndreas Gohr    }
2190cecf9d5Sandi
220cfa2b40eSAndreas Gohr    /**
221cfa2b40eSAndreas Gohr     * Render plain text data
222cfa2b40eSAndreas Gohr     *
22342ea7f44SGerrit Uitslag     * @param string $text
224cfa2b40eSAndreas Gohr     */
225faf3f01bSAndreas Gohr    public function cdata($text)
226faf3f01bSAndreas Gohr    {
2272c2835c2SAndreas Gohr    }
2280cecf9d5Sandi
229cfa2b40eSAndreas Gohr    /**
230cfa2b40eSAndreas Gohr     * Open a paragraph
231cfa2b40eSAndreas Gohr     */
232faf3f01bSAndreas Gohr    public function p_open()
233faf3f01bSAndreas Gohr    {
2342c2835c2SAndreas Gohr    }
2350cecf9d5Sandi
236cfa2b40eSAndreas Gohr    /**
237cfa2b40eSAndreas Gohr     * Close a paragraph
238cfa2b40eSAndreas Gohr     */
239faf3f01bSAndreas Gohr    public function p_close()
240faf3f01bSAndreas Gohr    {
2412c2835c2SAndreas Gohr    }
2420cecf9d5Sandi
243cfa2b40eSAndreas Gohr    /**
2443dd5c225SAndreas Gohr     * Create a line break
245cfa2b40eSAndreas Gohr     */
246faf3f01bSAndreas Gohr    public function linebreak()
247faf3f01bSAndreas Gohr    {
2482c2835c2SAndreas Gohr    }
2490cecf9d5Sandi
250cfa2b40eSAndreas Gohr    /**
251cfa2b40eSAndreas Gohr     * Create a horizontal line
252cfa2b40eSAndreas Gohr     */
253faf3f01bSAndreas Gohr    public function hr()
254faf3f01bSAndreas Gohr    {
2552c2835c2SAndreas Gohr    }
2560cecf9d5Sandi
257cfa2b40eSAndreas Gohr    /**
258cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
259cfa2b40eSAndreas Gohr     */
260faf3f01bSAndreas Gohr    public function strong_open()
261faf3f01bSAndreas Gohr    {
2622c2835c2SAndreas Gohr    }
2630cecf9d5Sandi
264cfa2b40eSAndreas Gohr    /**
265cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
266cfa2b40eSAndreas Gohr     */
267faf3f01bSAndreas Gohr    public function strong_close()
268faf3f01bSAndreas Gohr    {
2692c2835c2SAndreas Gohr    }
2700cecf9d5Sandi
271cfa2b40eSAndreas Gohr    /**
272cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
273cfa2b40eSAndreas Gohr     */
274faf3f01bSAndreas Gohr    public function emphasis_open()
275faf3f01bSAndreas Gohr    {
2762c2835c2SAndreas Gohr    }
2770cecf9d5Sandi
278cfa2b40eSAndreas Gohr    /**
279cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
280cfa2b40eSAndreas Gohr     */
281faf3f01bSAndreas Gohr    public function emphasis_close()
282faf3f01bSAndreas Gohr    {
2832c2835c2SAndreas Gohr    }
2840cecf9d5Sandi
285cfa2b40eSAndreas Gohr    /**
286cfa2b40eSAndreas Gohr     * Start underline formatting
287cfa2b40eSAndreas Gohr     */
288faf3f01bSAndreas Gohr    public function underline_open()
289faf3f01bSAndreas Gohr    {
2902c2835c2SAndreas Gohr    }
2910cecf9d5Sandi
292cfa2b40eSAndreas Gohr    /**
293cfa2b40eSAndreas Gohr     * Stop underline formatting
294cfa2b40eSAndreas Gohr     */
295faf3f01bSAndreas Gohr    public function underline_close()
296faf3f01bSAndreas Gohr    {
2972c2835c2SAndreas Gohr    }
2980cecf9d5Sandi
299cfa2b40eSAndreas Gohr    /**
300cfa2b40eSAndreas Gohr     * Start monospace formatting
301cfa2b40eSAndreas Gohr     */
302faf3f01bSAndreas Gohr    public function monospace_open()
303faf3f01bSAndreas Gohr    {
3042c2835c2SAndreas Gohr    }
3050cecf9d5Sandi
306cfa2b40eSAndreas Gohr    /**
307cfa2b40eSAndreas Gohr     * Stop monospace formatting
308cfa2b40eSAndreas Gohr     */
309faf3f01bSAndreas Gohr    public function monospace_close()
310faf3f01bSAndreas Gohr    {
3112c2835c2SAndreas Gohr    }
3120cecf9d5Sandi
313cfa2b40eSAndreas Gohr    /**
314cfa2b40eSAndreas Gohr     * Start a subscript
315cfa2b40eSAndreas Gohr     */
316faf3f01bSAndreas Gohr    public function subscript_open()
317faf3f01bSAndreas Gohr    {
3182c2835c2SAndreas Gohr    }
3190cecf9d5Sandi
320cfa2b40eSAndreas Gohr    /**
321cfa2b40eSAndreas Gohr     * Stop a subscript
322cfa2b40eSAndreas Gohr     */
323faf3f01bSAndreas Gohr    public function subscript_close()
324faf3f01bSAndreas Gohr    {
3252c2835c2SAndreas Gohr    }
3260cecf9d5Sandi
327cfa2b40eSAndreas Gohr    /**
328cfa2b40eSAndreas Gohr     * Start a superscript
329cfa2b40eSAndreas Gohr     */
330faf3f01bSAndreas Gohr    public function superscript_open()
331faf3f01bSAndreas Gohr    {
3322c2835c2SAndreas Gohr    }
3330cecf9d5Sandi
334cfa2b40eSAndreas Gohr    /**
335cfa2b40eSAndreas Gohr     * Stop a superscript
336cfa2b40eSAndreas Gohr     */
337faf3f01bSAndreas Gohr    public function superscript_close()
338faf3f01bSAndreas Gohr    {
3392c2835c2SAndreas Gohr    }
3400cecf9d5Sandi
341cfa2b40eSAndreas Gohr    /**
342cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
343cfa2b40eSAndreas Gohr     */
344faf3f01bSAndreas Gohr    public function deleted_open()
345faf3f01bSAndreas Gohr    {
3462c2835c2SAndreas Gohr    }
3470cecf9d5Sandi
348cfa2b40eSAndreas Gohr    /**
349cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
350cfa2b40eSAndreas Gohr     */
351faf3f01bSAndreas Gohr    public function deleted_close()
352faf3f01bSAndreas Gohr    {
3532c2835c2SAndreas Gohr    }
3540cecf9d5Sandi
355cfa2b40eSAndreas Gohr    /**
356cfa2b40eSAndreas Gohr     * Start a footnote
357cfa2b40eSAndreas Gohr     */
358faf3f01bSAndreas Gohr    public function footnote_open()
359faf3f01bSAndreas Gohr    {
3602c2835c2SAndreas Gohr    }
3610cecf9d5Sandi
362cfa2b40eSAndreas Gohr    /**
363cfa2b40eSAndreas Gohr     * Stop a footnote
364cfa2b40eSAndreas Gohr     */
365faf3f01bSAndreas Gohr    public function footnote_close()
366faf3f01bSAndreas Gohr    {
3672c2835c2SAndreas Gohr    }
3680cecf9d5Sandi
369cfa2b40eSAndreas Gohr    /**
370cfa2b40eSAndreas Gohr     * Open an unordered list
371cfa2b40eSAndreas Gohr     */
372faf3f01bSAndreas Gohr    public function listu_open()
373faf3f01bSAndreas Gohr    {
3742c2835c2SAndreas Gohr    }
3750cecf9d5Sandi
376cfa2b40eSAndreas Gohr    /**
377cfa2b40eSAndreas Gohr     * Close an unordered list
378cfa2b40eSAndreas Gohr     */
379faf3f01bSAndreas Gohr    public function listu_close()
380faf3f01bSAndreas Gohr    {
3812c2835c2SAndreas Gohr    }
3820cecf9d5Sandi
383cfa2b40eSAndreas Gohr    /**
384cfa2b40eSAndreas Gohr     * Open an ordered list
385cfa2b40eSAndreas Gohr     */
386faf3f01bSAndreas Gohr    public function listo_open()
387faf3f01bSAndreas Gohr    {
3882c2835c2SAndreas Gohr    }
3890cecf9d5Sandi
390cfa2b40eSAndreas Gohr    /**
391cfa2b40eSAndreas Gohr     * Close an ordered list
392cfa2b40eSAndreas Gohr     */
393faf3f01bSAndreas Gohr    public function listo_close()
394faf3f01bSAndreas Gohr    {
3952c2835c2SAndreas Gohr    }
3960cecf9d5Sandi
397cfa2b40eSAndreas Gohr    /**
398cfa2b40eSAndreas Gohr     * Open a list item
399cfa2b40eSAndreas Gohr     *
400cfa2b40eSAndreas Gohr     * @param int $level the nesting level
401e3a24861SChristopher Smith     * @param bool $node true when a node; false when a leaf
402cfa2b40eSAndreas Gohr     */
403faf3f01bSAndreas Gohr    public function listitem_open($level, $node = false)
404faf3f01bSAndreas Gohr    {
4052c2835c2SAndreas Gohr    }
4060cecf9d5Sandi
407cfa2b40eSAndreas Gohr    /**
408cfa2b40eSAndreas Gohr     * Close a list item
409cfa2b40eSAndreas Gohr     */
410faf3f01bSAndreas Gohr    public function listitem_close()
411faf3f01bSAndreas Gohr    {
4122c2835c2SAndreas Gohr    }
4130cecf9d5Sandi
414cfa2b40eSAndreas Gohr    /**
415cfa2b40eSAndreas Gohr     * Start the content of a list item
416cfa2b40eSAndreas Gohr     */
417faf3f01bSAndreas Gohr    public function listcontent_open()
418faf3f01bSAndreas Gohr    {
4192c2835c2SAndreas Gohr    }
4200cecf9d5Sandi
421cfa2b40eSAndreas Gohr    /**
422cfa2b40eSAndreas Gohr     * Stop the content of a list item
423cfa2b40eSAndreas Gohr     */
424faf3f01bSAndreas Gohr    public function listcontent_close()
425faf3f01bSAndreas Gohr    {
4262c2835c2SAndreas Gohr    }
4270cecf9d5Sandi
428cfa2b40eSAndreas Gohr    /**
429cfa2b40eSAndreas Gohr     * Output unformatted $text
430cfa2b40eSAndreas Gohr     *
431cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
432cfa2b40eSAndreas Gohr     *
433cfa2b40eSAndreas Gohr     * @param string $text
434cfa2b40eSAndreas Gohr     */
435faf3f01bSAndreas Gohr    public function unformatted($text)
436faf3f01bSAndreas Gohr    {
437cfa2b40eSAndreas Gohr        $this->cdata($text);
4382c2835c2SAndreas Gohr    }
4390cecf9d5Sandi
440cfa2b40eSAndreas Gohr    /**
441cfa2b40eSAndreas Gohr     * Output preformatted text
442cfa2b40eSAndreas Gohr     *
443cfa2b40eSAndreas Gohr     * @param string $text
444cfa2b40eSAndreas Gohr     */
445faf3f01bSAndreas Gohr    public function preformatted($text)
446faf3f01bSAndreas Gohr    {
4472c2835c2SAndreas Gohr    }
4480cecf9d5Sandi
449cfa2b40eSAndreas Gohr    /**
450cfa2b40eSAndreas Gohr     * Start a block quote
451cfa2b40eSAndreas Gohr     */
452faf3f01bSAndreas Gohr    public function quote_open()
453faf3f01bSAndreas Gohr    {
4542c2835c2SAndreas Gohr    }
4550cecf9d5Sandi
456cfa2b40eSAndreas Gohr    /**
457cfa2b40eSAndreas Gohr     * Stop a block quote
458cfa2b40eSAndreas Gohr     */
459faf3f01bSAndreas Gohr    public function quote_close()
460faf3f01bSAndreas Gohr    {
4612c2835c2SAndreas Gohr    }
4620cecf9d5Sandi
463cfa2b40eSAndreas Gohr    /**
464cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
465cfa2b40eSAndreas Gohr     *
466cfa2b40eSAndreas Gohr     * @param string $text text to show
467cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
468cfa2b40eSAndreas Gohr     * @param string $file file path label
469cfa2b40eSAndreas Gohr     */
470faf3f01bSAndreas Gohr    public function file($text, $lang = null, $file = null)
471faf3f01bSAndreas Gohr    {
4722c2835c2SAndreas Gohr    }
4733d491f75SAndreas Gohr
474cfa2b40eSAndreas Gohr    /**
475cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
476cfa2b40eSAndreas Gohr     *
477cfa2b40eSAndreas Gohr     * @param string $text text to show
478cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
479cfa2b40eSAndreas Gohr     * @param string $file file path label
480cfa2b40eSAndreas Gohr     */
481faf3f01bSAndreas Gohr    public function code($text, $lang = null, $file = null)
482faf3f01bSAndreas Gohr    {
4832c2835c2SAndreas Gohr    }
4840cecf9d5Sandi
485cfa2b40eSAndreas Gohr    /**
486cfa2b40eSAndreas Gohr     * Format an acronym
487cfa2b40eSAndreas Gohr     *
488cfa2b40eSAndreas Gohr     * Uses $this->acronyms
489cfa2b40eSAndreas Gohr     *
490cfa2b40eSAndreas Gohr     * @param string $acronym
491cfa2b40eSAndreas Gohr     */
492faf3f01bSAndreas Gohr    public function acronym($acronym)
493faf3f01bSAndreas Gohr    {
4942c2835c2SAndreas Gohr    }
4950cecf9d5Sandi
496cfa2b40eSAndreas Gohr    /**
497cfa2b40eSAndreas Gohr     * Format a smiley
498cfa2b40eSAndreas Gohr     *
499cfa2b40eSAndreas Gohr     * Uses $this->smiley
500cfa2b40eSAndreas Gohr     *
501cfa2b40eSAndreas Gohr     * @param string $smiley
502cfa2b40eSAndreas Gohr     */
503faf3f01bSAndreas Gohr    public function smiley($smiley)
504faf3f01bSAndreas Gohr    {
5052c2835c2SAndreas Gohr    }
5060cecf9d5Sandi
507cfa2b40eSAndreas Gohr    /**
508cfa2b40eSAndreas Gohr     * Format an entity
509cfa2b40eSAndreas Gohr     *
510cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
511cfa2b40eSAndreas Gohr     *
512cfa2b40eSAndreas Gohr     * Uses $this->entities
513cfa2b40eSAndreas Gohr     *
514cfa2b40eSAndreas Gohr     * @param string $entity
515cfa2b40eSAndreas Gohr     */
516faf3f01bSAndreas Gohr    public function entity($entity)
517faf3f01bSAndreas Gohr    {
5182c2835c2SAndreas Gohr    }
5190cecf9d5Sandi
520cfa2b40eSAndreas Gohr    /**
521cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
522cfa2b40eSAndreas Gohr     *
523cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
524cfa2b40eSAndreas Gohr     *
525cfa2b40eSAndreas Gohr     * @param string|int $x first value
526cfa2b40eSAndreas Gohr     * @param string|int $y second value
527cfa2b40eSAndreas Gohr     */
528faf3f01bSAndreas Gohr    public function multiplyentity($x, $y)
529faf3f01bSAndreas Gohr    {
5302c2835c2SAndreas Gohr    }
5310cecf9d5Sandi
532cfa2b40eSAndreas Gohr    /**
533cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
534cfa2b40eSAndreas Gohr     */
535faf3f01bSAndreas Gohr    public function singlequoteopening()
536faf3f01bSAndreas Gohr    {
5372c2835c2SAndreas Gohr    }
5380cecf9d5Sandi
539cfa2b40eSAndreas Gohr    /**
540cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
541cfa2b40eSAndreas Gohr     */
542faf3f01bSAndreas Gohr    public function singlequoteclosing()
543faf3f01bSAndreas Gohr    {
5442c2835c2SAndreas Gohr    }
5450cecf9d5Sandi
546cfa2b40eSAndreas Gohr    /**
547cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
548cfa2b40eSAndreas Gohr     */
549faf3f01bSAndreas Gohr    public function apostrophe()
550faf3f01bSAndreas Gohr    {
5512c2835c2SAndreas Gohr    }
55257d757d1SAndreas Gohr
553cfa2b40eSAndreas Gohr    /**
554cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
555cfa2b40eSAndreas Gohr     */
556faf3f01bSAndreas Gohr    public function doublequoteopening()
557faf3f01bSAndreas Gohr    {
5582c2835c2SAndreas Gohr    }
5590cecf9d5Sandi
560cfa2b40eSAndreas Gohr    /**
561cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
562cfa2b40eSAndreas Gohr     */
563faf3f01bSAndreas Gohr    public function doublequoteclosing()
564faf3f01bSAndreas Gohr    {
5652c2835c2SAndreas Gohr    }
5660cecf9d5Sandi
567cfa2b40eSAndreas Gohr    /**
568cfa2b40eSAndreas Gohr     * Render a CamelCase link
569cfa2b40eSAndreas Gohr     *
570cfa2b40eSAndreas Gohr     * @param string $link The link name
571cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
572cfa2b40eSAndreas Gohr     */
573faf3f01bSAndreas Gohr    public function camelcaselink($link)
574faf3f01bSAndreas Gohr    {
5752c2835c2SAndreas Gohr    }
5760cecf9d5Sandi
577cfa2b40eSAndreas Gohr    /**
578cfa2b40eSAndreas Gohr     * Render a page local link
579cfa2b40eSAndreas Gohr     *
580cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
581cfa2b40eSAndreas Gohr     * @param string $name name for the link
582cfa2b40eSAndreas Gohr     */
583faf3f01bSAndreas Gohr    public function locallink($hash, $name = null)
584faf3f01bSAndreas Gohr    {
5852c2835c2SAndreas Gohr    }
586a939d432SAndreas Gohr
587cfa2b40eSAndreas Gohr    /**
588cfa2b40eSAndreas Gohr     * Render a wiki internal link
589cfa2b40eSAndreas Gohr     *
590cfa2b40eSAndreas Gohr     * @param string $link page ID to link to. eg. 'wiki:syntax'
591cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
592cfa2b40eSAndreas Gohr     */
593faf3f01bSAndreas Gohr    public function internallink($link, $title = null)
594faf3f01bSAndreas Gohr    {
5952c2835c2SAndreas Gohr    }
5960cecf9d5Sandi
597cfa2b40eSAndreas Gohr    /**
598cfa2b40eSAndreas Gohr     * Render an external link
599cfa2b40eSAndreas Gohr     *
600cfa2b40eSAndreas Gohr     * @param string $link full URL with scheme
601cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
602cfa2b40eSAndreas Gohr     */
603faf3f01bSAndreas Gohr    public function externallink($link, $title = null)
604faf3f01bSAndreas Gohr    {
6052c2835c2SAndreas Gohr    }
6060cecf9d5Sandi
607cfa2b40eSAndreas Gohr    /**
608cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
609cfa2b40eSAndreas Gohr     *
610cfa2b40eSAndreas Gohr     * @param string $url URL of the feed
611cfa2b40eSAndreas Gohr     * @param array $params Finetuning of the output
612cfa2b40eSAndreas Gohr     */
613faf3f01bSAndreas Gohr    public function rss($url, $params)
614faf3f01bSAndreas Gohr    {
6152c2835c2SAndreas Gohr    }
616c5cfca61SAndreas Gohr
617cfa2b40eSAndreas Gohr    /**
618cfa2b40eSAndreas Gohr     * Render an interwiki link
619cfa2b40eSAndreas Gohr     *
620cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
621cfa2b40eSAndreas Gohr     *
622cfa2b40eSAndreas Gohr     * @param string $link original link - probably not much use
623cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
624cfa2b40eSAndreas Gohr     * @param string $wikiName indentifier (shortcut) for the remote wiki
625cfa2b40eSAndreas Gohr     * @param string $wikiUri the fragment parsed from the original link
626cfa2b40eSAndreas Gohr     */
627faf3f01bSAndreas Gohr    public function interwikilink($link, $title, $wikiName, $wikiUri)
628faf3f01bSAndreas Gohr    {
6292c2835c2SAndreas Gohr    }
6300cecf9d5Sandi
631cfa2b40eSAndreas Gohr    /**
632cfa2b40eSAndreas Gohr     * Link to file on users OS
633cfa2b40eSAndreas Gohr     *
634cfa2b40eSAndreas Gohr     * @param string $link the link
635cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
636cfa2b40eSAndreas Gohr     */
637faf3f01bSAndreas Gohr    public function filelink($link, $title = null)
638faf3f01bSAndreas Gohr    {
6392c2835c2SAndreas Gohr    }
6400cecf9d5Sandi
641cfa2b40eSAndreas Gohr    /**
642cfa2b40eSAndreas Gohr     * Link to windows share
643cfa2b40eSAndreas Gohr     *
644cfa2b40eSAndreas Gohr     * @param string $link the link
645cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
646cfa2b40eSAndreas Gohr     */
647faf3f01bSAndreas Gohr    public function windowssharelink($link, $title = null)
648faf3f01bSAndreas Gohr    {
6492c2835c2SAndreas Gohr    }
6500cecf9d5Sandi
651cfa2b40eSAndreas Gohr    /**
652cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
653cfa2b40eSAndreas Gohr     *
654cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
655cfa2b40eSAndreas Gohr     *
656cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6573dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
658cfa2b40eSAndreas Gohr     */
659faf3f01bSAndreas Gohr    public function emaillink($address, $name = null)
660faf3f01bSAndreas Gohr    {
6612c2835c2SAndreas Gohr    }
6620cecf9d5Sandi
663cfa2b40eSAndreas Gohr    /**
664cfa2b40eSAndreas Gohr     * Render an internal media file
665cfa2b40eSAndreas Gohr     *
666cfa2b40eSAndreas Gohr     * @param string $src media ID
667cfa2b40eSAndreas Gohr     * @param string $title descriptive text
668cfa2b40eSAndreas Gohr     * @param string $align left|center|right
669cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
670cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
671cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
672cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
673cfa2b40eSAndreas Gohr     */
67495078f23SAndreas Gohr    public function internalmedia(
67595078f23SAndreas Gohr        $src,
67695078f23SAndreas Gohr        $title = null,
67795078f23SAndreas Gohr        $align = null,
67895078f23SAndreas Gohr        $width = null,
67995078f23SAndreas Gohr        $height = null,
68095078f23SAndreas Gohr        $cache = null,
68195078f23SAndreas Gohr        $linking = null
68295078f23SAndreas Gohr    ) {
6832c2835c2SAndreas Gohr    }
684a939d432SAndreas Gohr
685cfa2b40eSAndreas Gohr    /**
686cfa2b40eSAndreas Gohr     * Render an external media file
687cfa2b40eSAndreas Gohr     *
688cfa2b40eSAndreas Gohr     * @param string $src full media URL
689cfa2b40eSAndreas Gohr     * @param string $title descriptive text
690cfa2b40eSAndreas Gohr     * @param string $align left|center|right
691cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
692cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
693cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
694cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
695cfa2b40eSAndreas Gohr     */
69695078f23SAndreas Gohr    public function externalmedia(
69795078f23SAndreas Gohr        $src,
69895078f23SAndreas Gohr        $title = null,
69995078f23SAndreas Gohr        $align = null,
70095078f23SAndreas Gohr        $width = null,
70195078f23SAndreas Gohr        $height = null,
70295078f23SAndreas Gohr        $cache = null,
70395078f23SAndreas Gohr        $linking = null
70495078f23SAndreas Gohr    ) {
7052c2835c2SAndreas Gohr    }
706a939d432SAndreas Gohr
707cfa2b40eSAndreas Gohr    /**
708cfa2b40eSAndreas Gohr     * Render a link to an internal media file
709cfa2b40eSAndreas Gohr     *
710cfa2b40eSAndreas Gohr     * @param string $src media ID
711cfa2b40eSAndreas Gohr     * @param string $title descriptive text
712cfa2b40eSAndreas Gohr     * @param string $align left|center|right
713cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
714cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
715cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
716cfa2b40eSAndreas Gohr     */
71795078f23SAndreas Gohr    public function internalmedialink(
71895078f23SAndreas Gohr        $src,
71995078f23SAndreas Gohr        $title = null,
72095078f23SAndreas Gohr        $align = null,
72195078f23SAndreas Gohr        $width = null,
72295078f23SAndreas Gohr        $height = null,
72395078f23SAndreas Gohr        $cache = null
72495078f23SAndreas Gohr    ) {
7252c2835c2SAndreas Gohr    }
7260cecf9d5Sandi
727cfa2b40eSAndreas Gohr    /**
728cfa2b40eSAndreas Gohr     * Render a link to an external media file
729cfa2b40eSAndreas Gohr     *
730cfa2b40eSAndreas Gohr     * @param string $src media ID
731cfa2b40eSAndreas Gohr     * @param string $title descriptive text
732cfa2b40eSAndreas Gohr     * @param string $align left|center|right
733cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
734cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
735cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
736cfa2b40eSAndreas Gohr     */
73795078f23SAndreas Gohr    public function externalmedialink(
73895078f23SAndreas Gohr        $src,
73995078f23SAndreas Gohr        $title = null,
74095078f23SAndreas Gohr        $align = null,
74195078f23SAndreas Gohr        $width = null,
74295078f23SAndreas Gohr        $height = null,
74395078f23SAndreas Gohr        $cache = null
74495078f23SAndreas Gohr    ) {
7452c2835c2SAndreas Gohr    }
7460cecf9d5Sandi
747cfa2b40eSAndreas Gohr    /**
748cfa2b40eSAndreas Gohr     * Start a table
749cfa2b40eSAndreas Gohr     *
750cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
751cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
752cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
753cfa2b40eSAndreas Gohr     */
754faf3f01bSAndreas Gohr    public function table_open($maxcols = null, $numrows = null, $pos = null)
755faf3f01bSAndreas Gohr    {
7562c2835c2SAndreas Gohr    }
7570cecf9d5Sandi
758cfa2b40eSAndreas Gohr    /**
759cfa2b40eSAndreas Gohr     * Close a table
760cfa2b40eSAndreas Gohr     *
761cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
762cfa2b40eSAndreas Gohr     */
763faf3f01bSAndreas Gohr    public function table_close($pos = null)
764faf3f01bSAndreas Gohr    {
7652c2835c2SAndreas Gohr    }
7660cecf9d5Sandi
767cfa2b40eSAndreas Gohr    /**
768cfa2b40eSAndreas Gohr     * Open a table header
769cfa2b40eSAndreas Gohr     */
770faf3f01bSAndreas Gohr    public function tablethead_open()
771faf3f01bSAndreas Gohr    {
7722c2835c2SAndreas Gohr    }
773f05a1cc5SGerrit Uitslag
774cfa2b40eSAndreas Gohr    /**
775cfa2b40eSAndreas Gohr     * Close a table header
776cfa2b40eSAndreas Gohr     */
777faf3f01bSAndreas Gohr    public function tablethead_close()
778faf3f01bSAndreas Gohr    {
7792c2835c2SAndreas Gohr    }
780f05a1cc5SGerrit Uitslag
781cfa2b40eSAndreas Gohr    /**
7825a93f869SAnika Henke     * Open a table body
7835a93f869SAnika Henke     */
784faf3f01bSAndreas Gohr    public function tabletbody_open()
785faf3f01bSAndreas Gohr    {
7865a93f869SAnika Henke    }
7875a93f869SAnika Henke
7885a93f869SAnika Henke    /**
7895a93f869SAnika Henke     * Close a table body
7905a93f869SAnika Henke     */
791faf3f01bSAndreas Gohr    public function tabletbody_close()
792faf3f01bSAndreas Gohr    {
7935a93f869SAnika Henke    }
7945a93f869SAnika Henke
7955a93f869SAnika Henke    /**
796d2a99739SAndreas Gohr     * Open a table footer
797d2a99739SAndreas Gohr     */
798faf3f01bSAndreas Gohr    public function tabletfoot_open()
799faf3f01bSAndreas Gohr    {
800d2a99739SAndreas Gohr    }
801d2a99739SAndreas Gohr
802d2a99739SAndreas Gohr    /**
803d2a99739SAndreas Gohr     * Close a table footer
804d2a99739SAndreas Gohr     */
805faf3f01bSAndreas Gohr    public function tabletfoot_close()
806faf3f01bSAndreas Gohr    {
807d2a99739SAndreas Gohr    }
808d2a99739SAndreas Gohr
809d2a99739SAndreas Gohr    /**
810cfa2b40eSAndreas Gohr     * Open a table row
811cfa2b40eSAndreas Gohr     */
812faf3f01bSAndreas Gohr    public function tablerow_open()
813faf3f01bSAndreas Gohr    {
8142c2835c2SAndreas Gohr    }
8150cecf9d5Sandi
816cfa2b40eSAndreas Gohr    /**
817cfa2b40eSAndreas Gohr     * Close a table row
818cfa2b40eSAndreas Gohr     */
819faf3f01bSAndreas Gohr    public function tablerow_close()
820faf3f01bSAndreas Gohr    {
8212c2835c2SAndreas Gohr    }
8220cecf9d5Sandi
823cfa2b40eSAndreas Gohr    /**
824cfa2b40eSAndreas Gohr     * Open a table header cell
825cfa2b40eSAndreas Gohr     *
826cfa2b40eSAndreas Gohr     * @param int $colspan
827cfa2b40eSAndreas Gohr     * @param string $align left|center|right
828cfa2b40eSAndreas Gohr     * @param int $rowspan
829cfa2b40eSAndreas Gohr     */
830faf3f01bSAndreas Gohr    public function tableheader_open($colspan = 1, $align = null, $rowspan = 1)
831faf3f01bSAndreas Gohr    {
8322c2835c2SAndreas Gohr    }
8330cecf9d5Sandi
834cfa2b40eSAndreas Gohr    /**
835cfa2b40eSAndreas Gohr     * Close a table header cell
836cfa2b40eSAndreas Gohr     */
837faf3f01bSAndreas Gohr    public function tableheader_close()
838faf3f01bSAndreas Gohr    {
8392c2835c2SAndreas Gohr    }
8400cecf9d5Sandi
841cfa2b40eSAndreas Gohr    /**
842cfa2b40eSAndreas Gohr     * Open a table cell
843cfa2b40eSAndreas Gohr     *
844cfa2b40eSAndreas Gohr     * @param int $colspan
845cfa2b40eSAndreas Gohr     * @param string $align left|center|right
846cfa2b40eSAndreas Gohr     * @param int $rowspan
847cfa2b40eSAndreas Gohr     */
848faf3f01bSAndreas Gohr    public function tablecell_open($colspan = 1, $align = null, $rowspan = 1)
849faf3f01bSAndreas Gohr    {
8502c2835c2SAndreas Gohr    }
8510cecf9d5Sandi
852cfa2b40eSAndreas Gohr    /**
853cfa2b40eSAndreas Gohr     * Close a table cell
854cfa2b40eSAndreas Gohr     */
855faf3f01bSAndreas Gohr    public function tablecell_close()
856faf3f01bSAndreas Gohr    {
8572c2835c2SAndreas Gohr    }
8582ea4044fSAndreas Gohr
859cfa2b40eSAndreas Gohr    #endregion
860cfa2b40eSAndreas Gohr
861cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
8622ea4044fSAndreas Gohr
8632ea4044fSAndreas Gohr    /**
864de369923SAndreas Gohr     * Creates a linkid from a headline
865de369923SAndreas Gohr     *
866de369923SAndreas Gohr     * @param string $title The headline title
867de369923SAndreas Gohr     * @param boolean $create Create a new unique ID?
868de369923SAndreas Gohr     * @return string
869faf3f01bSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
870de369923SAndreas Gohr     */
871faf3f01bSAndreas Gohr    public function _headerToLink($title, $create = false)
872faf3f01bSAndreas Gohr    {
873de369923SAndreas Gohr        if ($create) {
874de369923SAndreas Gohr            return sectionID($title, $this->headers);
875de369923SAndreas Gohr        } else {
876de369923SAndreas Gohr            $check = false;
877de369923SAndreas Gohr            return sectionID($title, $check);
878de369923SAndreas Gohr        }
879de369923SAndreas Gohr    }
880de369923SAndreas Gohr
881de369923SAndreas Gohr    /**
8822ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
8832ea4044fSAndreas Gohr     * casing and special chars
8842ea4044fSAndreas Gohr     *
88542ea7f44SGerrit Uitslag     * @param string $name
88642ea7f44SGerrit Uitslag     * @return string
887faf3f01bSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
888faf3f01bSAndreas Gohr     *
8892ea4044fSAndreas Gohr     */
890faf3f01bSAndreas Gohr    public function _simpleTitle($name)
891faf3f01bSAndreas Gohr    {
8922ea4044fSAndreas Gohr        global $conf;
8932ea4044fSAndreas Gohr
894*fb021356SAndreas Gohr        // remove relative namespace
895*fb021356SAndreas Gohr        $name = ltrim($name, '~');
896*fb021356SAndreas Gohr
8972ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
898faf3f01bSAndreas Gohr        [$name, $hash] = sexplode('#', $name, 2);
8992ea4044fSAndreas Gohr        if ($hash) return $hash;
9002ea4044fSAndreas Gohr
9012ea4044fSAndreas Gohr        if ($conf['useslash']) {
9023755fc25STom N Harris            $name = strtr($name, ';/', ';:');
9033755fc25STom N Harris        } else {
9043755fc25STom N Harris            $name = strtr($name, ';', ':');
9052ea4044fSAndreas Gohr        }
9062ea4044fSAndreas Gohr
9079708106bSAdrian Lang        return noNSorNS($name);
9082ea4044fSAndreas Gohr    }
9092ea4044fSAndreas Gohr
9101f82fabeSAndreas Gohr    /**
9111f82fabeSAndreas Gohr     * Resolve an interwikilink
91242ea7f44SGerrit Uitslag     *
91342ea7f44SGerrit Uitslag     * @param string $shortcut identifier for the interwiki link
91442ea7f44SGerrit Uitslag     * @param string $reference fragment that refers the content
91542ea7f44SGerrit Uitslag     * @param null|bool $exists reference which returns if an internal page exists
91642ea7f44SGerrit Uitslag     * @return string interwikilink
9171f82fabeSAndreas Gohr     */
918faf3f01bSAndreas Gohr    public function _resolveInterWiki(&$shortcut, $reference, &$exists = null)
919faf3f01bSAndreas Gohr    {
9201f82fabeSAndreas Gohr        //get interwiki URL
9211f82fabeSAndreas Gohr        if (isset($this->interwiki[$shortcut])) {
9221f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
923768be5a3SPhy        } elseif (isset($this->interwiki['default'])) {
924768be5a3SPhy            $shortcut = 'default';
925768be5a3SPhy            $url = $this->interwiki[$shortcut];
9261f82fabeSAndreas Gohr        } else {
927abde5980SPhy            // not parsable interwiki outputs '' to make sure string manipluation works
928abde5980SPhy            $shortcut = '';
929abde5980SPhy            $url = '';
9301f82fabeSAndreas Gohr        }
9312ea4044fSAndreas Gohr
9321f82fabeSAndreas Gohr        //split into hash and url part
93317e17ae2SPatrick Brown        $hash = strrchr($reference, '#');
93417e17ae2SPatrick Brown        if ($hash) {
93517e17ae2SPatrick Brown            $reference = substr($reference, 0, -strlen($hash));
93617e17ae2SPatrick Brown            $hash = substr($hash, 1);
93717e17ae2SPatrick Brown        }
9381f82fabeSAndreas Gohr
9391f82fabeSAndreas Gohr        //replace placeholder
9401f82fabeSAndreas Gohr        if (preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
9411f82fabeSAndreas Gohr            //use placeholders
9421f82fabeSAndreas Gohr            $url = str_replace('{URL}', rawurlencode($reference), $url);
94317e17ae2SPatrick Brown            //wiki names will be cleaned next, otherwise urlencode unsafe chars
944faf3f01bSAndreas Gohr            $url = str_replace(
945faf3f01bSAndreas Gohr                '{NAME}',
946faf3f01bSAndreas Gohr                ($url[0] === ':') ? $reference : preg_replace_callback(
94795078f23SAndreas Gohr                    '/[[\\\\\]^`{|}#%]/',
94895078f23SAndreas Gohr                    static fn($match) => rawurlencode($match[0]),
94995078f23SAndreas Gohr                    $reference
950faf3f01bSAndreas Gohr                ),
951faf3f01bSAndreas Gohr                $url
952faf3f01bSAndreas Gohr            );
9531f82fabeSAndreas Gohr            $parsed = parse_url($reference);
9548f34cf3dSMichael Große            if (empty($parsed['scheme'])) $parsed['scheme'] = '';
9558f34cf3dSMichael Große            if (empty($parsed['host'])) $parsed['host'] = '';
9568f34cf3dSMichael Große            if (empty($parsed['port'])) $parsed['port'] = 80;
9578f34cf3dSMichael Große            if (empty($parsed['path'])) $parsed['path'] = '';
9588f34cf3dSMichael Große            if (empty($parsed['query'])) $parsed['query'] = '';
9598f34cf3dSMichael Große            $url = strtr($url, [
9608f34cf3dSMichael Große                '{SCHEME}' => $parsed['scheme'],
9618f34cf3dSMichael Große                '{HOST}' => $parsed['host'],
9628f34cf3dSMichael Große                '{PORT}' => $parsed['port'],
9638f34cf3dSMichael Große                '{PATH}' => $parsed['path'],
9648f34cf3dSMichael Große                '{QUERY}' => $parsed['query'],
9658f34cf3dSMichael Große            ]);
966abde5980SPhy        } elseif ($url != '') {
967abde5980SPhy            // make sure when no url is defined, we keep it null
9681f82fabeSAndreas Gohr            // default
969faf3f01bSAndreas Gohr            $url .= rawurlencode($reference);
9701f82fabeSAndreas Gohr        }
971f379edc2SGerrit Uitslag        //handle as wiki links
972056bf31fSDamien Regad        if ($url && $url[0] === ':') {
973ac1d8211SAndreas Gohr            $urlparam = '';
974c55b109cSMichael Große            $id = $url;
975c55b109cSMichael Große            if (strpos($url, '?') !== false) {
976faf3f01bSAndreas Gohr                [$id, $urlparam] = sexplode('?', $url, 2, '');
977c55b109cSMichael Große            }
9786496c33fSGerrit Uitslag            $url = wl(cleanID($id), $urlparam);
9796496c33fSGerrit Uitslag            $exists = page_exists($id);
9802345e871SGerrit Uitslag        }
9811f82fabeSAndreas Gohr        if ($hash) $url .= '#' . rawurlencode($hash);
9821f82fabeSAndreas Gohr
9831f82fabeSAndreas Gohr        return $url;
9841f82fabeSAndreas Gohr    }
985cfa2b40eSAndreas Gohr
986cfa2b40eSAndreas Gohr    #endregion
9870cecf9d5Sandi}
9880cecf9d5Sandi
989340756e4Sandi
990e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
991