xref: /dokuwiki/inc/parser/renderer.php (revision 8e3a5477d12ec6c8413a09d966bf5a84c0666cab)
10cecf9d5Sandi<?php
261faf446Schris/**
35587e44cSchris * Renderer output base class
461faf446Schris *
561faf446Schris * @author Harry Fuecks <hfuecks@gmail.com>
661faf446Schris * @author Andreas Gohr <andi@splitbrain.org>
761faf446Schris */
8fa8adffeSAndreas Gohrif(!defined('DOKU_INC')) die('meh.');
961faf446Schris
10863befa1SAndreas Gohr/**
11863befa1SAndreas Gohr * An empty renderer, produces no output
12863befa1SAndreas Gohr *
13863befa1SAndreas Gohr * Inherits from DokuWiki_Plugin for giving additional functions to render plugins
14*8e3a5477SAndreas Gohr *
15*8e3a5477SAndreas Gohr * The renderer transforms the syntax instructions created by the parser and handler into the
16*8e3a5477SAndreas Gohr * desired output format. For each instruction a corresponding method defined in this class will
17*8e3a5477SAndreas Gohr * be called. That method needs to produce the desired output for the instruction and add it to the
18*8e3a5477SAndreas Gohr * $doc field. When all instructions are processed, the $doc field contents will be cached by
19*8e3a5477SAndreas Gohr * DokuWiki and sent to the user.
20863befa1SAndreas Gohr */
21863befa1SAndreas Gohrclass Doku_Renderer extends DokuWiki_Plugin {
22cfa2b40eSAndreas Gohr    /** @var array Settings, control the behavior of the renderer */
23cfa2b40eSAndreas Gohr    public $info = array(
2444881bd0Shenning.noren        'cache' => true, // may the rendered result cached?
2544881bd0Shenning.noren        'toc'   => true, // render the TOC?
269dc2c2afSandi    );
279dc2c2afSandi
28cfa2b40eSAndreas Gohr    /** @var array contains the smiley configuration, set in p_render() */
29cfa2b40eSAndreas Gohr    public $smileys = array();
30cfa2b40eSAndreas Gohr    /** @var array contains the entity configuration, set in p_render() */
31cfa2b40eSAndreas Gohr    public $entities = array();
32cfa2b40eSAndreas Gohr    /** @var array contains the acronym configuration, set in p_render() */
33cfa2b40eSAndreas Gohr    public $acronyms = array();
34cfa2b40eSAndreas Gohr    /** @var array contains the interwiki configuration, set in p_render() */
35cfa2b40eSAndreas Gohr    public $interwiki = array();
36e41c4da9SAndreas Gohr
375f70445dSAndreas Gohr    /**
38cfa2b40eSAndreas Gohr     * @var string the rendered document, this will be cached after the renderer ran through
395f70445dSAndreas Gohr     */
40cfa2b40eSAndreas Gohr    public $doc = '';
41cfa2b40eSAndreas Gohr
42cfa2b40eSAndreas Gohr    /**
43cfa2b40eSAndreas Gohr     * clean out any per-use values
44cfa2b40eSAndreas Gohr     *
45cfa2b40eSAndreas Gohr     * This is called before each use of the renderer object and should be used to
46cfa2b40eSAndreas Gohr     * completely reset the state of the renderer to be reused for a new document
47cfa2b40eSAndreas Gohr     */
48cfa2b40eSAndreas Gohr    function reset() {
495f70445dSAndreas Gohr    }
505f70445dSAndreas Gohr
51f6ec8df8SAdrian Lang    /**
52f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
53f6ec8df8SAdrian Lang     *
54cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
55cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
56cfa2b40eSAndreas Gohr     *
57f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
58f6ec8df8SAdrian Lang     */
59f6ec8df8SAdrian Lang    function isSingleton() {
60f6ec8df8SAdrian Lang        return false;
61f6ec8df8SAdrian Lang    }
62f6ec8df8SAdrian Lang
638cc41db0SAndreas Gohr    /**
64cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
65cfa2b40eSAndreas Gohr     *
66cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
67cfa2b40eSAndreas Gohr     *
68cfa2b40eSAndreas Gohr     * @return string
69cfa2b40eSAndreas Gohr     */
70cfa2b40eSAndreas Gohr    function getFormat() {
71cfa2b40eSAndreas Gohr        trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
72cfa2b40eSAndreas Gohr        return '';
73cfa2b40eSAndreas Gohr    }
74cfa2b40eSAndreas Gohr
75cfa2b40eSAndreas Gohr    /**
76cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
77cfa2b40eSAndreas Gohr     */
78cfa2b40eSAndreas Gohr    function nocache() {
79cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
80cfa2b40eSAndreas Gohr    }
81cfa2b40eSAndreas Gohr
82cfa2b40eSAndreas Gohr    /**
83cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
84cfa2b40eSAndreas Gohr     *
85cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
86cfa2b40eSAndreas Gohr     */
87cfa2b40eSAndreas Gohr    function notoc() {
88cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
89cfa2b40eSAndreas Gohr    }
90cfa2b40eSAndreas Gohr
91cfa2b40eSAndreas Gohr    /**
92cfa2b40eSAndreas Gohr     * Handle plugin rendering
93cfa2b40eSAndreas Gohr     *
94cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
958cc41db0SAndreas Gohr     *
968cc41db0SAndreas Gohr     * @param string $name  Plugin name
978cc41db0SAndreas Gohr     * @param mixed  $data  custom data set by handler
988cc41db0SAndreas Gohr     * @param string $state matched state if any
998cc41db0SAndreas Gohr     * @param string $match raw matched syntax
1008cc41db0SAndreas Gohr     */
1018cc41db0SAndreas Gohr    function plugin($name, $data, $state = '', $match = '') {
102cfa2b40eSAndreas Gohr        /** @var DokuWiki_Syntax_Plugin $plugin */
103e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
10461faf446Schris        if($plugin != null) {
1055f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
10661faf446Schris        }
10761faf446Schris    }
10861faf446Schris
1095587e44cSchris    /**
1105587e44cSchris     * handle nested render instructions
1115587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
112cfa2b40eSAndreas Gohr     *
113cfa2b40eSAndreas Gohr     * @param array $instructions
1145587e44cSchris     */
1155587e44cSchris    function nest($instructions) {
1165587e44cSchris        foreach($instructions as $instruction) {
1175587e44cSchris            // execute the callback against ourself
118c2122b83SChristopher Smith            if(method_exists($this, $instruction[0])) {
119d6a1a955SAndreas Gohr                call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
120c2122b83SChristopher Smith            }
1215587e44cSchris        }
1225587e44cSchris    }
1235587e44cSchris
124cfa2b40eSAndreas Gohr    /**
125cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
126cfa2b40eSAndreas Gohr     *
127cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
128cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
129cfa2b40eSAndreas Gohr     */
1302c2835c2SAndreas Gohr    function nest_close() {
1312c2835c2SAndreas Gohr    }
1325587e44cSchris
133cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
134cfa2b40eSAndreas Gohr
135cfa2b40eSAndreas Gohr    /**
136cfa2b40eSAndreas Gohr     * Initialize the document
137cfa2b40eSAndreas Gohr     */
1382c2835c2SAndreas Gohr    function document_start() {
1392c2835c2SAndreas Gohr    }
1400cecf9d5Sandi
141cfa2b40eSAndreas Gohr    /**
142cfa2b40eSAndreas Gohr     * Finalize the document
143cfa2b40eSAndreas Gohr     */
1442c2835c2SAndreas Gohr    function document_end() {
1452c2835c2SAndreas Gohr    }
1460cecf9d5Sandi
147cfa2b40eSAndreas Gohr    /**
148cfa2b40eSAndreas Gohr     * Render the Table of Contents
149cfa2b40eSAndreas Gohr     *
150cfa2b40eSAndreas Gohr     * @return string
151cfa2b40eSAndreas Gohr     */
1522c2835c2SAndreas Gohr    function render_TOC() {
1532c2835c2SAndreas Gohr        return '';
1542c2835c2SAndreas Gohr    }
1550cecf9d5Sandi
156cfa2b40eSAndreas Gohr    /**
157cfa2b40eSAndreas Gohr     * Add an item to the TOC
158cfa2b40eSAndreas Gohr     *
159cfa2b40eSAndreas Gohr     * @param string $id       the hash link
160cfa2b40eSAndreas Gohr     * @param string $text     the text to display
161cfa2b40eSAndreas Gohr     * @param int    $level    the nesting level
162cfa2b40eSAndreas Gohr     */
1632c2835c2SAndreas Gohr    function toc_additem($id, $text, $level) {
1642c2835c2SAndreas Gohr    }
165e7856beaSchris
166cfa2b40eSAndreas Gohr    /**
167cfa2b40eSAndreas Gohr     * Render a heading
168cfa2b40eSAndreas Gohr     *
169cfa2b40eSAndreas Gohr     * @param string $text  the text to display
170cfa2b40eSAndreas Gohr     * @param int    $level header level
171cfa2b40eSAndreas Gohr     * @param int    $pos   byte position in the original source
172cfa2b40eSAndreas Gohr     */
1732c2835c2SAndreas Gohr    function header($text, $level, $pos) {
1742c2835c2SAndreas Gohr    }
1750cecf9d5Sandi
176cfa2b40eSAndreas Gohr    /**
177cfa2b40eSAndreas Gohr     * Open a new section
178cfa2b40eSAndreas Gohr     *
179cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
180cfa2b40eSAndreas Gohr     */
1812c2835c2SAndreas Gohr    function section_open($level) {
1822c2835c2SAndreas Gohr    }
1830cecf9d5Sandi
184cfa2b40eSAndreas Gohr    /**
185cfa2b40eSAndreas Gohr     * Close the current section
186cfa2b40eSAndreas Gohr     */
1872c2835c2SAndreas Gohr    function section_close() {
1882c2835c2SAndreas Gohr    }
1890cecf9d5Sandi
190cfa2b40eSAndreas Gohr    /**
191cfa2b40eSAndreas Gohr     * Render plain text data
192cfa2b40eSAndreas Gohr     *
193cfa2b40eSAndreas Gohr     * @param $text
194cfa2b40eSAndreas Gohr     */
1952c2835c2SAndreas Gohr    function cdata($text) {
1962c2835c2SAndreas Gohr    }
1970cecf9d5Sandi
198cfa2b40eSAndreas Gohr    /**
199cfa2b40eSAndreas Gohr     * Open a paragraph
200cfa2b40eSAndreas Gohr     */
2012c2835c2SAndreas Gohr    function p_open() {
2022c2835c2SAndreas Gohr    }
2030cecf9d5Sandi
204cfa2b40eSAndreas Gohr    /**
205cfa2b40eSAndreas Gohr     * Close a paragraph
206cfa2b40eSAndreas Gohr     */
2072c2835c2SAndreas Gohr    function p_close() {
2082c2835c2SAndreas Gohr    }
2090cecf9d5Sandi
210cfa2b40eSAndreas Gohr    /**
2113dd5c225SAndreas Gohr     * Create a line break
212cfa2b40eSAndreas Gohr     */
2132c2835c2SAndreas Gohr    function linebreak() {
2142c2835c2SAndreas Gohr    }
2150cecf9d5Sandi
216cfa2b40eSAndreas Gohr    /**
217cfa2b40eSAndreas Gohr     * Create a horizontal line
218cfa2b40eSAndreas Gohr     */
2192c2835c2SAndreas Gohr    function hr() {
2202c2835c2SAndreas Gohr    }
2210cecf9d5Sandi
222cfa2b40eSAndreas Gohr    /**
223cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
224cfa2b40eSAndreas Gohr     */
2252c2835c2SAndreas Gohr    function strong_open() {
2262c2835c2SAndreas Gohr    }
2270cecf9d5Sandi
228cfa2b40eSAndreas Gohr    /**
229cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
230cfa2b40eSAndreas Gohr     */
2312c2835c2SAndreas Gohr    function strong_close() {
2322c2835c2SAndreas Gohr    }
2330cecf9d5Sandi
234cfa2b40eSAndreas Gohr    /**
235cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
236cfa2b40eSAndreas Gohr     */
2372c2835c2SAndreas Gohr    function emphasis_open() {
2382c2835c2SAndreas Gohr    }
2390cecf9d5Sandi
240cfa2b40eSAndreas Gohr    /**
241cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
242cfa2b40eSAndreas Gohr     */
2432c2835c2SAndreas Gohr    function emphasis_close() {
2442c2835c2SAndreas Gohr    }
2450cecf9d5Sandi
246cfa2b40eSAndreas Gohr    /**
247cfa2b40eSAndreas Gohr     * Start underline formatting
248cfa2b40eSAndreas Gohr     */
2492c2835c2SAndreas Gohr    function underline_open() {
2502c2835c2SAndreas Gohr    }
2510cecf9d5Sandi
252cfa2b40eSAndreas Gohr    /**
253cfa2b40eSAndreas Gohr     * Stop underline formatting
254cfa2b40eSAndreas Gohr     */
2552c2835c2SAndreas Gohr    function underline_close() {
2562c2835c2SAndreas Gohr    }
2570cecf9d5Sandi
258cfa2b40eSAndreas Gohr    /**
259cfa2b40eSAndreas Gohr     * Start monospace formatting
260cfa2b40eSAndreas Gohr     */
2612c2835c2SAndreas Gohr    function monospace_open() {
2622c2835c2SAndreas Gohr    }
2630cecf9d5Sandi
264cfa2b40eSAndreas Gohr    /**
265cfa2b40eSAndreas Gohr     * Stop monospace formatting
266cfa2b40eSAndreas Gohr     */
2672c2835c2SAndreas Gohr    function monospace_close() {
2682c2835c2SAndreas Gohr    }
2690cecf9d5Sandi
270cfa2b40eSAndreas Gohr    /**
271cfa2b40eSAndreas Gohr     * Start a subscript
272cfa2b40eSAndreas Gohr     */
2732c2835c2SAndreas Gohr    function subscript_open() {
2742c2835c2SAndreas Gohr    }
2750cecf9d5Sandi
276cfa2b40eSAndreas Gohr    /**
277cfa2b40eSAndreas Gohr     * Stop a subscript
278cfa2b40eSAndreas Gohr     */
2792c2835c2SAndreas Gohr    function subscript_close() {
2802c2835c2SAndreas Gohr    }
2810cecf9d5Sandi
282cfa2b40eSAndreas Gohr    /**
283cfa2b40eSAndreas Gohr     * Start a superscript
284cfa2b40eSAndreas Gohr     */
2852c2835c2SAndreas Gohr    function superscript_open() {
2862c2835c2SAndreas Gohr    }
2870cecf9d5Sandi
288cfa2b40eSAndreas Gohr    /**
289cfa2b40eSAndreas Gohr     * Stop a superscript
290cfa2b40eSAndreas Gohr     */
2912c2835c2SAndreas Gohr    function superscript_close() {
2922c2835c2SAndreas Gohr    }
2930cecf9d5Sandi
294cfa2b40eSAndreas Gohr    /**
295cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
296cfa2b40eSAndreas Gohr     */
2972c2835c2SAndreas Gohr    function deleted_open() {
2982c2835c2SAndreas Gohr    }
2990cecf9d5Sandi
300cfa2b40eSAndreas Gohr    /**
301cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
302cfa2b40eSAndreas Gohr     */
3032c2835c2SAndreas Gohr    function deleted_close() {
3042c2835c2SAndreas Gohr    }
3050cecf9d5Sandi
306cfa2b40eSAndreas Gohr    /**
307cfa2b40eSAndreas Gohr     * Start a footnote
308cfa2b40eSAndreas Gohr     */
3092c2835c2SAndreas Gohr    function footnote_open() {
3102c2835c2SAndreas Gohr    }
3110cecf9d5Sandi
312cfa2b40eSAndreas Gohr    /**
313cfa2b40eSAndreas Gohr     * Stop a footnote
314cfa2b40eSAndreas Gohr     */
3152c2835c2SAndreas Gohr    function footnote_close() {
3162c2835c2SAndreas Gohr    }
3170cecf9d5Sandi
318cfa2b40eSAndreas Gohr    /**
319cfa2b40eSAndreas Gohr     * Open an unordered list
320cfa2b40eSAndreas Gohr     */
3212c2835c2SAndreas Gohr    function listu_open() {
3222c2835c2SAndreas Gohr    }
3230cecf9d5Sandi
324cfa2b40eSAndreas Gohr    /**
325cfa2b40eSAndreas Gohr     * Close an unordered list
326cfa2b40eSAndreas Gohr     */
3272c2835c2SAndreas Gohr    function listu_close() {
3282c2835c2SAndreas Gohr    }
3290cecf9d5Sandi
330cfa2b40eSAndreas Gohr    /**
331cfa2b40eSAndreas Gohr     * Open an ordered list
332cfa2b40eSAndreas Gohr     */
3332c2835c2SAndreas Gohr    function listo_open() {
3342c2835c2SAndreas Gohr    }
3350cecf9d5Sandi
336cfa2b40eSAndreas Gohr    /**
337cfa2b40eSAndreas Gohr     * Close an ordered list
338cfa2b40eSAndreas Gohr     */
3392c2835c2SAndreas Gohr    function listo_close() {
3402c2835c2SAndreas Gohr    }
3410cecf9d5Sandi
342cfa2b40eSAndreas Gohr    /**
343cfa2b40eSAndreas Gohr     * Open a list item
344cfa2b40eSAndreas Gohr     *
345cfa2b40eSAndreas Gohr     * @param int $level the nesting level
346cfa2b40eSAndreas Gohr     */
3472c2835c2SAndreas Gohr    function listitem_open($level) {
3482c2835c2SAndreas Gohr    }
3490cecf9d5Sandi
350cfa2b40eSAndreas Gohr    /**
351cfa2b40eSAndreas Gohr     * Close a list item
352cfa2b40eSAndreas Gohr     */
3532c2835c2SAndreas Gohr    function listitem_close() {
3542c2835c2SAndreas Gohr    }
3550cecf9d5Sandi
356cfa2b40eSAndreas Gohr    /**
357cfa2b40eSAndreas Gohr     * Start the content of a list item
358cfa2b40eSAndreas Gohr     */
3592c2835c2SAndreas Gohr    function listcontent_open() {
3602c2835c2SAndreas Gohr    }
3610cecf9d5Sandi
362cfa2b40eSAndreas Gohr    /**
363cfa2b40eSAndreas Gohr     * Stop the content of a list item
364cfa2b40eSAndreas Gohr     */
3652c2835c2SAndreas Gohr    function listcontent_close() {
3662c2835c2SAndreas Gohr    }
3670cecf9d5Sandi
368cfa2b40eSAndreas Gohr    /**
369cfa2b40eSAndreas Gohr     * Output unformatted $text
370cfa2b40eSAndreas Gohr     *
371cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
372cfa2b40eSAndreas Gohr     *
373cfa2b40eSAndreas Gohr     * @param string $text
374cfa2b40eSAndreas Gohr     */
3752c2835c2SAndreas Gohr    function unformatted($text) {
376cfa2b40eSAndreas Gohr        $this->cdata($text);
3772c2835c2SAndreas Gohr    }
3780cecf9d5Sandi
379cfa2b40eSAndreas Gohr    /**
380cfa2b40eSAndreas Gohr     * Output inline PHP code
381cfa2b40eSAndreas Gohr     *
382cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
383cfa2b40eSAndreas Gohr     * to $doc
384cfa2b40eSAndreas Gohr     *
385cfa2b40eSAndreas Gohr     * @param string $text The PHP code
386cfa2b40eSAndreas Gohr     */
3872c2835c2SAndreas Gohr    function php($text) {
3882c2835c2SAndreas Gohr    }
3890cecf9d5Sandi
390cfa2b40eSAndreas Gohr    /**
391cfa2b40eSAndreas Gohr     * Output block level PHP code
392cfa2b40eSAndreas Gohr     *
393cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
394cfa2b40eSAndreas Gohr     * to $doc
395cfa2b40eSAndreas Gohr     *
396cfa2b40eSAndreas Gohr     * @param string $text The PHP code
397cfa2b40eSAndreas Gohr     */
3982c2835c2SAndreas Gohr    function phpblock($text) {
3992c2835c2SAndreas Gohr    }
40007f89c3cSAnika Henke
401cfa2b40eSAndreas Gohr    /**
402cfa2b40eSAndreas Gohr     * Output raw inline HTML
403cfa2b40eSAndreas Gohr     *
404cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
405cfa2b40eSAndreas Gohr     *
406cfa2b40eSAndreas Gohr     * @param string $text The HTML
407cfa2b40eSAndreas Gohr     */
4082c2835c2SAndreas Gohr    function html($text) {
4092c2835c2SAndreas Gohr    }
4100cecf9d5Sandi
411cfa2b40eSAndreas Gohr    /**
412cfa2b40eSAndreas Gohr     * Output raw block-level HTML
413cfa2b40eSAndreas Gohr     *
414cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
415cfa2b40eSAndreas Gohr     *
416cfa2b40eSAndreas Gohr     * @param string $text The HTML
417cfa2b40eSAndreas Gohr     */
4182c2835c2SAndreas Gohr    function htmlblock($text) {
4192c2835c2SAndreas Gohr    }
42007f89c3cSAnika Henke
421cfa2b40eSAndreas Gohr    /**
422cfa2b40eSAndreas Gohr     * Output preformatted text
423cfa2b40eSAndreas Gohr     *
424cfa2b40eSAndreas Gohr     * @param string $text
425cfa2b40eSAndreas Gohr     */
4262c2835c2SAndreas Gohr    function preformatted($text) {
4272c2835c2SAndreas Gohr    }
4280cecf9d5Sandi
429cfa2b40eSAndreas Gohr    /**
430cfa2b40eSAndreas Gohr     * Start a block quote
431cfa2b40eSAndreas Gohr     */
4322c2835c2SAndreas Gohr    function quote_open() {
4332c2835c2SAndreas Gohr    }
4340cecf9d5Sandi
435cfa2b40eSAndreas Gohr    /**
436cfa2b40eSAndreas Gohr     * Stop a block quote
437cfa2b40eSAndreas Gohr     */
4382c2835c2SAndreas Gohr    function quote_close() {
4392c2835c2SAndreas Gohr    }
4400cecf9d5Sandi
441cfa2b40eSAndreas Gohr    /**
442cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
443cfa2b40eSAndreas Gohr     *
444cfa2b40eSAndreas Gohr     * @param string $text text to show
445cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
446cfa2b40eSAndreas Gohr     * @param string $file file path label
447cfa2b40eSAndreas Gohr     */
4482c2835c2SAndreas Gohr    function file($text, $lang = null, $file = null) {
4492c2835c2SAndreas Gohr    }
4503d491f75SAndreas Gohr
451cfa2b40eSAndreas Gohr    /**
452cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
453cfa2b40eSAndreas Gohr     *
454cfa2b40eSAndreas Gohr     * @param string $text text to show
455cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
456cfa2b40eSAndreas Gohr     * @param string $file file path label
457cfa2b40eSAndreas Gohr     */
4582c2835c2SAndreas Gohr    function code($text, $lang = null, $file = null) {
4592c2835c2SAndreas Gohr    }
4600cecf9d5Sandi
461cfa2b40eSAndreas Gohr    /**
462cfa2b40eSAndreas Gohr     * Format an acronym
463cfa2b40eSAndreas Gohr     *
464cfa2b40eSAndreas Gohr     * Uses $this->acronyms
465cfa2b40eSAndreas Gohr     *
466cfa2b40eSAndreas Gohr     * @param string $acronym
467cfa2b40eSAndreas Gohr     */
4682c2835c2SAndreas Gohr    function acronym($acronym) {
4692c2835c2SAndreas Gohr    }
4700cecf9d5Sandi
471cfa2b40eSAndreas Gohr    /**
472cfa2b40eSAndreas Gohr     * Format a smiley
473cfa2b40eSAndreas Gohr     *
474cfa2b40eSAndreas Gohr     * Uses $this->smiley
475cfa2b40eSAndreas Gohr     *
476cfa2b40eSAndreas Gohr     * @param string $smiley
477cfa2b40eSAndreas Gohr     */
4782c2835c2SAndreas Gohr    function smiley($smiley) {
4792c2835c2SAndreas Gohr    }
4800cecf9d5Sandi
481cfa2b40eSAndreas Gohr    /**
482cfa2b40eSAndreas Gohr     * Format an entity
483cfa2b40eSAndreas Gohr     *
484cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
485cfa2b40eSAndreas Gohr     *
486cfa2b40eSAndreas Gohr     * Uses $this->entities
487cfa2b40eSAndreas Gohr     *
488cfa2b40eSAndreas Gohr     * @param string $entity
489cfa2b40eSAndreas Gohr     */
4902c2835c2SAndreas Gohr    function entity($entity) {
4912c2835c2SAndreas Gohr    }
4920cecf9d5Sandi
493cfa2b40eSAndreas Gohr    /**
494cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
495cfa2b40eSAndreas Gohr     *
496cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
497cfa2b40eSAndreas Gohr     *
498cfa2b40eSAndreas Gohr     * @param string|int $x first value
499cfa2b40eSAndreas Gohr     * @param string|int $y second value
500cfa2b40eSAndreas Gohr     */
5012c2835c2SAndreas Gohr    function multiplyentity($x, $y) {
5022c2835c2SAndreas Gohr    }
5030cecf9d5Sandi
504cfa2b40eSAndreas Gohr    /**
505cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
506cfa2b40eSAndreas Gohr     */
5072c2835c2SAndreas Gohr    function singlequoteopening() {
5082c2835c2SAndreas Gohr    }
5090cecf9d5Sandi
510cfa2b40eSAndreas Gohr    /**
511cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
512cfa2b40eSAndreas Gohr     */
5132c2835c2SAndreas Gohr    function singlequoteclosing() {
5142c2835c2SAndreas Gohr    }
5150cecf9d5Sandi
516cfa2b40eSAndreas Gohr    /**
517cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
518cfa2b40eSAndreas Gohr     */
5192c2835c2SAndreas Gohr    function apostrophe() {
5202c2835c2SAndreas Gohr    }
52157d757d1SAndreas Gohr
522cfa2b40eSAndreas Gohr    /**
523cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
524cfa2b40eSAndreas Gohr     */
5252c2835c2SAndreas Gohr    function doublequoteopening() {
5262c2835c2SAndreas Gohr    }
5270cecf9d5Sandi
528cfa2b40eSAndreas Gohr    /**
529cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
530cfa2b40eSAndreas Gohr     */
5312c2835c2SAndreas Gohr    function doublequoteclosing() {
5322c2835c2SAndreas Gohr    }
5330cecf9d5Sandi
534cfa2b40eSAndreas Gohr    /**
535cfa2b40eSAndreas Gohr     * Render a CamelCase link
536cfa2b40eSAndreas Gohr     *
537cfa2b40eSAndreas Gohr     * @param string $link The link name
538cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
539cfa2b40eSAndreas Gohr     */
5402c2835c2SAndreas Gohr    function camelcaselink($link) {
5412c2835c2SAndreas Gohr    }
5420cecf9d5Sandi
543cfa2b40eSAndreas Gohr    /**
544cfa2b40eSAndreas Gohr     * Render a page local link
545cfa2b40eSAndreas Gohr     *
546cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
547cfa2b40eSAndreas Gohr     * @param string $name name for the link
548cfa2b40eSAndreas Gohr     */
5492c2835c2SAndreas Gohr    function locallink($hash, $name = null) {
5502c2835c2SAndreas Gohr    }
551a939d432SAndreas Gohr
552cfa2b40eSAndreas Gohr    /**
553cfa2b40eSAndreas Gohr     * Render a wiki internal link
554cfa2b40eSAndreas Gohr     *
555cfa2b40eSAndreas Gohr     * @param string       $link  page ID to link to. eg. 'wiki:syntax'
556cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
557cfa2b40eSAndreas Gohr     */
5582c2835c2SAndreas Gohr    function internallink($link, $title = null) {
5592c2835c2SAndreas Gohr    }
5600cecf9d5Sandi
561cfa2b40eSAndreas Gohr    /**
562cfa2b40eSAndreas Gohr     * Render an external link
563cfa2b40eSAndreas Gohr     *
564cfa2b40eSAndreas Gohr     * @param string       $link  full URL with scheme
565cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
566cfa2b40eSAndreas Gohr     */
5672c2835c2SAndreas Gohr    function externallink($link, $title = null) {
5682c2835c2SAndreas Gohr    }
5690cecf9d5Sandi
570cfa2b40eSAndreas Gohr    /**
571cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
572cfa2b40eSAndreas Gohr     *
573cfa2b40eSAndreas Gohr     * @param string $url    URL of the feed
574cfa2b40eSAndreas Gohr     * @param array  $params Finetuning of the output
575cfa2b40eSAndreas Gohr     */
5762c2835c2SAndreas Gohr    function rss($url, $params) {
5772c2835c2SAndreas Gohr    }
578c5cfca61SAndreas Gohr
579cfa2b40eSAndreas Gohr    /**
580cfa2b40eSAndreas Gohr     * Render an interwiki link
581cfa2b40eSAndreas Gohr     *
582cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
583cfa2b40eSAndreas Gohr     *
584cfa2b40eSAndreas Gohr     * @param string       $link     original link - probably not much use
585cfa2b40eSAndreas Gohr     * @param string|array $title    name for the link, array for media file
586cfa2b40eSAndreas Gohr     * @param string       $wikiName indentifier (shortcut) for the remote wiki
587cfa2b40eSAndreas Gohr     * @param string       $wikiUri  the fragment parsed from the original link
588cfa2b40eSAndreas Gohr     */
5892c2835c2SAndreas Gohr    function interwikilink($link, $title = null, $wikiName, $wikiUri) {
5902c2835c2SAndreas Gohr    }
5910cecf9d5Sandi
592cfa2b40eSAndreas Gohr    /**
593cfa2b40eSAndreas Gohr     * Link to file on users OS
594cfa2b40eSAndreas Gohr     *
595cfa2b40eSAndreas Gohr     * @param string       $link  the link
596cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
597cfa2b40eSAndreas Gohr     */
5982c2835c2SAndreas Gohr    function filelink($link, $title = null) {
5992c2835c2SAndreas Gohr    }
6000cecf9d5Sandi
601cfa2b40eSAndreas Gohr    /**
602cfa2b40eSAndreas Gohr     * Link to windows share
603cfa2b40eSAndreas Gohr     *
604cfa2b40eSAndreas Gohr     * @param string       $link  the link
605cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
606cfa2b40eSAndreas Gohr     */
6072c2835c2SAndreas Gohr    function windowssharelink($link, $title = null) {
6082c2835c2SAndreas Gohr    }
6090cecf9d5Sandi
610cfa2b40eSAndreas Gohr    /**
611cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
612cfa2b40eSAndreas Gohr     *
613cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
614cfa2b40eSAndreas Gohr     *
615cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6163dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
617cfa2b40eSAndreas Gohr     */
6182c2835c2SAndreas Gohr    function emaillink($address, $name = null) {
6192c2835c2SAndreas Gohr    }
6200cecf9d5Sandi
621cfa2b40eSAndreas Gohr    /**
622cfa2b40eSAndreas Gohr     * Render an internal media file
623cfa2b40eSAndreas Gohr     *
624cfa2b40eSAndreas Gohr     * @param string $src     media ID
625cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
626cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
627cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
628cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
629cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
630cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
631cfa2b40eSAndreas Gohr     */
6320ea51e63SMatt Perry    function internalmedia($src, $title = null, $align = null, $width = null,
6332c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6342c2835c2SAndreas Gohr    }
635a939d432SAndreas Gohr
636cfa2b40eSAndreas Gohr    /**
637cfa2b40eSAndreas Gohr     * Render an external media file
638cfa2b40eSAndreas Gohr     *
639cfa2b40eSAndreas Gohr     * @param string $src     full media URL
640cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
641cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
642cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
643cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
644cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
645cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
646cfa2b40eSAndreas Gohr     */
6470ea51e63SMatt Perry    function externalmedia($src, $title = null, $align = null, $width = null,
6482c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6492c2835c2SAndreas Gohr    }
650a939d432SAndreas Gohr
651cfa2b40eSAndreas Gohr    /**
652cfa2b40eSAndreas Gohr     * Render a link to an internal media file
653cfa2b40eSAndreas Gohr     *
654cfa2b40eSAndreas Gohr     * @param string $src     media ID
655cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
656cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
657cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
658cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
659cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
660cfa2b40eSAndreas Gohr     */
661cfa2b40eSAndreas Gohr    function internalmedialink($src, $title = null, $align = null,
662cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6632c2835c2SAndreas Gohr    }
6640cecf9d5Sandi
665cfa2b40eSAndreas Gohr    /**
666cfa2b40eSAndreas Gohr     * Render a link to an external media file
667cfa2b40eSAndreas Gohr     *
668cfa2b40eSAndreas Gohr     * @param string $src     media ID
669cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
670cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
671cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
672cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
673cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
674cfa2b40eSAndreas Gohr     */
675cfa2b40eSAndreas Gohr    function externalmedialink($src, $title = null, $align = null,
676cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6772c2835c2SAndreas Gohr    }
6780cecf9d5Sandi
679cfa2b40eSAndreas Gohr    /**
680cfa2b40eSAndreas Gohr     * Start a table
681cfa2b40eSAndreas Gohr     *
682cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
683cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
684cfa2b40eSAndreas Gohr     * @param int $pos     byte position in the original source
685cfa2b40eSAndreas Gohr     */
6862c2835c2SAndreas Gohr    function table_open($maxcols = null, $numrows = null, $pos = null) {
6872c2835c2SAndreas Gohr    }
6880cecf9d5Sandi
689cfa2b40eSAndreas Gohr    /**
690cfa2b40eSAndreas Gohr     * Close a table
691cfa2b40eSAndreas Gohr     *
692cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
693cfa2b40eSAndreas Gohr     */
6942c2835c2SAndreas Gohr    function table_close($pos = null) {
6952c2835c2SAndreas Gohr    }
6960cecf9d5Sandi
697cfa2b40eSAndreas Gohr    /**
698cfa2b40eSAndreas Gohr     * Open a table header
699cfa2b40eSAndreas Gohr     */
7002c2835c2SAndreas Gohr    function tablethead_open() {
7012c2835c2SAndreas Gohr    }
702f05a1cc5SGerrit Uitslag
703cfa2b40eSAndreas Gohr    /**
704cfa2b40eSAndreas Gohr     * Close a table header
705cfa2b40eSAndreas Gohr     */
7062c2835c2SAndreas Gohr    function tablethead_close() {
7072c2835c2SAndreas Gohr    }
708f05a1cc5SGerrit Uitslag
709cfa2b40eSAndreas Gohr    /**
710cfa2b40eSAndreas Gohr     * Open a table row
711cfa2b40eSAndreas Gohr     */
7122c2835c2SAndreas Gohr    function tablerow_open() {
7132c2835c2SAndreas Gohr    }
7140cecf9d5Sandi
715cfa2b40eSAndreas Gohr    /**
716cfa2b40eSAndreas Gohr     * Close a table row
717cfa2b40eSAndreas Gohr     */
7182c2835c2SAndreas Gohr    function tablerow_close() {
7192c2835c2SAndreas Gohr    }
7200cecf9d5Sandi
721cfa2b40eSAndreas Gohr    /**
722cfa2b40eSAndreas Gohr     * Open a table header cell
723cfa2b40eSAndreas Gohr     *
724cfa2b40eSAndreas Gohr     * @param int    $colspan
725cfa2b40eSAndreas Gohr     * @param string $align left|center|right
726cfa2b40eSAndreas Gohr     * @param int    $rowspan
727cfa2b40eSAndreas Gohr     */
7282c2835c2SAndreas Gohr    function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
7292c2835c2SAndreas Gohr    }
7300cecf9d5Sandi
731cfa2b40eSAndreas Gohr    /**
732cfa2b40eSAndreas Gohr     * Close a table header cell
733cfa2b40eSAndreas Gohr     */
7342c2835c2SAndreas Gohr    function tableheader_close() {
7352c2835c2SAndreas Gohr    }
7360cecf9d5Sandi
737cfa2b40eSAndreas Gohr    /**
738cfa2b40eSAndreas Gohr     * Open a table cell
739cfa2b40eSAndreas Gohr     *
740cfa2b40eSAndreas Gohr     * @param int    $colspan
741cfa2b40eSAndreas Gohr     * @param string $align left|center|right
742cfa2b40eSAndreas Gohr     * @param int    $rowspan
743cfa2b40eSAndreas Gohr     */
7442c2835c2SAndreas Gohr    function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
7452c2835c2SAndreas Gohr    }
7460cecf9d5Sandi
747cfa2b40eSAndreas Gohr    /**
748cfa2b40eSAndreas Gohr     * Close a table cell
749cfa2b40eSAndreas Gohr     */
7502c2835c2SAndreas Gohr    function tablecell_close() {
7512c2835c2SAndreas Gohr    }
7522ea4044fSAndreas Gohr
753cfa2b40eSAndreas Gohr    #endregion
754cfa2b40eSAndreas Gohr
755cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
7562ea4044fSAndreas Gohr
7572ea4044fSAndreas Gohr    /**
7582ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
7592ea4044fSAndreas Gohr     * casing and special chars
7602ea4044fSAndreas Gohr     *
7612ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
7622ea4044fSAndreas Gohr     */
7632ea4044fSAndreas Gohr    function _simpleTitle($name) {
7642ea4044fSAndreas Gohr        global $conf;
7652ea4044fSAndreas Gohr
7662ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
7676d2af55dSChristopher Smith        @list($name, $hash) = explode('#', $name, 2);
7682ea4044fSAndreas Gohr        if($hash) return $hash;
7692ea4044fSAndreas Gohr
7702ea4044fSAndreas Gohr        if($conf['useslash']) {
7713755fc25STom N Harris            $name = strtr($name, ';/', ';:');
7723755fc25STom N Harris        } else {
7733755fc25STom N Harris            $name = strtr($name, ';', ':');
7742ea4044fSAndreas Gohr        }
7752ea4044fSAndreas Gohr
7769708106bSAdrian Lang        return noNSorNS($name);
7772ea4044fSAndreas Gohr    }
7782ea4044fSAndreas Gohr
7791f82fabeSAndreas Gohr    /**
7801f82fabeSAndreas Gohr     * Resolve an interwikilink
7811f82fabeSAndreas Gohr     */
7826496c33fSGerrit Uitslag    function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
7831f82fabeSAndreas Gohr        //get interwiki URL
7841f82fabeSAndreas Gohr        if(isset($this->interwiki[$shortcut])) {
7851f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
7861f82fabeSAndreas Gohr        } else {
7871f82fabeSAndreas Gohr            // Default to Google I'm feeling lucky
7881f82fabeSAndreas Gohr            $url      = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
7891f82fabeSAndreas Gohr            $shortcut = 'go';
7901f82fabeSAndreas Gohr        }
7912ea4044fSAndreas Gohr
7921f82fabeSAndreas Gohr        //split into hash and url part
7936d2af55dSChristopher Smith        @list($reference, $hash) = explode('#', $reference, 2);
7941f82fabeSAndreas Gohr
7951f82fabeSAndreas Gohr        //replace placeholder
7961f82fabeSAndreas Gohr        if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
7971f82fabeSAndreas Gohr            //use placeholders
7981f82fabeSAndreas Gohr            $url    = str_replace('{URL}', rawurlencode($reference), $url);
7991f82fabeSAndreas Gohr            $url    = str_replace('{NAME}', $reference, $url);
8001f82fabeSAndreas Gohr            $parsed = parse_url($reference);
8011f82fabeSAndreas Gohr            if(!$parsed['port']) $parsed['port'] = 80;
8021f82fabeSAndreas Gohr            $url = str_replace('{SCHEME}', $parsed['scheme'], $url);
8031f82fabeSAndreas Gohr            $url = str_replace('{HOST}', $parsed['host'], $url);
8041f82fabeSAndreas Gohr            $url = str_replace('{PORT}', $parsed['port'], $url);
8051f82fabeSAndreas Gohr            $url = str_replace('{PATH}', $parsed['path'], $url);
8061f82fabeSAndreas Gohr            $url = str_replace('{QUERY}', $parsed['query'], $url);
8071f82fabeSAndreas Gohr        } else {
8081f82fabeSAndreas Gohr            //default
8091f82fabeSAndreas Gohr            $url = $url.rawurlencode($reference);
8101f82fabeSAndreas Gohr        }
811f379edc2SGerrit Uitslag        //handle as wiki links
8126496c33fSGerrit Uitslag        if($url{0} === ':') {
8136496c33fSGerrit Uitslag            list($id, $urlparam) = explode('?', $url, 2);
8146496c33fSGerrit Uitslag            $url    = wl(cleanID($id), $urlparam);
8156496c33fSGerrit Uitslag            $exists = page_exists($id);
8162345e871SGerrit Uitslag        }
8171f82fabeSAndreas Gohr        if($hash) $url .= '#'.rawurlencode($hash);
8181f82fabeSAndreas Gohr
8191f82fabeSAndreas Gohr        return $url;
8201f82fabeSAndreas Gohr    }
821cfa2b40eSAndreas Gohr
822cfa2b40eSAndreas Gohr    #endregion
8230cecf9d5Sandi}
8240cecf9d5Sandi
825340756e4Sandi
826e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
827