xref: /dokuwiki/inc/parser/renderer.php (revision e3a24861f53db7293b2b17f05d5821871b85b2f6)
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
148e3a5477SAndreas Gohr *
158e3a5477SAndreas Gohr * The renderer transforms the syntax instructions created by the parser and handler into the
168e3a5477SAndreas Gohr * desired output format. For each instruction a corresponding method defined in this class will
178e3a5477SAndreas Gohr * be called. That method needs to produce the desired output for the instruction and add it to the
188e3a5477SAndreas Gohr * $doc field. When all instructions are processed, the $doc field contents will be cached by
198e3a5477SAndreas 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
346*e3a24861SChristopher Smith     * @param bool $node true when a node; false when a leaf
347cfa2b40eSAndreas Gohr     */
348*e3a24861SChristopher Smith    function listitem_open($level,$node=false) {
3492c2835c2SAndreas Gohr    }
3500cecf9d5Sandi
351cfa2b40eSAndreas Gohr    /**
352cfa2b40eSAndreas Gohr     * Close a list item
353cfa2b40eSAndreas Gohr     */
3542c2835c2SAndreas Gohr    function listitem_close() {
3552c2835c2SAndreas Gohr    }
3560cecf9d5Sandi
357cfa2b40eSAndreas Gohr    /**
358cfa2b40eSAndreas Gohr     * Start the content of a list item
359cfa2b40eSAndreas Gohr     */
3602c2835c2SAndreas Gohr    function listcontent_open() {
3612c2835c2SAndreas Gohr    }
3620cecf9d5Sandi
363cfa2b40eSAndreas Gohr    /**
364cfa2b40eSAndreas Gohr     * Stop the content of a list item
365cfa2b40eSAndreas Gohr     */
3662c2835c2SAndreas Gohr    function listcontent_close() {
3672c2835c2SAndreas Gohr    }
3680cecf9d5Sandi
369cfa2b40eSAndreas Gohr    /**
370cfa2b40eSAndreas Gohr     * Output unformatted $text
371cfa2b40eSAndreas Gohr     *
372cfa2b40eSAndreas Gohr     * Defaults to $this->cdata()
373cfa2b40eSAndreas Gohr     *
374cfa2b40eSAndreas Gohr     * @param string $text
375cfa2b40eSAndreas Gohr     */
3762c2835c2SAndreas Gohr    function unformatted($text) {
377cfa2b40eSAndreas Gohr        $this->cdata($text);
3782c2835c2SAndreas Gohr    }
3790cecf9d5Sandi
380cfa2b40eSAndreas Gohr    /**
381cfa2b40eSAndreas Gohr     * Output inline PHP code
382cfa2b40eSAndreas Gohr     *
383cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
384cfa2b40eSAndreas Gohr     * to $doc
385cfa2b40eSAndreas Gohr     *
386cfa2b40eSAndreas Gohr     * @param string $text The PHP code
387cfa2b40eSAndreas Gohr     */
3882c2835c2SAndreas Gohr    function php($text) {
3892c2835c2SAndreas Gohr    }
3900cecf9d5Sandi
391cfa2b40eSAndreas Gohr    /**
392cfa2b40eSAndreas Gohr     * Output block level PHP code
393cfa2b40eSAndreas Gohr     *
394cfa2b40eSAndreas Gohr     * If $conf['phpok'] is true this should evaluate the given code and append the result
395cfa2b40eSAndreas Gohr     * to $doc
396cfa2b40eSAndreas Gohr     *
397cfa2b40eSAndreas Gohr     * @param string $text The PHP code
398cfa2b40eSAndreas Gohr     */
3992c2835c2SAndreas Gohr    function phpblock($text) {
4002c2835c2SAndreas Gohr    }
40107f89c3cSAnika Henke
402cfa2b40eSAndreas Gohr    /**
403cfa2b40eSAndreas Gohr     * Output raw inline HTML
404cfa2b40eSAndreas Gohr     *
405cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
406cfa2b40eSAndreas Gohr     *
407cfa2b40eSAndreas Gohr     * @param string $text The HTML
408cfa2b40eSAndreas Gohr     */
4092c2835c2SAndreas Gohr    function html($text) {
4102c2835c2SAndreas Gohr    }
4110cecf9d5Sandi
412cfa2b40eSAndreas Gohr    /**
413cfa2b40eSAndreas Gohr     * Output raw block-level HTML
414cfa2b40eSAndreas Gohr     *
415cfa2b40eSAndreas Gohr     * If $conf['htmlok'] is true this should add the code as is to $doc
416cfa2b40eSAndreas Gohr     *
417cfa2b40eSAndreas Gohr     * @param string $text The HTML
418cfa2b40eSAndreas Gohr     */
4192c2835c2SAndreas Gohr    function htmlblock($text) {
4202c2835c2SAndreas Gohr    }
42107f89c3cSAnika Henke
422cfa2b40eSAndreas Gohr    /**
423cfa2b40eSAndreas Gohr     * Output preformatted text
424cfa2b40eSAndreas Gohr     *
425cfa2b40eSAndreas Gohr     * @param string $text
426cfa2b40eSAndreas Gohr     */
4272c2835c2SAndreas Gohr    function preformatted($text) {
4282c2835c2SAndreas Gohr    }
4290cecf9d5Sandi
430cfa2b40eSAndreas Gohr    /**
431cfa2b40eSAndreas Gohr     * Start a block quote
432cfa2b40eSAndreas Gohr     */
4332c2835c2SAndreas Gohr    function quote_open() {
4342c2835c2SAndreas Gohr    }
4350cecf9d5Sandi
436cfa2b40eSAndreas Gohr    /**
437cfa2b40eSAndreas Gohr     * Stop a block quote
438cfa2b40eSAndreas Gohr     */
4392c2835c2SAndreas Gohr    function quote_close() {
4402c2835c2SAndreas Gohr    }
4410cecf9d5Sandi
442cfa2b40eSAndreas Gohr    /**
443cfa2b40eSAndreas Gohr     * Display text as file content, optionally syntax highlighted
444cfa2b40eSAndreas Gohr     *
445cfa2b40eSAndreas Gohr     * @param string $text text to show
446cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
447cfa2b40eSAndreas Gohr     * @param string $file file path label
448cfa2b40eSAndreas Gohr     */
4492c2835c2SAndreas Gohr    function file($text, $lang = null, $file = null) {
4502c2835c2SAndreas Gohr    }
4513d491f75SAndreas Gohr
452cfa2b40eSAndreas Gohr    /**
453cfa2b40eSAndreas Gohr     * Display text as code content, optionally syntax highlighted
454cfa2b40eSAndreas Gohr     *
455cfa2b40eSAndreas Gohr     * @param string $text text to show
456cfa2b40eSAndreas Gohr     * @param string $lang programming language to use for syntax highlighting
457cfa2b40eSAndreas Gohr     * @param string $file file path label
458cfa2b40eSAndreas Gohr     */
4592c2835c2SAndreas Gohr    function code($text, $lang = null, $file = null) {
4602c2835c2SAndreas Gohr    }
4610cecf9d5Sandi
462cfa2b40eSAndreas Gohr    /**
463cfa2b40eSAndreas Gohr     * Format an acronym
464cfa2b40eSAndreas Gohr     *
465cfa2b40eSAndreas Gohr     * Uses $this->acronyms
466cfa2b40eSAndreas Gohr     *
467cfa2b40eSAndreas Gohr     * @param string $acronym
468cfa2b40eSAndreas Gohr     */
4692c2835c2SAndreas Gohr    function acronym($acronym) {
4702c2835c2SAndreas Gohr    }
4710cecf9d5Sandi
472cfa2b40eSAndreas Gohr    /**
473cfa2b40eSAndreas Gohr     * Format a smiley
474cfa2b40eSAndreas Gohr     *
475cfa2b40eSAndreas Gohr     * Uses $this->smiley
476cfa2b40eSAndreas Gohr     *
477cfa2b40eSAndreas Gohr     * @param string $smiley
478cfa2b40eSAndreas Gohr     */
4792c2835c2SAndreas Gohr    function smiley($smiley) {
4802c2835c2SAndreas Gohr    }
4810cecf9d5Sandi
482cfa2b40eSAndreas Gohr    /**
483cfa2b40eSAndreas Gohr     * Format an entity
484cfa2b40eSAndreas Gohr     *
485cfa2b40eSAndreas Gohr     * Entities are basically small text replacements
486cfa2b40eSAndreas Gohr     *
487cfa2b40eSAndreas Gohr     * Uses $this->entities
488cfa2b40eSAndreas Gohr     *
489cfa2b40eSAndreas Gohr     * @param string $entity
490cfa2b40eSAndreas Gohr     */
4912c2835c2SAndreas Gohr    function entity($entity) {
4922c2835c2SAndreas Gohr    }
4930cecf9d5Sandi
494cfa2b40eSAndreas Gohr    /**
495cfa2b40eSAndreas Gohr     * Typographically format a multiply sign
496cfa2b40eSAndreas Gohr     *
497cfa2b40eSAndreas Gohr     * Example: ($x=640, $y=480) should result in "640×480"
498cfa2b40eSAndreas Gohr     *
499cfa2b40eSAndreas Gohr     * @param string|int $x first value
500cfa2b40eSAndreas Gohr     * @param string|int $y second value
501cfa2b40eSAndreas Gohr     */
5022c2835c2SAndreas Gohr    function multiplyentity($x, $y) {
5032c2835c2SAndreas Gohr    }
5040cecf9d5Sandi
505cfa2b40eSAndreas Gohr    /**
506cfa2b40eSAndreas Gohr     * Render an opening single quote char (language specific)
507cfa2b40eSAndreas Gohr     */
5082c2835c2SAndreas Gohr    function singlequoteopening() {
5092c2835c2SAndreas Gohr    }
5100cecf9d5Sandi
511cfa2b40eSAndreas Gohr    /**
512cfa2b40eSAndreas Gohr     * Render a closing single quote char (language specific)
513cfa2b40eSAndreas Gohr     */
5142c2835c2SAndreas Gohr    function singlequoteclosing() {
5152c2835c2SAndreas Gohr    }
5160cecf9d5Sandi
517cfa2b40eSAndreas Gohr    /**
518cfa2b40eSAndreas Gohr     * Render an apostrophe char (language specific)
519cfa2b40eSAndreas Gohr     */
5202c2835c2SAndreas Gohr    function apostrophe() {
5212c2835c2SAndreas Gohr    }
52257d757d1SAndreas Gohr
523cfa2b40eSAndreas Gohr    /**
524cfa2b40eSAndreas Gohr     * Render an opening double quote char (language specific)
525cfa2b40eSAndreas Gohr     */
5262c2835c2SAndreas Gohr    function doublequoteopening() {
5272c2835c2SAndreas Gohr    }
5280cecf9d5Sandi
529cfa2b40eSAndreas Gohr    /**
530cfa2b40eSAndreas Gohr     * Render an closinging double quote char (language specific)
531cfa2b40eSAndreas Gohr     */
5322c2835c2SAndreas Gohr    function doublequoteclosing() {
5332c2835c2SAndreas Gohr    }
5340cecf9d5Sandi
535cfa2b40eSAndreas Gohr    /**
536cfa2b40eSAndreas Gohr     * Render a CamelCase link
537cfa2b40eSAndreas Gohr     *
538cfa2b40eSAndreas Gohr     * @param string $link The link name
539cfa2b40eSAndreas Gohr     * @see http://en.wikipedia.org/wiki/CamelCase
540cfa2b40eSAndreas Gohr     */
5412c2835c2SAndreas Gohr    function camelcaselink($link) {
5422c2835c2SAndreas Gohr    }
5430cecf9d5Sandi
544cfa2b40eSAndreas Gohr    /**
545cfa2b40eSAndreas Gohr     * Render a page local link
546cfa2b40eSAndreas Gohr     *
547cfa2b40eSAndreas Gohr     * @param string $hash hash link identifier
548cfa2b40eSAndreas Gohr     * @param string $name name for the link
549cfa2b40eSAndreas Gohr     */
5502c2835c2SAndreas Gohr    function locallink($hash, $name = null) {
5512c2835c2SAndreas Gohr    }
552a939d432SAndreas Gohr
553cfa2b40eSAndreas Gohr    /**
554cfa2b40eSAndreas Gohr     * Render a wiki internal link
555cfa2b40eSAndreas Gohr     *
556cfa2b40eSAndreas Gohr     * @param string       $link  page ID to link to. eg. 'wiki:syntax'
557cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
558cfa2b40eSAndreas Gohr     */
5592c2835c2SAndreas Gohr    function internallink($link, $title = null) {
5602c2835c2SAndreas Gohr    }
5610cecf9d5Sandi
562cfa2b40eSAndreas Gohr    /**
563cfa2b40eSAndreas Gohr     * Render an external link
564cfa2b40eSAndreas Gohr     *
565cfa2b40eSAndreas Gohr     * @param string       $link  full URL with scheme
566cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
567cfa2b40eSAndreas Gohr     */
5682c2835c2SAndreas Gohr    function externallink($link, $title = null) {
5692c2835c2SAndreas Gohr    }
5700cecf9d5Sandi
571cfa2b40eSAndreas Gohr    /**
572cfa2b40eSAndreas Gohr     * Render the output of an RSS feed
573cfa2b40eSAndreas Gohr     *
574cfa2b40eSAndreas Gohr     * @param string $url    URL of the feed
575cfa2b40eSAndreas Gohr     * @param array  $params Finetuning of the output
576cfa2b40eSAndreas Gohr     */
5772c2835c2SAndreas Gohr    function rss($url, $params) {
5782c2835c2SAndreas Gohr    }
579c5cfca61SAndreas Gohr
580cfa2b40eSAndreas Gohr    /**
581cfa2b40eSAndreas Gohr     * Render an interwiki link
582cfa2b40eSAndreas Gohr     *
583cfa2b40eSAndreas Gohr     * You may want to use $this->_resolveInterWiki() here
584cfa2b40eSAndreas Gohr     *
585cfa2b40eSAndreas Gohr     * @param string       $link     original link - probably not much use
586cfa2b40eSAndreas Gohr     * @param string|array $title    name for the link, array for media file
587cfa2b40eSAndreas Gohr     * @param string       $wikiName indentifier (shortcut) for the remote wiki
588cfa2b40eSAndreas Gohr     * @param string       $wikiUri  the fragment parsed from the original link
589cfa2b40eSAndreas Gohr     */
5902c2835c2SAndreas Gohr    function interwikilink($link, $title = null, $wikiName, $wikiUri) {
5912c2835c2SAndreas Gohr    }
5920cecf9d5Sandi
593cfa2b40eSAndreas Gohr    /**
594cfa2b40eSAndreas Gohr     * Link to file on users OS
595cfa2b40eSAndreas Gohr     *
596cfa2b40eSAndreas Gohr     * @param string       $link  the link
597cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
598cfa2b40eSAndreas Gohr     */
5992c2835c2SAndreas Gohr    function filelink($link, $title = null) {
6002c2835c2SAndreas Gohr    }
6010cecf9d5Sandi
602cfa2b40eSAndreas Gohr    /**
603cfa2b40eSAndreas Gohr     * Link to windows share
604cfa2b40eSAndreas Gohr     *
605cfa2b40eSAndreas Gohr     * @param string       $link  the link
606cfa2b40eSAndreas Gohr     * @param string|array $title name for the link, array for media file
607cfa2b40eSAndreas Gohr     */
6082c2835c2SAndreas Gohr    function windowssharelink($link, $title = null) {
6092c2835c2SAndreas Gohr    }
6100cecf9d5Sandi
611cfa2b40eSAndreas Gohr    /**
612cfa2b40eSAndreas Gohr     * Render a linked E-Mail Address
613cfa2b40eSAndreas Gohr     *
614cfa2b40eSAndreas Gohr     * Should honor $conf['mailguard'] setting
615cfa2b40eSAndreas Gohr     *
616cfa2b40eSAndreas Gohr     * @param string $address Email-Address
6173dd5c225SAndreas Gohr     * @param string|array $name name for the link, array for media file
618cfa2b40eSAndreas Gohr     */
6192c2835c2SAndreas Gohr    function emaillink($address, $name = null) {
6202c2835c2SAndreas Gohr    }
6210cecf9d5Sandi
622cfa2b40eSAndreas Gohr    /**
623cfa2b40eSAndreas Gohr     * Render an internal media file
624cfa2b40eSAndreas Gohr     *
625cfa2b40eSAndreas Gohr     * @param string $src     media ID
626cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
627cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
628cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
629cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
630cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
631cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
632cfa2b40eSAndreas Gohr     */
6330ea51e63SMatt Perry    function internalmedia($src, $title = null, $align = null, $width = null,
6342c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6352c2835c2SAndreas Gohr    }
636a939d432SAndreas Gohr
637cfa2b40eSAndreas Gohr    /**
638cfa2b40eSAndreas Gohr     * Render an external media file
639cfa2b40eSAndreas Gohr     *
640cfa2b40eSAndreas Gohr     * @param string $src     full media URL
641cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
642cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
643cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
644cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
645cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
646cfa2b40eSAndreas Gohr     * @param string $linking linkonly|detail|nolink
647cfa2b40eSAndreas Gohr     */
6480ea51e63SMatt Perry    function externalmedia($src, $title = null, $align = null, $width = null,
6492c2835c2SAndreas Gohr                           $height = null, $cache = null, $linking = null) {
6502c2835c2SAndreas Gohr    }
651a939d432SAndreas Gohr
652cfa2b40eSAndreas Gohr    /**
653cfa2b40eSAndreas Gohr     * Render a link to an internal media file
654cfa2b40eSAndreas Gohr     *
655cfa2b40eSAndreas Gohr     * @param string $src     media ID
656cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
657cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
658cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
659cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
660cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
661cfa2b40eSAndreas Gohr     */
662cfa2b40eSAndreas Gohr    function internalmedialink($src, $title = null, $align = null,
663cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6642c2835c2SAndreas Gohr    }
6650cecf9d5Sandi
666cfa2b40eSAndreas Gohr    /**
667cfa2b40eSAndreas Gohr     * Render a link to an external media file
668cfa2b40eSAndreas Gohr     *
669cfa2b40eSAndreas Gohr     * @param string $src     media ID
670cfa2b40eSAndreas Gohr     * @param string $title   descriptive text
671cfa2b40eSAndreas Gohr     * @param string $align   left|center|right
672cfa2b40eSAndreas Gohr     * @param int    $width   width of media in pixel
673cfa2b40eSAndreas Gohr     * @param int    $height  height of media in pixel
674cfa2b40eSAndreas Gohr     * @param string $cache   cache|recache|nocache
675cfa2b40eSAndreas Gohr     */
676cfa2b40eSAndreas Gohr    function externalmedialink($src, $title = null, $align = null,
677cfa2b40eSAndreas Gohr                               $width = null, $height = null, $cache = null) {
6782c2835c2SAndreas Gohr    }
6790cecf9d5Sandi
680cfa2b40eSAndreas Gohr    /**
681cfa2b40eSAndreas Gohr     * Start a table
682cfa2b40eSAndreas Gohr     *
683cfa2b40eSAndreas Gohr     * @param int $maxcols maximum number of columns
684cfa2b40eSAndreas Gohr     * @param int $numrows NOT IMPLEMENTED
685cfa2b40eSAndreas Gohr     * @param int $pos     byte position in the original source
686cfa2b40eSAndreas Gohr     */
6872c2835c2SAndreas Gohr    function table_open($maxcols = null, $numrows = null, $pos = null) {
6882c2835c2SAndreas Gohr    }
6890cecf9d5Sandi
690cfa2b40eSAndreas Gohr    /**
691cfa2b40eSAndreas Gohr     * Close a table
692cfa2b40eSAndreas Gohr     *
693cfa2b40eSAndreas Gohr     * @param int $pos byte position in the original source
694cfa2b40eSAndreas Gohr     */
6952c2835c2SAndreas Gohr    function table_close($pos = null) {
6962c2835c2SAndreas Gohr    }
6970cecf9d5Sandi
698cfa2b40eSAndreas Gohr    /**
699cfa2b40eSAndreas Gohr     * Open a table header
700cfa2b40eSAndreas Gohr     */
7012c2835c2SAndreas Gohr    function tablethead_open() {
7022c2835c2SAndreas Gohr    }
703f05a1cc5SGerrit Uitslag
704cfa2b40eSAndreas Gohr    /**
705cfa2b40eSAndreas Gohr     * Close a table header
706cfa2b40eSAndreas Gohr     */
7072c2835c2SAndreas Gohr    function tablethead_close() {
7082c2835c2SAndreas Gohr    }
709f05a1cc5SGerrit Uitslag
710cfa2b40eSAndreas Gohr    /**
711cfa2b40eSAndreas Gohr     * Open a table row
712cfa2b40eSAndreas Gohr     */
7132c2835c2SAndreas Gohr    function tablerow_open() {
7142c2835c2SAndreas Gohr    }
7150cecf9d5Sandi
716cfa2b40eSAndreas Gohr    /**
717cfa2b40eSAndreas Gohr     * Close a table row
718cfa2b40eSAndreas Gohr     */
7192c2835c2SAndreas Gohr    function tablerow_close() {
7202c2835c2SAndreas Gohr    }
7210cecf9d5Sandi
722cfa2b40eSAndreas Gohr    /**
723cfa2b40eSAndreas Gohr     * Open a table header cell
724cfa2b40eSAndreas Gohr     *
725cfa2b40eSAndreas Gohr     * @param int    $colspan
726cfa2b40eSAndreas Gohr     * @param string $align left|center|right
727cfa2b40eSAndreas Gohr     * @param int    $rowspan
728cfa2b40eSAndreas Gohr     */
7292c2835c2SAndreas Gohr    function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
7302c2835c2SAndreas Gohr    }
7310cecf9d5Sandi
732cfa2b40eSAndreas Gohr    /**
733cfa2b40eSAndreas Gohr     * Close a table header cell
734cfa2b40eSAndreas Gohr     */
7352c2835c2SAndreas Gohr    function tableheader_close() {
7362c2835c2SAndreas Gohr    }
7370cecf9d5Sandi
738cfa2b40eSAndreas Gohr    /**
739cfa2b40eSAndreas Gohr     * Open a table cell
740cfa2b40eSAndreas Gohr     *
741cfa2b40eSAndreas Gohr     * @param int    $colspan
742cfa2b40eSAndreas Gohr     * @param string $align left|center|right
743cfa2b40eSAndreas Gohr     * @param int    $rowspan
744cfa2b40eSAndreas Gohr     */
7452c2835c2SAndreas Gohr    function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
7462c2835c2SAndreas Gohr    }
7470cecf9d5Sandi
748cfa2b40eSAndreas Gohr    /**
749cfa2b40eSAndreas Gohr     * Close a table cell
750cfa2b40eSAndreas Gohr     */
7512c2835c2SAndreas Gohr    function tablecell_close() {
7522c2835c2SAndreas Gohr    }
7532ea4044fSAndreas Gohr
754cfa2b40eSAndreas Gohr    #endregion
755cfa2b40eSAndreas Gohr
756cfa2b40eSAndreas Gohr    #region util functions, you probably won't need to reimplement them
7572ea4044fSAndreas Gohr
7582ea4044fSAndreas Gohr    /**
7592ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
7602ea4044fSAndreas Gohr     * casing and special chars
7612ea4044fSAndreas Gohr     *
7622ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
7632ea4044fSAndreas Gohr     */
7642ea4044fSAndreas Gohr    function _simpleTitle($name) {
7652ea4044fSAndreas Gohr        global $conf;
7662ea4044fSAndreas Gohr
7672ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
7686d2af55dSChristopher Smith        @list($name, $hash) = explode('#', $name, 2);
7692ea4044fSAndreas Gohr        if($hash) return $hash;
7702ea4044fSAndreas Gohr
7712ea4044fSAndreas Gohr        if($conf['useslash']) {
7723755fc25STom N Harris            $name = strtr($name, ';/', ';:');
7733755fc25STom N Harris        } else {
7743755fc25STom N Harris            $name = strtr($name, ';', ':');
7752ea4044fSAndreas Gohr        }
7762ea4044fSAndreas Gohr
7779708106bSAdrian Lang        return noNSorNS($name);
7782ea4044fSAndreas Gohr    }
7792ea4044fSAndreas Gohr
7801f82fabeSAndreas Gohr    /**
7811f82fabeSAndreas Gohr     * Resolve an interwikilink
7821f82fabeSAndreas Gohr     */
7836496c33fSGerrit Uitslag    function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
7841f82fabeSAndreas Gohr        //get interwiki URL
7851f82fabeSAndreas Gohr        if(isset($this->interwiki[$shortcut])) {
7861f82fabeSAndreas Gohr            $url = $this->interwiki[$shortcut];
7871f82fabeSAndreas Gohr        } else {
7881f82fabeSAndreas Gohr            // Default to Google I'm feeling lucky
7891f82fabeSAndreas Gohr            $url      = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
7901f82fabeSAndreas Gohr            $shortcut = 'go';
7911f82fabeSAndreas Gohr        }
7922ea4044fSAndreas Gohr
7931f82fabeSAndreas Gohr        //split into hash and url part
7946d2af55dSChristopher Smith        @list($reference, $hash) = explode('#', $reference, 2);
7951f82fabeSAndreas Gohr
7961f82fabeSAndreas Gohr        //replace placeholder
7971f82fabeSAndreas Gohr        if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
7981f82fabeSAndreas Gohr            //use placeholders
7991f82fabeSAndreas Gohr            $url    = str_replace('{URL}', rawurlencode($reference), $url);
8001f82fabeSAndreas Gohr            $url    = str_replace('{NAME}', $reference, $url);
8011f82fabeSAndreas Gohr            $parsed = parse_url($reference);
8021f82fabeSAndreas Gohr            if(!$parsed['port']) $parsed['port'] = 80;
8031f82fabeSAndreas Gohr            $url = str_replace('{SCHEME}', $parsed['scheme'], $url);
8041f82fabeSAndreas Gohr            $url = str_replace('{HOST}', $parsed['host'], $url);
8051f82fabeSAndreas Gohr            $url = str_replace('{PORT}', $parsed['port'], $url);
8061f82fabeSAndreas Gohr            $url = str_replace('{PATH}', $parsed['path'], $url);
8071f82fabeSAndreas Gohr            $url = str_replace('{QUERY}', $parsed['query'], $url);
8081f82fabeSAndreas Gohr        } else {
8091f82fabeSAndreas Gohr            //default
8101f82fabeSAndreas Gohr            $url = $url.rawurlencode($reference);
8111f82fabeSAndreas Gohr        }
812f379edc2SGerrit Uitslag        //handle as wiki links
8136496c33fSGerrit Uitslag        if($url{0} === ':') {
8146496c33fSGerrit Uitslag            list($id, $urlparam) = explode('?', $url, 2);
8156496c33fSGerrit Uitslag            $url    = wl(cleanID($id), $urlparam);
8166496c33fSGerrit Uitslag            $exists = page_exists($id);
8172345e871SGerrit Uitslag        }
8181f82fabeSAndreas Gohr        if($hash) $url .= '#'.rawurlencode($hash);
8191f82fabeSAndreas Gohr
8201f82fabeSAndreas Gohr        return $url;
8211f82fabeSAndreas Gohr    }
822cfa2b40eSAndreas Gohr
823cfa2b40eSAndreas Gohr    #endregion
8240cecf9d5Sandi}
8250cecf9d5Sandi
826340756e4Sandi
827e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 :
828