1<?php 2/** 3 * PHPImplicitNocache plugin: <php> blocks make pages NOCACHE by default 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author B.J. Black <bj@schmong.org> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12 13/** 14 * All DokuWiki plugins to extend the parser/rendering mechanism 15 * need to inherit from this class 16 */ 17class syntax_plugin_phpimplicitnocache extends DokuWiki_Syntax_Plugin { 18 19 /** 20 * return some info 21 */ 22 function getInfo(){ 23 return array( 24 'author' => 'B.J. Black', 25 'email' => 'bj@schmong.org', 26 'date' => '2007-11-26', 27 'name' => 'PHPImplicitNocache Plugin', 28 'desc' => 'PHP blocks in a page make it NOCACHE by default', 29 'url' => 'http://wiki.splitbrain.org/plugin:phpimplicitnocache', 30 ); 31 } 32 33 function getType(){ return 'protected'; } 34 function getAllowedTypes() { return array('protected'); } 35 function getSort(){ return 179; } 36 function connectTo($mode) { 37 $this->Lexer->addEntryPattern('<php>(?=.*</php>)',$mode,'plugin_phpimplicitnocache'); 38 $this->Lexer->addEntryPattern('<PHP>(?=.*</PHP>)',$mode,'plugin_phpimplicitnocache'); 39 } 40 function postConnect() { 41 $this->Lexer->addExitPattern('</php>','plugin_phpimplicitnocache'); 42 $this->Lexer->addExitPattern('</PHP>','plugin_phpimplicitnocache'); 43 } 44 45 /** 46 * Handle the match 47 */ 48 function handle($match, $state, $pos, &$handler){ 49 if( $state == DOKU_LEXER_UNMATCHED ) { 50 return array($match); 51 } 52 } 53 54 /** 55 * Create output 56 */ 57 function render($mode, &$renderer, $data) { 58 $renderer->info['cache'] = false; 59 if( $mode == 'xhtml' ) { 60 ob_start(); 61 eval($data[0]); 62 $renderer->doc .= ob_get_contents(); 63 ob_end_clean(); 64 } 65 return true; 66 } 67} 68 69//Setup VIM: ex: et ts=4 enc=utf-8 : 70