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