source: documentation/trunk/packages/dokuwiki-2011-05-25a/inc/parser/renderer.php@ 25027

Last change on this file since 25027 was 25027, checked in by jmt12, 12 years ago

Adding the packages directory, and within it a configured version of dokuwiki all ready to run

File size: 8.1 KB
Line 
1<?php
2/**
3 * Renderer output base class
4 *
5 * @author Harry Fuecks <[email protected]>
6 * @author Andreas Gohr <[email protected]>
7 */
8if(!defined('DOKU_INC')) die('meh.');
9require_once DOKU_INC . 'inc/plugin.php';
10require_once DOKU_INC . 'inc/pluginutils.php';
11
12/**
13 * An empty renderer, produces no output
14 *
15 * Inherits from DokuWiki_Plugin for giving additional functions to render plugins
16 */
17class Doku_Renderer extends DokuWiki_Plugin {
18 var $info = array(
19 'cache' => true, // may the rendered result cached?
20 'toc' => true, // render the TOC?
21 );
22
23 // keep some config options
24 var $acronyms = array();
25 var $smileys = array();
26 var $badwords = array();
27 var $entities = array();
28 var $interwiki = array();
29
30 // allows renderer to be used again, clean out any per-use values
31 function reset() {
32 }
33
34 function nocache() {
35 $this->info['cache'] = false;
36 }
37
38 function notoc() {
39 $this->info['toc'] = false;
40 }
41
42 /**
43 * Returns the format produced by this renderer.
44 *
45 * Has to be overidden by decendend classes
46 */
47 function getFormat(){
48 trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING);
49 }
50
51 /**
52 * Allow the plugin to prevent DokuWiki from reusing an instance
53 *
54 * @return bool false if the plugin has to be instantiated
55 */
56 function isSingleton() {
57 return false;
58 }
59
60
61 //handle plugin rendering
62 function plugin($name,$data){
63 $plugin =& plugin_load('syntax',$name);
64 if($plugin != null){
65 $plugin->render($this->getFormat(),$this,$data);
66 }
67 }
68
69 /**
70 * handle nested render instructions
71 * this method (and nest_close method) should not be overloaded in actual renderer output classes
72 */
73 function nest($instructions) {
74
75 foreach ( $instructions as $instruction ) {
76 // execute the callback against ourself
77 if (method_exists($this,$instruction[0])) {
78 call_user_func_array(array($this, $instruction[0]),$instruction[1]);
79 }
80 }
81 }
82
83 // dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should
84 // override this instruction when instantiating Doku_Handler_Nest - however plugins will not
85 // be able to - as their instructions require data.
86 function nest_close() {}
87
88 function document_start() {}
89
90 function document_end() {}
91
92 function render_TOC() { return ''; }
93
94 function toc_additem($id, $text, $level) {}
95
96 function header($text, $level, $pos) {}
97
98 function section_open($level) {}
99
100 function section_close() {}
101
102 function cdata($text) {}
103
104 function p_open() {}
105
106 function p_close() {}
107
108 function linebreak() {}
109
110 function hr() {}
111
112 function strong_open() {}
113
114 function strong_close() {}
115
116 function emphasis_open() {}
117
118 function emphasis_close() {}
119
120 function underline_open() {}
121
122 function underline_close() {}
123
124 function monospace_open() {}
125
126 function monospace_close() {}
127
128 function subscript_open() {}
129
130 function subscript_close() {}
131
132 function superscript_open() {}
133
134 function superscript_close() {}
135
136 function deleted_open() {}
137
138 function deleted_close() {}
139
140 function footnote_open() {}
141
142 function footnote_close() {}
143
144 function listu_open() {}
145
146 function listu_close() {}
147
148 function listo_open() {}
149
150 function listo_close() {}
151
152 function listitem_open($level) {}
153
154 function listitem_close() {}
155
156 function listcontent_open() {}
157
158 function listcontent_close() {}
159
160 function unformatted($text) {}
161
162 function php($text) {}
163
164 function phpblock($text) {}
165
166 function html($text) {}
167
168 function htmlblock($text) {}
169
170 function preformatted($text) {}
171
172 function quote_open() {}
173
174 function quote_close() {}
175
176 function file($text, $lang = null, $file = null ) {}
177
178 function code($text, $lang = null, $file = null ) {}
179
180 function acronym($acronym) {}
181
182 function smiley($smiley) {}
183
184 function wordblock($word) {}
185
186 function entity($entity) {}
187
188 // 640x480 ($x=640, $y=480)
189 function multiplyentity($x, $y) {}
190
191 function singlequoteopening() {}
192
193 function singlequoteclosing() {}
194
195 function apostrophe() {}
196
197 function doublequoteopening() {}
198
199 function doublequoteclosing() {}
200
201 // $link like 'SomePage'
202 function camelcaselink($link) {}
203
204 function locallink($hash, $name = NULL) {}
205
206 // $link like 'wiki:syntax', $title could be an array (media)
207 function internallink($link, $title = NULL) {}
208
209 // $link is full URL with scheme, $title could be an array (media)
210 function externallink($link, $title = NULL) {}
211
212 function rss ($url,$params) {}
213
214 // $link is the original link - probably not much use
215 // $wikiName is an indentifier for the wiki
216 // $wikiUri is the URL fragment to append to some known URL
217 function interwikilink($link, $title = NULL, $wikiName, $wikiUri) {}
218
219 // Link to file on users OS, $title could be an array (media)
220 function filelink($link, $title = NULL) {}
221
222 // Link to a Windows share, , $title could be an array (media)
223 function windowssharelink($link, $title = NULL) {}
224
225// function email($address, $title = NULL) {}
226 function emaillink($address, $name = NULL) {}
227
228 function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
229 $height=NULL, $cache=NULL, $linking=NULL) {}
230
231 function externalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
232 $height=NULL, $cache=NULL, $linking=NULL) {}
233
234 function internalmedialink (
235 $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
236 ) {}
237
238 function externalmedialink(
239 $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
240 ) {}
241
242 function table_open($maxcols = null, $numrows = null, $pos = null){}
243
244 function table_close($pos = null){}
245
246 function tablerow_open(){}
247
248 function tablerow_close(){}
249
250 function tableheader_open($colspan = 1, $align = NULL, $rowspan = 1){}
251
252 function tableheader_close(){}
253
254 function tablecell_open($colspan = 1, $align = NULL, $rowspan = 1){}
255
256 function tablecell_close(){}
257
258
259 // util functions follow, you probably won't need to reimplement them
260
261
262 /**
263 * Removes any Namespace from the given name but keeps
264 * casing and special chars
265 *
266 * @author Andreas Gohr <[email protected]>
267 */
268 function _simpleTitle($name){
269 global $conf;
270
271 //if there is a hash we use the ancor name only
272 list($name,$hash) = explode('#',$name,2);
273 if($hash) return $hash;
274
275 $name = strtr($name,';',':');
276 if($conf['useslash']){
277 $name = strtr($name,'/',':');
278 }
279
280 return noNSorNS($name);
281 }
282
283 /**
284 * Resolve an interwikilink
285 */
286 function _resolveInterWiki(&$shortcut,$reference){
287 //get interwiki URL
288 if ( isset($this->interwiki[$shortcut]) ) {
289 $url = $this->interwiki[$shortcut];
290 } else {
291 // Default to Google I'm feeling lucky
292 $url = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
293 $shortcut = 'go';
294 }
295
296 //split into hash and url part
297 list($reference,$hash) = explode('#',$reference,2);
298
299 //replace placeholder
300 if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#',$url)){
301 //use placeholders
302 $url = str_replace('{URL}',rawurlencode($reference),$url);
303 $url = str_replace('{NAME}',$reference,$url);
304 $parsed = parse_url($reference);
305 if(!$parsed['port']) $parsed['port'] = 80;
306 $url = str_replace('{SCHEME}',$parsed['scheme'],$url);
307 $url = str_replace('{HOST}',$parsed['host'],$url);
308 $url = str_replace('{PORT}',$parsed['port'],$url);
309 $url = str_replace('{PATH}',$parsed['path'],$url);
310 $url = str_replace('{QUERY}',$parsed['query'],$url);
311 }else{
312 //default
313 $url = $url.rawurlencode($reference);
314 }
315 if($hash) $url .= '#'.rawurlencode($hash);
316
317 return $url;
318 }
319}
320
321
322//Setup VIM: ex: et ts=4 :
Note: See TracBrowser for help on using the repository browser.