1<?php 2/** 3 * DokuWiki Plugin notification (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Szymon Olewniczak <it@rid.pl> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) { 11 die(); 12} 13 14class action_plugin_ireadit_cache extends DokuWiki_Action_Plugin 15{ 16 17 /** 18 * Registers a callback function for a given event 19 * 20 * @param Doku_Event_Handler $controller DokuWiki's event controller object 21 * 22 * @return void 23 */ 24 public function register(Doku_Event_Handler $controller) 25 { 26 $controller->register_hook('PARSER_CACHE_USE', 'AFTER', $this, 'handle_parser_cache_use'); 27 } 28 29 /** 30 * @param Doku_Event $event event object by reference 31 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 32 * handler was registered] 33 * 34 * @return void 35 */ 36 public function handle_parser_cache_use(Doku_Event $event, $param) 37 { 38 /** @var \dokuwiki\Cache\CacheParser $cache */ 39 $cache = $event->data; 40 if ($cache->mode != 'xhtml') return true; 41 if (!$cache->page) return true; // not a page cache 42 43 //Check if it is plugins 44 if (p_get_metadata($cache->page, 'plugin_ireadit_list')) { 45 $event->result = false; 46 return true; 47 } 48 return true; 49 } 50} 51