[ Index ] |
|
Code source de DokuWiki 2006-11-06 |
1 <?php 2 //FIXME!! remove the line ignoring the 'wiki' export mode from 3 // inc/parserutils.php#p_renderer() when this file works. 4 5 /** 6 * Basis for converting to Dokuwiki syntax 7 * This is not yet complete but useable for converting 8 * phpWiki syntax. 9 * Main issues lie with lists, quote and tables 10 */ 11 class Doku_Renderer_Wiki extends Doku_Renderer { 12 13 var $doc = ''; 14 15 // This should be eliminated 16 var $listMarker = '*'; 17 18 function document_start() { 19 ob_start(); 20 } 21 22 function document_end() { 23 24 $this->doc .= ob_get_contents(); 25 ob_end_clean(); 26 27 } 28 29 function header($text, $level) { 30 $levels = array( 31 1=>'======', 32 2=>'=====', 33 3=>'====', 34 4=>'===', 35 5=>'==', 36 ); 37 38 if ( isset($levels[$level]) ) { 39 $token = $levels[$level]; 40 } else { 41 $token = $levels[1]; 42 } 43 echo "\n{$token} "; 44 echo trim($text); 45 echo " {$token}\n"; 46 } 47 48 function cdata($text) { 49 echo $text; 50 } 51 52 function linebreak() { 53 echo '\\\\ '; 54 } 55 56 function hr() { 57 echo "\n----\n"; 58 } 59 60 function strong_open() { 61 echo '**'; 62 } 63 64 function strong_close() { 65 echo '**'; 66 } 67 68 function emphasis_open() { 69 echo '//'; 70 } 71 72 function emphasis_close() { 73 echo '//'; 74 } 75 76 function underline_open() { 77 echo '__'; 78 } 79 80 function underline_close() { 81 echo '__'; 82 } 83 84 function monospace_open() { 85 echo "''"; 86 } 87 88 function monospace_close() { 89 echo "''"; 90 } 91 92 function subscript_open() { 93 echo '<sub>'; 94 } 95 96 function subscript_close() { 97 echo '</sub>'; 98 } 99 100 function superscript_open() { 101 echo '<sup>'; 102 } 103 104 function superscript_close() { 105 echo '</sup>'; 106 } 107 108 function deleted_open() { 109 echo '<del>'; 110 } 111 112 function deleted_close() { 113 echo '</del>'; 114 } 115 116 function footnote_open() { 117 echo '(('; 118 } 119 120 function footnote_close() { 121 echo '))'; 122 } 123 124 function listu_open() { 125 $this->listMarker = '*'; 126 echo "\n"; 127 } 128 129 function listo_open() { 130 $this->listMarker = '-'; 131 echo "\n"; 132 } 133 134 /** 135 * @TODO Problem here with nested lists 136 */ 137 function listitem_open($level) { 138 echo str_repeat(' ', $level).$this->listMarker; 139 } 140 141 function listitem_close() { 142 echo "\n"; 143 } 144 145 function unformatted($text) { 146 echo '%%'.$text.'%%'; 147 } 148 149 function php($text) { 150 echo "\n<php>\n$text\n</php>\n"; 151 } 152 153 function html($text) { 154 echo "\n<html>\n$text\n</html>\n"; 155 } 156 157 /** 158 * Indent? 159 */ 160 function preformatted($text) { 161 echo "\n<code>\n$text\n</code>\n"; 162 } 163 164 function file($text) { 165 echo "\n<file>\n$text\n</file>\n"; 166 } 167 168 /** 169 * Problem here with nested quotes 170 */ 171 function quote_open() { 172 echo '>'; 173 } 174 175 function quote_close() { 176 echo "\n"; 177 } 178 179 function code($text, $lang = NULL) { 180 if ( !$lang ) { 181 echo "\n<code>\n$text\n</code>\n"; 182 } else { 183 echo "\n<code $lang>\n$text\n</code>\n"; 184 } 185 186 } 187 188 function acronym($acronym) { 189 echo $acronym; 190 } 191 192 function smiley($smiley) { 193 echo $smiley; 194 } 195 196 function wordblock($word) { 197 echo $word; 198 } 199 200 function entity($entity) { 201 echo $entity; 202 } 203 204 // 640x480 ($x=640, $y=480) 205 function multiplyentity($x, $y) { 206 echo "{$x}x{$y}"; 207 } 208 209 function singlequoteopening() { 210 echo "'"; 211 } 212 213 function singlequoteclosing() { 214 echo "'"; 215 } 216 217 function doublequoteopening() { 218 echo '"'; 219 } 220 221 function doublequoteclosing() { 222 echo '"'; 223 } 224 225 // $link like 'SomePage' 226 function camelcaselink($link) { 227 echo $link; 228 } 229 230 // $link like 'wikie:syntax', $title could be an array (media) 231 function internallink($link, $title = NULL) { 232 if ( $title ) { 233 echo '[['.$link.'|'.$title.']]'; 234 } else { 235 echo '[['.$link.']]'; 236 } 237 } 238 239 // $link is full URL with scheme, $title could be an array (media) 240 function externallink($link, $title = NULL) { 241 if ( $title ) { 242 echo '[['.$link.'|'.$title.']]'; 243 } else { 244 echo '[['.$link.']]'; 245 } 246 } 247 248 // $link is the original link - probably not much use 249 // $wikiName is an indentifier for the wiki 250 // $wikiUri is the URL fragment to append to some known URL 251 function interwikilink($link, $title = NULL, $wikiName, $wikiUri) { 252 if ( $title ) { 253 echo '[['.$link.'|'.$title.']]'; 254 } else { 255 echo '[['.$link.']]'; 256 } 257 } 258 259 // Link to file on users OS, $title could be an array (media) 260 function filelink($link, $title = NULL) { 261 if ( $title ) { 262 echo '[['.$link.'|'.$title.']]'; 263 } else { 264 echo '[['.$link.']]'; 265 } 266 } 267 268 // Link to a Windows share, , $title could be an array (media) 269 function windowssharelink($link, $title = NULL) { 270 if ( $title ) { 271 echo '[['.$link.'|'.$title.']]'; 272 } else { 273 echo '[['.$link.']]'; 274 } 275 } 276 277 function email($address, $title = NULL) { 278 if ( $title ) { 279 echo '[['.$address.'|'.$title.']]'; 280 } else { 281 echo '[['.$address.']]'; 282 } 283 } 284 285 // @TODO 286 function internalmedialink ( 287 $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL 288 ) { 289 290 } 291 292 // @TODO 293 function externalmedialink( 294 $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL 295 ) { 296 if ( $title ) { 297 echo '{{'.$src.'|'.$title.'}}'; 298 } else { 299 echo '{{'.$src.'}}'; 300 } 301 } 302 303 function table_open($maxcols = NULL, $numrows = NULL){} 304 305 function table_close(){} 306 307 function tablerow_open(){} 308 309 function tablerow_close(){} 310 311 function tableheader_open($colspan = 1, $align = NULL){} 312 313 function tableheader_close(){} 314 315 function tablecell_open($colspan = 1, $align = NULL){} 316 317 function tablecell_close(){} 318 319 } 320 321 322 //Setup VIM: ex: et ts=2 enc=utf-8 :
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 20:47:31 2007 | par Balluche grâce à PHPXref 0.7 |