xref: /dokuwiki/inc/parser/renderer.php (revision 2ea4044fe6adc821853ef4f360c95a6f97df0558)
10cecf9d5Sandi<?php
261faf446Schris/**
35587e44cSchris * Renderer output base class
461faf446Schris *
561faf446Schris * @author Harry Fuecks <hfuecks@gmail.com>
661faf446Schris * @author Andreas Gohr <andi@splitbrain.org>
761faf446Schris */
861faf446Schrisif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
961faf446Schris
1061faf446Schrisrequire_once DOKU_INC . 'inc/parser/renderer.php';
11863befa1SAndreas Gohrrequire_once DOKU_INC . 'inc/plugin.php';
1261faf446Schrisrequire_once DOKU_INC . 'inc/pluginutils.php';
1361faf446Schris
14863befa1SAndreas Gohr/**
15863befa1SAndreas Gohr * An empty renderer, produces no output
16863befa1SAndreas Gohr *
17863befa1SAndreas Gohr * Inherits from DokuWiki_Plugin for giving additional functions to render plugins
18863befa1SAndreas Gohr */
19863befa1SAndreas Gohrclass Doku_Renderer extends DokuWiki_Plugin {
209dc2c2afSandi    var $info = array(
2144881bd0Shenning.noren        'cache' => true, // may the rendered result cached?
2244881bd0Shenning.noren        'toc'   => true, // render the TOC?
239dc2c2afSandi    );
249dc2c2afSandi
259dc2c2afSandi
269dc2c2afSandi    function nocache() {
2744881bd0Shenning.noren        $this->info['cache'] = false;
289dc2c2afSandi    }
290cecf9d5Sandi
30e41c4da9SAndreas Gohr    function notoc() {
3144881bd0Shenning.noren        $this->info['toc'] = false;
32e41c4da9SAndreas Gohr    }
33e41c4da9SAndreas Gohr
3461faf446Schris    //handle plugin rendering
3561faf446Schris    function plugin($name,$data){
3661faf446Schris        $plugin =& plugin_load('syntax',$name);
3761faf446Schris        if($plugin != null){
3861faf446Schris            // determine mode from renderer class name - format = "Doku_Renderer_<mode>"
3961faf446Schris            $mode = substr(get_class($this), 14);
4061faf446Schris            $plugin->render($mode,$this,$data);
4161faf446Schris        }
4261faf446Schris    }
4361faf446Schris
445587e44cSchris    /**
455587e44cSchris     * handle nested render instructions
465587e44cSchris     * this method (and nest_close method) should not be overloaded in actual renderer output classes
475587e44cSchris     */
485587e44cSchris    function nest($instructions) {
495587e44cSchris
505587e44cSchris      foreach ( $instructions as $instruction ) {
515587e44cSchris        // execute the callback against ourself
525587e44cSchris        call_user_func_array(array(&$this, $instruction[0]),$instruction[1]);
535587e44cSchris      }
545587e44cSchris    }
555587e44cSchris
565587e44cSchris    // dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should
575587e44cSchris    // override this instruction when instantiating Doku_Handler_Nest - however plugins will not
585587e44cSchris    // be able to - as their instructions require data.
595587e44cSchris    function nest_close() {}
605587e44cSchris
610cecf9d5Sandi    function document_start() {}
620cecf9d5Sandi
630cecf9d5Sandi    function document_end() {}
640cecf9d5Sandi
654fced885SAndreas Gohr    function render_TOC() { return ''; }
660cecf9d5Sandi
67af587fa8Sandi    function header($text, $level, $pos) {}
680cecf9d5Sandi
6935dae8b0SBen Coburn    function section_edit($start, $end, $level, $name) {}
7035dae8b0SBen Coburn
710cecf9d5Sandi    function section_open($level) {}
720cecf9d5Sandi
730cecf9d5Sandi    function section_close() {}
740cecf9d5Sandi
750cecf9d5Sandi    function cdata($text) {}
760cecf9d5Sandi
770cecf9d5Sandi    function p_open() {}
780cecf9d5Sandi
790cecf9d5Sandi    function p_close() {}
800cecf9d5Sandi
810cecf9d5Sandi    function linebreak() {}
820cecf9d5Sandi
830cecf9d5Sandi    function hr() {}
840cecf9d5Sandi
850cecf9d5Sandi    function strong_open() {}
860cecf9d5Sandi
870cecf9d5Sandi    function strong_close() {}
880cecf9d5Sandi
890cecf9d5Sandi    function emphasis_open() {}
900cecf9d5Sandi
910cecf9d5Sandi    function emphasis_close() {}
920cecf9d5Sandi
930cecf9d5Sandi    function underline_open() {}
940cecf9d5Sandi
950cecf9d5Sandi    function underline_close() {}
960cecf9d5Sandi
970cecf9d5Sandi    function monospace_open() {}
980cecf9d5Sandi
990cecf9d5Sandi    function monospace_close() {}
1000cecf9d5Sandi
1010cecf9d5Sandi    function subscript_open() {}
1020cecf9d5Sandi
1030cecf9d5Sandi    function subscript_close() {}
1040cecf9d5Sandi
1050cecf9d5Sandi    function superscript_open() {}
1060cecf9d5Sandi
1070cecf9d5Sandi    function superscript_close() {}
1080cecf9d5Sandi
1090cecf9d5Sandi    function deleted_open() {}
1100cecf9d5Sandi
1110cecf9d5Sandi    function deleted_close() {}
1120cecf9d5Sandi
1130cecf9d5Sandi    function footnote_open() {}
1140cecf9d5Sandi
1150cecf9d5Sandi    function footnote_close() {}
1160cecf9d5Sandi
1170cecf9d5Sandi    function listu_open() {}
1180cecf9d5Sandi
1190cecf9d5Sandi    function listu_close() {}
1200cecf9d5Sandi
1210cecf9d5Sandi    function listo_open() {}
1220cecf9d5Sandi
1230cecf9d5Sandi    function listo_close() {}
1240cecf9d5Sandi
1250cecf9d5Sandi    function listitem_open($level) {}
1260cecf9d5Sandi
1270cecf9d5Sandi    function listitem_close() {}
1280cecf9d5Sandi
129699afdebSchris    function listcontent_open() {}
1300cecf9d5Sandi
1310cecf9d5Sandi    function listcontent_close() {}
1320cecf9d5Sandi
1330cecf9d5Sandi    function unformatted($text) {}
1340cecf9d5Sandi
1350cecf9d5Sandi    function php($text) {}
1360cecf9d5Sandi
1370cecf9d5Sandi    function html($text) {}
1380cecf9d5Sandi
1390cecf9d5Sandi    function preformatted($text) {}
1400cecf9d5Sandi
1410cecf9d5Sandi    function file($text) {}
1420cecf9d5Sandi
1430cecf9d5Sandi    function quote_open() {}
1440cecf9d5Sandi
1450cecf9d5Sandi    function quote_close() {}
1460cecf9d5Sandi
1470cecf9d5Sandi    function code($text, $lang = NULL) {}
1480cecf9d5Sandi
1490cecf9d5Sandi    function acronym($acronym) {}
1500cecf9d5Sandi
1510cecf9d5Sandi    function smiley($smiley) {}
1520cecf9d5Sandi
1530cecf9d5Sandi    function wordblock($word) {}
1540cecf9d5Sandi
1550cecf9d5Sandi    function entity($entity) {}
1560cecf9d5Sandi
1570cecf9d5Sandi    // 640x480 ($x=640, $y=480)
1580cecf9d5Sandi    function multiplyentity($x, $y) {}
1590cecf9d5Sandi
1600cecf9d5Sandi    function singlequoteopening() {}
1610cecf9d5Sandi
1620cecf9d5Sandi    function singlequoteclosing() {}
1630cecf9d5Sandi
1640cecf9d5Sandi    function doublequoteopening() {}
1650cecf9d5Sandi
1660cecf9d5Sandi    function doublequoteclosing() {}
1670cecf9d5Sandi
1680cecf9d5Sandi    // $link like 'SomePage'
1690cecf9d5Sandi    function camelcaselink($link) {}
1700cecf9d5Sandi
171a939d432SAndreas Gohr    function locallink($hash, $name = NULL) {}
172a939d432SAndreas Gohr
1730e1c636eSandi    // $link like 'wiki:syntax', $title could be an array (media)
1740cecf9d5Sandi    function internallink($link, $title = NULL) {}
1750cecf9d5Sandi
1760cecf9d5Sandi    // $link is full URL with scheme, $title could be an array (media)
1770cecf9d5Sandi    function externallink($link, $title = NULL) {}
1780cecf9d5Sandi
1790cecf9d5Sandi    // $link is the original link - probably not much use
1800cecf9d5Sandi    // $wikiName is an indentifier for the wiki
1810cecf9d5Sandi    // $wikiUri is the URL fragment to append to some known URL
1820cecf9d5Sandi    function interwikilink($link, $title = NULL, $wikiName, $wikiUri) {}
1830cecf9d5Sandi
1840cecf9d5Sandi    // Link to file on users OS, $title could be an array (media)
1850cecf9d5Sandi    function filelink($link, $title = NULL) {}
1860cecf9d5Sandi
1870cecf9d5Sandi    // Link to a Windows share, , $title could be an array (media)
1880cecf9d5Sandi    function windowssharelink($link, $title = NULL) {}
1890cecf9d5Sandi
190699afdebSchris//  function email($address, $title = NULL) {}
191699afdebSchris    function emaillink($address, $name = NULL) {}
1920cecf9d5Sandi
193a939d432SAndreas Gohr    function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
194a939d432SAndreas Gohr                            $height=NULL, $cache=NULL, $linking=NULL) {}
195a939d432SAndreas Gohr
196a939d432SAndreas Gohr    function externalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
197a939d432SAndreas Gohr                            $height=NULL, $cache=NULL, $linking=NULL) {}
198a939d432SAndreas Gohr
1990cecf9d5Sandi    function internalmedialink (
2000cecf9d5Sandi        $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
2010cecf9d5Sandi        ) {}
2020cecf9d5Sandi
2030cecf9d5Sandi    function externalmedialink(
2040cecf9d5Sandi        $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
2050cecf9d5Sandi        ) {}
2060cecf9d5Sandi
2070cecf9d5Sandi    function table_open($maxcols = NULL, $numrows = NULL){}
2080cecf9d5Sandi
2090cecf9d5Sandi    function table_close(){}
2100cecf9d5Sandi
2110cecf9d5Sandi    function tablerow_open(){}
2120cecf9d5Sandi
2130cecf9d5Sandi    function tablerow_close(){}
2140cecf9d5Sandi
2150cecf9d5Sandi    function tableheader_open($colspan = 1, $align = NULL){}
2160cecf9d5Sandi
2170cecf9d5Sandi    function tableheader_close(){}
2180cecf9d5Sandi
2190cecf9d5Sandi    function tablecell_open($colspan = 1, $align = NULL){}
2200cecf9d5Sandi
2210cecf9d5Sandi    function tablecell_close(){}
2220cecf9d5Sandi
223*2ea4044fSAndreas Gohr
224*2ea4044fSAndreas Gohr    // util functions follow, you probably won't need to reimplement them
225*2ea4044fSAndreas Gohr
226*2ea4044fSAndreas Gohr
227*2ea4044fSAndreas Gohr    /**
228*2ea4044fSAndreas Gohr     * Removes any Namespace from the given name but keeps
229*2ea4044fSAndreas Gohr     * casing and special chars
230*2ea4044fSAndreas Gohr     *
231*2ea4044fSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
232*2ea4044fSAndreas Gohr     */
233*2ea4044fSAndreas Gohr    function _simpleTitle($name){
234*2ea4044fSAndreas Gohr        global $conf;
235*2ea4044fSAndreas Gohr
236*2ea4044fSAndreas Gohr        //if there is a hash we use the ancor name only
237*2ea4044fSAndreas Gohr        list($name,$hash) = explode('#',$name,2);
238*2ea4044fSAndreas Gohr        if($hash) return $hash;
239*2ea4044fSAndreas Gohr
240*2ea4044fSAndreas Gohr        //trim colons of a namespace link
241*2ea4044fSAndreas Gohr        $name = rtrim($name,':');
242*2ea4044fSAndreas Gohr
243*2ea4044fSAndreas Gohr        if($conf['useslash']){
244*2ea4044fSAndreas Gohr            $nssep = '[:;/]';
245*2ea4044fSAndreas Gohr        }else{
246*2ea4044fSAndreas Gohr            $nssep = '[:;]';
247*2ea4044fSAndreas Gohr        }
248*2ea4044fSAndreas Gohr        $name = preg_replace('!.*'.$nssep.'!','',$name);
249*2ea4044fSAndreas Gohr
250*2ea4044fSAndreas Gohr        if(!$name) return $this->_simpleTitle($conf['start']);
251*2ea4044fSAndreas Gohr        return $name;
252*2ea4044fSAndreas Gohr    }
253*2ea4044fSAndreas Gohr
254*2ea4044fSAndreas Gohr
2550cecf9d5Sandi}
2560cecf9d5Sandi
257340756e4Sandi
2589dc2c2afSandi//Setup VIM: ex: et ts=4 enc=utf-8 :
259