1<?php 2/** 3 * PyCode plugin: it embeds a Python script hosted in a remote repository. 4 * 5 * syntax.php: it defines all the methods used by PyCode plugin 6 * who extend DokuWiki's syntax. 7 * 8 * @author Torpedo <dgtorpedo@gmail.com> 9 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 10 * @package syntax 11 */ 12 13if (!defined("DOKU_INC")) die(); // the plugin must be run within Dokuwiki 14 15require_once "method.php"; // common methods used by PyCode plugin 16 17/** 18 * This class defines all the methods used by the PyCode plugin to produce 19 * the plugin's output. 20 * 21 * It extends DokuWiki's basic syntax defined in lib/plugins/syntax.php. 22 * 23 * @package syntax_pycode 24 */ 25class syntax_plugin_pycode extends DokuWiki_Syntax_Plugin { 26 27 /** 28 * Constructor method for class suitable for any initialization. 29 */ 30 public function __construct() { 31 $this->mpp = new method_pycode_plugin; 32 } 33 34 /** 35 * Define the syntax types that this plugin applies when founds 36 * its token: it is simply replaced. 37 * 38 * @return (str) 39 */ 40 public function getType() { 41 return "substition"; 42 } 43 44 /** 45 * Define how the plugin's output is handled regarding paragraphs. 46 * 47 * Open paragraphs will be closed before plugin output and 48 * the plugin output will not starts with a paragraph: 49 * <p>foo</p> 50 * <pycode> 51 * <p>bar</p> 52 * 53 * @return (str) 54 */ 55 public function getPType() { 56 return "block"; 57 } 58 59 /** 60 * Define the priority used to determine in which order modes are added: 61 * the mode with the lowest sort number will win. 62 * 63 * Since this plugin provides text codes and internal links, it is 64 * sorted at: 65 * Doku_Parser_Mode_code (= 200) < PyCode plugin 66 * Doku_Parser_Mode_internallink (= 310) < PyCode plugin 67 * 68 * @return (int) 69 */ 70 public function getSort() { 71 return 315; 72 } 73 74 /** 75 * Define the regular expression needed to match the plugin's syntax. 76 * 77 * This plugin use the following general syntax: 78 * <pycode [list of parameters]> 79 * 80 * @param (str) $mode name for the format mode of the final output 81 * (at the present only $mode == "xhtml" is supported) 82 */ 83 public function connectTo($mode) { 84 $this->Lexer->addSpecialPattern("<pycode.*?>", $mode, "plugin_pycode"); 85 } 86 87 /** 88 * Handle the plugin's syntax matched. 89 * 90 * This method is called every time the parser encounters the 91 * plugin's syntax in order to produce a list of instructions for the 92 * renderer, which will be interpreted later. 93 * 94 * @param (str) $match the text matched 95 * @param (int) $state the lexer state 96 * @param (int) $pos the character position of the matched text 97 * @param (obj) $handler object reference to the Doku_Handler class, 98 * defined in inc/parser/handler.php 99 * @return (arr) $data it contains the parameters handed to the 100 * plugin's syntax and found in the wiki page, that is: 101 * array { 102 * [0] => (str) <src-url> 103 * [1] => (str) <flag-c|f|l> 104 * [2] => (str) <name-class|function|lines> 105 * [3] => (str) <name-class> 106 * } 107 * where only element [0] is obligatory so the following 108 * are valid combinations: 109 * <src-url> 110 * <src-url> c <name-class> 111 * <src-url> f <name-function> <name-class> 112 * <src-url> f <name-function> 113 * <src-url> l <name-lines> 114 */ 115 public function handle($match, $state, $pos, Doku_Handler $handler) { 116 $data = array(); 117 118 $match = $this->mpp->_remove_multi_space($match); 119 $match = substr($match, 8, -1); // strips "<pycode " and ">" 120 121 // get user option for line numbers 122 $usr_nums = null; 123 $re = "/(-nums)(\s*)(=)(\s*)(0|1)/"; 124 preg_match($re, $match, $matches); 125 if (preg_match($re, $match, $matches) == 1) { 126 $usr_nums = $matches[5]; 127 } 128 129 // get user option for title 130 $usr_title = null; 131 $re = "/(-title)(\s*)(=)(\s*)(\'|\")(.*)(\'|\")/"; 132 preg_match($re, $match, $matches); 133 if (preg_match($re, $match, $matches) == 1) { 134 $usr_title = $matches[6]; 135 } 136 137 // get user option for docstrings 138 $usr_docstr = null; 139 $re = "/(-docstr)(\s*)(=)(\s*)(0|1)/"; 140 preg_match($re, $match, $matches); 141 if (preg_match($re, $match, $matches) == 1) { 142 $usr_docstr = $matches[5]; 143 } 144 145 // remove user options and create data array 146 $re = "/(\s*-nums.*|\s*-title.*|\s*-docstr.*)/"; 147 $subst = ""; 148 $match = preg_replace($re, $subst, $match); 149 $data = explode(" ", $match); 150 151 // append user options 152 $data["usr_nums"] = $usr_nums; 153 $data["usr_title"] = $usr_title; 154 $data["usr_docstr"] = $usr_docstr; 155 156 return $data; 157 } 158 159 /** 160 * Process the list of instructions that render the final output. 161 * 162 * It's used an array to remember if, in the same wiki page, 163 * the same <file> is called one or more times, in order to do only one 164 * connection to the relative repository to download its code. 165 * As soon as the content of <file> is downloaded, it's stored in a local 166 * directory and used to render the output, even for the oher calls 167 * of <file>. 168 * If, visiting another wiki page, the same <file> is called again or 169 * every time the page is refreshed, this array is unset (desired effect) 170 * so, before download the code again, it's checked how much 171 * up-to-date is the local copy of <file> against the original copy 172 * in the repository. 173 * The array is of the form: 174 * array { 175 * [<src-url>] => (int) 0|1|2 176 * } 177 * with the following meaning: 178 * <src-url> = 0: <file> has been just downloaded so it's up-to-date 179 * <src-url> = 1: <file> has been downloaded in the current session 180 * and can be reused in the same page 181 * <src-url> = 2: <file> was downloaded in a previous session so 182 * it could be out-of-date 183 * 184 * Since is saved a copy of <file>, it is necessary to know when it's no 185 * longer used in any wiki page. 186 * Hence it's used a logfile in which are recorded, for each wiki page, all 187 * the repository used. When all the references to the same repository are 188 * deleted from all wiki pages, the relative local copy of <file> is 189 * deleted too. 190 * 191 * @param (str) $mode name for the format mode of the final output 192 * (at the present only $mode == "xhtml" is supported) 193 * @param (obj) $renderer object reference to the Doku_Render class, 194 * defined in /inc/parser/renderer.php, which defines functions for the 195 * output (see also /lib/styles/screen.css for some styles) 196 * @param (arr) $data it contains the parameters handled to the 197 * plugin's syntax and found in the wiki page, that is: 198 * array { 199 * [0] => (str) <src-url> 200 * [1] => (str) <flag-c|f|l> 201 * [2] => (str) <name-class|function|lines> 202 * [3] => (str) <name-class> 203 * ["usr_nums"] => (str) -nums = 0|1 204 * ["usr_title"] => (str) -title = "<new-title>" 205 * ["usr-docstr"] => (str) -docstr = 0|1 206 * } 207 * where only element [0] is obligatory and element [3] is 208 * the name of the class at wich the method belongs to 209 * so the following are valid combinations: 210 * <src-url> 211 * <src-url> [c <name-class> [-docstr]] 212 * <src-url> [f <name-function> [<name-class>] [-nums] [-title]] 213 * <src-url> [l <name-lines> [-nums] [-title]] 214 */ 215 public function render($mode, Doku_Renderer $renderer, $data) { 216 global $INPUT; 217 $repo = array(); // store all <src-url>(s) found in the current page 218 $code_error = array("error", "notfound-lns", "notfound-def", "notfound-cls"); 219 220 // eventualy disable the cache 221 $cache = $this->getConf("cache"); 222 if ($cache == 1){ 223 $renderer->nocache(); 224 } 225 226 try { 227 // check if url to the source code is right 228 $src_url = $data[0]; 229 $src_url = $this->mpp->_check_src_url($src_url); 230 if (in_array($src_url, $code_error)) { 231 throw new Exception($this->mpp->_check_src_url($src_url)); 232 } 233 234 // get info associated to the code 235 $flag = $data[1]; 236 $name = $data[2]; 237 $subname = $data[3]; 238 $nums = $data["usr_nums"]; 239 $title = $data["usr_title"]; 240 $docstr = $data["usr_docstr"]; 241 list($name_host, $name_repo, $name_brch, $name_file) = $this->mpp->_get_names($src_url); 242 $loc_url = $this->mpp->_get_loc_url($name_host, $name_repo, $name_brch, $name_file); 243 $lang = $this->mpp->_get_lang($name_file); 244 $raw_url = $this->mpp->_get_raw_url($src_url); 245 246 // check if in this session <file> has been alredy downloaded 247 if ((file_exists($loc_url) == false)) { 248 $repo[$src_url] = 0; 249 } 250 elseif (file_exists($loc_url) == true and 251 in_array($src_url, array_keys($repo)) == false) { 252 $repo[$src_url] = 2; 253 } 254 255 // get the code 256 if ($flag == "" and $name != "") { 257 throw new Exception("wrong-flag"); 258 } 259 elseif ($flag != "" and $name == "") { 260 throw new Exception("wrong-flag"); 261 } 262 elseif (($flag == "f" or $flag == "c") and $lang != "python") { 263 throw new Exception("wrong-flag"); 264 } 265 if ($repo[$src_url] == 0) { 266 // get the whole code 267 list($code_raw, $sl_raw, $el_raw) = $this->mpp->_get_code($raw_url); 268 if (in_array($code_raw, $code_error)) { 269 throw new Exception($code_raw); 270 } 271 // save in local and use this instead of the repo 272 $this->mpp->_save_code($loc_url, $code_raw); 273 } 274 elseif ($repo[$src_url] == 2) { 275 list($code_raw, $sl_raw, $el_raw) = $this->mpp->_get_code($raw_url, $flag, $name, $subname); 276 if (in_array($code_raw, $code_error)) { 277 throw new Exception($code_raw); 278 } 279 if ($flag == "c") { 280 // temporaly save in local and use this instead of the repo 281 // because to chek if a class is changed is necessary to 282 // check if all its methods are changed too 283 $tmp_raw_loc_url = $loc_url . ".tmp"; 284 $this->mpp->_save_code($tmp_raw_loc_url, $code_raw); 285 } 286 } 287 list($code_loc, $sl_loc, $el_loc) = $this->mpp->_get_code($loc_url, $flag, $name, $subname); 288 if (in_array($code_loc, $code_error)) { 289 throw new Exception($code_loc); 290 } 291 292 // call the printer 293 if ($repo[$src_url] == 0 or $repo[$src_url] == 1) { 294 if (in_array($flag, array("", "l", "f"))) { 295 $range = range($sl_loc, $el_loc); 296 $this->_print_code($renderer, $src_url, $code_loc, $lang, $range, $flag, $name, $subname, $nums, $title); 297 } 298 elseif ($flag == "c") { 299 $tree_loc = $this->mpp->_get_tree($code_loc); 300 $this->_print_tree($renderer, $loc_url, $tree_loc, $docstr); 301 } 302 $repo[$src_url] = 1; 303 } 304 elseif ($repo[$src_url] == 2) { 305 $code_dif = $this->mpp->_get_code_dif($code_raw, $code_loc); 306 if (in_array($flag, array("", "l", "f"))) { 307 if ($code_dif == "dif") { 308 $this->_print_note($renderer, $loc_url, $code_raw, $sl_loc, $el_loc); 309 $range = range($sl_loc, $el_loc); 310 } 311 else { 312 $range = range($sl_raw, $el_raw); // sth. is changed outside the range 313 } 314 $this->_print_code($renderer, $src_url, $code_loc, $lang, $range, $flag, $name, $subname, $nums, $title); 315 } 316 elseif ($flag == "c") { 317 $tree_loc = $this->mpp->_get_tree($code_loc); 318 if ($code_dif == "dif") { 319 $tree_raw = $this->mpp->_get_tree($code_raw); 320 $tree_dif = $this->mpp->_get_tree_dif($tmp_raw_loc_url, $loc_url, $tree_raw, $tree_loc); 321 $this->_print_note($renderer, $loc_url, $code_raw, $sl_loc, $el_loc); 322 $this->_print_tree($renderer, $loc_url, $tree_dif, $docstr); 323 } 324 else { 325 $this->_print_tree($renderer, $loc_url, $tree_loc, $docstr); 326 } 327 unlink($tmp_raw_loc_url); 328 } 329 } 330 331 // record the <file>(s) embedded in this wiki page 332 $tmp_log_url = DOKU_PLUGIN . "pycode/tmp/logfile.tmp"; 333 $this->mpp->_save_code($tmp_log_url, $loc_url); 334 } 335 336 catch (Exception $error) { 337 if ($error->getMessage() == "error") { 338 $this->_print_error($renderer); 339 } 340 elseif ($error->getMessage() == "wrong-flag") { 341 $this->_print_wrong_flag($renderer); 342 } 343 elseif ($error->getMessage() == "notfound-lns") { 344 $this->_print_notfound_lns($renderer); 345 } 346 elseif ($error->getMessage() == "notfound-def") { 347 $this->_print_notfound_def($renderer); 348 } 349 elseif ($error->getMessage() == "notfound-cls") { 350 $this->_print_notfound_cls($renderer); 351 } 352 } 353 } 354 355 /** 356 * Print the code of <file>. 357 * 358 * @param (obj) $renderer object reference to the Doku_Render class, 359 * defined in /inc/parser/renderer.php, which defines functions for the 360 * output (see also /lib/styles/screen.css for some styles) 361 * @param (str) $src_url the url to the source code of <file> in the repo 362 * Bitbucket <src-url> = 363 * "https://bitbucket.org/<user>/<repo>/src/<branch>/<file>" 364 * GitHub <src-url> = 365 * "https://github.com/<user>/<repo>/blob/<branch>/<file>" 366 * @param (arr) $code the code to embed 367 * @param (str) $lang the language name used in <file> 368 * @param (arr) $range the numbers of the lines matching the code to embed 369 * @param (str) $flag flag to indicate what kind of code we want to embed: 370 * "" = all | "c" = class | "f" = function | "l" = lines 371 * @param (str) $name if specified, it can be only: 372 * name-function|lines 373 * @param (str) $subname if specified, it can be only: 374 * name-class 375 * @param (int) $nums if specified, it can be only: 376 * 0 = hide line numbers | 1 = show line numbers 377 * @param (str) $title if specified, it is the new user's title for the 378 * code embedded 379 */ 380 private function _print_code(Doku_Renderer $renderer, $src_url, $code, $lang, $range, $flag, 381 $name = null, $subname = null, $nums = null, $title = null) { 382 if ($flag == "f") { 383 $code = $this->mpp->_remove_indent($code); 384 } 385 $code = implode($code, PHP_EOL); 386 387 if ($nums === null) { 388 $nums = $this->getConf("nums"); 389 } 390 391 // make the title for the code 392 if ($title === null) { 393 $title = $this->getConf("title"); 394 if ($title != "none") { 395 if ($title == "file ⋅ class ⋅ def ⋅ #:#") { 396 $src = basename($src_url) . " ⋅ "; 397 } 398 elseif ($title == "src-url ⋅ class ⋅ def ⋅ #:#") { 399 $src = $src_url . " ⋅ "; 400 } 401 if ($flag == "") { 402 $class = ""; 403 $def = ""; 404 } 405 elseif ($flag == "f") { 406 if ($subname === null) { 407 $class = ""; 408 $def = "def: " . $name . " ⋅ "; 409 } 410 else { 411 $class = "class: " . $subname . " ⋅ "; 412 $def = "def: " . $name . " ⋅ "; 413 } 414 } 415 elseif ($flag == "l") { 416 $class = ""; 417 $def = ""; 418 } 419 $lns = "Ln: " . reset($range) . "-" . end($range); 420 $title = "$src" . "$class" . "$def" . "$lns"; 421 } 422 } 423 else { 424 if ($title == "") { 425 $title = "none"; 426 } 427 } 428 429 // print 430 if ($nums == 1) { 431 $renderer->doc .= "<div class='nums_pycode'>"; 432 $renderer->doc .= "<dl class='code nums_pycode'>"; 433 if ($title != "none") { 434 $renderer->doc .= "<dt> </dt>"; 435 } 436 $renderer->doc .= "<dd>"; 437 $renderer->doc .= "<pre class='code nums_pycode'>"; 438 foreach ($range as $number) { 439 if (strlen(end($range)) <= 4) { 440 $number = str_pad($number, 4, " ", STR_PAD_LEFT); 441 } 442 else { 443 $number = str_pad($number, 5, " ", STR_PAD_LEFT); 444 } 445 $renderer->doc .= "$number<br>"; 446 } 447 $renderer->doc .= "</pre> </dd> </dl> </div>"; 448 $renderer->doc .= "<div class='code_pycode'>"; 449 } 450 451 if ($title != "none") { 452 $icon = $this->mpp->_get_icon($src_url); 453 $renderer->doc .= "<dl class='code code_pycode'>"; 454 $renderer->doc .= "<dt><img class='code_pycode' src='" . $icon . "'>$title</dt>"; 455 $renderer->doc .= "<dd>"; 456 } 457 458 $renderer->doc .= "<pre class='code $lang'>"; 459 $renderer->doc .= $this->mpp->_get_geshi_code($code, $lang); 460 $renderer->doc .= "</pre>"; 461 462 if ($title != "none") { 463 $renderer->doc .= "</dd> </dl>"; 464 } 465 466 if ($nums == 1) { 467 $renderer->doc .= "</div>"; 468 } 469 } 470 471 /** 472 * Print the tree structure of a given class defined in <file>. 473 * 474 * @param (obj) $renderer object reference to the Doku_Render class, 475 * defined in /inc/parser/renderer.php, which defines functions for the 476 * output (see also /lib/styles/screen.css for some styles) 477 * @param (str) $loc_url the url to the raw code of the copy of <file> in 478 * <srv-path>/lib/plugins/pycode/tmp/<host>/<repo>/<branch>/<file> 479 * @param (arr) $tree the name of a class and its methods, that is: 480 * array { 481 * [0] => array { 482 * [0] => (str) "class <name-class>(<parameters>)" 483 * [1] => (str) <name-class> 484 * [2] => (int) <#> 485 * } 486 * [i] => array { 487 * [0] => (str) "class <name-function>(<parameters>)" 488 * [1] => (str) <name-function> 489 * [2] => (int) <#> 490 * } 491 * } 492 * where <#> is a flag used by the print function of the tree 493 * structure of the given class and which tells "how" to render 494 * each name; it can takes the following values: 495 * <#> = 0 means "unchanged" 496 * <#> = 1 means "changed" 497 * <#> = 2 means "deleted" 498 * <#> = 3 means "added" 499 * @param (int) $docstr if specified, it can be only: 500 * 0 = hide docstring | 1 = show docstring 501 */ 502 private function _print_tree(Doku_Renderer $renderer, $loc_url, $tree, $docstr = null) { 503 global $INFO; 504 $namespace = $INFO["namespace"]; 505 506 if ($docstr === null) { 507 $docstr = $this->getConf("docstr"); 508 } 509 510 // get the descriptive part of the docstring 511 if ($docstr == 1) { 512 $all_brief = array(); 513 foreach ($tree as $key => $val) { 514 if ($key == 0) { 515 list($code, $sl, $el) = $this->mpp->_get_code($loc_url, "c", $val[1]); 516 if ($code != "notfound-cls") { 517 $brief = $this->mpp->_get_docstr($code, $val[1], "c"); 518 } 519 } 520 else { 521 list($code, $sl, $el) = $this->mpp->_get_code($loc_url, "f", $val[1], $tree[0][1]); 522 if ($code != "notfound-def") { 523 $brief = $this->mpp->_get_docstr($code, $val[1], "f"); 524 } 525 } 526 array_push($all_brief, $brief); 527 } 528 } 529 530 // this is what we want to produce: 531 // * class <name-class>(<parameters>) 532 // * def <name-function>(<parameters>) 533 // * ... 534 // * def <name-function>(<parameters>) 535 // 536 // the equivalent xhtml code is: 537 // <ul> 538 // <li> 539 // <div>class <name-class>(<parameters>)</div> 540 // <ul> 541 // <li> 542 // <div>def <name-function>(<parameters>)</div> 543 // </li> 544 // ... 545 // <li> 546 // <div>def <name-function>(<parameters>)</div> 547 // </li> 548 // </ul> 549 // </li> 550 // </ul> 551 552 $renderer->listu_open(); // <ul> 553 $renderer->listitem_open(1); // <li> 554 $renderer->listcontent_open(); // <div> 555 if ($tree[0][2] == 1) { 556 $renderer->strong_open(); // start bold 557 $renderer->cdata($tree[0][0]); 558 $renderer->strong_close(); // stop bold 559 } 560 else { 561 $renderer->cdata($tree[0][0]); 562 } 563 if ($docstr == 1) { 564 $renderer->doc .= "<blockquote class='quote_pycode'>"; 565 $renderer->emphasis_open(); 566 foreach ($all_brief[0] as $line) { 567 $renderer->doc .= $line . "<br />"; 568 } 569 $renderer->emphasis_close(); 570 $renderer->doc .= "</blockquote>"; 571 } 572 $renderer->listcontent_close(); // </div> 573 574 $renderer->listu_open(); // <ul> start indented 575 foreach ($tree as $key => $val) { 576 if ($key == 0) { 577 continue; 578 } 579 $renderer->listitem_open(2); // <li> 580 $renderer->listcontent_open(); // <div> 581 if ($val[2] == 1) { 582 $renderer->strong_open(); // start bold 583 } 584 elseif ($val[2] == 2) { 585 $renderer->deleted_open(); // start strike out 586 } 587 $renderer->internallink($namespace . ":" . $val[1], $val[0]); 588 if ($val[2] == 1) { 589 $renderer->strong_close(); // stop bold 590 } 591 elseif ($val[2] == 2) { 592 $renderer->deleted_close(); // stop strike out 593 } 594 if ($docstr == 1) { 595 $renderer->doc .= "<blockquote class='quote_pycode'>"; 596 $renderer->emphasis_open(); 597 foreach ($all_brief[$key] as $line) { 598 $renderer->doc .= $line . "<br />"; 599 } 600 $renderer->emphasis_close(); 601 $renderer->doc .= "</blockquote>"; 602 } 603 $renderer->listcontent_close(); // </div> 604 $renderer->listitem_close(); // </li> 605 } 606 $renderer->listu_close(); // </ul> stop indented 607 608 $renderer->listitem_close(); // </li> 609 $renderer->listu_close(); // </ul> 610 } 611 612 /** 613 * Print a notificaton which informs that the copy of <file> 614 * is out-of-date. 615 * 616 * Only users with a level permission greater than or equal to 2, 617 * can flush it away (see DokuWiki's ACL): 618 * level | 0 1 2 4 8 16 255 619 * permission| none read edit create upload delete admin 620 * 621 * @param (obj) $renderer object reference to the Doku_Render class, 622 * defined in /inc/parser/renderer.php, which defines functions for the 623 * output (see also /lib/styles/screen.css for some styles) 624 * @param (str) $loc_url the url to the raw code of the copy of <file> in 625 * <srv-path>/lib/plugins/pycode/tmp/<host>/<repo>/<branch>/<file> 626 * @param (arr) $code_new the updated code got from the repository 627 * @param (int) $sl the number of the starting line of the code 628 * @param (int) $el the number of the ending line of the code 629 */ 630 private function _print_note(Doku_Renderer $renderer, $loc_url, $code_new, $sl, $el) { 631 global $INFO; 632 $perm = $INFO["perm"]; 633 $note = $this->getLang("note"); 634 $code_new = base64_encode(serialize($code_new)); 635 636 $renderer->doc .= "<div class='notify'>"; 637 $renderer->cdata($note); 638 if ($perm >= AUTH_EDIT) { 639 $renderer->doc .= "<form method='post'>"; 640 $renderer->doc .= "<input type='hidden' name='url' value=$loc_url>"; 641 $renderer->doc .= "<input type='hidden' name='new' value=$code_new>"; 642 $renderer->doc .= "<input type='hidden' name='start' value=$sl>"; 643 $renderer->doc .= "<input type='hidden' name='end' value=$el>"; 644 $renderer->doc .= "<input class='button ok_pycode' type='submit' 645 name='submit' value='Ok'>"; 646 $renderer->doc .= "</form>"; 647 } 648 $renderer->doc .= "</div>"; 649 } 650 651 /** 652 * Print an error message which informs that the code between the 653 * specified lines is out of range. 654 * 655 * @param (obj) $renderer object reference to the Doku_Render class, 656 * defined in /inc/parser/renderer.php, which defines functions for the 657 * output (see also /lib/styles/screen.css for some styles) 658 */ 659 private function _print_notfound_lns(Doku_Renderer $renderer) { 660 $notfound_lns = $this->getLang("notfound-lns"); 661 662 $renderer->doc .= "<div class='error'>"; 663 $renderer->cdata($notfound_lns); 664 $renderer->doc .= "</div>"; 665 } 666 667 /** 668 * Print an error message which informs that the given function was 669 * not found in <file>. 670 * 671 * @param (obj) $renderer object reference to the Doku_Render class, 672 * defined in /inc/parser/renderer.php, which defines functions for the 673 * output (see also /lib/styles/screen.css for some styles) 674 */ 675 private function _print_notfound_def(Doku_Renderer $renderer) { 676 $notfound_def = $this->getLang("notfound-def"); 677 678 $renderer->doc .= "<div class='error'>"; 679 $renderer->cdata($notfound_def); 680 $renderer->doc .= "</div>"; 681 } 682 683 /** 684 * Print an error message which informs that the given class was 685 * not found in <file>. 686 * 687 * @param (obj) $renderer object reference to the Doku_Render class, 688 * defined in /inc/parser/renderer.php, which defines functions for the 689 * output (see also /lib/styles/screen.css for some styles) 690 */ 691 private function _print_notfound_cls(Doku_Renderer $renderer) { 692 $notfound_cls = $this->getLang("notfound-cls"); 693 694 $renderer->doc .= "<div class='error'>"; 695 $renderer->cdata($notfound_cls); 696 $renderer->doc .= "</div>"; 697 } 698 699 /** 700 * Prints an error message which informs that the flag is not correct. 701 * 702 * @param (obj) $renderer object reference to the Doku_Render class, 703 * defined in /inc/parser/renderer.php, which defines functions for the 704 * output (see also /lib/styles/screen.css for some styles) 705 */ 706 private function _print_wrong_flag(Doku_Renderer $renderer) { 707 $wrong_flag = $this->getLang("wrong-flag"); 708 709 $renderer->doc .= "<div class='error'>"; 710 $renderer->cdata($wrong_flag); 711 $renderer->doc .= "</div>"; 712 } 713 714 /** 715 * Print an error message which informs that the file is not 716 * a Python script. 717 * 718 * @param (obj) $renderer object reference to the Doku_Render class, 719 * defined in /inc/parser/renderer.php, which defines functions for the 720 * output (see also /lib/styles/screen.css for some styles) 721 */ 722 private function _print_wrong_lang(Doku_Renderer $renderer) { 723 $wrong_lang = $this->getLang("wrong-lang"); 724 725 $renderer->doc .= "<div class='error'>"; 726 $renderer->cdata($wrong_lang); 727 $renderer->doc .= "</div>"; 728 } 729 730 /** 731 * Print an error message which informs that there was some problems 732 * to contact the repository. 733 * 734 * @param (obj) $renderer object reference to the Doku_Render class, 735 * defined in /inc/parser/renderer.php, which defines functions for the 736 * output (see also /lib/styles/screen.css for some styles) 737 */ 738 private function _print_error(Doku_Renderer $renderer) { 739 $error = $this->getLang("error"); 740 741 $renderer->doc .= "<div class='error'>"; 742 $renderer->cdata($error); 743 $renderer->doc .= "</div>"; 744 } 745} 746