1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 3 4class Doku_Handler { 5 6 var $Renderer = NULL; 7 8 var $CallWriter = NULL; 9 10 var $calls = array(); 11 12 var $status = array( 13 'section' => FALSE, 14 'section_edit_start' => -1, 15 'section_edit_level' => 1, 16 'section_edit_title' => '' 17 ); 18 19 var $rewriteBlocks = TRUE; 20 21 function Doku_Handler() { 22 $this->CallWriter = & new Doku_Handler_CallWriter($this); 23 } 24 25 function _addCall($handler, $args, $pos) { 26 $call = array($handler,$args, $pos); 27 $this->CallWriter->writeCall($call); 28 } 29 30 function _finalize(){ 31 32 $this->CallWriter->finalise(); 33 34 if ( $this->status['section'] ) { 35 $last_call = end($this->calls); 36 array_push($this->calls,array('section_close',array(), $last_call[2])); 37 if ($this->status['section_edit_start']>1) { 38 // ignore last edit section if there is only one header 39 array_push($this->calls,array('section_edit',array($this->status['section_edit_start'], 0, $this->status['section_edit_level'], $this->status['section_edit_title']), $last_call[2])); 40 } 41 } 42 43 if ( $this->rewriteBlocks ) { 44 $B = & new Doku_Handler_Block(); 45 $this->calls = $B->process($this->calls); 46 } 47 48 trigger_event('PARSER_HANDLER_DONE',$this); 49 50 array_unshift($this->calls,array('document_start',array(),0)); 51 $last_call = end($this->calls); 52 array_push($this->calls,array('document_end',array(),$last_call[2])); 53 } 54 55 function fetch() { 56 $call = each($this->calls); 57 if ( $call ) { 58 return $call['value']; 59 } 60 return FALSE; 61 } 62 63 64 /** 65 * Special plugin handler 66 * 67 * This handler is called for all modes starting with 'plugin_'. 68 * An additional parameter with the plugin name is passed 69 * 70 * @author Andreas Gohr <andi@splitbrain.org> 71 */ 72 function plugin($match, $state, $pos, $pluginname){ 73 $data = array($match); 74 $plugin =& plugin_load('syntax',$pluginname); 75 if($plugin != null){ 76 $data = $plugin->handle($match, $state, $pos, $this); 77 } 78 $this->_addCall('plugin',array($pluginname,$data,$state),$pos); 79 return TRUE; 80 } 81 82 function base($match, $state, $pos) { 83 switch ( $state ) { 84 case DOKU_LEXER_UNMATCHED: 85 $this->_addCall('cdata',array($match), $pos); 86 return TRUE; 87 break; 88 89 } 90 } 91 92 function header($match, $state, $pos) { 93 global $conf; 94 95 // get level and title 96 $title = trim($match); 97 $level = 7 - strspn($title,'='); 98 if($level < 1) $level = 1; 99 $title = trim($title,'='); 100 $title = trim($title); 101 102 if ($this->status['section']) $this->_addCall('section_close',array(),$pos); 103 104 if ($level<=$conf['maxseclevel']) { 105 $this->_addCall('section_edit',array($this->status['section_edit_start'], $pos-1, $this->status['section_edit_level'], $this->status['section_edit_title']), $pos); 106 $this->status['section_edit_start'] = $pos; 107 $this->status['section_edit_level'] = $level; 108 $this->status['section_edit_title'] = $title; 109 } 110 111 $this->_addCall('header',array($title,$level,$pos), $pos); 112 113 $this->_addCall('section_open',array($level),$pos); 114 $this->status['section'] = TRUE; 115 return TRUE; 116 } 117 118 function notoc($match, $state, $pos) { 119 $this->_addCall('notoc',array(),$pos); 120 return TRUE; 121 } 122 123 function nocache($match, $state, $pos) { 124 $this->_addCall('nocache',array(),$pos); 125 return TRUE; 126 } 127 128 function linebreak($match, $state, $pos) { 129 $this->_addCall('linebreak',array(),$pos); 130 return TRUE; 131 } 132 133 function eol($match, $state, $pos) { 134 $this->_addCall('eol',array(),$pos); 135 return TRUE; 136 } 137 138 function hr($match, $state, $pos) { 139 $this->_addCall('hr',array(),$pos); 140 return TRUE; 141 } 142 143 function _nestingTag($match, $state, $pos, $name) { 144 switch ( $state ) { 145 case DOKU_LEXER_ENTER: 146 $this->_addCall($name.'_open', array(), $pos); 147 break; 148 case DOKU_LEXER_EXIT: 149 $this->_addCall($name.'_close', array(), $pos); 150 break; 151 case DOKU_LEXER_UNMATCHED: 152 $this->_addCall('cdata',array($match), $pos); 153 break; 154 } 155 } 156 157 function strong($match, $state, $pos) { 158 $this->_nestingTag($match, $state, $pos, 'strong'); 159 return TRUE; 160 } 161 162 function emphasis($match, $state, $pos) { 163 $this->_nestingTag($match, $state, $pos, 'emphasis'); 164 return TRUE; 165 } 166 167 function underline($match, $state, $pos) { 168 $this->_nestingTag($match, $state, $pos, 'underline'); 169 return TRUE; 170 } 171 172 function monospace($match, $state, $pos) { 173 $this->_nestingTag($match, $state, $pos, 'monospace'); 174 return TRUE; 175 } 176 177 function subscript($match, $state, $pos) { 178 $this->_nestingTag($match, $state, $pos, 'subscript'); 179 return TRUE; 180 } 181 182 function superscript($match, $state, $pos) { 183 $this->_nestingTag($match, $state, $pos, 'superscript'); 184 return TRUE; 185 } 186 187 function deleted($match, $state, $pos) { 188 $this->_nestingTag($match, $state, $pos, 'deleted'); 189 return TRUE; 190 } 191 192 193 function footnote($match, $state, $pos) { 194 $this->_nestingTag($match, $state, $pos, 'footnote'); 195 return TRUE; 196 } 197 198 function listblock($match, $state, $pos) { 199 switch ( $state ) { 200 case DOKU_LEXER_ENTER: 201 $ReWriter = & new Doku_Handler_List($this->CallWriter); 202 $this->CallWriter = & $ReWriter; 203 $this->_addCall('list_open', array($match), $pos); 204 break; 205 case DOKU_LEXER_EXIT: 206 $this->_addCall('list_close', array(), $pos); 207 $this->CallWriter->process(); 208 $ReWriter = & $this->CallWriter; 209 $this->CallWriter = & $ReWriter->CallWriter; 210 break; 211 case DOKU_LEXER_MATCHED: 212 $this->_addCall('list_item', array($match), $pos); 213 break; 214 case DOKU_LEXER_UNMATCHED: 215 $this->_addCall('cdata', array($match), $pos); 216 break; 217 } 218 return TRUE; 219 } 220 221 function unformatted($match, $state, $pos) { 222 if ( $state == DOKU_LEXER_UNMATCHED ) { 223 $this->_addCall('unformatted',array($match), $pos); 224 } 225 return TRUE; 226 } 227 228 function php($match, $state, $pos) { 229 global $conf; 230 if ( $state == DOKU_LEXER_UNMATCHED ) { 231 if ($conf['phpok']) { 232 $this->_addCall('php',array($match), $pos); 233 } else { 234 $this->_addCall('file',array($match), $pos); 235 } 236 } 237 return TRUE; 238 } 239 240 function html($match, $state, $pos) { 241 global $conf; 242 if ( $state == DOKU_LEXER_UNMATCHED ) { 243 if($conf['htmlok']){ 244 $this->_addCall('html',array($match), $pos); 245 } else { 246 $this->_addCall('file',array($match), $pos); 247 } 248 } 249 return TRUE; 250 } 251 252 function preformatted($match, $state, $pos) { 253 switch ( $state ) { 254 case DOKU_LEXER_ENTER: 255 $ReWriter = & new Doku_Handler_Preformatted($this->CallWriter); 256 $this->CallWriter = & $ReWriter; 257 $this->_addCall('preformatted_start',array(), $pos); 258 break; 259 case DOKU_LEXER_EXIT: 260 $this->_addCall('preformatted_end',array(), $pos); 261 $this->CallWriter->process(); 262 $ReWriter = & $this->CallWriter; 263 $this->CallWriter = & $ReWriter->CallWriter; 264 break; 265 case DOKU_LEXER_MATCHED: 266 $this->_addCall('preformatted_newline',array(), $pos); 267 break; 268 case DOKU_LEXER_UNMATCHED: 269 $this->_addCall('preformatted_content',array($match), $pos); 270 break; 271 } 272 273 return TRUE; 274 } 275 276 function file($match, $state, $pos) { 277 if ( $state == DOKU_LEXER_UNMATCHED ) { 278 $this->_addCall('file',array($match), $pos); 279 } 280 return TRUE; 281 } 282 283 function quote($match, $state, $pos) { 284 285 switch ( $state ) { 286 287 case DOKU_LEXER_ENTER: 288 $ReWriter = & new Doku_Handler_Quote($this->CallWriter); 289 $this->CallWriter = & $ReWriter; 290 $this->_addCall('quote_start',array($match), $pos); 291 break; 292 293 case DOKU_LEXER_EXIT: 294 $this->_addCall('quote_end',array(), $pos); 295 $this->CallWriter->process(); 296 $ReWriter = & $this->CallWriter; 297 $this->CallWriter = & $ReWriter->CallWriter; 298 break; 299 300 case DOKU_LEXER_MATCHED: 301 $this->_addCall('quote_newline',array($match), $pos); 302 break; 303 304 case DOKU_LEXER_UNMATCHED: 305 $this->_addCall('cdata',array($match), $pos); 306 break; 307 308 } 309 310 return TRUE; 311 } 312 313 function code($match, $state, $pos) { 314 switch ( $state ) { 315 case DOKU_LEXER_UNMATCHED: 316 $matches = preg_split('/>/u',$match,2); 317 $matches[0] = trim($matches[0]); 318 if ( trim($matches[0]) == '' ) { 319 $matches[0] = NULL; 320 } 321 # $matches[0] contains name of programming language 322 # if available, We shortcut html here. 323 if($matches[0] == 'html') $matches[0] = 'html4strict'; 324 $this->_addCall( 325 'code', 326 array($matches[1],$matches[0]), 327 $pos 328 ); 329 break; 330 } 331 return TRUE; 332 } 333 334 function acronym($match, $state, $pos) { 335 $this->_addCall('acronym',array($match), $pos); 336 return TRUE; 337 } 338 339 function smiley($match, $state, $pos) { 340 $this->_addCall('smiley',array($match), $pos); 341 return TRUE; 342 } 343 344 function wordblock($match, $state, $pos) { 345 $this->_addCall('wordblock',array($match), $pos); 346 return TRUE; 347 } 348 349 function entity($match, $state, $pos) { 350 $this->_addCall('entity',array($match), $pos); 351 return TRUE; 352 } 353 354 function multiplyentity($match, $state, $pos) { 355 preg_match_all('/\d+/',$match,$matches); 356 $this->_addCall('multiplyentity',array($matches[0][0],$matches[0][1]), $pos); 357 return TRUE; 358 } 359 360 function singlequoteopening($match, $state, $pos) { 361 $this->_addCall('singlequoteopening',array(), $pos); 362 return TRUE; 363 } 364 365 function singlequoteclosing($match, $state, $pos) { 366 $this->_addCall('singlequoteclosing',array(), $pos); 367 return TRUE; 368 } 369 370 function doublequoteopening($match, $state, $pos) { 371 $this->_addCall('doublequoteopening',array(), $pos); 372 return TRUE; 373 } 374 375 function doublequoteclosing($match, $state, $pos) { 376 $this->_addCall('doublequoteclosing',array(), $pos); 377 return TRUE; 378 } 379 380 function camelcaselink($match, $state, $pos) { 381 $this->_addCall('camelcaselink',array($match), $pos); 382 return TRUE; 383 } 384 385 /* 386 */ 387 function internallink($match, $state, $pos) { 388 // Strip the opening and closing markup 389 $link = preg_replace(array('/^\[\[/','/\]\]$/u'),'',$match); 390 391 // Split title from URL 392 $link = preg_split('/\|/u',$link,2); 393 if ( !isset($link[1]) ) { 394 $link[1] = NULL; 395 } else if ( preg_match('/^\{\{[^\}]+\}\}$/',$link[1]) ) { 396 // If the title is an image, convert it to an array containing the image details 397 $link[1] = Doku_Handler_Parse_Media($link[1]); 398 } 399 $link[0] = trim($link[0]); 400 401 //decide which kind of link it is 402 403 if ( preg_match('/^[a-zA-Z\.]+>{1}.*$/u',$link[0]) ) { 404 // Interwiki 405 $interwiki = preg_split('/>/u',$link[0]); 406 $this->_addCall( 407 'interwikilink', 408 array($link[0],$link[1],strtolower($interwiki[0]),$interwiki[1]), 409 $pos 410 ); 411 }elseif ( preg_match('/^\\\\\\\\[\w.:?\-;,]+?\\\\/u',$link[0]) ) { 412 // Windows Share 413 $this->_addCall( 414 'windowssharelink', 415 array($link[0],$link[1]), 416 $pos 417 ); 418 }elseif ( preg_match('#^([a-z0-9\-\.+]+?)://#i',$link[0]) ) { 419 // external link (accepts all protocols) 420 $this->_addCall( 421 'externallink', 422 array($link[0],$link[1]), 423 $pos 424 ); 425 }elseif ( preg_match('#([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i',$link[0]) ) { 426 // E-Mail 427 $this->_addCall( 428 'emaillink', 429 array($link[0],$link[1]), 430 $pos 431 ); 432 }elseif ( preg_match('!^#.+!',$link[0]) ){ 433 // local link 434 $this->_addCall( 435 'locallink', 436 array(substr($link[0],1),$link[1]), 437 $pos 438 ); 439 }else{ 440 // internal link 441 $this->_addCall( 442 'internallink', 443 array($link[0],$link[1]), 444 $pos 445 ); 446 } 447 448 return TRUE; 449 } 450 451 function filelink($match, $state, $pos) { 452 $this->_addCall('filelink',array($match, NULL), $pos); 453 return TRUE; 454 } 455 456 function windowssharelink($match, $state, $pos) { 457 $this->_addCall('windowssharelink',array($match, NULL), $pos); 458 return TRUE; 459 } 460 461 function media($match, $state, $pos) { 462 $p = Doku_Handler_Parse_Media($match); 463 464 $this->_addCall( 465 $p['type'], 466 array($p['src'], $p['title'], $p['align'], $p['width'], 467 $p['height'], $p['cache'], $p['linking']), 468 $pos 469 ); 470 return TRUE; 471 } 472 473 function rss($match, $state, $pos) { 474 $link = preg_replace(array('/^\{\{rss>/','/\}\}$/'),'',$match); 475 476 // get params 477 list($link,$params) = explode(' ',$link,2); 478 479 $p = array(); 480 if(preg_match('/\b(\d+)\b/',$params,$match)){ 481 $p['max'] = $match[1]; 482 }else{ 483 $p['max'] = 8; 484 } 485 $p['reverse'] = (preg_match('/rev/',$params)); 486 $p['author'] = (preg_match('/\b(by|author)/',$params)); 487 $p['date'] = (preg_match('/\b(date)/',$params)); 488 $p['details'] = (preg_match('/\b(desc|detail)/',$params)); 489 490 $this->_addCall('rss',array($link,$p),$pos); 491 return TRUE; 492 } 493 494 function externallink($match, $state, $pos) { 495 // Prevent use of multibyte strings in URLs 496 // See: http://www.boingboing.net/2005/02/06/shmoo_group_exploit_.html 497 // Not worried about other charsets so long as page is output as UTF-8 498 /*if ( strlen($match) != utf8_strlen($match) ) { 499 $this->_addCall('cdata',array($match), $pos); 500 } else {*/ 501 502 $this->_addCall('externallink',array($match, NULL), $pos); 503 //} 504 return TRUE; 505 } 506 507 function emaillink($match, $state, $pos) { 508 $email = preg_replace(array('/^</','/>$/'),'',$match); 509 $this->_addCall('emaillink',array($email, NULL), $pos); 510 return TRUE; 511 } 512 513 function table($match, $state, $pos) { 514 switch ( $state ) { 515 516 case DOKU_LEXER_ENTER: 517 518 $ReWriter = & new Doku_Handler_Table($this->CallWriter); 519 $this->CallWriter = & $ReWriter; 520 521 $this->_addCall('table_start', array(), $pos); 522 //$this->_addCall('table_row', array(), $pos); 523 if ( trim($match) == '^' ) { 524 $this->_addCall('tableheader', array(), $pos); 525 } else { 526 $this->_addCall('tablecell', array(), $pos); 527 } 528 break; 529 530 case DOKU_LEXER_EXIT: 531 $this->_addCall('table_end', array(), $pos); 532 $this->CallWriter->process(); 533 $ReWriter = & $this->CallWriter; 534 $this->CallWriter = & $ReWriter->CallWriter; 535 break; 536 537 case DOKU_LEXER_UNMATCHED: 538 if ( trim($match) != '' ) { 539 $this->_addCall('cdata',array($match), $pos); 540 } 541 break; 542 543 case DOKU_LEXER_MATCHED: 544 if ( $match == ' ' ){ 545 $this->_addCall('cdata', array($match), $pos); 546 } else if ( preg_match('/\t+/',$match) ) { 547 $this->_addCall('table_align', array($match), $pos); 548 } else if ( preg_match('/ {2,}/',$match) ) { 549 $this->_addCall('table_align', array($match), $pos); 550 } else if ( $match == "\n|" ) { 551 $this->_addCall('table_row', array(), $pos); 552 $this->_addCall('tablecell', array(), $pos); 553 } else if ( $match == "\n^" ) { 554 $this->_addCall('table_row', array(), $pos); 555 $this->_addCall('tableheader', array(), $pos); 556 } else if ( $match == '|' ) { 557 $this->_addCall('tablecell', array(), $pos); 558 } else if ( $match == '^' ) { 559 $this->_addCall('tableheader', array(), $pos); 560 } 561 break; 562 } 563 return TRUE; 564 } 565} 566 567//------------------------------------------------------------------------ 568function Doku_Handler_Parse_Media($match) { 569 570 // Strip the opening and closing markup 571 $link = preg_replace(array('/^\{\{/','/\}\}$/u'),'',$match); 572 573 // Split title from URL 574 $link = preg_split('/\|/u',$link,2); 575 576 577 // Check alignment 578 $ralign = (bool)preg_match('/^ /',$link[0]); 579 $lalign = (bool)preg_match('/ $/',$link[0]); 580 581 // Logic = what's that ;)... 582 if ( $lalign & $ralign ) { 583 $align = 'center'; 584 } else if ( $ralign ) { 585 $align = 'right'; 586 } else if ( $lalign ) { 587 $align = 'left'; 588 } else { 589 $align = NULL; 590 } 591 592 // The title... 593 if ( !isset($link[1]) ) { 594 $link[1] = NULL; 595 } 596 597 //remove aligning spaces 598 $link[0] = trim($link[0]); 599 600 //split into src and parameters (using the very last questionmark) 601 $pos = strrpos($link[0], '?'); 602 if($pos !== false){ 603 $src = substr($link[0],0,$pos); 604 $param = substr($link[0],$pos+1); 605 }else{ 606 $src = $link[0]; 607 $param = ''; 608 } 609 610 //parse width and height 611 if(preg_match('#(\d+)(x(\d+))?#i',$param,$size)){ 612 ($size[1]) ? $w = $size[1] : $w = NULL; 613 ($size[3]) ? $h = $size[3] : $h = NULL; 614 } else { 615 $w = NULL; 616 $h = NULL; 617 } 618 619 //get linking command 620 if(preg_match('/nolink/i',$param)){ 621 $linking = 'nolink'; 622 }else if(preg_match('/direct/i',$param)){ 623 $linking = 'direct'; 624 }else{ 625 $linking = 'details'; 626 } 627 628 //get caching command 629 if (preg_match('/(nocache|recache)/i',$param,$cachemode)){ 630 $cache = $cachemode[1]; 631 }else{ 632 $cache = 'cache'; 633 } 634 635 // Check whether this is a local or remote image 636 if ( preg_match('#^(https?|ftp)#i',$src) ) { 637 $call = 'externalmedia'; 638 } else { 639 $call = 'internalmedia'; 640 } 641 642 $params = array( 643 'type'=>$call, 644 'src'=>$src, 645 'title'=>$link[1], 646 'align'=>$align, 647 'width'=>$w, 648 'height'=>$h, 649 'cache'=>$cache, 650 'linking'=>$linking, 651 ); 652 653 return $params; 654} 655 656//------------------------------------------------------------------------ 657class Doku_Handler_CallWriter { 658 659 var $Handler; 660 661 function Doku_Handler_CallWriter(& $Handler) { 662 $this->Handler = & $Handler; 663 } 664 665 function writeCall($call) { 666 $this->Handler->calls[] = $call; 667 } 668 669 function writeCalls($calls) { 670 $this->Handler->calls = array_merge($this->Handler->calls, $calls); 671 } 672 673 // function is required, but since this call writer is first/highest in 674 // the chain it is not required to do anything 675 function finalise() { 676 } 677} 678 679//------------------------------------------------------------------------ 680class Doku_Handler_List { 681 682 var $CallWriter; 683 684 var $calls = array(); 685 var $listCalls = array(); 686 var $listStack = array(); 687 688 function Doku_Handler_List(& $CallWriter) { 689 $this->CallWriter = & $CallWriter; 690 } 691 692 function writeCall($call) { 693 $this->calls[] = $call; 694 } 695 696 // Probably not needed but just in case... 697 function writeCalls($calls) { 698 $this->calls = array_merge($this->calls, $calls); 699# $this->CallWriter->writeCalls($this->calls); 700 } 701 702 function finalise() { 703 $last_call = end($this->calls); 704 $this->writeCall(array('list_close',array(), $last_call[2])); 705 706 $this->process(); 707 $this->CallWriter->finalise(); 708 } 709 710 //------------------------------------------------------------------------ 711 function process() { 712 713 foreach ( $this->calls as $call ) { 714 switch ($call[0]) { 715 case 'list_item': 716 $this->listOpen($call); 717 break; 718 case 'list_open': 719 $this->listStart($call); 720 break; 721 case 'list_close': 722 $this->listEnd($call); 723 break; 724 default: 725 $this->listContent($call); 726 break; 727 } 728 } 729 730 $this->CallWriter->writeCalls($this->listCalls); 731 } 732 733 //------------------------------------------------------------------------ 734 function listStart($call) { 735 $depth = $this->interpretSyntax($call[1][0], $listType); 736 737 $this->initialDepth = $depth; 738 $this->listStack[] = array($listType, $depth); 739 740 $this->listCalls[] = array('list'.$listType.'_open',array(),$call[2]); 741 $this->listCalls[] = array('listitem_open',array(1),$call[2]); 742 $this->listCalls[] = array('listcontent_open',array(),$call[2]); 743 } 744 745 //------------------------------------------------------------------------ 746 function listEnd($call) { 747 $closeContent = TRUE; 748 749 while ( $list = array_pop($this->listStack) ) { 750 if ( $closeContent ) { 751 $this->listCalls[] = array('listcontent_close',array(),$call[2]); 752 $closeContent = FALSE; 753 } 754 $this->listCalls[] = array('listitem_close',array(),$call[2]); 755 $this->listCalls[] = array('list'.$list[0].'_close', array(), $call[2]); 756 } 757 } 758 759 //------------------------------------------------------------------------ 760 function listOpen($call) { 761 $depth = $this->interpretSyntax($call[1][0], $listType); 762 $end = end($this->listStack); 763 764 // Not allowed to be shallower than initialDepth 765 if ( $depth < $this->initialDepth ) { 766 $depth = $this->initialDepth; 767 } 768 769 //------------------------------------------------------------------------ 770 if ( $depth == $end[1] ) { 771 772 // Just another item in the list... 773 if ( $listType == $end[0] ) { 774 $this->listCalls[] = array('listcontent_close',array(),$call[2]); 775 $this->listCalls[] = array('listitem_close',array(),$call[2]); 776 $this->listCalls[] = array('listitem_open',array($depth-1),$call[2]); 777 $this->listCalls[] = array('listcontent_open',array(),$call[2]); 778 779 // Switched list type... 780 } else { 781 782 $this->listCalls[] = array('listcontent_close',array(),$call[2]); 783 $this->listCalls[] = array('listitem_close',array(),$call[2]); 784 $this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]); 785 $this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]); 786 $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); 787 $this->listCalls[] = array('listcontent_open',array(),$call[2]); 788 789 array_pop($this->listStack); 790 $this->listStack[] = array($listType, $depth); 791 } 792 793 //------------------------------------------------------------------------ 794 // Getting deeper... 795 } else if ( $depth > $end[1] ) { 796 797 $this->listCalls[] = array('listcontent_close',array(),$call[2]); 798 $this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]); 799 $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); 800 $this->listCalls[] = array('listcontent_open',array(),$call[2]); 801 802 $this->listStack[] = array($listType, $depth); 803 804 //------------------------------------------------------------------------ 805 // Getting shallower ( $depth < $end[1] ) 806 } else { 807 $this->listCalls[] = array('listcontent_close',array(),$call[2]); 808 $this->listCalls[] = array('listitem_close',array(),$call[2]); 809 $this->listCalls[] = array('list'.$end[0].'_close',array(),$call[2]); 810 811 // Throw away the end - done 812 array_pop($this->listStack); 813 814 while (1) { 815 $end = end($this->listStack); 816 817 if ( $end[1] <= $depth ) { 818 819 // Normalize depths 820 $depth = $end[1]; 821 822 $this->listCalls[] = array('listitem_close',array(),$call[2]); 823 824 if ( $end[0] == $listType ) { 825 $this->listCalls[] = array('listitem_open',array($depth-1),$call[2]); 826 $this->listCalls[] = array('listcontent_open',array(),$call[2]); 827 828 } else { 829 // Switching list type... 830 $this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]); 831 $this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]); 832 $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); 833 $this->listCalls[] = array('listcontent_open',array(),$call[2]); 834 835 array_pop($this->listStack); 836 $this->listStack[] = array($listType, $depth); 837 } 838 839 break; 840 841 // Haven't dropped down far enough yet.... ( $end[1] > $depth ) 842 } else { 843 844 $this->listCalls[] = array('listitem_close',array(),$call[2]); 845 $this->listCalls[] = array('list'.$end[0].'_close',array(),$call[2]); 846 847 array_pop($this->listStack); 848 849 } 850 851 } 852 853 } 854 } 855 856 //------------------------------------------------------------------------ 857 function listContent($call) { 858 $this->listCalls[] = $call; 859 } 860 861 //------------------------------------------------------------------------ 862 function interpretSyntax($match, & $type) { 863 if ( substr($match,-1) == '*' ) { 864 $type = 'u'; 865 } else { 866 $type = 'o'; 867 } 868 return count(explode(' ',str_replace("\t",' ',$match))); 869 } 870} 871 872//------------------------------------------------------------------------ 873class Doku_Handler_Preformatted { 874 875 var $CallWriter; 876 877 var $calls = array(); 878 var $pos; 879 var $text =''; 880 881 882 883 function Doku_Handler_Preformatted(& $CallWriter) { 884 $this->CallWriter = & $CallWriter; 885 } 886 887 function writeCall($call) { 888 $this->calls[] = $call; 889 } 890 891 // Probably not needed but just in case... 892 function writeCalls($calls) { 893 $this->calls = array_merge($this->calls, $calls); 894# $this->CallWriter->writeCalls($this->calls); 895 } 896 897 function finalise() { 898 $last_call = end($this->calls); 899 $this->writeCall(array('preformatted_end',array(), $last_call[2])); 900 901 $this->process(); 902 $this->CallWriter->finalise(); 903 } 904 905 function process() { 906 foreach ( $this->calls as $call ) { 907 switch ($call[0]) { 908 case 'preformatted_start': 909 $this->pos = $call[2]; 910 break; 911 case 'preformatted_newline': 912 $this->text .= "\n"; 913 break; 914 case 'preformatted_content': 915 $this->text .= $call[1][0]; 916 break; 917 case 'preformatted_end': 918 $this->CallWriter->writeCall(array('preformatted',array($this->text),$this->pos)); 919 break; 920 } 921 } 922 } 923 924} 925 926//------------------------------------------------------------------------ 927class Doku_Handler_Quote { 928 929 var $CallWriter; 930 931 var $calls = array(); 932 933 var $quoteCalls = array(); 934 935 function Doku_Handler_Quote(& $CallWriter) { 936 $this->CallWriter = & $CallWriter; 937 } 938 939 function writeCall($call) { 940 $this->calls[] = $call; 941 } 942 943 // Probably not needed but just in case... 944 function writeCalls($calls) { 945 $this->calls = array_merge($this->calls, $calls); 946# $this->CallWriter->writeCalls($this->calls); 947 } 948 949 function finalise() { 950 $last_call = end($this->calls); 951 $this->writeCall(array('quote_end',array(), $last_call[2])); 952 953 $this->process(); 954 $this->CallWriter->finalise(); 955 } 956 957 function process() { 958 959 $quoteDepth = 1; 960 961 foreach ( $this->calls as $call ) { 962 switch ($call[0]) { 963 964 case 'quote_start': 965 966 $this->quoteCalls[] = array('quote_open',array(),$call[2]); 967 968 case 'quote_newline': 969 970 $quoteLength = $this->getDepth($call[1][0]); 971 972 if ( $quoteLength > $quoteDepth ) { 973 $quoteDiff = $quoteLength - $quoteDepth; 974 for ( $i = 1; $i <= $quoteDiff; $i++ ) { 975 $this->quoteCalls[] = array('quote_open',array(),$call[2]); 976 } 977 } else if ( $quoteLength < $quoteDepth ) { 978 $quoteDiff = $quoteDepth - $quoteLength; 979 for ( $i = 1; $i <= $quoteDiff; $i++ ) { 980 $this->quoteCalls[] = array('quote_close',array(),$call[2]); 981 } 982 } else { 983 if ($call[0] != 'quote_start') $this->quoteCalls[] = array('linebreak',array(),$call[2]); 984 } 985 986 $quoteDepth = $quoteLength; 987 988 break; 989 990 case 'quote_end': 991 992 if ( $quoteDepth > 1 ) { 993 $quoteDiff = $quoteDepth - 1; 994 for ( $i = 1; $i <= $quoteDiff; $i++ ) { 995 $this->quoteCalls[] = array('quote_close',array(),$call[2]); 996 } 997 } 998 999 $this->quoteCalls[] = array('quote_close',array(),$call[2]); 1000 1001 $this->CallWriter->writeCalls($this->quoteCalls); 1002 break; 1003 1004 default: 1005 $this->quoteCalls[] = $call; 1006 break; 1007 } 1008 } 1009 } 1010 1011 function getDepth($marker) { 1012 preg_match('/>{1,}/', $marker, $matches); 1013 $quoteLength = strlen($matches[0]); 1014 return $quoteLength; 1015 } 1016} 1017 1018//------------------------------------------------------------------------ 1019class Doku_Handler_Table { 1020 1021 var $CallWriter; 1022 1023 var $calls = array(); 1024 var $tableCalls = array(); 1025 var $maxCols = 0; 1026 var $maxRows = 1; 1027 var $currentCols = 0; 1028 var $firstCell = FALSE; 1029 var $lastCellType = 'tablecell'; 1030 1031 function Doku_Handler_Table(& $CallWriter) { 1032 $this->CallWriter = & $CallWriter; 1033 } 1034 1035 function writeCall($call) { 1036 $this->calls[] = $call; 1037 } 1038 1039 // Probably not needed but just in case... 1040 function writeCalls($calls) { 1041 $this->calls = array_merge($this->calls, $calls); 1042# $this->CallWriter->writeCalls($this->calls); 1043 } 1044 1045 function finalise() { 1046 $last_call = end($this->calls); 1047 $this->writeCall(array('table_end',array(), $last_call[2])); 1048 1049 $this->process(); 1050 $this->CallWriter->finalise(); 1051 } 1052 1053 //------------------------------------------------------------------------ 1054 function process() { 1055 foreach ( $this->calls as $call ) { 1056 switch ( $call[0] ) { 1057 case 'table_start': 1058 $this->tableStart($call); 1059 break; 1060 case 'table_row': 1061 $this->tableRowClose(array('tablerow_close',$call[1],$call[2])); 1062 $this->tableRowOpen(array('tablerow_open',$call[1],$call[2])); 1063 break; 1064 case 'tableheader': 1065 case 'tablecell': 1066 $this->tableCell($call); 1067 break; 1068 case 'table_end': 1069 $this->tableRowClose(array('tablerow_close',$call[1],$call[2])); 1070 $this->tableEnd($call); 1071 break; 1072 default: 1073 $this->tableDefault($call); 1074 break; 1075 } 1076 } 1077 $this->CallWriter->writeCalls($this->tableCalls); 1078 } 1079 1080 function tableStart($call) { 1081 $this->tableCalls[] = array('table_open',array(),$call[2]); 1082 $this->tableCalls[] = array('tablerow_open',array(),$call[2]); 1083 $this->firstCell = TRUE; 1084 } 1085 1086 function tableEnd($call) { 1087 $this->tableCalls[] = array('table_close',array(),$call[2]); 1088 $this->finalizeTable(); 1089 } 1090 1091 function tableRowOpen($call) { 1092 $this->tableCalls[] = $call; 1093 $this->currentCols = 0; 1094 $this->firstCell = TRUE; 1095 $this->lastCellType = 'tablecell'; 1096 $this->maxRows++; 1097 } 1098 1099 function tableRowClose($call) { 1100 // Strip off final cell opening and anything after it 1101 while ( $discard = array_pop($this->tableCalls ) ) { 1102 1103 if ( $discard[0] == 'tablecell_open' || $discard[0] == 'tableheader_open') { 1104 1105 // Its a spanning element - put it back and close it 1106 if ( $discard[1][0] > 1 ) { 1107 1108 $this->tableCalls[] = $discard; 1109 if ( strstr($discard[0],'cell') ) { 1110 $name = 'tablecell'; 1111 } else { 1112 $name = 'tableheader'; 1113 } 1114 $this->tableCalls[] = array($name.'_close',array(),$call[2]); 1115 } 1116 1117 break; 1118 } 1119 } 1120 $this->tableCalls[] = $call; 1121 1122 if ( $this->currentCols > $this->maxCols ) { 1123 $this->maxCols = $this->currentCols; 1124 } 1125 } 1126 1127 function tableCell($call) { 1128 if ( !$this->firstCell ) { 1129 1130 // Increase the span 1131 $lastCall = end($this->tableCalls); 1132 1133 // A cell call which follows an open cell means an empty cell so span 1134 if ( $lastCall[0] == 'tablecell_open' || $lastCall[0] == 'tableheader_open' ) { 1135 $this->tableCalls[] = array('colspan',array(),$call[2]); 1136 1137 } 1138 1139 $this->tableCalls[] = array($this->lastCellType.'_close',array(),$call[2]); 1140 $this->tableCalls[] = array($call[0].'_open',array(1,NULL),$call[2]); 1141 $this->lastCellType = $call[0]; 1142 1143 } else { 1144 1145 $this->tableCalls[] = array($call[0].'_open',array(1,NULL),$call[2]); 1146 $this->lastCellType = $call[0]; 1147 $this->firstCell = FALSE; 1148 1149 } 1150 1151 $this->currentCols++; 1152 } 1153 1154 function tableDefault($call) { 1155 $this->tableCalls[] = $call; 1156 } 1157 1158 function finalizeTable() { 1159 1160 // Add the max cols and rows to the table opening 1161 if ( $this->tableCalls[0][0] == 'table_open' ) { 1162 // Adjust to num cols not num col delimeters 1163 $this->tableCalls[0][1][] = $this->maxCols - 1; 1164 $this->tableCalls[0][1][] = $this->maxRows; 1165 } else { 1166 trigger_error('First element in table call list is not table_open'); 1167 } 1168 1169 $lastRow = 0; 1170 $lastCell = 0; 1171 $toDelete = array(); 1172 1173 // Look for the colspan elements and increment the colspan on the 1174 // previous non-empty opening cell. Once done, delete all the cells 1175 // that contain colspans 1176 foreach ( $this->tableCalls as $key => $call ) { 1177 1178 if ( $call[0] == 'tablerow_open' ) { 1179 1180 $lastRow = $key; 1181 1182 } else if ( $call[0] == 'tablecell_open' || $call[0] == 'tableheader_open' ) { 1183 1184 $lastCell = $key; 1185 1186 } else if ( $call[0] == 'table_align' ) { 1187 1188 // If the previous element was a cell open, align right 1189 if ( $this->tableCalls[$key-1][0] == 'tablecell_open' || $this->tableCalls[$key-1][0] == 'tableheader_open' ) { 1190 $this->tableCalls[$key-1][1][1] = 'right'; 1191 1192 // If the next element if the close of an element, align either center or left 1193 } else if ( $this->tableCalls[$key+1][0] == 'tablecell_close' || $this->tableCalls[$key+1][0] == 'tableheader_close' ) { 1194 if ( $this->tableCalls[$lastCell][1][1] == 'right' ) { 1195 $this->tableCalls[$lastCell][1][1] = 'center'; 1196 } else { 1197 $this->tableCalls[$lastCell][1][1] = 'left'; 1198 } 1199 1200 } 1201 1202 // Now convert the whitespace back to cdata 1203 $this->tableCalls[$key][0] = 'cdata'; 1204 1205 } else if ( $call[0] == 'colspan' ) { 1206 1207 $this->tableCalls[$key-1][1][0] = FALSE; 1208 1209 for($i = $key-2; $i > $lastRow; $i--) { 1210 1211 if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) { 1212 1213 if ( FALSE !== $this->tableCalls[$i][1][0] ) { 1214 $this->tableCalls[$i][1][0]++; 1215 break; 1216 } 1217 1218 1219 } 1220 } 1221 1222 $toDelete[] = $key-1; 1223 $toDelete[] = $key; 1224 $toDelete[] = $key+1; 1225 } 1226 } 1227 1228 1229 // condense cdata 1230 $cnt = count($this->tableCalls); 1231 for( $key = 0; $key < $cnt; $key++){ 1232 if($this->tableCalls[$key][0] == 'cdata'){ 1233 $ckey = $key; 1234 $key++; 1235 while($this->tableCalls[$key][0] == 'cdata'){ 1236 $this->tableCalls[$ckey][1][0] .= $this->tableCalls[$key][1][0]; 1237 $toDelete[] = $key; 1238 $key++; 1239 } 1240 continue; 1241 } 1242 } 1243 1244 foreach ( $toDelete as $delete ) { 1245 unset($this->tableCalls[$delete]); 1246 } 1247 $this->tableCalls = array_values($this->tableCalls); 1248 } 1249} 1250 1251//------------------------------------------------------------------------ 1252class Doku_Handler_Section { 1253 1254 function process($calls) { 1255 1256 $sectionCalls = array(); 1257 $inSection = FALSE; 1258 1259 foreach ( $calls as $call ) { 1260 1261 if ( $call[0] == 'header' ) { 1262 1263 if ( $inSection ) { 1264 $sectionCalls[] = array('section_close',array(), $call[2]); 1265 } 1266 1267 $sectionCalls[] = $call; 1268 $sectionCalls[] = array('section_open',array($call[1][1]), $call[2]); 1269 $inSection = TRUE; 1270 1271 } else { 1272 1273 if ($call[0] == 'section_open' ) { 1274 $inSection = TRUE; 1275 } else if ($call[0] == 'section_open' ) { 1276 $inSection = FALSE; 1277 } 1278 $sectionCalls[] = $call; 1279 } 1280 } 1281 1282 if ( $inSection ) { 1283 $sectionCalls[] = array('section_close',array(), $call[2]); 1284 } 1285 1286 return $sectionCalls; 1287 } 1288 1289} 1290 1291/** 1292 * Handler for paragraphs 1293 * 1294 * @author Harry Fuecks <hfuecks@gmail.com> 1295 */ 1296class Doku_Handler_Block { 1297 1298 var $calls = array(); 1299 1300 var $blockStack = array(); 1301 1302 var $inParagraph = FALSE; 1303 var $atStart = TRUE; 1304 var $skipEolKey = -1; 1305 1306 // Blocks these should not be inside paragraphs 1307 var $blockOpen = array( 1308 'header', 1309 'listu_open','listo_open','listitem_open','listcontent_open', 1310 'table_open','tablerow_open','tablecell_open','tableheader_open', 1311 'quote_open', 1312 'section_open', // Needed to prevent p_open between header and section_open 1313 'code','file','hr','preformatted', 1314 ); 1315 1316 var $blockClose = array( 1317 'header', 1318 'listu_close','listo_close','listitem_close','listcontent_close', 1319 'table_close','tablerow_close','tablecell_close','tableheader_close', 1320 'quote_close', 1321 'section_close', // Needed to prevent p_close after section_close 1322 'code','file','hr','preformatted', 1323 ); 1324 1325 // Stacks can contain paragraphs 1326 var $stackOpen = array( 1327 'footnote_open','section_open', 1328 ); 1329 1330 var $stackClose = array( 1331 'footnote_close','section_close', 1332 ); 1333 1334 1335 /** 1336 * Constructor. Adds loaded syntax plugins to the block and stack 1337 * arrays 1338 * 1339 * @author Andreas Gohr <andi@splitbrain.org> 1340 */ 1341 function Doku_Handler_Block(){ 1342 global $DOKU_PLUGINS; 1343 //check if syntax plugins were loaded 1344 if(!is_array($DOKU_PLUGINS['syntax'])) return; 1345 foreach($DOKU_PLUGINS['syntax'] as $n => $p){ 1346 $ptype = $p->getPType(); 1347 if($ptype == 'block'){ 1348 $this->blockOpen[] = 'plugin_'.$n; 1349 $this->blockClose[] = 'plugin_'.$n; 1350 }elseif($ptype == 'stack'){ 1351 $this->stackOpen[] = 'plugin_'.$n; 1352 $this->stackClose[] = 'plugin_'.$n; 1353 } 1354 } 1355 } 1356 1357 /** 1358 * Close a paragraph if needed 1359 * 1360 * This function makes sure there are no empty paragraphs on the stack 1361 * 1362 * @author Andreas Gohr <andi@splitbrain.org> 1363 */ 1364 function closeParagraph($pos){ 1365 // look back if there was any content - we don't want empty paragraphs 1366 $content = ''; 1367 for($i=count($this->calls)-1; $i>=0; $i--){ 1368 if($this->calls[$i][0] == 'p_open'){ 1369 break; 1370 }elseif($this->calls[$i][0] == 'cdata'){ 1371 $content .= $this->calls[$i][1][0]; 1372 }else{ 1373 $content = 'found markup'; 1374 break; 1375 } 1376 } 1377 1378 if(trim($content)==''){ 1379 //remove the whole paragraph 1380 array_splice($this->calls,$i); 1381 }else{ 1382 if ($this->calls[count($this->calls)-1][0] == 'section_edit') { 1383 $tmp = array_pop($this->calls); 1384 $this->calls[] = array('p_close',array(), $pos); 1385 $this->calls[] = $tmp; 1386 } else { 1387 $this->calls[] = array('p_close',array(), $pos); 1388 } 1389 } 1390 1391 $this->inParagraph = FALSE; 1392 } 1393 1394 /** 1395 * Processes the whole instruction stack to open and close paragraphs 1396 * 1397 * @author Harry Fuecks <hfuecks@gmail.com> 1398 * @author Andreas Gohr <andi@splitbrain.org> 1399 * @todo This thing is really messy and should be rewritten 1400 */ 1401 function process($calls) { 1402 foreach ( $calls as $key => $call ) { 1403 $cname = $call[0]; 1404 if($cname == 'plugin') { 1405 $cname='plugin_'.$call[1][0]; 1406 1407 $plugin = true; 1408 $plugin_open = (($call[1][2] == DOKU_LEXER_ENTER) || ($call[1][2] == DOKU_LEXER_SPECIAL)); 1409 $plugin_close = (($call[1][2] == DOKU_LEXER_EXIT) || ($call[1][2] == DOKU_LEXER_SPECIAL)); 1410 } else { 1411 $plugin = false; 1412 } 1413 1414 // Process blocks which are stack like... (contain linefeeds) 1415 if ( in_array($cname,$this->stackOpen ) && (!$plugin || $plugin_open) ) { 1416 1417 $this->calls[] = $call; 1418 1419 // Hack - footnotes shouldn't immediately contain a p_open 1420 if ( $cname != 'footnote_open' ) { 1421 $this->addToStack(); 1422 } else { 1423 $this->addToStack(FALSE); 1424 } 1425 continue; 1426 } 1427 1428 if ( in_array($cname,$this->stackClose ) && (!$plugin || $plugin_close)) { 1429 1430 if ( $this->inParagraph ) { 1431 $this->closeParagraph($call[2]); 1432 } 1433 $this->calls[] = $call; 1434 $this->removeFromStack(); 1435 continue; 1436 } 1437 1438 if ( !$this->atStart ) { 1439 1440 if ( $cname == 'eol' ) { 1441 1442 // Check this isn't an eol instruction to skip... 1443 if ( $this->skipEolKey != $key ) { 1444 // Look to see if the next instruction is an EOL 1445 if ( isset($calls[$key+1]) && $calls[$key+1][0] == 'eol' ) { 1446 1447 if ( $this->inParagraph ) { 1448 //$this->calls[] = array('p_close',array(), $call[2]); 1449 $this->closeParagraph($call[2]); 1450 } 1451 1452 $this->calls[] = array('p_open',array(), $call[2]); 1453 $this->inParagraph = TRUE; 1454 1455 1456 // Mark the next instruction for skipping 1457 $this->skipEolKey = $key+1; 1458 1459 }else{ 1460 //if this is just a single eol make a space from it 1461 $this->calls[] = array('cdata',array(" "), $call[2]); 1462 } 1463 } 1464 1465 1466 } else { 1467 1468 $storeCall = TRUE; 1469 if ( $this->inParagraph && (in_array($cname, $this->blockOpen) && (!$plugin || $plugin_open))) { 1470 $this->closeParagraph($call[2]); 1471 $this->calls[] = $call; 1472 $storeCall = FALSE; 1473 } 1474 1475 if ( in_array($cname, $this->blockClose) && (!$plugin || $plugin_close)) { 1476 if ( $this->inParagraph ) { 1477 $this->closeParagraph($call[2]); 1478 } 1479 if ( $storeCall ) { 1480 $this->calls[] = $call; 1481 $storeCall = FALSE; 1482 } 1483 1484 // This really sucks and suggests this whole class sucks but... 1485 if ( isset($calls[$key+1])) { 1486 $cname_plusone = $calls[$key+1][0]; 1487 if ($cname_plusone == 'plugin') { 1488 $cname_plusone = 'plugin'.$calls[$key+1][1][0]; 1489 1490 // plugin test, true if plugin has a state which precludes it requiring blockOpen or blockClose 1491 $plugin_plusone = true; 1492 $plugin_test = ($call[$key+1][1][2] == DOKU_LEXER_MATCHED) || ($call[$key+1][1][2] == DOKU_LEXER_MATCHED); 1493 } else { 1494 $plugin_plusone = false; 1495 } 1496 if ((!in_array($cname_plusone, $this->blockOpen) && !in_array($cname_plusone, $this->blockClose)) || 1497 ($plugin_plusone && $plugin_test) 1498 ) { 1499 1500 $this->calls[] = array('p_open',array(), $call[2]); 1501 $this->inParagraph = TRUE; 1502 } 1503 } 1504 } 1505 1506 if ( $storeCall ) { 1507 $this->calls[] = $call; 1508 } 1509 1510 } 1511 1512 1513 } else { 1514 1515 // Unless there's already a block at the start, start a paragraph 1516 if ( !in_array($cname,$this->blockOpen) ) { 1517 $this->calls[] = array('p_open',array(), $call[2]); 1518 if ( $call[0] != 'eol' ) { 1519 $this->calls[] = $call; 1520 } 1521 $this->atStart = FALSE; 1522 $this->inParagraph = TRUE; 1523 } else { 1524 $this->calls[] = $call; 1525 $this->atStart = FALSE; 1526 } 1527 1528 } 1529 1530 } 1531 1532 if ( $this->inParagraph ) { 1533 if ( $cname == 'p_open' ) { 1534 // Ditch the last call 1535 array_pop($this->calls); 1536 } else if ( !in_array($cname, $this->blockClose) ) { 1537 //$this->calls[] = array('p_close',array(), $call[2]); 1538 $this->closeParagraph($call[2]); 1539 } else { 1540 $last_call = array_pop($this->calls); 1541 //$this->calls[] = array('p_close',array(), $call[2]); 1542 $this->closeParagraph($call[2]); 1543 $this->calls[] = $last_call; 1544 } 1545 } 1546 1547 return $this->calls; 1548 } 1549 1550 function addToStack($newStart = TRUE) { 1551 $this->blockStack[] = array($this->atStart, $this->inParagraph); 1552 $this->atStart = $newStart; 1553 $this->inParagraph = FALSE; 1554 } 1555 1556 function removeFromStack() { 1557 $state = array_pop($this->blockStack); 1558 $this->atStart = $state[0]; 1559 $this->inParagraph = $state[1]; 1560 } 1561} 1562 1563//Setup VIM: ex: et ts=4 enc=utf-8 : 1564