1<?php 2/** 3 * DokuWiki Plugin filelisting (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Szymon Olewniczak <dokuwiki@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10use dokuwiki\Cache\CacheRenderer; 11 12if (!defined('DOKU_INC')) { 13 die(); 14} 15 16class action_plugin_filelisting_cache extends DokuWiki_Action_Plugin 17{ 18 19 /** 20 * Registers a callback function for a given event 21 * 22 * @param Doku_Event_Handler $controller DokuWiki's event controller object 23 * 24 * @return void 25 */ 26 public function register(Doku_Event_Handler $controller) 27 { 28 $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handle_parser_cache_use'); 29 } 30 31 /** 32 * [Custom event handler which performs action] 33 * 34 * @param Doku_Event $event event object by reference 35 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 36 * handler was registered] 37 * 38 * @return void 39 */ 40 public function handle_parser_cache_use(Doku_Event $event, $param) 41 { 42 global $conf; 43 /** @var CacheRenderer $cache */ 44 $cache = $event->data; 45 46 if(!isset($cache->page)) return; 47 //purge only xhtml cache 48 if($cache->mode != 'xhtml') return; 49 //Check if it is an filelisting page 50 $filelisting = p_get_metadata($cache->page, 'filelisting'); 51 if(!$filelisting) return; 52 53 //since every user can have diffirent view regarding the permission 54 //and the cache invalidates every files change - just ignore it. 55 $cache->_nocache = true; 56 } 57} 58 59// vim:ts=4:sw=4:et: 60