[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php # $Id: serendipity_event_textwiki.php 1528 2006-12-01 08:58:47Z garvinhicking $ 2 3 4 if (IN_serendipity !== true) { 5 die ("Don't hack!"); 6 } 7 8 // Probe for a language include with constants. Still include defines later on, if some constants were missing 9 $probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php'; 10 if (file_exists($probelang)) { 11 include $probelang; 12 } 13 14 include dirname(__FILE__) . '/lang_en.inc.php'; 15 16 // Currently only english available 17 18 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PREFILETER', 'Converts different OS linebreaks (Unix/DOS) to unified format and concates lines ending with \. Default is on. Not recommended to switch off.'); 19 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_DELIMITER', 'Converts the Text_Wiki internal delimiter "\xFF" (255) to avoid conflicts while parsing. Default is on. Not recommended to switch off.'); 20 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_CODE', 'Marks text between <code> and </code> as code. Using <code type=".."> you can switch highlighting on (e.g. for PHP). Default is on.'); 21 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PHPCODE', 'Marks and highlights text between <php> and </php> as PHP code and adds PHP open tags. Default is on.'); 22 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_HTML', 'Allows you to use real HTML between <html> and </html>. Beware JS is possible, too! If you use this, switch off markup for comments! Default is off. Not recommended to switch on.'); 23 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_RAW', 'Text between `` and `` is not touched by other markup rules. Default is on.'); 24 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_INCLUDE', 'Allows you to include and run PHP code with the syntax [[include /path/to/script.php]]. Resulting output is parsed by markup rules. Beware, security risk! If you use this, switch off markup for comments! Default is off. Not recommended to switch on.'); 25 @define('PLUGIN_EVENT_TEXTWIKI_RULE_INCLUDE_DESC_BASE', 'The base directory to your scripts. Default for this is set to "/path/to/scripts/". If you leave this blank and switch include on you can only use absolute paths.'); 26 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_HEADING', 'Lines starting with "+ " are marked as headlines (+ = <h1>, ++++++ = <h6>). Default is on.'); 27 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_HORIZ', '---- is converted to a horizontal line (<hr>). Default is on.'); 28 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_BREAK', 'Line endings marked with " _" define explicit linebreaks. Default is on.'); 29 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_BLOCKQUOTE', 'Enables to use email style quoting ("> ", ">> ",...). Default is on.'); 30 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_LIST', 'Allows creation of lists ("* " = undefined, "# " = numbered). Default is on.'); 31 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_DEFLIST', 'Enables to create definition lists. Syntax: ": Topic : Definition". Default is on.'); 32 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TABLE', 'Allows you to create tables. Only used for complete lines. Syntax: "|| Cell 1 || Cell 2 || Cell 3 ||". Default is on.'); 33 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_EMBED', 'Allows you to include and run PHP code with the syntax [[embed /path/to/script.php]]. Resulting output is not parsed by markup rules. Beware, security risk! If you use this, switch off markup for comments! Default is off. Not recommended to switch on.'); 34 @define('PLUGIN_EVENT_TEXTWIKI_RULE_EMBED_DESC_BASE', 'The base directory to your scripts. Default for this is set to "/path/to/scripts/". If you leave this blank and switch embed on you can only use absolute paths.'); 35 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_IMAGE', 'Enables the inclusion of images. ([[image /path/to/image.ext [HTML attributes] ]] or [[image path/to/image.ext [link="PageName"] [HTML attributes] ]] for linked images). Por omissão ligado.'); 36 @define('PLUGIN_EVENT_TEXTWIKI_RULE_IMAGE_DESC_BASE', 'Base directory to your images. Default for this is set to "/path/to/images". If you leave this blank you can only use absolute paths or URLs.'); 37 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PHPLOOKUP', 'Creates lookup links to the PHP manual with [[php function-name]]. Default is on.'); 38 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TOC', 'Generates a table of contents over all used headlines with [[toc]]. Default is on.'); 39 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_NEWLINE', 'Converts single newlines ("\n") to line breaks. Default is on.'); 40 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_CENTER', 'Lines starting with "= " are centered. Default is on.'); 41 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PARAGRAPH', 'Double newlines are converted to paragraphs (<p></p>). Default is on.'); 42 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_URL', 'Normal converts http://example.com to links, [http://example.com] to footnotes and [http://example.com Example] to descriptive links. Default is on.'); 43 @define('PLUGIN_EVENT_TEXTWIKI_RULE_URL_DESC_TARGET', 'Defines the target for your URLs. This is default set to "_blank", what is mostly feasible.'); 44 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_FREELINK', 'Enables definition of non-standard wiki links using "((Non-standard link format))" and "((Non-standard link|Description))". Default is off.'); 45 @define('PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_PAGES', 'The freelink rule (as well as the wikilink rule) must know, which pages exist and which have to be marked as "new". This specifies a file (local or remote) which has to contain 1 pagename per line. If the file is remote, it will be cached for the specified time.'); 46 @define('PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_VIEWURL', 'This URL is specified to view the freelinks. You have to specify a "%s" inside this URL which will be replaced with the name of the freelink page.'); 47 @define('PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_NEWURL', 'This URL is specified to create new freelinks. You have to specify a "%s" inside this URL which will be replaced with the name of the freelink page.'); 48 @define('PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_NEWTEXT', 'This text will be added to undefined freelinks to link to the create page. Initially this is set to "?".'); 49 @define('PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_CACHETIME', 'If you specify a remote file (URL) for your freelink pages, this file will be cached for as many seconds you specify here. Default is 1 hour.'); 50 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_INTERWIKI', 'Allows inter wiki linking to MeatBall, Advogato and Wiki using SiteName:PageName or [SiteName:PageName Show this text instead]. Default is on.'); 51 @define('PLUGIN_EVENT_TEXTWIKI_RULE_INTERWIKI_DESC_TARGET', ''); 52 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_WIKILINK', 'Enables usage of standard WikiWords (2-X x uppercase) as wiki links. Default is off.'); 53 @define('PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_PAGES', 'The wikilink rule must know, which pages exist and which have to be marked as "new". This specifies a file (local or remote) which has to contain 1 pagename per line. If the file is remote, it will be cached for the specified time.'); 54 @define('PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_VIEWURL', 'This URL is specified to view the wikilinks. You have to specify a "%s" inside this URL which will be replaced with the name of the wikilink page.'); 55 @define('PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_NEWURL', 'This URL is specified to create new wikilinks. You have to specify a "%s" inside this URL which will be replaced with the name of the wikilink page.'); 56 @define('PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_NEWTEXT', 'This text will be added to undefined wikilinks to link to the create page. Initially this is set to "?".'); 57 @define('PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_CACHETIME', 'If you specify a remote file (URL) for your wikilink pages, this file will be cached for as many seconds you specify here. Default is 1 hour.'); 58 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_COLORTEXT', 'Colorize text using ##color|text##. Default is on.'); 59 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_STRONG', '**Text** is marked strong. Default is on.'); 60 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_BOLD', '\'\'\'Text\'\'\' is marked bold. Default is on.'); 61 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_EMPHASIS', '//Text// is marked emphasised. Default is on.'); 62 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_ITALIC', '\'\'Text\'\' is marked italic. Default is on.'); 63 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TT', '{{Text}} is writen in teletext (monotype). Default is on.'); 64 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_SUPERSCRIPT', '^^Text^^ is written in superscript. Default is on.'); 65 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_REVISE', 'Enables marking texts as revisions using "@@---delete this text+++insert this text@@". Default is on.'); 66 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TIGHTEN', 'Finds more than 3 newlines and reduces them to 2 newlines (paragraph). Default is on.'); 67 @define('PLUGIN_EVENT_TEXTWIKI_RULE_DESC_ENTITIES', 'Escapes HTML entities. Default is on.'); 68 69 class serendipity_event_textwiki extends serendipity_event 70 { 71 72 var $wikiRules = array( 73 'prefilter' => array( 74 'file' => 'Text/Wiki/Rule/prefilter.php', 75 'name' => 'Text_Wiki_Rule_prefilter', 76 'flag' => true, 77 'conf' => array(), 78 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PREFILETER 79 ), 80 81 'delimiter' => array( 82 'file' => 'Text/Wiki/Rule/delimiter.php', 83 'name' => 'Text_Wiki_Rule_delimiter', 84 'flag' => true, 85 'conf' => array(), 86 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_DELIMITER 87 ), 88 89 'code' => array( 90 'file' => 'Text/Wiki/Rule/code.php', 91 'name' => 'Text_Wiki_Rule_code', 92 'flag' => true, 93 'conf' => array(), 94 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_CODE 95 ), 96 97 'phpcode' => array( 98 'file' => 'Text/Wiki/Rule/phpcode.php', 99 'name' => 'Text_Wiki_Rule_phpcode', 100 'flag' => true, 101 'conf' => array(), 102 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PHPCODE 103 ), 104 105 'html' => array( 106 'file' => 'Text/Wiki/Rule/html.php', 107 'name' => 'Text_Wiki_Rule_html', 108 'flag' => false, 109 'conf' => array(), 110 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_HTML 111 ), 112 113 'raw' => array( 114 'file' => 'Text/Wiki/Rule/raw.php', 115 'name' => 'Text_Wiki_Rule_raw', 116 'flag' => true, 117 'conf' => array(), 118 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_RAW 119 ), 120 121 'include' => array( 122 'file' => 'Text/Wiki/Rule/include.php', 123 'name' => 'Text_Wiki_Rule_include', 124 'flag' => false, 125 'conf' => array( 126 'base' => '/path/to/scripts/' 127 ), 128 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_INCLUDE, 129 's9yc' => array( 130 'base' => array( 131 'type' => 'string', 132 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_INCLUDE_DESC_BASE)) 133 ), 134 135 'heading' => array( 136 'file' => 'Text/Wiki/Rule/heading.php', 137 'name' => 'Text_Wiki_Rule_heading', 138 'flag' => true, 139 'conf' => array(), 140 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_HEADING 141 ), 142 143 'horiz' => array( 144 'file' => 'Text/Wiki/Rule/horiz.php', 145 'name' => 'Text_Wiki_Rule_horiz', 146 'flag' => true, 147 'conf' => array(), 148 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_HORIZ 149 ), 150 151 'break' => array( 152 'file' => 'Text/Wiki/Rule/break.php', 153 'name' => 'Text_Wiki_Rule_break', 154 'flag' => true, 155 'conf' => array(), 156 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_BREAK 157 ), 158 159 'blockquote' => array( 160 'file' => 'Text/Wiki/Rule/blockquote.php', 161 'name' => 'Text_Wiki_Rule_blockquote', 162 'flag' => true, 163 'conf' => array(), 164 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_BLOCKQUOTE 165 ), 166 167 'list' => array( 168 'file' => 'Text/Wiki/Rule/list.php', 169 'name' => 'Text_Wiki_Rule_list', 170 'flag' => true, 171 'conf' => array(), 172 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_LIST 173 ), 174 175 'deflist' => array( 176 'file' => 'Text/Wiki/Rule/deflist.php', 177 'name' => 'Text_Wiki_Rule_deflist', 178 'flag' => true, 179 'conf' => array(), 180 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_DEFLIST 181 ), 182 183 'table' => array( 184 'file' => 'Text/Wiki/Rule/table.php', 185 'name' => 'Text_Wiki_Rule_table', 186 'flag' => true, 187 'conf' => array( 188 'border' => 1, 189 'spacing' => 0, 190 'padding' => 4 191 ), 192 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TABLE 193 ), 194 195 'embed' => array( 196 'file' => 'Text/Wiki/Rule/embed.php', 197 'name' => 'Text_Wiki_Rule_embed', 198 'flag' => false, 199 'conf' => array( 200 'base' => '/path/to/scripts/' 201 ), 202 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_EMBED, 203 's9yc' => array( 204 'base' => array( 205 'type' => 'string', 206 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_EMBED_DESC_BASE)) 207 ), 208 209 'image' => array( 210 'file' => 'Text/Wiki/Rule/image.php', 211 'name' => 'Text_Wiki_Rule_image', 212 'flag' => true, 213 'conf' => array( 214 'base' => '' 215 ), 216 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_IMAGE, 217 's9yc' => array( 218 'base' => array( 219 'type' => 'string', 220 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_IMAGE_DESC_BASE)) 221 ), 222 223 'phplookup' => array( 224 'file' => 'Text/Wiki/Rule/phplookup.php', 225 'name' => 'Text_Wiki_Rule_phplookup', 226 'flag' => true, 227 'conf' => array(), 228 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PHPLOOKUP 229 ), 230 231 'toc' => array( 232 'file' => 'Text/Wiki/Rule/toc.php', 233 'name' => 'Text_Wiki_Rule_toc', 234 'flag' => true, 235 'conf' => array(), 236 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TOC 237 ), 238 239 'newline' => array( 240 'file' => 'Text/Wiki/Rule/newline.php', 241 'name' => 'Text_Wiki_Rule_newline', 242 'flag' => true, 243 'conf' => array( 244 'skip' => array( 245 'code', 246 'phpcode', 247 'heading', 248 'horiz', 249 'deflist', 250 'table', 251 'list', 252 'toc' 253 ) 254 ), 255 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_NEWLINE 256 ), 257 258 'center' => array( 259 'file' => 'Text/Wiki/Rule/center.php', 260 'name' => 'Text_Wiki_Rule_center', 261 'flag' => true, 262 'conf' => array(), 263 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_CENTER 264 ), 265 266 'paragraph' => array( 267 'file' => 'Text/Wiki/Rule/paragraph.php', 268 'name' => 'Text_Wiki_Rule_paragraph', 269 'flag' => true, 270 'conf' => array( 271 'skip' => array( 272 'blockquote', 273 'code', 274 'phpcode', 275 'heading', 276 'horiz', 277 'deflist', 278 'table', 279 'list', 280 'toc' 281 ) 282 ), 283 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_PARAGRAPH 284 ), 285 286 'url' => array( 287 'file' => 'Text/Wiki/Rule/url.php', 288 'name' => 'Text_Wiki_Rule_url', 289 'flag' => true, 290 'conf' => array( 291 'target' => '_BLANK' 292 ), 293 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_URL, 294 's9yc' => array( 295 'target' => array( 296 'type' => 'string', 297 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_URL_DESC_TARGET)), 298 ), 299 300 'freelink' => array( 301 'file' => 'Text/Wiki/Rule/freelink.php', 302 'name' => 'Text_Wiki_Rule_freelink', 303 'flag' => false, 304 'conf' => array( 305 'pages' => array(), 306 'view_url' => 'http://example.com/index.php?page=%s', 307 'new_url' => 'http://example.com/new.php?page=%s', 308 'new_text' => '?' 309 ), 310 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_FREELINK, 311 's9yc' => array( 312 'pages' => array( 313 'type' => 'string', 314 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_PAGES), 315 'view_url' => array( 316 'type' => 'string', 317 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_VIEWURL), 318 'new_url' => array( 319 'type' => 'string', 320 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_NEWURL), 321 'new_text' => array( 322 'type' => 'string', 323 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_FREELINK_DESC_NEWTEXT), 324 'cachetime' => array( 325 'type' => 'string', 326 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_CACHETIME)) 327 ), 328 329 'interwiki' => array( 330 'file' => 'Text/Wiki/Rule/interwiki.php', 331 'name' => 'Text_Wiki_Rule_interwiki', 332 'flag' => true, 333 'conf' => array( 334 'sites' => array( 335 'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s', 336 'Advogato' => 'http://advogato.org/%s', 337 'Wiki' => 'http://c2.com/cgi/wiki?%s' 338 ), 339 'target' => '_BLANK' 340 ), 341 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_INTERWIKI, 342 's9yc' => array( 343 'pages' => array( 344 'target' => 'string', 345 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_INTERWIKI_DESC_TARGET)) 346 ), 347 348 'wikilink' => array( 349 'file' => 'Text/Wiki/Rule/wikilink.php', 350 'name' => 'Text_Wiki_Rule_wikilink', 351 'flag' => false, 352 'conf' => array( 353 'pages' => array(), 354 'view_url' => 'http://example.com/index.php?page=%s', 355 'new_url' => 'http://example.com/new.php?page=%s', 356 'new_text' => '?' 357 ), 358 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_WIKILINK, 359 's9yc' => array( 360 'pages' => array( 361 'type' => 'string', 362 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_PAGES), 363 'view_url' => array( 364 'type' => 'string', 365 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_VIEWURL), 366 'new_url' => array( 367 'type' => 'string', 368 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_NEWURL), 369 'new_text' => array( 370 'type' => 'string', 371 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_NEWTEXT), 372 'cachetime' => array( 373 'type' => 'string', 374 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_WIKILINK_DESC_CACHETIME)) 375 ), 376 377 'colortext' => array( 378 'file' => 'Text/Wiki/Rule/colortext.php', 379 'name' => 'Text_Wiki_Rule_colortext', 380 'flag' => true, 381 'conf' => array(), 382 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_COLORTEXT 383 ), 384 385 'strong' => array( 386 'file' => 'Text/Wiki/Rule/strong.php', 387 'name' => 'Text_Wiki_Rule_strong', 388 'flag' => true, 389 'conf' => array(), 390 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_STRONG 391 ), 392 393 'bold' => array( 394 'file' => 'Text/Wiki/Rule/bold.php', 395 'name' => 'Text_Wiki_Rule_bold', 396 'flag' => true, 397 'conf' => array(), 398 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_BOLD 399 ), 400 401 'emphasis' => array( 402 'file' => 'Text/Wiki/Rule/emphasis.php', 403 'name' => 'Text_Wiki_Rule_emphasis', 404 'flag' => true, 405 'conf' => array(), 406 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_EMPHASIS 407 ), 408 409 'italic' => array( 410 'file' => 'Text/Wiki/Rule/italic.php', 411 'name' => 'Text_Wiki_Rule_italic', 412 'flag' => true, 413 'conf' => array(), 414 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_ITALIC 415 ), 416 417 'tt' => array( 418 'file' => 'Text/Wiki/Rule/tt.php', 419 'name' => 'Text_Wiki_Rule_tt', 420 'flag' => true, 421 'conf' => array(), 422 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TT 423 ), 424 425 'superscript' => array( 426 'file' => 'Text/Wiki/Rule/superscript.php', 427 'name' => 'Text_Wiki_Rule_superscript', 428 'flag' => true, 429 'conf' => array(), 430 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_SUPERSCRIPT 431 ), 432 433 'revise' => array( 434 'file' => 'Text/Wiki/Rule/revise.php', 435 'name' => 'Text_Wiki_Rule_revise', 436 'flag' => true, 437 'conf' => array(), 438 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_REVISE 439 ), 440 441 'tighten' => array( 442 'file' => 'Text/Wiki/Rule/tighten.php', 443 'name' => 'Text_Wiki_Rule_tighten', 444 'flag' => true, 445 'conf' => array(), 446 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_TIGHTEN 447 ), 448 449 'entities' => array( 450 'file' => 'Text/Wiki/Rule/entities.php', 451 'name' => 'Text_Wiki_Rule_entities', 452 'flag' => true, 453 'conf' => array(), 454 'desc' => PLUGIN_EVENT_TEXTWIKI_RULE_DESC_ENTITIES 455 ) 456 ); 457 458 var $nonWikiRules = array(); 459 var $title = PLUGIN_EVENT_TEXTWIKI_NAME; 460 461 function introspect(&$propbag) 462 { 463 global $serendipity; 464 465 $propbag->add('name', PLUGIN_EVENT_TEXTWIKI_NAME); 466 $propbag->add('description', PLUGIN_EVENT_TEXTWIKI_DESC); 467 $propbag->add('stackable', false); 468 $propbag->add('author', 'Tobias Schlitt'); 469 $propbag->add('version', '1.4'); 470 $propbag->add('requirements', array( 471 'serendipity' => '0.8', 472 'smarty' => '2.6.7', 473 'php' => '4.1.0' 474 )); 475 $propbag->add('cachable_events', array('frontend_display' => true)); 476 $propbag->add('event_hooks', array('frontend_display' => true, 'frontend_comment' => true)); 477 $propbag->add('groups', array('MARKUP')); 478 479 $this->markup_elements = array( 480 array( 481 'name' => 'ENTRY_BODY', 482 'element' => 'body', 483 ), 484 array( 485 'name' => 'EXTENDED_BODY', 486 'element' => 'extended', 487 ), 488 array( 489 'name' => 'COMMENT', 490 'element' => 'comment', 491 ), 492 array( 493 'name' => 'HTML_NUGGET', 494 'element' => 'html_nugget', 495 ) 496 ); 497 498 $conf_array = array(); 499 // Add markup elements config 500 foreach($this->markup_elements as $element) { 501 $conf_array[] = $element['name']; 502 } 503 // Save non wiki-rule configuration 504 $this->nonWikiRules = $conf_array; 505 // Seperate markup elements from wiki-rule config 506 $conf_array[] = "internal_seperator"; 507 // Add wiki-rule config 508 $this->_introspect_rule_config($conf_array); 509 $propbag->add('configuration', $conf_array); 510 } 511 512 function _introspect_rule_config(&$conf_array) { 513 foreach($this->wikiRules as $name => $rule) { 514 // If sub configurations exist 515 if (isset($rule['s9yc']) && is_array($rule['s9yc'])) { 516 if ($conf_array[(count($conf_array) - 1)] != 'internal_seperator') { 517 $conf_array[] = 'internal_seperator'; 518 } 519 // Add wiki-rule config itself 520 $conf_array[] = $name; 521 foreach ($rule['s9yc'] as $confname => $conf) { 522 $conf_array[] = $name . '_' . $confname; 523 } 524 $conf_array[] = "internal_seperator"; 525 } else { 526 // Add only wiki-rule config itself 527 $conf_array[] = $name; 528 } 529 } 530 } 531 532 function generate_content(&$title) { 533 $title = $this->title; 534 } 535 536 function install() { 537 serendipity_plugin_api::hook_event('backend_cache_entries', $this->title); 538 } 539 540 function uninstall() { 541 serendipity_plugin_api::hook_event('backend_cache_purge', $this->title); 542 serendipity_plugin_api::hook_event('backend_cache_entries', $this->title); 543 } 544 545 function introspect_config_item($name, &$propbag) 546 { 547 if (in_array($name, $this->nonWikiRules)) { 548 $propbag->add('type', 'boolean'); 549 $propbag->add('name', defined($name) ? constant($name) : $name); 550 $propbag->add('description', sprintf(APPLY_MARKUP_TO, defined($name) ? constant($name) : $name)); 551 $propbag->add('default', true); 552 } else if ($name == 'internal_seperator') { 553 $propbag->add('type', 'seperator'); 554 $propbag->add('name', 'Seperator'); 555 $propbag->add('description', 'Seperator'); 556 } else { 557 $this->_introspect_rule_config_item($name, $propbag); 558 } 559 return true; 560 } 561 562 function _introspect_rule_config_item($name, &$propbag) { 563 if (strpos($name, '_') === false) { 564 $propbag->add('type', 'boolean'); 565 $propbag->add('name', ucfirst($name)); 566 $propbag->add('description', $this->wikiRules[$name]['desc']); 567 $propbag->add('default', $this->wikiRules[$name]['flag']); 568 return true; 569 } else { 570 $parts = explode('_', $name, 2); 571 $conf = $this->wikiRules[$parts[0]]['s9yc'][$parts[1]]; 572 $propbag->add('type', $conf['type']); 573 $propbag->add('name', ucfirst($parts[0]).' '.ucwords((str_replace('_', ' ',$parts[1])))); 574 $propbag->add('description', $conf['desc']); 575 $propbag->add('default', ''); 576 return true; 577 } 578 } 579 580 function event_hook($event, &$bag, &$eventData) { 581 global $serendipity; 582 583 $hooks = &$bag->get('event_hooks'); 584 585 if (!isset($this->wiki) || !is_a($this->wiki, 'text_wiki')) { 586 $this->_init_wiki($bag); 587 } 588 589 if (isset($hooks[$event])) { 590 switch($event) { 591 case 'frontend_display': 592 foreach ($this->markup_elements as $temp) { 593 if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && 594 !$eventData['properties']['ep_disable_markup_' . $this->instance] && 595 !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) { 596 $element = $temp['element']; 597 $eventData[$element] = $this->wiki->transform($eventData[$element]); 598 } 599 } 600 return true; 601 break; 602 603 case 'frontend_comment': 604 if (serendipity_db_bool($this->get_config('COMMENT', true))) { 605 echo '<div class="serendipity_commentDirection serendipity_comment_textwiki">' . PLUGIN_EVENT_TEXTWIKI_TRANSFORM . '</div>'; 606 } 607 return true; 608 break; 609 610 default: 611 return false; 612 } 613 } else { 614 return false; 615 } 616 } 617 618 function _init_wiki(&$bag) { 619 include_once S9Y_PEAR_PATH . 'Text/Wiki.php'; 620 621 if (class_exists('Text_Wiki')) { 622 $this->wiki =& new Text_Wiki; 623 $this->wiki->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS); 624 $this->wiki->setFormatConf('Xhtml', 'charset', LANG_CHARSET); 625 } else { 626 return false; 627 } 628 foreach ($this->wikiRules as $name => $rule) { 629 if (serendipity_db_bool($this->get_config($name, $rule['flag']))) { 630 $this->_add_wiki_rule($bag, $name, $rule); 631 } else { 632 $this->_remove_wiki_rule($bag, $name); 633 } 634 } 635 return true; 636 } 637 638 function _remove_wiki_rule(&$bag, $name) { 639 $this->wiki->disableRule($name); 640 } 641 642 function _add_wiki_rule(&$bag, $name, $rule) { 643 $rule_info = $rule; 644 $rule_info['flag'] = true; 645 if (isset($rule['s9yc']) && is_array($rule['s9yc'])) { 646 foreach ($rule['s9yc'] as $confName => $confVals) { 647 if ($confName === 'pages') { 648 $rule_info['conf']['pages'] = $this->_get_link_pages($bag, $name); 649 } else { 650 $rule_info['conf'][$confName] = $this->get_config($name.'_'.$confName, $rule_info['conf'][$confName]); 651 } 652 } 653 } 654 $this->wiki->enableRule($name); 655 $this->wiki->setRenderConf("Xhtml", $name, $rule_info); 656 return true; 657 } 658 659 function _get_link_pages(&$bag, $ruleName) { 660 global $serendipity; 661 if ($this->get_config($ruleName.'_pages') === null) { 662 return array(); 663 } 664 $pagesFile = $this->get_config($ruleName.'_pages'); 665 if (!is_file($pagesFile)) { 666 $cacheFile = $serendipity['uploadPath']."serendipity_plugin_event_wiki_".$ruleName.".cache"; 667 $cacheTime = (int)$this->get_config($ruleName.'_cachetime', 3600); 668 if (!is_file($cacheFile) || (filemtime($cacheFile) + $cacheTime) < time()) { 669 $pagesArray = @file($pagesFile); 670 if (!$pagesArray) { return array(); } 671 $putCache = @fopen($cacheFile, 'w'); 672 if (!$putCache) { return array(); } 673 fputs($putCache, implode("", $pagesArray)); 674 fclose($putCache); 675 } 676 $pagesFile = $cacheFile; 677 } 678 $pagesArray = array_map(trim, file($pagesFile)); 679 return (is_array($pagesArray)) ? $pagesArray : array(); 680 } 681 } 682 683 /* vim: set sts=4 ts=4 expandtab : */ 684 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |