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', 'BEFORE', $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 cache_renderer $cache */ 39 $cache = $event->data; 40 41 if(!$cache->page) return; 42 //purge only xhtml cache 43 if($cache->mode != 'xhtml') return; 44 45 //Check if it is plugins 46 $ireadit_list = p_get_metadata($cache->page, 'plugin ireadit_list'); 47 if(!$ireadit_list) return; 48 49 if ($ireadit_list['dynamic_user']) { 50 $cache->_nocache = true; 51 } else { 52 /** @var helper_plugin_ireadit_db $db_helper */ 53 $db_helper = plugin_load('helper', 'ireadit_db'); 54 $cache->depends['files'][] = $db_helper->getDB()->getAdapter()->getDbFile(); 55 } 56 } 57} 58