xref: /dokuwiki/inc/parser/renderer.php (revision 95078f236f25cbd6aa6d3e5aae7a3f3d39de6834)
10cecf9d5Sandi<?php
2*95078f23SAndreas 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 = [
34faf3f01bSAndreas Gohr        'cache' => true,
35faf3f01bSAndreas Gohr        // may the rendered result cached?
36faf3f01bSAndreas Gohr        'toc' => true,
37faf3f01bSAndreas Gohr    ];
389dc2c2afSandi
39cfa2b40eSAndreas Gohr    /** @var array contains the smiley configuration, set in p_render() */
40faf3f01bSAndreas Gohr    public $smileys = [];
41cfa2b40eSAndreas Gohr    /** @var array contains the entity configuration, set in p_render() */
42faf3f01bSAndreas Gohr    public $entities = [];
43cfa2b40eSAndreas Gohr    /** @var array contains the acronym configuration, set in p_render() */
44faf3f01bSAndreas Gohr    public $acronyms = [];
45cfa2b40eSAndreas Gohr    /** @var array contains the interwiki configuration, set in p_render() */
46faf3f01bSAndreas Gohr    public $interwiki = [];
4778b498a7SAndreas Gohr    /** @var string|int link pages and media against this revision */
4878b498a7SAndreas Gohr    public $date_at = '';
49e41c4da9SAndreas Gohr
50de369923SAndreas Gohr    /** @var array the list of headers used to create unique link ids */
51faf3f01bSAndreas Gohr    protected $headers = [];
52de369923SAndreas Gohr
535f70445dSAndreas Gohr    /**
54cfa2b40eSAndreas Gohr     * @var string the rendered document, this will be cached after the renderer ran through
555f70445dSAndreas Gohr     */
56cfa2b40eSAndreas Gohr    public $doc = '';
57cfa2b40eSAndreas Gohr
58cfa2b40eSAndreas Gohr    /**
59cfa2b40eSAndreas Gohr     * clean out any per-use values
60cfa2b40eSAndreas Gohr     *
61cfa2b40eSAndreas Gohr     * This is called before each use of the renderer object and should be used to
62cfa2b40eSAndreas Gohr     * completely reset the state of the renderer to be reused for a new document
63cfa2b40eSAndreas Gohr     */
64faf3f01bSAndreas Gohr    public function reset()
65faf3f01bSAndreas Gohr    {
66faf3f01bSAndreas Gohr        $this->headers = [];
67abaaba9aSSatoshi Sahara        $this->doc = '';
68abaaba9aSSatoshi Sahara        $this->info['cache'] = true;
69abaaba9aSSatoshi Sahara        $this->info['toc'] = true;
705f70445dSAndreas Gohr    }
715f70445dSAndreas Gohr
72f6ec8df8SAdrian Lang    /**
73f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
74f6ec8df8SAdrian Lang     *
75cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
76cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
77cfa2b40eSAndreas Gohr     *
78f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
79f6ec8df8SAdrian Lang     */
80faf3f01bSAndreas Gohr    public function isSingleton()
81faf3f01bSAndreas Gohr    {
82f6ec8df8SAdrian Lang        return false;
83f6ec8df8SAdrian Lang    }
84f6ec8df8SAdrian Lang
858cc41db0SAndreas Gohr    /**
86cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
87cfa2b40eSAndreas Gohr     *
88cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
89cfa2b40eSAndreas Gohr     *
90cfa2b40eSAndreas Gohr     * @return string
91cfa2b40eSAndreas Gohr     */
92de369923SAndreas Gohr    abstract public function getFormat();
93cfa2b40eSAndreas Gohr
94cfa2b40eSAndreas Gohr    /**
95cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
96cfa2b40eSAndreas Gohr     */
97faf3f01bSAndreas Gohr    public function nocache()
98faf3f01bSAndreas Gohr    {
99cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
100cfa2b40eSAndreas Gohr    }
101cfa2b40eSAndreas Gohr
102cfa2b40eSAndreas Gohr    /**
103cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
104cfa2b40eSAndreas Gohr     *
105cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
106cfa2b40eSAndreas Gohr     */
107faf3f01bSAndreas Gohr    public function notoc()
108faf3f01bSAndreas Gohr    {
109cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
110cfa2b40eSAndreas Gohr    }
111cfa2b40eSAndreas Gohr
112cfa2b40eSAndreas Gohr    /**
113cfa2b40eSAndreas Gohr     * Handle plugin rendering
114cfa2b40eSAndreas Gohr     *
115cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
1168cc41db0SAndreas Gohr     *
1178cc41db0SAndreas Gohr     * @param string $name Plugin name
1188cc41db0SAndreas Gohr     * @param mixed $data custom data set by handler
1198cc41db0SAndreas Gohr     * @param string $state matched state if any
1208cc41db0SAndreas Gohr     * @param string $match raw matched syntax
1218cc41db0SAndreas Gohr     */
122faf3f01bSAndreas Gohr    public function plugin($name, $data, $state = '', $match = '')
123faf3f01bSAndreas Gohr    {
124e1d9dcc8SAndreas Gohr        /** @var SyntaxPlugin $plugin */
125e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
12661faf446Schris        if ($plugin != null) {
1275f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
12861faf446Schris        }
12961faf446Schris    }
13061faf446Schris
1315587e44cSchris    /**
1325587e44cSchris     * handle nested render instructions
1335587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
134cfa2b40eSAndreas Gohr     *
135cfa2b40eSAndreas Gohr     * @param array $instructions
1365587e44cSchris     */
137faf3f01bSAndreas Gohr    public function nest($instructions)
138faf3f01bSAndreas Gohr    {
1395587e44cSchris        foreach ($instructions as $instruction) {
1405587e44cSchris            // execute the callback against ourself
141c2122b83SChristopher Smith            if (method_exists($this, $instruction[0])) {
142faf3f01bSAndreas Gohr                call_user_func_array([$this, $instruction[0]], $instruction[1] ?: []);
143c2122b83SChristopher Smith            }
1445587e44cSchris        }
1455587e44cSchris    }
1465587e44cSchris
147cfa2b40eSAndreas Gohr    /**
148cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
149cfa2b40eSAndreas Gohr     *
150cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
151cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
152cfa2b40eSAndreas Gohr     */
153faf3f01bSAndreas Gohr    public function nest_close()
154faf3f01bSAndreas Gohr    {
1552c2835c2SAndreas Gohr    }
1565587e44cSchris
157cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
158cfa2b40eSAndreas Gohr
159cfa2b40eSAndreas Gohr    /**
160cfa2b40eSAndreas Gohr     * Initialize the document
161cfa2b40eSAndreas Gohr     */
162faf3f01bSAndreas Gohr    public function document_start()
163faf3f01bSAndreas Gohr    {
1642c2835c2SAndreas Gohr    }
1650cecf9d5Sandi
166cfa2b40eSAndreas Gohr    /**
167cfa2b40eSAndreas Gohr     * Finalize the document
168cfa2b40eSAndreas Gohr     */
169faf3f01bSAndreas Gohr    public function document_end()
170faf3f01bSAndreas Gohr    {
1712c2835c2SAndreas Gohr    }
1720cecf9d5Sandi
173cfa2b40eSAndreas Gohr    /**
174cfa2b40eSAndreas Gohr     * Render the Table of Contents
175cfa2b40eSAndreas Gohr     *
176cfa2b40eSAndreas Gohr     * @return string
177cfa2b40eSAndreas Gohr     */
178faf3f01bSAndreas Gohr    public function render_TOC()
179faf3f01bSAndreas Gohr    {
1802c2835c2SAndreas Gohr        return '';
1812c2835c2SAndreas Gohr    }
1820cecf9d5Sandi
183cfa2b40eSAndreas Gohr    /**
184cfa2b40eSAndreas Gohr     * Add an item to the TOC
185cfa2b40eSAndreas Gohr     *
186cfa2b40eSAndreas Gohr     * @param string $id the hash link
187cfa2b40eSAndreas Gohr     * @param string $text the text to display
188cfa2b40eSAndreas Gohr     * @param int $level the nesting level
189cfa2b40eSAndreas Gohr     */
190faf3f01bSAndreas Gohr    public function toc_additem($id, $text, $level)
191faf3f01bSAndreas Gohr    {
1922c2835c2SAndreas Gohr    }
193e7856beaSchris
194cfa2b40eSAndreas Gohr    /**
195cfa2b40eSAndreas Gohr     * Render a heading
196cfa2b40eSAndreas Gohr     *
197cfa2b40eSAndreas Gohr     * @param string $text the text to display
198cfa2b40eSAndreas Gohr     * @param int $level header level
199cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
200cfa2b40eSAndreas Gohr     */
201faf3f01bSAndreas Gohr    public function header($text, $level, $pos)
202faf3f01bSAndreas Gohr    {
2032c2835c2SAndreas Gohr    }
2040cecf9d5Sandi
205cfa2b40eSAndreas Gohr    /**
206cfa2b40eSAndreas Gohr     * Open a new section
207cfa2b40eSAndreas Gohr     *
208cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
209cfa2b40eSAndreas Gohr     */
210faf3f01bSAndreas Gohr    public function section_open($level)
211faf3f01bSAndreas Gohr    {
2122c2835c2SAndreas Gohr    }
2130cecf9d5Sandi
214cfa2b40eSAndreas Gohr    /**
215cfa2b40eSAndreas Gohr     * Close the current section
216cfa2b40eSAndreas Gohr     */
217faf3f01bSAndreas Gohr    public function section_close()
218faf3f01bSAndreas Gohr    {
2192c2835c2SAndreas Gohr    }
2200cecf9d5Sandi
221cfa2b40eSAndreas Gohr    /**
222cfa2b40eSAndreas Gohr     * Render plain text data
223cfa2b40eSAndreas Gohr     *
22442ea7f44SGerrit Uitslag     * @param string $text
225cfa2b40eSAndreas Gohr     */
226faf3f01bSAndreas Gohr    public function cdata($text)
227faf3f01bSAndreas Gohr    {
2282c2835c2SAndreas Gohr    }
2290cecf9d5Sandi
230cfa2b40eSAndreas Gohr    /**
231cfa2b40eSAndreas Gohr     * Open a paragraph
232cfa2b40eSAndreas Gohr     */
233faf3f01bSAndreas Gohr    public function p_open()
234faf3f01bSAndreas Gohr    {
2352c2835c2SAndreas Gohr    }
2360cecf9d5Sandi
237cfa2b40eSAndreas Gohr    /**
238cfa2b40eSAndreas Gohr     * Close a paragraph
239cfa2b40eSAndreas Gohr     */
240faf3f01bSAndreas Gohr    public function p_close()
241faf3f01bSAndreas Gohr    {
2422c2835c2SAndreas Gohr    }
2430cecf9d5Sandi
244cfa2b40eSAndreas Gohr    /**
2453dd5c225SAndreas Gohr     * Create a line break
246cfa2b40eSAndreas Gohr     */
247faf3f01bSAndreas Gohr    public function linebreak()
248faf3f01bSAndreas Gohr    {
2492c2835c2SAndreas Gohr    }
2500cecf9d5Sandi
251cfa2b40eSAndreas Gohr    /**
252cfa2b40eSAndreas Gohr     * Create a horizontal line
253cfa2b40eSAndreas Gohr     */
254faf3f01bSAndreas Gohr    public function hr()
255faf3f01bSAndreas Gohr    {
2562c2835c2SAndreas Gohr    }
2570cecf9d5Sandi
258cfa2b40eSAndreas Gohr    /**
259cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
260cfa2b40eSAndreas Gohr     */
261faf3f01bSAndreas Gohr    public function strong_open()
262faf3f01bSAndreas Gohr    {
2632c2835c2SAndreas Gohr    }
2640cecf9d5Sandi
265cfa2b40eSAndreas Gohr    /**
266cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
267cfa2b40eSAndreas Gohr     */
268faf3f01bSAndreas Gohr    public function strong_close()
269faf3f01bSAndreas Gohr    {
2702c2835c2SAndreas Gohr    }
2710cecf9d5Sandi
272cfa2b40eSAndreas Gohr    /**
273cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
274cfa2b40eSAndreas Gohr     */
275faf3f01bSAndreas Gohr    public function emphasis_open()
276faf3f01bSAndreas Gohr    {
2772c2835c2SAndreas Gohr    }
2780cecf9d5Sandi
279cfa2b40eSAndreas Gohr    /**
280cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
281cfa2b40eSAndreas Gohr     */
282faf3f01bSAndreas Gohr    public function emphasis_close()
283faf3f01bSAndreas Gohr    {
2842c2835c2SAndreas Gohr    }
2850cecf9d5Sandi
286cfa2b40eSAndreas Gohr    /**
287cfa2b40eSAndreas Gohr     * Start underline formatting
288cfa2b40eSAndreas Gohr     */
289faf3f01bSAndreas Gohr    public function underline_open()
290faf3f01bSAndreas Gohr    {
2912c2835c2SAndreas Gohr    }
2920cecf9d5Sandi
293cfa2b40eSAndreas Gohr    /**
294cfa2b40eSAndreas Gohr     * Stop underline formatting
295cfa2b40eSAndreas Gohr     */
296faf3f01bSAndreas Gohr    public function underline_close()
297faf3f01bSAndreas Gohr    {
2982c2835c2SAndreas Gohr    }
2990cecf9d5Sandi
300cfa2b40eSAndreas Gohr    /**
301cfa2b40eSAndreas Gohr     * Start monospace formatting
302cfa2b40eSAndreas Gohr     */
303faf3f01bSAndreas Gohr    public function monospace_open()
304faf3f01bSAndreas Gohr    {
3052c2835c2SAndreas Gohr    }
3060cecf9d5Sandi
307cfa2b40eSAndreas Gohr    /**
308cfa2b40eSAndreas Gohr     * Stop monospace formatting
309cfa2b40eSAndreas Gohr     */
310faf3f01bSAndreas Gohr    public function monospace_close()
311faf3f01bSAndreas Gohr    {
3122c2835c2SAndreas Gohr    }
3130cecf9d5Sandi
314cfa2b40eSAndreas Gohr    /**
315cfa2b40eSAndreas Gohr     * Start a subscript
316cfa2b40eSAndreas Gohr     */
317faf3f01bSAndreas Gohr    public function subscript_open()
318faf3f01bSAndreas Gohr    {
3192c2835c2SAndreas Gohr    }
3200cecf9d5Sandi
321cfa2b40eSAndreas Gohr    /**
322cfa2b40eSAndreas Gohr     * Stop a subscript
323cfa2b40eSAndreas Gohr     */
324faf3f01bSAndreas Gohr    public function subscript_close()
325faf3f01bSAndreas Gohr    {
3262c2835c2SAndreas Gohr    }
3270cecf9d5Sandi
328cfa2b40eSAndreas Gohr    /**
329cfa2b40eSAndreas Gohr     * Start a superscript
330cfa2b40eSAndreas Gohr     */
331faf3f01bSAndreas Gohr    public function superscript_open()
332faf3f01bSAndreas Gohr    {
3332c2835c2SAndreas Gohr    }
3340cecf9d5Sandi
335cfa2b40eSAndreas Gohr    /**
336cfa2b40eSAndreas Gohr     * Stop a superscript
337cfa2b40eSAndreas Gohr     */
338faf3f01bSAndreas Gohr    public function superscript_close()
339faf3f01bSAndreas Gohr    {
3402c2835c2SAndreas Gohr    }
3410cecf9d5Sandi
342cfa2b40eSAndreas Gohr    /**
343cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
344cfa2b40eSAndreas Gohr     */
345faf3f01bSAndreas Gohr    public function deleted_open()
346faf3f01bSAndreas Gohr    {
3472c2835c2SAndreas Gohr    }
3480cecf9d5Sandi
349cfa2b40eSAndreas Gohr    /**
350cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
351cfa2b40eSAndreas Gohr     */
352faf3f01bSAndreas Gohr    public function deleted_close()
353faf3f01bSAndreas Gohr    {
3542c2835c2SAndreas Gohr    }
3550cecf9d5Sandi
356cfa2b40eSAndreas Gohr    /**
357cfa2b40eSAndreas Gohr     * Start a footnote
358cfa2b40eSAndreas Gohr     */
359faf3f01bSAndreas Gohr    public function footnote_open()
360faf3f01bSAndreas Gohr    {
3612c2835c2SAndreas Gohr    }
3620cecf9d5Sandi
363cfa2b40eSAndreas Gohr    /**
364cfa2b40eSAndreas Gohr     * Stop a footnote
365cfa2b40eSAndreas Gohr     */
366faf3f01bSAndreas Gohr    public function footnote_close()
367faf3f01bSAndreas Gohr    {
3682c2835c2SAndreas Gohr    }
3690cecf9d5Sandi
370cfa2b40eSAndreas Gohr    /**
371cfa2b40eSAndreas Gohr     * Open an unordered list
372cfa2b40eSAndreas Gohr     */
373faf3f01bSAndreas Gohr    public function listu_open()
374faf3f01bSAndreas Gohr    {
3752c2835c2SAndreas Gohr    }
3760cecf9d5Sandi
377cfa2b40eSAndreas Gohr    /**
378cfa2b40eSAndreas Gohr     * Close an unordered list
379cfa2b40eSAndreas Gohr     */
380faf3f01bSAndreas Gohr    public function listu_close()
381faf3f01bSAndreas Gohr    {
3822c2835c2SAndreas Gohr    }
3830cecf9d5Sandi
384cfa2b40eSAndreas Gohr    /**
385cfa2b40eSAndreas Gohr     * Open an ordered list
386cfa2b40eSAndreas Gohr     */
387faf3f01bSAndreas Gohr    public function listo_open()
388faf3f01bSAndreas Gohr    {
3892c2835c2SAndreas Gohr    }
3900cecf9d5Sandi
391cfa2b40eSAndreas Gohr    /**
392cfa2b40eSAndreas Gohr     * Close an ordered list
393cfa2b40eSAndreas Gohr     */
394faf3f01bSAndreas Gohr    public function listo_close()
395faf3f01bSAndreas Gohr    {
3962c2835c2SAndreas Gohr    }
3970cecf9d5Sandi
398cfa2b40eSAndreas Gohr    /**
399cfa2b40eSAndreas Gohr     * Open a list item
400cfa2b40eSAndreas Gohr     *
401cfa2b40eSAndreas Gohr     * @param int $level the nesting level
402e3a24861SChristopher Smith     * @param bool $node true when a node; false when a leaf
403cfa2b40eSAndreas Gohr     */
404faf3f01bSAndreas Gohr    public function listitem_open($level, $node = false)
405faf3f01bSAndreas Gohr    {
4062c2835c2SAndreas Gohr    }
4070cecf9d5Sandi
408cfa2b40eSAndreas Gohr    /**
409cfa2b40eSAndreas Gohr     * Close a list item
410cfa2b40eSAndreas Gohr     */
411faf3f01bSAndreas Gohr    public function listitem_close()
412faf3f01bSAndreas Gohr    {
4132c2835c2SAndreas Gohr    }
4140cecf9d5Sandi
415cfa2b40eSAndreas Gohr    /**
416cfa2b40eSAndreas Gohr     * Start the content of a list item
417cfa2b40eSAndreas Gohr     */
418faf3f01bSAndreas Gohr    public function listcontent_open()
419faf3f01bSAndreas Gohr    {
4202c2835c2SAndreas Gohr    }
4210cecf9d5Sandi
422cfa2b40eSAndreas Gohr    /**
423cfa2b40eSAndreas Gohr     * Stop the content of a list item
424cfa2b40eSAndreas Gohr     */
425faf3f01bSAndreas Gohr    public function listcontent_close()
426faf3f01bSAndreas Gohr    {
4272c2835c2SAndreas Gohr    }
4280cecf9d5Sandi
429cfa2b40eSAndreas Gohr    /**
430cfa2b40eSAndreas Gohr     * Output unformatted $text
431cfa2b40eSAndreas Gohr     *
432cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
433cfa2b40eSAndreas Gohr     *
434cfa2b40eSAndreas Gohr     * @param string $text
435cfa2b40eSAndreas Gohr     */
436faf3f01bSAndreas Gohr    public function unformatted($text)
437faf3f01bSAndreas Gohr    {
438cfa2b40eSAndreas Gohr        $this->cdata($text);
4392c2835c2SAndreas Gohr    }
4400cecf9d5Sandi
441cfa2b40eSAndreas Gohr    /**
442cfa2b40eSAndreas Gohr     * Output preformatted text
443cfa2b40eSAndreas Gohr     *
444cfa2b40eSAndreas Gohr     * @param string $text
445cfa2b40eSAndreas Gohr     */
446faf3f01bSAndreas Gohr    public function preformatted($text)
447faf3f01bSAndreas Gohr    {
4482c2835c2SAndreas Gohr    }
4490cecf9d5Sandi
450cfa2b40eSAndreas Gohr    /**
451cfa2b40eSAndreas Gohr     * Start a block quote
452cfa2b40eSAndreas Gohr     */
453faf3f01bSAndreas Gohr    public function quote_open()
454faf3f01bSAndreas Gohr    {
4552c2835c2SAndreas Gohr    }
4560cecf9d5Sandi
457cfa2b40eSAndreas Gohr    /**
458cfa2b40eSAndreas Gohr     * Stop a block quote
459cfa2b40eSAndreas Gohr     */
460faf3f01bSAndreas Gohr    public function quote_close()
461faf3f01bSAndreas Gohr    {
4622c2835c2SAndreas Gohr    }
4630cecf9d5Sandi
464cfa2b40eSAndreas Gohr    /**
465cfa2b40eSAndreas Gohr     * Display text as file 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     */
471faf3f01bSAndreas Gohr    public function file($text, $lang = null, $file = null)
472faf3f01bSAndreas Gohr    {
4732c2835c2SAndreas Gohr    }
4743d491f75SAndreas Gohr
475cfa2b40eSAndreas Gohr    /**
476cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
477cfa2b40eSAndreas Gohr     *
478cfa2b40eSAndreas Gohr     * @param string $text text to show
479cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
480cfa2b40eSAndreas Gohr     * @param string $file file path label
481cfa2b40eSAndreas Gohr     */
482faf3f01bSAndreas Gohr    public function code($text, $lang = null, $file = null)
483faf3f01bSAndreas Gohr    {
4842c2835c2SAndreas Gohr    }
4850cecf9d5Sandi
486cfa2b40eSAndreas Gohr    /**
487cfa2b40eSAndreas Gohr     * Format an acronym
488cfa2b40eSAndreas Gohr     *
489cfa2b40eSAndreas Gohr     * Uses $this->acronyms
490cfa2b40eSAndreas Gohr     *
491cfa2b40eSAndreas Gohr     * @param string $acronym
492cfa2b40eSAndreas Gohr     */
493faf3f01bSAndreas Gohr    public function acronym($acronym)
494faf3f01bSAndreas Gohr    {
4952c2835c2SAndreas Gohr    }
4960cecf9d5Sandi
497cfa2b40eSAndreas Gohr    /**
498cfa2b40eSAndreas Gohr     * Format a smiley
499cfa2b40eSAndreas Gohr     *
500cfa2b40eSAndreas Gohr     * Uses $this->smiley
501cfa2b40eSAndreas Gohr     *
502cfa2b40eSAndreas Gohr     * @param string $smiley
503cfa2b40eSAndreas Gohr     */
504faf3f01bSAndreas Gohr    public function smiley($smiley)
505faf3f01bSAndreas Gohr    {
5062c2835c2SAndreas Gohr    }
5070cecf9d5Sandi
508cfa2b40eSAndreas Gohr    /**
509cfa2b40eSAndreas Gohr     * Format an entity
510cfa2b40eSAndreas Gohr     *
511cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
512cfa2b40eSAndreas Gohr     *
513cfa2b40eSAndreas Gohr     * Uses $this->entities
514cfa2b40eSAndreas Gohr     *
515cfa2b40eSAndreas Gohr     * @param string $entity
516cfa2b40eSAndreas Gohr     */
517faf3f01bSAndreas Gohr    public function entity($entity)
518faf3f01bSAndreas Gohr    {
5192c2835c2SAndreas Gohr    }
5200cecf9d5Sandi
521cfa2b40eSAndreas Gohr    /**
522cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
523cfa2b40eSAndreas Gohr     *
524cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
525cfa2b40eSAndreas Gohr     *
526cfa2b40eSAndreas Gohr     * @param string|int $x first value
527cfa2b40eSAndreas Gohr     * @param string|int $y second value
528cfa2b40eSAndreas Gohr     */
529faf3f01bSAndreas Gohr    public function multiplyentity($x, $y)
530faf3f01bSAndreas Gohr    {
5312c2835c2SAndreas Gohr    }
5320cecf9d5Sandi
533cfa2b40eSAndreas Gohr    /**
534cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
535cfa2b40eSAndreas Gohr     */
536faf3f01bSAndreas Gohr    public function singlequoteopening()
537faf3f01bSAndreas Gohr    {
5382c2835c2SAndreas Gohr    }
5390cecf9d5Sandi
540cfa2b40eSAndreas Gohr    /**
541cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
542cfa2b40eSAndreas Gohr     */
543faf3f01bSAndreas Gohr    public function singlequoteclosing()
544faf3f01bSAndreas Gohr    {
5452c2835c2SAndreas Gohr    }
5460cecf9d5Sandi
547cfa2b40eSAndreas Gohr    /**
548cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
549cfa2b40eSAndreas Gohr     */
550faf3f01bSAndreas Gohr    public function apostrophe()
551faf3f01bSAndreas Gohr    {
5522c2835c2SAndreas Gohr    }
55357d757d1SAndreas Gohr
554cfa2b40eSAndreas Gohr    /**
555cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
556cfa2b40eSAndreas Gohr     */
557faf3f01bSAndreas Gohr    public function doublequoteopening()
558faf3f01bSAndreas Gohr    {
5592c2835c2SAndreas Gohr    }
5600cecf9d5Sandi
561cfa2b40eSAndreas Gohr    /**
562cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
563cfa2b40eSAndreas Gohr     */
564faf3f01bSAndreas Gohr    public function doublequoteclosing()
565faf3f01bSAndreas Gohr    {
5662c2835c2SAndreas Gohr    }
5670cecf9d5Sandi
568cfa2b40eSAndreas Gohr    /**
569cfa2b40eSAndreas Gohr     * Render a CamelCase link
570cfa2b40eSAndreas Gohr     *
571cfa2b40eSAndreas Gohr     * @param string $link The link name
572cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
573cfa2b40eSAndreas Gohr     */
574faf3f01bSAndreas Gohr    public function camelcaselink($link)
575faf3f01bSAndreas Gohr    {
5762c2835c2SAndreas Gohr    }
5770cecf9d5Sandi
578cfa2b40eSAndreas Gohr    /**
579cfa2b40eSAndreas Gohr     * Render a page local link
580cfa2b40eSAndreas Gohr     *
581cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
582cfa2b40eSAndreas Gohr     * @param string $name name for the link
583cfa2b40eSAndreas Gohr     */
584faf3f01bSAndreas Gohr    public function locallink($hash, $name = null)
585faf3f01bSAndreas Gohr    {
5862c2835c2SAndreas Gohr    }
587a939d432SAndreas Gohr
588cfa2b40eSAndreas Gohr    /**
589cfa2b40eSAndreas Gohr     * Render a wiki internal link
590cfa2b40eSAndreas Gohr     *
591cfa2b40eSAndreas Gohr     * @param string $link page ID to link to. eg. 'wiki:syntax'
592cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
593cfa2b40eSAndreas Gohr     */
594faf3f01bSAndreas Gohr    public function internallink($link, $title = null)
595faf3f01bSAndreas Gohr    {
5962c2835c2SAndreas Gohr    }
5970cecf9d5Sandi
598cfa2b40eSAndreas Gohr    /**
599cfa2b40eSAndreas Gohr     * Render an external link
600cfa2b40eSAndreas Gohr     *
601cfa2b40eSAndreas Gohr     * @param string $link full URL with scheme
602cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
603cfa2b40eSAndreas Gohr     */
604faf3f01bSAndreas Gohr    public function externallink($link, $title = null)
605faf3f01bSAndreas Gohr    {
6062c2835c2SAndreas Gohr    }
6070cecf9d5Sandi
608cfa2b40eSAndreas Gohr    /**
609cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
610cfa2b40eSAndreas Gohr     *
611cfa2b40eSAndreas Gohr     * @param string $url URL of the feed
612cfa2b40eSAndreas Gohr     * @param array $params Finetuning of the output
613cfa2b40eSAndreas Gohr     */
614faf3f01bSAndreas Gohr    public function rss($url, $params)
615faf3f01bSAndreas Gohr    {
6162c2835c2SAndreas Gohr    }
617c5cfca61SAndreas Gohr
618cfa2b40eSAndreas Gohr    /**
619cfa2b40eSAndreas Gohr     * Render an interwiki link
620cfa2b40eSAndreas Gohr     *
621cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
622cfa2b40eSAndreas Gohr     *
623cfa2b40eSAndreas Gohr     * @param string $link original link - probably not much use
624cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
625cfa2b40eSAndreas Gohr     * @param string $wikiName indentifier (shortcut) for the remote wiki
626cfa2b40eSAndreas Gohr     * @param string $wikiUri the fragment parsed from the original link
627cfa2b40eSAndreas Gohr     */
628faf3f01bSAndreas Gohr    public function interwikilink($link, $title, $wikiName, $wikiUri)
629faf3f01bSAndreas Gohr    {
6302c2835c2SAndreas Gohr    }
6310cecf9d5Sandi
632cfa2b40eSAndreas Gohr    /**
633cfa2b40eSAndreas Gohr     * Link to file on users OS
634cfa2b40eSAndreas Gohr     *
635cfa2b40eSAndreas Gohr     * @param string $link the link
636cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
637cfa2b40eSAndreas Gohr     */
638faf3f01bSAndreas Gohr    public function filelink($link, $title = null)
639faf3f01bSAndreas Gohr    {
6402c2835c2SAndreas Gohr    }
6410cecf9d5Sandi
642cfa2b40eSAndreas Gohr    /**
643cfa2b40eSAndreas Gohr     * Link to windows share
644cfa2b40eSAndreas Gohr     *
645cfa2b40eSAndreas Gohr     * @param string $link the link
646cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
647cfa2b40eSAndreas Gohr     */
648faf3f01bSAndreas Gohr    public function windowssharelink($link, $title = null)
649faf3f01bSAndreas Gohr    {
6502c2835c2SAndreas Gohr    }
6510cecf9d5Sandi
652cfa2b40eSAndreas Gohr    /**
653cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
654cfa2b40eSAndreas Gohr     *
655cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
656cfa2b40eSAndreas Gohr     *
657cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6583dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
659cfa2b40eSAndreas Gohr     */
660faf3f01bSAndreas Gohr    public function emaillink($address, $name = null)
661faf3f01bSAndreas Gohr    {
6622c2835c2SAndreas Gohr    }
6630cecf9d5Sandi
664cfa2b40eSAndreas Gohr    /**
665cfa2b40eSAndreas Gohr     * Render 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     * @param string $linking linkonly|detail|nolink
674cfa2b40eSAndreas Gohr     */
675*95078f23SAndreas Gohr    public function internalmedia(
676*95078f23SAndreas Gohr        $src,
677*95078f23SAndreas Gohr        $title = null,
678*95078f23SAndreas Gohr        $align = null,
679*95078f23SAndreas Gohr        $width = null,
680*95078f23SAndreas Gohr        $height = null,
681*95078f23SAndreas Gohr        $cache = null,
682*95078f23SAndreas Gohr        $linking = null
683*95078f23SAndreas Gohr    ) {
6842c2835c2SAndreas Gohr    }
685a939d432SAndreas Gohr
686cfa2b40eSAndreas Gohr    /**
687cfa2b40eSAndreas Gohr     * Render an external media file
688cfa2b40eSAndreas Gohr     *
689cfa2b40eSAndreas Gohr     * @param string $src full media URL
690cfa2b40eSAndreas Gohr     * @param string $title descriptive text
691cfa2b40eSAndreas Gohr     * @param string $align left|center|right
692cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
693cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
694cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
695cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
696cfa2b40eSAndreas Gohr     */
697*95078f23SAndreas Gohr    public function externalmedia(
698*95078f23SAndreas Gohr        $src,
699*95078f23SAndreas Gohr        $title = null,
700*95078f23SAndreas Gohr        $align = null,
701*95078f23SAndreas Gohr        $width = null,
702*95078f23SAndreas Gohr        $height = null,
703*95078f23SAndreas Gohr        $cache = null,
704*95078f23SAndreas Gohr        $linking = null
705*95078f23SAndreas Gohr    ) {
7062c2835c2SAndreas Gohr    }
707a939d432SAndreas Gohr
708cfa2b40eSAndreas Gohr    /**
709cfa2b40eSAndreas Gohr     * Render a link to an internal media file
710cfa2b40eSAndreas Gohr     *
711cfa2b40eSAndreas Gohr     * @param string $src media ID
712cfa2b40eSAndreas Gohr     * @param string $title descriptive text
713cfa2b40eSAndreas Gohr     * @param string $align left|center|right
714cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
715cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
716cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
717cfa2b40eSAndreas Gohr     */
718*95078f23SAndreas Gohr    public function internalmedialink(
719*95078f23SAndreas Gohr        $src,
720*95078f23SAndreas Gohr        $title = null,
721*95078f23SAndreas Gohr        $align = null,
722*95078f23SAndreas Gohr        $width = null,
723*95078f23SAndreas Gohr        $height = null,
724*95078f23SAndreas Gohr        $cache = null
725*95078f23SAndreas Gohr    ) {
7262c2835c2SAndreas Gohr    }
7270cecf9d5Sandi
728cfa2b40eSAndreas Gohr    /**
729cfa2b40eSAndreas Gohr     * Render a link to an external media file
730cfa2b40eSAndreas Gohr     *
731cfa2b40eSAndreas Gohr     * @param string $src media ID
732cfa2b40eSAndreas Gohr     * @param string $title descriptive text
733cfa2b40eSAndreas Gohr     * @param string $align left|center|right
734cfa2b40eSAndreas Gohr     * @param int $width width of media in pixel
735cfa2b40eSAndreas Gohr     * @param int $height height of media in pixel
736cfa2b40eSAndreas Gohr     * @param string $cache cache|recache|nocache
737cfa2b40eSAndreas Gohr     */
738*95078f23SAndreas Gohr    public function externalmedialink(
739*95078f23SAndreas Gohr        $src,
740*95078f23SAndreas Gohr        $title = null,
741*95078f23SAndreas Gohr        $align = null,
742*95078f23SAndreas Gohr        $width = null,
743*95078f23SAndreas Gohr        $height = null,
744*95078f23SAndreas Gohr        $cache = null
745*95078f23SAndreas Gohr    ) {
7462c2835c2SAndreas Gohr    }
7470cecf9d5Sandi
748cfa2b40eSAndreas Gohr    /**
749cfa2b40eSAndreas Gohr     * Start a table
750cfa2b40eSAndreas Gohr     *
751cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
752cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
753cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
754cfa2b40eSAndreas Gohr     */
755faf3f01bSAndreas Gohr    public function table_open($maxcols = null, $numrows = null, $pos = null)
756faf3f01bSAndreas Gohr    {
7572c2835c2SAndreas Gohr    }
7580cecf9d5Sandi
759cfa2b40eSAndreas Gohr    /**
760cfa2b40eSAndreas Gohr     * Close a table
761cfa2b40eSAndreas Gohr     *
762cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
763cfa2b40eSAndreas Gohr     */
764faf3f01bSAndreas Gohr    public function table_close($pos = null)
765faf3f01bSAndreas Gohr    {
7662c2835c2SAndreas Gohr    }
7670cecf9d5Sandi
768cfa2b40eSAndreas Gohr    /**
769cfa2b40eSAndreas Gohr     * Open a table header
770cfa2b40eSAndreas Gohr     */
771faf3f01bSAndreas Gohr    public function tablethead_open()
772faf3f01bSAndreas Gohr    {
7732c2835c2SAndreas Gohr    }
774f05a1cc5SGerrit Uitslag
775cfa2b40eSAndreas Gohr    /**
776cfa2b40eSAndreas Gohr     * Close a table header
777cfa2b40eSAndreas Gohr     */
778faf3f01bSAndreas Gohr    public function tablethead_close()
779faf3f01bSAndreas Gohr    {
7802c2835c2SAndreas Gohr    }
781f05a1cc5SGerrit Uitslag
782cfa2b40eSAndreas Gohr    /**
7835a93f869SAnika Henke     * Open a table body
7845a93f869SAnika Henke     */
785faf3f01bSAndreas Gohr    public function tabletbody_open()
786faf3f01bSAndreas Gohr    {
7875a93f869SAnika Henke    }
7885a93f869SAnika Henke
7895a93f869SAnika Henke    /**
7905a93f869SAnika Henke     * Close a table body
7915a93f869SAnika Henke     */
792faf3f01bSAndreas Gohr    public function tabletbody_close()
793faf3f01bSAndreas Gohr    {
7945a93f869SAnika Henke    }
7955a93f869SAnika Henke
7965a93f869SAnika Henke    /**
797d2a99739SAndreas Gohr     * Open a table footer
798d2a99739SAndreas Gohr     */
799faf3f01bSAndreas Gohr    public function tabletfoot_open()
800faf3f01bSAndreas Gohr    {
801d2a99739SAndreas Gohr    }
802d2a99739SAndreas Gohr
803d2a99739SAndreas Gohr    /**
804d2a99739SAndreas Gohr     * Close a table footer
805d2a99739SAndreas Gohr     */
806faf3f01bSAndreas Gohr    public function tabletfoot_close()
807faf3f01bSAndreas Gohr    {
808d2a99739SAndreas Gohr    }
809d2a99739SAndreas Gohr
810d2a99739SAndreas Gohr    /**
811cfa2b40eSAndreas Gohr     * Open a table row
812cfa2b40eSAndreas Gohr     */
813faf3f01bSAndreas Gohr    public function tablerow_open()
814faf3f01bSAndreas Gohr    {
8152c2835c2SAndreas Gohr    }
8160cecf9d5Sandi
817cfa2b40eSAndreas Gohr    /**
818cfa2b40eSAndreas Gohr     * Close a table row
819cfa2b40eSAndreas Gohr     */
820faf3f01bSAndreas Gohr    public function tablerow_close()
821faf3f01bSAndreas Gohr    {
8222c2835c2SAndreas Gohr    }
8230cecf9d5Sandi
824cfa2b40eSAndreas Gohr    /**
825cfa2b40eSAndreas Gohr     * Open a table header cell
826cfa2b40eSAndreas Gohr     *
827cfa2b40eSAndreas Gohr     * @param int $colspan
828cfa2b40eSAndreas Gohr     * @param string $align left|center|right
829cfa2b40eSAndreas Gohr     * @param int $rowspan
830cfa2b40eSAndreas Gohr     */
831faf3f01bSAndreas Gohr    public function tableheader_open($colspan = 1, $align = null, $rowspan = 1)
832faf3f01bSAndreas Gohr    {
8332c2835c2SAndreas Gohr    }
8340cecf9d5Sandi
835cfa2b40eSAndreas Gohr    /**
836cfa2b40eSAndreas Gohr     * Close a table header cell
837cfa2b40eSAndreas Gohr     */
838faf3f01bSAndreas Gohr    public function tableheader_close()
839faf3f01bSAndreas Gohr    {
8402c2835c2SAndreas Gohr    }
8410cecf9d5Sandi
842cfa2b40eSAndreas Gohr    /**
843cfa2b40eSAndreas Gohr     * Open a table cell
844cfa2b40eSAndreas Gohr     *
845cfa2b40eSAndreas Gohr     * @param int $colspan
846cfa2b40eSAndreas Gohr     * @param string $align left|center|right
847cfa2b40eSAndreas Gohr     * @param int $rowspan
848cfa2b40eSAndreas Gohr     */
849faf3f01bSAndreas Gohr    public function tablecell_open($colspan = 1, $align = null, $rowspan = 1)
850faf3f01bSAndreas Gohr    {
8512c2835c2SAndreas Gohr    }
8520cecf9d5Sandi
853cfa2b40eSAndreas Gohr    /**
854cfa2b40eSAndreas Gohr     * Close a table cell
855cfa2b40eSAndreas Gohr     */
856faf3f01bSAndreas Gohr    public function tablecell_close()
857faf3f01bSAndreas Gohr    {
8582c2835c2SAndreas Gohr    }
8592ea4044fSAndreas Gohr
860cfa2b40eSAndreas Gohr    #endregion
861cfa2b40eSAndreas Gohr
862cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
8632ea4044fSAndreas Gohr
8642ea4044fSAndreas Gohr    /**
865de369923SAndreas Gohr     * Creates a linkid from a headline
866de369923SAndreas Gohr     *
867de369923SAndreas Gohr     * @param string $title The headline title
868de369923SAndreas Gohr     * @param boolean $create Create a new unique ID?
869de369923SAndreas Gohr     * @return string
870faf3f01bSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
871de369923SAndreas Gohr     */
872faf3f01bSAndreas Gohr    public function _headerToLink($title, $create = false)
873faf3f01bSAndreas Gohr    {
874de369923SAndreas Gohr        if ($create) {
875de369923SAndreas Gohr            return sectionID($title, $this->headers);
876de369923SAndreas Gohr        } else {
877de369923SAndreas Gohr            $check = false;
878de369923SAndreas Gohr            return sectionID($title, $check);
879de369923SAndreas Gohr        }
880de369923SAndreas Gohr    }
881de369923SAndreas Gohr
882de369923SAndreas Gohr    /**
8832ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
8842ea4044fSAndreas Gohr     * casing and special chars
8852ea4044fSAndreas Gohr     *
88642ea7f44SGerrit Uitslag     * @param string $name
88742ea7f44SGerrit Uitslag     * @return string
888faf3f01bSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
889faf3f01bSAndreas Gohr     *
8902ea4044fSAndreas Gohr     */
891faf3f01bSAndreas Gohr    public function _simpleTitle($name)
892faf3f01bSAndreas Gohr    {
8932ea4044fSAndreas Gohr        global $conf;
8942ea4044fSAndreas Gohr
8952ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
896faf3f01bSAndreas Gohr        [$name, $hash] = sexplode('#', $name, 2);
8972ea4044fSAndreas Gohr        if ($hash) return $hash;
8982ea4044fSAndreas Gohr
8992ea4044fSAndreas Gohr        if ($conf['useslash']) {
9003755fc25STom N Harris            $name = strtr($name, ';/', ';:');
9013755fc25STom N Harris        } else {
9023755fc25STom N Harris            $name = strtr($name, ';', ':');
9032ea4044fSAndreas Gohr        }
9042ea4044fSAndreas Gohr
9059708106bSAdrian Lang        return noNSorNS($name);
9062ea4044fSAndreas Gohr    }
9072ea4044fSAndreas Gohr
9081f82fabeSAndreas Gohr    /**
9091f82fabeSAndreas Gohr     * Resolve an interwikilink
91042ea7f44SGerrit Uitslag     *
91142ea7f44SGerrit Uitslag     * @param string $shortcut identifier for the interwiki link
91242ea7f44SGerrit Uitslag     * @param string $reference fragment that refers the content
91342ea7f44SGerrit Uitslag     * @param null|bool $exists reference which returns if an internal page exists
91442ea7f44SGerrit Uitslag     * @return string interwikilink
9151f82fabeSAndreas Gohr     */
916faf3f01bSAndreas Gohr    public function _resolveInterWiki(&$shortcut, $reference, &$exists = null)
917faf3f01bSAndreas Gohr    {
9181f82fabeSAndreas Gohr        //get interwiki URL
9191f82fabeSAndreas Gohr        if (isset($this->interwiki[$shortcut])) {
9201f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
921768be5a3SPhy        } elseif (isset($this->interwiki['default'])) {
922768be5a3SPhy            $shortcut = 'default';
923768be5a3SPhy            $url = $this->interwiki[$shortcut];
9241f82fabeSAndreas Gohr        } else {
925abde5980SPhy            // not parsable interwiki outputs '' to make sure string manipluation works
926abde5980SPhy            $shortcut = '';
927abde5980SPhy            $url = '';
9281f82fabeSAndreas Gohr        }
9292ea4044fSAndreas Gohr
9301f82fabeSAndreas Gohr        //split into hash and url part
93117e17ae2SPatrick Brown        $hash = strrchr($reference, '#');
93217e17ae2SPatrick Brown        if ($hash) {
93317e17ae2SPatrick Brown            $reference = substr($reference, 0, -strlen($hash));
93417e17ae2SPatrick Brown            $hash = substr($hash, 1);
93517e17ae2SPatrick Brown        }
9361f82fabeSAndreas Gohr
9371f82fabeSAndreas Gohr        //replace placeholder
9381f82fabeSAndreas Gohr        if (preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
9391f82fabeSAndreas Gohr            //use placeholders
9401f82fabeSAndreas Gohr            $url = str_replace('{URL}', rawurlencode($reference), $url);
94117e17ae2SPatrick Brown            //wiki names will be cleaned next, otherwise urlencode unsafe chars
942faf3f01bSAndreas Gohr            $url = str_replace(
943faf3f01bSAndreas Gohr                '{NAME}',
944faf3f01bSAndreas Gohr                ($url[0] === ':') ? $reference : preg_replace_callback(
945*95078f23SAndreas Gohr                    '/[[\\\\\]^`{|}#%]/',
946*95078f23SAndreas Gohr                    static fn($match) => rawurlencode($match[0]),
947*95078f23SAndreas Gohr                    $reference
948faf3f01bSAndreas Gohr                ),
949faf3f01bSAndreas Gohr                $url
950faf3f01bSAndreas Gohr            );
9511f82fabeSAndreas Gohr            $parsed = parse_url($reference);
9528f34cf3dSMichael Große            if (empty($parsed['scheme'])) $parsed['scheme'] = '';
9538f34cf3dSMichael Große            if (empty($parsed['host'])) $parsed['host'] = '';
9548f34cf3dSMichael Große            if (empty($parsed['port'])) $parsed['port'] = 80;
9558f34cf3dSMichael Große            if (empty($parsed['path'])) $parsed['path'] = '';
9568f34cf3dSMichael Große            if (empty($parsed['query'])) $parsed['query'] = '';
9578f34cf3dSMichael Große            $url = strtr($url, [
9588f34cf3dSMichael Große                '{SCHEME}' => $parsed['scheme'],
9598f34cf3dSMichael Große                '{HOST}' => $parsed['host'],
9608f34cf3dSMichael Große                '{PORT}' => $parsed['port'],
9618f34cf3dSMichael Große                '{PATH}' => $parsed['path'],
9628f34cf3dSMichael Große                '{QUERY}' => $parsed['query'],
9638f34cf3dSMichael Große            ]);
964abde5980SPhy        } elseif ($url != '') {
965abde5980SPhy            // make sure when no url is defined, we keep it null
9661f82fabeSAndreas Gohr            // default
967faf3f01bSAndreas Gohr            $url .= rawurlencode($reference);
9681f82fabeSAndreas Gohr        }
969f379edc2SGerrit Uitslag        //handle as wiki links
970056bf31fSDamien Regad        if ($url && $url[0] === ':') {
971ac1d8211SAndreas Gohr            $urlparam = '';
972c55b109cSMichael Große            $id = $url;
973c55b109cSMichael Große            if (strpos($url, '?') !== false) {
974faf3f01bSAndreas Gohr                [$id, $urlparam] = sexplode('?', $url, 2, '');
975c55b109cSMichael Große            }
9766496c33fSGerrit Uitslag            $url = wl(cleanID($id), $urlparam);
9776496c33fSGerrit Uitslag            $exists = page_exists($id);
9782345e871SGerrit Uitslag        }
9791f82fabeSAndreas Gohr        if ($hash) $url .= '#' . rawurlencode($hash);
9801f82fabeSAndreas Gohr
9811f82fabeSAndreas Gohr        return $url;
9821f82fabeSAndreas Gohr    }
983cfa2b40eSAndreas Gohr
984cfa2b40eSAndreas Gohr    #endregion
9850cecf9d5Sandi}
9860cecf9d5Sandi
987340756e4Sandi
988e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
989