xref: /dokuwiki/inc/parser/renderer.php (revision cfa2b40e6bb053ff32af7199e4177fbbb92b0a57)
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
14863befa1SAndreas Gohr */
15863befa1SAndreas Gohrclass Doku_Renderer extends DokuWiki_Plugin {
16*cfa2b40eSAndreas Gohr    /** @var array Settings, control the behavior of the renderer */
17*cfa2b40eSAndreas Gohr    public $info = array(
1844881bd0Shenning.noren        'cache' => true, // may the rendered result cached?
1944881bd0Shenning.noren        'toc'   => true, // render the TOC?
209dc2c2afSandi    );
219dc2c2afSandi
22*cfa2b40eSAndreas Gohr    /** @var array contains the smiley configuration, set in p_render() */
23*cfa2b40eSAndreas Gohr    public $smileys = array();
24*cfa2b40eSAndreas Gohr    /** @var array contains the entity configuration, set in p_render() */
25*cfa2b40eSAndreas Gohr    public $entities = array();
26*cfa2b40eSAndreas Gohr    /** @var array contains the acronym configuration, set in p_render() */
27*cfa2b40eSAndreas Gohr    public $acronyms = array();
28*cfa2b40eSAndreas Gohr    /** @var array contains the interwiki configuration, set in p_render() */
29*cfa2b40eSAndreas Gohr    public $interwiki = array();
30e41c4da9SAndreas Gohr
315f70445dSAndreas Gohr    /**
32*cfa2b40eSAndreas Gohr     * @var string the rendered document, this will be cached after the renderer ran through
335f70445dSAndreas Gohr     */
34*cfa2b40eSAndreas Gohr    public $doc = '';
35*cfa2b40eSAndreas Gohr
36*cfa2b40eSAndreas Gohr    /**
37*cfa2b40eSAndreas Gohr     * clean out any per-use values
38*cfa2b40eSAndreas Gohr     *
39*cfa2b40eSAndreas Gohr     * This is called before each use of the renderer object and should be used to
40*cfa2b40eSAndreas Gohr     * completely reset the state of the renderer to be reused for a new document
41*cfa2b40eSAndreas Gohr     */
42*cfa2b40eSAndreas Gohr    function reset() {
435f70445dSAndreas Gohr    }
445f70445dSAndreas Gohr
45f6ec8df8SAdrian Lang    /**
46f6ec8df8SAdrian Lang     * Allow the plugin to prevent DokuWiki from reusing an instance
47f6ec8df8SAdrian Lang     *
48*cfa2b40eSAndreas Gohr     * Since most renderer plugins fail to implement Doku_Renderer::reset() we default
49*cfa2b40eSAndreas Gohr     * to reinstantiating the renderer here
50*cfa2b40eSAndreas Gohr     *
51f6ec8df8SAdrian Lang     * @return bool   false if the plugin has to be instantiated
52f6ec8df8SAdrian Lang     */
53f6ec8df8SAdrian Lang    function isSingleton() {
54f6ec8df8SAdrian Lang        return false;
55f6ec8df8SAdrian Lang    }
56f6ec8df8SAdrian Lang
578cc41db0SAndreas Gohr    /**
58*cfa2b40eSAndreas Gohr     * Returns the format produced by this renderer.
59*cfa2b40eSAndreas Gohr     *
60*cfa2b40eSAndreas Gohr     * Has to be overidden by sub classes
61*cfa2b40eSAndreas Gohr     *
62*cfa2b40eSAndreas Gohr     * @return string
63*cfa2b40eSAndreas Gohr     */
64*cfa2b40eSAndreas Gohr    function getFormat() {
65*cfa2b40eSAndreas Gohr        trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
66*cfa2b40eSAndreas Gohr        return '';
67*cfa2b40eSAndreas Gohr    }
68*cfa2b40eSAndreas Gohr
69*cfa2b40eSAndreas Gohr    /**
70*cfa2b40eSAndreas Gohr     * Disable caching of this renderer's output
71*cfa2b40eSAndreas Gohr     */
72*cfa2b40eSAndreas Gohr    function nocache() {
73*cfa2b40eSAndreas Gohr        $this->info['cache'] = false;
74*cfa2b40eSAndreas Gohr    }
75*cfa2b40eSAndreas Gohr
76*cfa2b40eSAndreas Gohr    /**
77*cfa2b40eSAndreas Gohr     * Disable TOC generation for this renderer's output
78*cfa2b40eSAndreas Gohr     *
79*cfa2b40eSAndreas Gohr     * This might not be used for certain sub renderer
80*cfa2b40eSAndreas Gohr     */
81*cfa2b40eSAndreas Gohr    function notoc() {
82*cfa2b40eSAndreas Gohr        $this->info['toc'] = false;
83*cfa2b40eSAndreas Gohr    }
84*cfa2b40eSAndreas Gohr
85*cfa2b40eSAndreas Gohr    /**
86*cfa2b40eSAndreas Gohr     * Handle plugin rendering
87*cfa2b40eSAndreas Gohr     *
88*cfa2b40eSAndreas Gohr     * Most likely this needs NOT to be overwritten by sub classes
898cc41db0SAndreas Gohr     *
908cc41db0SAndreas Gohr     * @param string $name  Plugin name
918cc41db0SAndreas Gohr     * @param mixed  $data  custom data set by handler
928cc41db0SAndreas Gohr     * @param string $state matched state if any
938cc41db0SAndreas Gohr     * @param string $match raw matched syntax
948cc41db0SAndreas Gohr     */
958cc41db0SAndreas Gohr    function plugin($name, $data, $state = '', $match = '') {
96*cfa2b40eSAndreas Gohr        /** @var DokuWiki_Syntax_Plugin $plugin */
97e8b5a4f9SAndreas Gohr        $plugin = plugin_load('syntax', $name);
9861faf446Schris        if($plugin != null) {
995f70445dSAndreas Gohr            $plugin->render($this->getFormat(), $this, $data);
10061faf446Schris        }
10161faf446Schris    }
10261faf446Schris
1035587e44cSchris    /**
1045587e44cSchris     * handle nested render instructions
1055587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
106*cfa2b40eSAndreas Gohr     *
107*cfa2b40eSAndreas Gohr     * @param array $instructions
1085587e44cSchris     */
1095587e44cSchris    function nest($instructions) {
1105587e44cSchris        foreach($instructions as $instruction) {
1115587e44cSchris            // execute the callback against ourself
112c2122b83SChristopher Smith            if(method_exists($this, $instruction[0])) {
113d6a1a955SAndreas Gohr                call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
114c2122b83SChristopher Smith            }
1155587e44cSchris        }
1165587e44cSchris    }
1175587e44cSchris
118*cfa2b40eSAndreas Gohr    /**
119*cfa2b40eSAndreas Gohr     * dummy closing instruction issued by Doku_Handler_Nest
120*cfa2b40eSAndreas Gohr     *
121*cfa2b40eSAndreas Gohr     * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest -
122*cfa2b40eSAndreas Gohr     * however plugins will not be able to - as their instructions require data.
123*cfa2b40eSAndreas Gohr     */
1242c2835c2SAndreas Gohr    function nest_close() {
1252c2835c2SAndreas Gohr    }
1265587e44cSchris
127*cfa2b40eSAndreas Gohr    #region Syntax modes - sub classes will need to implement them to fill $doc
128*cfa2b40eSAndreas Gohr
129*cfa2b40eSAndreas Gohr    /**
130*cfa2b40eSAndreas Gohr     * Initialize the document
131*cfa2b40eSAndreas Gohr     */
1322c2835c2SAndreas Gohr    function document_start() {
1332c2835c2SAndreas Gohr    }
1340cecf9d5Sandi
135*cfa2b40eSAndreas Gohr    /**
136*cfa2b40eSAndreas Gohr     * Finalize the document
137*cfa2b40eSAndreas Gohr     */
1382c2835c2SAndreas Gohr    function document_end() {
1392c2835c2SAndreas Gohr    }
1400cecf9d5Sandi
141*cfa2b40eSAndreas Gohr    /**
142*cfa2b40eSAndreas Gohr     * Render the Table of Contents
143*cfa2b40eSAndreas Gohr     *
144*cfa2b40eSAndreas Gohr     * @return string
145*cfa2b40eSAndreas Gohr     */
1462c2835c2SAndreas Gohr    function render_TOC() {
1472c2835c2SAndreas Gohr        return '';
1482c2835c2SAndreas Gohr    }
1490cecf9d5Sandi
150*cfa2b40eSAndreas Gohr    /**
151*cfa2b40eSAndreas Gohr     * Add an item to the TOC
152*cfa2b40eSAndreas Gohr     *
153*cfa2b40eSAndreas Gohr     * @param string $id       the hash link
154*cfa2b40eSAndreas Gohr     * @param string $text     the text to display
155*cfa2b40eSAndreas Gohr     * @param int    $level    the nesting level
156*cfa2b40eSAndreas Gohr     */
1572c2835c2SAndreas Gohr    function toc_additem($id, $text, $level) {
1582c2835c2SAndreas Gohr    }
159e7856beaSchris
160*cfa2b40eSAndreas Gohr    /**
161*cfa2b40eSAndreas Gohr     * Render a heading
162*cfa2b40eSAndreas Gohr     *
163*cfa2b40eSAndreas Gohr     * @param string $text  the text to display
164*cfa2b40eSAndreas Gohr     * @param int    $level header level
165*cfa2b40eSAndreas Gohr     * @param int    $pos   byte position in the original source
166*cfa2b40eSAndreas Gohr     */
1672c2835c2SAndreas Gohr    function header($text, $level, $pos) {
1682c2835c2SAndreas Gohr    }
1690cecf9d5Sandi
170*cfa2b40eSAndreas Gohr    /**
171*cfa2b40eSAndreas Gohr     * Open a new section
172*cfa2b40eSAndreas Gohr     *
173*cfa2b40eSAndreas Gohr     * @param int $level section level (as determined by the previous header)
174*cfa2b40eSAndreas Gohr     */
1752c2835c2SAndreas Gohr    function section_open($level) {
1762c2835c2SAndreas Gohr    }
1770cecf9d5Sandi
178*cfa2b40eSAndreas Gohr    /**
179*cfa2b40eSAndreas Gohr     * Close the current section
180*cfa2b40eSAndreas Gohr     */
1812c2835c2SAndreas Gohr    function section_close() {
1822c2835c2SAndreas Gohr    }
1830cecf9d5Sandi
184*cfa2b40eSAndreas Gohr    /**
185*cfa2b40eSAndreas Gohr     * Render plain text data
186*cfa2b40eSAndreas Gohr     *
187*cfa2b40eSAndreas Gohr     * @param $text
188*cfa2b40eSAndreas Gohr     */
1892c2835c2SAndreas Gohr    function cdata($text) {
1902c2835c2SAndreas Gohr    }
1910cecf9d5Sandi
192*cfa2b40eSAndreas Gohr    /**
193*cfa2b40eSAndreas Gohr     * Open a paragraph
194*cfa2b40eSAndreas Gohr     */
1952c2835c2SAndreas Gohr    function p_open() {
1962c2835c2SAndreas Gohr    }
1970cecf9d5Sandi
198*cfa2b40eSAndreas Gohr    /**
199*cfa2b40eSAndreas Gohr     * Close a paragraph
200*cfa2b40eSAndreas Gohr     */
2012c2835c2SAndreas Gohr    function p_close() {
2022c2835c2SAndreas Gohr    }
2030cecf9d5Sandi
204*cfa2b40eSAndreas Gohr    /**
205*cfa2b40eSAndreas Gohr     * Create a line breake
206*cfa2b40eSAndreas Gohr     */
2072c2835c2SAndreas Gohr    function linebreak() {
2082c2835c2SAndreas Gohr    }
2090cecf9d5Sandi
210*cfa2b40eSAndreas Gohr    /**
211*cfa2b40eSAndreas Gohr     * Create a horizontal line
212*cfa2b40eSAndreas Gohr     */
2132c2835c2SAndreas Gohr    function hr() {
2142c2835c2SAndreas Gohr    }
2150cecf9d5Sandi
216*cfa2b40eSAndreas Gohr    /**
217*cfa2b40eSAndreas Gohr     * Start strong (bold) formatting
218*cfa2b40eSAndreas Gohr     */
2192c2835c2SAndreas Gohr    function strong_open() {
2202c2835c2SAndreas Gohr    }
2210cecf9d5Sandi
222*cfa2b40eSAndreas Gohr    /**
223*cfa2b40eSAndreas Gohr     * Stop strong (bold) formatting
224*cfa2b40eSAndreas Gohr     */
2252c2835c2SAndreas Gohr    function strong_close() {
2262c2835c2SAndreas Gohr    }
2270cecf9d5Sandi
228*cfa2b40eSAndreas Gohr    /**
229*cfa2b40eSAndreas Gohr     * Start emphasis (italics) formatting
230*cfa2b40eSAndreas Gohr     */
2312c2835c2SAndreas Gohr    function emphasis_open() {
2322c2835c2SAndreas Gohr    }
2330cecf9d5Sandi
234*cfa2b40eSAndreas Gohr    /**
235*cfa2b40eSAndreas Gohr     * Stop emphasis (italics) formatting
236*cfa2b40eSAndreas Gohr     */
2372c2835c2SAndreas Gohr    function emphasis_close() {
2382c2835c2SAndreas Gohr    }
2390cecf9d5Sandi
240*cfa2b40eSAndreas Gohr    /**
241*cfa2b40eSAndreas Gohr     * Start underline formatting
242*cfa2b40eSAndreas Gohr     */
2432c2835c2SAndreas Gohr    function underline_open() {
2442c2835c2SAndreas Gohr    }
2450cecf9d5Sandi
246*cfa2b40eSAndreas Gohr    /**
247*cfa2b40eSAndreas Gohr     * Stop underline formatting
248*cfa2b40eSAndreas Gohr     */
2492c2835c2SAndreas Gohr    function underline_close() {
2502c2835c2SAndreas Gohr    }
2510cecf9d5Sandi
252*cfa2b40eSAndreas Gohr    /**
253*cfa2b40eSAndreas Gohr     * Start monospace formatting
254*cfa2b40eSAndreas Gohr     */
2552c2835c2SAndreas Gohr    function monospace_open() {
2562c2835c2SAndreas Gohr    }
2570cecf9d5Sandi
258*cfa2b40eSAndreas Gohr    /**
259*cfa2b40eSAndreas Gohr     * Stop monospace formatting
260*cfa2b40eSAndreas Gohr     */
2612c2835c2SAndreas Gohr    function monospace_close() {
2622c2835c2SAndreas Gohr    }
2630cecf9d5Sandi
264*cfa2b40eSAndreas Gohr    /**
265*cfa2b40eSAndreas Gohr     * Start a subscript
266*cfa2b40eSAndreas Gohr     */
2672c2835c2SAndreas Gohr    function subscript_open() {
2682c2835c2SAndreas Gohr    }
2690cecf9d5Sandi
270*cfa2b40eSAndreas Gohr    /**
271*cfa2b40eSAndreas Gohr     * Stop a subscript
272*cfa2b40eSAndreas Gohr     */
2732c2835c2SAndreas Gohr    function subscript_close() {
2742c2835c2SAndreas Gohr    }
2750cecf9d5Sandi
276*cfa2b40eSAndreas Gohr    /**
277*cfa2b40eSAndreas Gohr     * Start a superscript
278*cfa2b40eSAndreas Gohr     */
2792c2835c2SAndreas Gohr    function superscript_open() {
2802c2835c2SAndreas Gohr    }
2810cecf9d5Sandi
282*cfa2b40eSAndreas Gohr    /**
283*cfa2b40eSAndreas Gohr     * Stop a superscript
284*cfa2b40eSAndreas Gohr     */
2852c2835c2SAndreas Gohr    function superscript_close() {
2862c2835c2SAndreas Gohr    }
2870cecf9d5Sandi
288*cfa2b40eSAndreas Gohr    /**
289*cfa2b40eSAndreas Gohr     * Start deleted (strike-through) formatting
290*cfa2b40eSAndreas Gohr     */
2912c2835c2SAndreas Gohr    function deleted_open() {
2922c2835c2SAndreas Gohr    }
2930cecf9d5Sandi
294*cfa2b40eSAndreas Gohr    /**
295*cfa2b40eSAndreas Gohr     * Stop deleted (strike-through) formatting
296*cfa2b40eSAndreas Gohr     */
2972c2835c2SAndreas Gohr    function deleted_close() {
2982c2835c2SAndreas Gohr    }
2990cecf9d5Sandi
300*cfa2b40eSAndreas Gohr    /**
301*cfa2b40eSAndreas Gohr     * Start a footnote
302*cfa2b40eSAndreas Gohr     */
3032c2835c2SAndreas Gohr    function footnote_open() {
3042c2835c2SAndreas Gohr    }
3050cecf9d5Sandi
306*cfa2b40eSAndreas Gohr    /**
307*cfa2b40eSAndreas Gohr     * Stop a footnote
308*cfa2b40eSAndreas Gohr     */
3092c2835c2SAndreas Gohr    function footnote_close() {
3102c2835c2SAndreas Gohr    }
3110cecf9d5Sandi
312*cfa2b40eSAndreas Gohr    /**
313*cfa2b40eSAndreas Gohr     * Open an unordered list
314*cfa2b40eSAndreas Gohr     */
3152c2835c2SAndreas Gohr    function listu_open() {
3162c2835c2SAndreas Gohr    }
3170cecf9d5Sandi
318*cfa2b40eSAndreas Gohr    /**
319*cfa2b40eSAndreas Gohr     * Close an unordered list
320*cfa2b40eSAndreas Gohr     */
3212c2835c2SAndreas Gohr    function listu_close() {
3222c2835c2SAndreas Gohr    }
3230cecf9d5Sandi
324*cfa2b40eSAndreas Gohr    /**
325*cfa2b40eSAndreas Gohr     * Open an ordered list
326*cfa2b40eSAndreas Gohr     */
3272c2835c2SAndreas Gohr    function listo_open() {
3282c2835c2SAndreas Gohr    }
3290cecf9d5Sandi
330*cfa2b40eSAndreas Gohr    /**
331*cfa2b40eSAndreas Gohr     * Close an ordered list
332*cfa2b40eSAndreas Gohr     */
3332c2835c2SAndreas Gohr    function listo_close() {
3342c2835c2SAndreas Gohr    }
3350cecf9d5Sandi
336*cfa2b40eSAndreas Gohr    /**
337*cfa2b40eSAndreas Gohr     * Open a list item
338*cfa2b40eSAndreas Gohr     *
339*cfa2b40eSAndreas Gohr     * @param int $level the nesting level
340*cfa2b40eSAndreas Gohr     */
3412c2835c2SAndreas Gohr    function listitem_open($level) {
3422c2835c2SAndreas Gohr    }
3430cecf9d5Sandi
344*cfa2b40eSAndreas Gohr    /**
345*cfa2b40eSAndreas Gohr     * Close a list item
346*cfa2b40eSAndreas Gohr     */
3472c2835c2SAndreas Gohr    function listitem_close() {
3482c2835c2SAndreas Gohr    }
3490cecf9d5Sandi
350*cfa2b40eSAndreas Gohr    /**
351*cfa2b40eSAndreas Gohr     * Start the content of a list item
352*cfa2b40eSAndreas Gohr     */
3532c2835c2SAndreas Gohr    function listcontent_open() {
3542c2835c2SAndreas Gohr    }
3550cecf9d5Sandi
356*cfa2b40eSAndreas Gohr    /**
357*cfa2b40eSAndreas Gohr     * Stop the content of a list item
358*cfa2b40eSAndreas Gohr     */
3592c2835c2SAndreas Gohr    function listcontent_close() {
3602c2835c2SAndreas Gohr    }
3610cecf9d5Sandi
362*cfa2b40eSAndreas Gohr    /**
363*cfa2b40eSAndreas Gohr     * Output unformatted $text
364*cfa2b40eSAndreas Gohr     *
365*cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
366*cfa2b40eSAndreas Gohr     *
367*cfa2b40eSAndreas Gohr     * @param string $text
368*cfa2b40eSAndreas Gohr     */
3692c2835c2SAndreas Gohr    function unformatted($text) {
370*cfa2b40eSAndreas Gohr        $this->cdata($text);
3712c2835c2SAndreas Gohr    }
3720cecf9d5Sandi
373*cfa2b40eSAndreas Gohr    /**
374*cfa2b40eSAndreas Gohr     * Output inline PHP code
375*cfa2b40eSAndreas Gohr     *
376*cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
377*cfa2b40eSAndreas Gohr     * to $doc
378*cfa2b40eSAndreas Gohr     *
379*cfa2b40eSAndreas Gohr     * @param string $text The PHP code
380*cfa2b40eSAndreas Gohr     */
3812c2835c2SAndreas Gohr    function php($text) {
3822c2835c2SAndreas Gohr    }
3830cecf9d5Sandi
384*cfa2b40eSAndreas Gohr    /**
385*cfa2b40eSAndreas Gohr     * Output block level PHP code
386*cfa2b40eSAndreas Gohr     *
387*cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
388*cfa2b40eSAndreas Gohr     * to $doc
389*cfa2b40eSAndreas Gohr     *
390*cfa2b40eSAndreas Gohr     * @param string $text The PHP code
391*cfa2b40eSAndreas Gohr     */
3922c2835c2SAndreas Gohr    function phpblock($text) {
3932c2835c2SAndreas Gohr    }
39407f89c3cSAnika Henke
395*cfa2b40eSAndreas Gohr    /**
396*cfa2b40eSAndreas Gohr     * Output raw inline HTML
397*cfa2b40eSAndreas Gohr     *
398*cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
399*cfa2b40eSAndreas Gohr     *
400*cfa2b40eSAndreas Gohr     * @param string $text The HTML
401*cfa2b40eSAndreas Gohr     */
4022c2835c2SAndreas Gohr    function html($text) {
4032c2835c2SAndreas Gohr    }
4040cecf9d5Sandi
405*cfa2b40eSAndreas Gohr    /**
406*cfa2b40eSAndreas Gohr     * Output raw block-level HTML
407*cfa2b40eSAndreas Gohr     *
408*cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
409*cfa2b40eSAndreas Gohr     *
410*cfa2b40eSAndreas Gohr     * @param string $text The HTML
411*cfa2b40eSAndreas Gohr     */
4122c2835c2SAndreas Gohr    function htmlblock($text) {
4132c2835c2SAndreas Gohr    }
41407f89c3cSAnika Henke
415*cfa2b40eSAndreas Gohr    /**
416*cfa2b40eSAndreas Gohr     * Output preformatted text
417*cfa2b40eSAndreas Gohr     *
418*cfa2b40eSAndreas Gohr     * @param string $text
419*cfa2b40eSAndreas Gohr     */
4202c2835c2SAndreas Gohr    function preformatted($text) {
4212c2835c2SAndreas Gohr    }
4220cecf9d5Sandi
423*cfa2b40eSAndreas Gohr    /**
424*cfa2b40eSAndreas Gohr     * Start a block quote
425*cfa2b40eSAndreas Gohr     */
4262c2835c2SAndreas Gohr    function quote_open() {
4272c2835c2SAndreas Gohr    }
4280cecf9d5Sandi
429*cfa2b40eSAndreas Gohr    /**
430*cfa2b40eSAndreas Gohr     * Stop a block quote
431*cfa2b40eSAndreas Gohr     */
4322c2835c2SAndreas Gohr    function quote_close() {
4332c2835c2SAndreas Gohr    }
4340cecf9d5Sandi
435*cfa2b40eSAndreas Gohr    /**
436*cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
437*cfa2b40eSAndreas Gohr     *
438*cfa2b40eSAndreas Gohr     * @param string $text text to show
439*cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
440*cfa2b40eSAndreas Gohr     * @param string $file file path label
441*cfa2b40eSAndreas Gohr     */
4422c2835c2SAndreas Gohr    function file($text, $lang = null, $file = null) {
4432c2835c2SAndreas Gohr    }
4443d491f75SAndreas Gohr
445*cfa2b40eSAndreas Gohr    /**
446*cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
447*cfa2b40eSAndreas Gohr     *
448*cfa2b40eSAndreas Gohr     * @param string $text text to show
449*cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
450*cfa2b40eSAndreas Gohr     * @param string $file file path label
451*cfa2b40eSAndreas Gohr     */
4522c2835c2SAndreas Gohr    function code($text, $lang = null, $file = null) {
4532c2835c2SAndreas Gohr    }
4540cecf9d5Sandi
455*cfa2b40eSAndreas Gohr    /**
456*cfa2b40eSAndreas Gohr     * Format an acronym
457*cfa2b40eSAndreas Gohr     *
458*cfa2b40eSAndreas Gohr     * Uses $this->acronyms
459*cfa2b40eSAndreas Gohr     *
460*cfa2b40eSAndreas Gohr     * @param string $acronym
461*cfa2b40eSAndreas Gohr     */
4622c2835c2SAndreas Gohr    function acronym($acronym) {
4632c2835c2SAndreas Gohr    }
4640cecf9d5Sandi
465*cfa2b40eSAndreas Gohr    /**
466*cfa2b40eSAndreas Gohr     * Format a smiley
467*cfa2b40eSAndreas Gohr     *
468*cfa2b40eSAndreas Gohr     * Uses $this->smiley
469*cfa2b40eSAndreas Gohr     *
470*cfa2b40eSAndreas Gohr     * @param string $smiley
471*cfa2b40eSAndreas Gohr     */
4722c2835c2SAndreas Gohr    function smiley($smiley) {
4732c2835c2SAndreas Gohr    }
4740cecf9d5Sandi
475*cfa2b40eSAndreas Gohr    /**
476*cfa2b40eSAndreas Gohr     * Format an entity
477*cfa2b40eSAndreas Gohr     *
478*cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
479*cfa2b40eSAndreas Gohr     *
480*cfa2b40eSAndreas Gohr     * Uses $this->entities
481*cfa2b40eSAndreas Gohr     *
482*cfa2b40eSAndreas Gohr     * @param string $entity
483*cfa2b40eSAndreas Gohr     */
4842c2835c2SAndreas Gohr    function entity($entity) {
4852c2835c2SAndreas Gohr    }
4860cecf9d5Sandi
487*cfa2b40eSAndreas Gohr    /**
488*cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
489*cfa2b40eSAndreas Gohr     *
490*cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
491*cfa2b40eSAndreas Gohr     *
492*cfa2b40eSAndreas Gohr     * @param string|int $x first value
493*cfa2b40eSAndreas Gohr     * @param string|int $y second value
494*cfa2b40eSAndreas Gohr     */
4952c2835c2SAndreas Gohr    function multiplyentity($x, $y) {
4962c2835c2SAndreas Gohr    }
4970cecf9d5Sandi
498*cfa2b40eSAndreas Gohr    /**
499*cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
500*cfa2b40eSAndreas Gohr     */
5012c2835c2SAndreas Gohr    function singlequoteopening() {
5022c2835c2SAndreas Gohr    }
5030cecf9d5Sandi
504*cfa2b40eSAndreas Gohr    /**
505*cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
506*cfa2b40eSAndreas Gohr     */
5072c2835c2SAndreas Gohr    function singlequoteclosing() {
5082c2835c2SAndreas Gohr    }
5090cecf9d5Sandi
510*cfa2b40eSAndreas Gohr    /**
511*cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
512*cfa2b40eSAndreas Gohr     */
5132c2835c2SAndreas Gohr    function apostrophe() {
5142c2835c2SAndreas Gohr    }
51557d757d1SAndreas Gohr
516*cfa2b40eSAndreas Gohr    /**
517*cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
518*cfa2b40eSAndreas Gohr     */
5192c2835c2SAndreas Gohr    function doublequoteopening() {
5202c2835c2SAndreas Gohr    }
5210cecf9d5Sandi
522*cfa2b40eSAndreas Gohr    /**
523*cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
524*cfa2b40eSAndreas Gohr     */
5252c2835c2SAndreas Gohr    function doublequoteclosing() {
5262c2835c2SAndreas Gohr    }
5270cecf9d5Sandi
528*cfa2b40eSAndreas Gohr    /**
529*cfa2b40eSAndreas Gohr     * Render a CamelCase link
530*cfa2b40eSAndreas Gohr     *
531*cfa2b40eSAndreas Gohr     * @param string $link The link name
532*cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
533*cfa2b40eSAndreas Gohr     */
5342c2835c2SAndreas Gohr    function camelcaselink($link) {
5352c2835c2SAndreas Gohr    }
5360cecf9d5Sandi
537*cfa2b40eSAndreas Gohr    /**
538*cfa2b40eSAndreas Gohr     * Render a page local link
539*cfa2b40eSAndreas Gohr     *
540*cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
541*cfa2b40eSAndreas Gohr     * @param string $name name for the link
542*cfa2b40eSAndreas Gohr     */
5432c2835c2SAndreas Gohr    function locallink($hash, $name = null) {
5442c2835c2SAndreas Gohr    }
545a939d432SAndreas Gohr
546*cfa2b40eSAndreas Gohr    /**
547*cfa2b40eSAndreas Gohr     * Render a wiki internal link
548*cfa2b40eSAndreas Gohr     *
549*cfa2b40eSAndreas Gohr     * @param string       $link  page ID to link to. eg. 'wiki:syntax'
550*cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
551*cfa2b40eSAndreas Gohr     */
5522c2835c2SAndreas Gohr    function internallink($link, $title = null) {
5532c2835c2SAndreas Gohr    }
5540cecf9d5Sandi
555*cfa2b40eSAndreas Gohr    /**
556*cfa2b40eSAndreas Gohr     * Render an external link
557*cfa2b40eSAndreas Gohr     *
558*cfa2b40eSAndreas Gohr     * @param string       $link  full URL with scheme
559*cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
560*cfa2b40eSAndreas Gohr     */
5612c2835c2SAndreas Gohr    function externallink($link, $title = null) {
5622c2835c2SAndreas Gohr    }
5630cecf9d5Sandi
564*cfa2b40eSAndreas Gohr    /**
565*cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
566*cfa2b40eSAndreas Gohr     *
567*cfa2b40eSAndreas Gohr     * @param string $url    URL of the feed
568*cfa2b40eSAndreas Gohr     * @param array  $params Finetuning of the output
569*cfa2b40eSAndreas Gohr     */
5702c2835c2SAndreas Gohr    function rss($url, $params) {
5712c2835c2SAndreas Gohr    }
572c5cfca61SAndreas Gohr
573*cfa2b40eSAndreas Gohr    /**
574*cfa2b40eSAndreas Gohr     * Render an interwiki link
575*cfa2b40eSAndreas Gohr     *
576*cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
577*cfa2b40eSAndreas Gohr     *
578*cfa2b40eSAndreas Gohr     * @param string       $link     original link - probably not much use
579*cfa2b40eSAndreas Gohr     * @param string|array $title    name for the link, array for media file
580*cfa2b40eSAndreas Gohr     * @param string       $wikiName indentifier (shortcut) for the remote wiki
581*cfa2b40eSAndreas Gohr     * @param string       $wikiUri  the fragment parsed from the original link
582*cfa2b40eSAndreas Gohr     */
5832c2835c2SAndreas Gohr    function interwikilink($link, $title = null, $wikiName, $wikiUri) {
5842c2835c2SAndreas Gohr    }
5850cecf9d5Sandi
586*cfa2b40eSAndreas Gohr    /**
587*cfa2b40eSAndreas Gohr     * Link to file on users OS
588*cfa2b40eSAndreas Gohr     *
589*cfa2b40eSAndreas Gohr     * @param string       $link  the link
590*cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
591*cfa2b40eSAndreas Gohr     */
5922c2835c2SAndreas Gohr    function filelink($link, $title = null) {
5932c2835c2SAndreas Gohr    }
5940cecf9d5Sandi
595*cfa2b40eSAndreas Gohr    /**
596*cfa2b40eSAndreas Gohr     * Link to windows share
597*cfa2b40eSAndreas Gohr     *
598*cfa2b40eSAndreas Gohr     * @param string       $link  the link
599*cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
600*cfa2b40eSAndreas Gohr     */
6012c2835c2SAndreas Gohr    function windowssharelink($link, $title = null) {
6022c2835c2SAndreas Gohr    }
6030cecf9d5Sandi
604*cfa2b40eSAndreas Gohr    /**
605*cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
606*cfa2b40eSAndreas Gohr     *
607*cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
608*cfa2b40eSAndreas Gohr     *
609*cfa2b40eSAndreas Gohr     * @param string $address Email-Address
610*cfa2b40eSAndreas Gohr     * @param string $name    Display name
611*cfa2b40eSAndreas Gohr     */
6122c2835c2SAndreas Gohr    function emaillink($address, $name = null) {
6132c2835c2SAndreas Gohr    }
6140cecf9d5Sandi
615*cfa2b40eSAndreas Gohr    /**
616*cfa2b40eSAndreas Gohr     * Render an internal media file
617*cfa2b40eSAndreas Gohr     *
618*cfa2b40eSAndreas Gohr     * @param string $src     media ID
619*cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
620*cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
621*cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
622*cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
623*cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
624*cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
625*cfa2b40eSAndreas Gohr     */
6260ea51e63SMatt Perry    function internalmedia($src, $title = null, $align = null, $width = null,
6272c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6282c2835c2SAndreas Gohr    }
629a939d432SAndreas Gohr
630*cfa2b40eSAndreas Gohr    /**
631*cfa2b40eSAndreas Gohr     * Render an external media file
632*cfa2b40eSAndreas Gohr     *
633*cfa2b40eSAndreas Gohr     * @param string $src     full media URL
634*cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
635*cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
636*cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
637*cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
638*cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
639*cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
640*cfa2b40eSAndreas Gohr     */
6410ea51e63SMatt Perry    function externalmedia($src, $title = null, $align = null, $width = null,
6422c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6432c2835c2SAndreas Gohr    }
644a939d432SAndreas Gohr
645*cfa2b40eSAndreas Gohr    /**
646*cfa2b40eSAndreas Gohr     * Render a link to an internal media file
647*cfa2b40eSAndreas Gohr     *
648*cfa2b40eSAndreas Gohr     * @param string $src     media ID
649*cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
650*cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
651*cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
652*cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
653*cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
654*cfa2b40eSAndreas Gohr     */
655*cfa2b40eSAndreas Gohr    function internalmedialink($src, $title = null, $align = null,
656*cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6572c2835c2SAndreas Gohr    }
6580cecf9d5Sandi
659*cfa2b40eSAndreas Gohr    /**
660*cfa2b40eSAndreas Gohr     * Render a link to an external media file
661*cfa2b40eSAndreas Gohr     *
662*cfa2b40eSAndreas Gohr     * @param string $src     media ID
663*cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
664*cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
665*cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
666*cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
667*cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
668*cfa2b40eSAndreas Gohr     */
669*cfa2b40eSAndreas Gohr    function externalmedialink($src, $title = null, $align = null,
670*cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6712c2835c2SAndreas Gohr    }
6720cecf9d5Sandi
673*cfa2b40eSAndreas Gohr    /**
674*cfa2b40eSAndreas Gohr     * Start a table
675*cfa2b40eSAndreas Gohr     *
676*cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
677*cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
678*cfa2b40eSAndreas Gohr     * @param int $pos     byte position in the original source
679*cfa2b40eSAndreas Gohr     */
6802c2835c2SAndreas Gohr    function table_open($maxcols = null, $numrows = null, $pos = null) {
6812c2835c2SAndreas Gohr    }
6820cecf9d5Sandi
683*cfa2b40eSAndreas Gohr    /**
684*cfa2b40eSAndreas Gohr     * Close a table
685*cfa2b40eSAndreas Gohr     *
686*cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
687*cfa2b40eSAndreas Gohr     */
6882c2835c2SAndreas Gohr    function table_close($pos = null) {
6892c2835c2SAndreas Gohr    }
6900cecf9d5Sandi
691*cfa2b40eSAndreas Gohr    /**
692*cfa2b40eSAndreas Gohr     * Open a table header
693*cfa2b40eSAndreas Gohr     */
6942c2835c2SAndreas Gohr    function tablethead_open() {
6952c2835c2SAndreas Gohr    }
696f05a1cc5SGerrit Uitslag
697*cfa2b40eSAndreas Gohr    /**
698*cfa2b40eSAndreas Gohr     * Close a table header
699*cfa2b40eSAndreas Gohr     */
7002c2835c2SAndreas Gohr    function tablethead_close() {
7012c2835c2SAndreas Gohr    }
702f05a1cc5SGerrit Uitslag
703*cfa2b40eSAndreas Gohr    /**
704*cfa2b40eSAndreas Gohr     * Open a table row
705*cfa2b40eSAndreas Gohr     */
7062c2835c2SAndreas Gohr    function tablerow_open() {
7072c2835c2SAndreas Gohr    }
7080cecf9d5Sandi
709*cfa2b40eSAndreas Gohr    /**
710*cfa2b40eSAndreas Gohr     * Close a table row
711*cfa2b40eSAndreas Gohr     */
7122c2835c2SAndreas Gohr    function tablerow_close() {
7132c2835c2SAndreas Gohr    }
7140cecf9d5Sandi
715*cfa2b40eSAndreas Gohr    /**
716*cfa2b40eSAndreas Gohr     * Open a table header cell
717*cfa2b40eSAndreas Gohr     *
718*cfa2b40eSAndreas Gohr     * @param int    $colspan
719*cfa2b40eSAndreas Gohr     * @param string $align left|center|right
720*cfa2b40eSAndreas Gohr     * @param int    $rowspan
721*cfa2b40eSAndreas Gohr     */
7222c2835c2SAndreas Gohr    function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
7232c2835c2SAndreas Gohr    }
7240cecf9d5Sandi
725*cfa2b40eSAndreas Gohr    /**
726*cfa2b40eSAndreas Gohr     * Close a table header cell
727*cfa2b40eSAndreas Gohr     */
7282c2835c2SAndreas Gohr    function tableheader_close() {
7292c2835c2SAndreas Gohr    }
7300cecf9d5Sandi
731*cfa2b40eSAndreas Gohr    /**
732*cfa2b40eSAndreas Gohr     * Open a table cell
733*cfa2b40eSAndreas Gohr     *
734*cfa2b40eSAndreas Gohr     * @param int    $colspan
735*cfa2b40eSAndreas Gohr     * @param string $align left|center|right
736*cfa2b40eSAndreas Gohr     * @param int    $rowspan
737*cfa2b40eSAndreas Gohr     */
7382c2835c2SAndreas Gohr    function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
7392c2835c2SAndreas Gohr    }
7400cecf9d5Sandi
741*cfa2b40eSAndreas Gohr    /**
742*cfa2b40eSAndreas Gohr     * Close a table cell
743*cfa2b40eSAndreas Gohr     */
7442c2835c2SAndreas Gohr    function tablecell_close() {
7452c2835c2SAndreas Gohr    }
7462ea4044fSAndreas Gohr
747*cfa2b40eSAndreas Gohr    #endregion
748*cfa2b40eSAndreas Gohr
749*cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
7502ea4044fSAndreas Gohr
7512ea4044fSAndreas Gohr    /**
7522ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
7532ea4044fSAndreas Gohr     * casing and special chars
7542ea4044fSAndreas Gohr     *
7552ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
7562ea4044fSAndreas Gohr     */
7572ea4044fSAndreas Gohr    function _simpleTitle($name) {
7582ea4044fSAndreas Gohr        global $conf;
7592ea4044fSAndreas Gohr
7602ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
7616d2af55dSChristopher Smith        @list($name, $hash) = explode('#', $name, 2);
7622ea4044fSAndreas Gohr        if($hash) return $hash;
7632ea4044fSAndreas Gohr
7642ea4044fSAndreas Gohr        if($conf['useslash']) {
7653755fc25STom N Harris            $name = strtr($name, ';/', ';:');
7663755fc25STom N Harris        } else {
7673755fc25STom N Harris            $name = strtr($name, ';', ':');
7682ea4044fSAndreas Gohr        }
7692ea4044fSAndreas Gohr
7709708106bSAdrian Lang        return noNSorNS($name);
7712ea4044fSAndreas Gohr    }
7722ea4044fSAndreas Gohr
7731f82fabeSAndreas Gohr    /**
7741f82fabeSAndreas Gohr     * Resolve an interwikilink
7751f82fabeSAndreas Gohr     */
7766496c33fSGerrit Uitslag    function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
7771f82fabeSAndreas Gohr        //get interwiki URL
7781f82fabeSAndreas Gohr        if(isset($this->interwiki[$shortcut])) {
7791f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
7801f82fabeSAndreas Gohr        } else {
7811f82fabeSAndreas Gohr            // Default to Google I'm feeling lucky
7821f82fabeSAndreas Gohr            $url      = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
7831f82fabeSAndreas Gohr            $shortcut = 'go';
7841f82fabeSAndreas Gohr        }
7852ea4044fSAndreas Gohr
7861f82fabeSAndreas Gohr        //split into hash and url part
7876d2af55dSChristopher Smith        @list($reference, $hash) = explode('#', $reference, 2);
7881f82fabeSAndreas Gohr
7891f82fabeSAndreas Gohr        //replace placeholder
7901f82fabeSAndreas Gohr        if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
7911f82fabeSAndreas Gohr            //use placeholders
7921f82fabeSAndreas Gohr            $url    = str_replace('{URL}', rawurlencode($reference), $url);
7931f82fabeSAndreas Gohr            $url    = str_replace('{NAME}', $reference, $url);
7941f82fabeSAndreas Gohr            $parsed = parse_url($reference);
7951f82fabeSAndreas Gohr            if(!$parsed['port']) $parsed['port'] = 80;
7961f82fabeSAndreas Gohr            $url = str_replace('{SCHEME}', $parsed['scheme'], $url);
7971f82fabeSAndreas Gohr            $url = str_replace('{HOST}', $parsed['host'], $url);
7981f82fabeSAndreas Gohr            $url = str_replace('{PORT}', $parsed['port'], $url);
7991f82fabeSAndreas Gohr            $url = str_replace('{PATH}', $parsed['path'], $url);
8001f82fabeSAndreas Gohr            $url = str_replace('{QUERY}', $parsed['query'], $url);
8011f82fabeSAndreas Gohr        } else {
8021f82fabeSAndreas Gohr            //default
8031f82fabeSAndreas Gohr            $url = $url.rawurlencode($reference);
8041f82fabeSAndreas Gohr        }
805f379edc2SGerrit Uitslag        //handle as wiki links
8066496c33fSGerrit Uitslag        if($url{0} === ':') {
8076496c33fSGerrit Uitslag            list($id, $urlparam) = explode('?', $url, 2);
8086496c33fSGerrit Uitslag            $url    = wl(cleanID($id), $urlparam);
8096496c33fSGerrit Uitslag            $exists = page_exists($id);
8102345e871SGerrit Uitslag        }
8111f82fabeSAndreas Gohr        if($hash) $url .= '#'.rawurlencode($hash);
8121f82fabeSAndreas Gohr
8131f82fabeSAndreas Gohr        return $url;
8141f82fabeSAndreas Gohr    }
815*cfa2b40eSAndreas Gohr
816*cfa2b40eSAndreas Gohr    #endregion
8170cecf9d5Sandi}
8180cecf9d5Sandi
819340756e4Sandi
820e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
821