1<?php 2 3/** 4 * DokuWiki DAVCal PlugIn - Cache component 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Böhler <dev@aboehler.at> 7 */ 8 9if(!defined('DOKU_INC')) die(); 10 11class action_plugin_davcard_cache extends DokuWiki_Action_Plugin { 12 13 function __construct() { 14 15 } 16 17 function register(Doku_Event_Handler $controller) { 18 $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handle_parser_cache_use'); 19 } 20 21 function handle_parser_cache_use(Doku_Event $event, $param) 22 { 23 $cache = &$event->data; 24 if(!isset($cache->page)) return; 25 //purge only xhtml cache 26 if($cache->mode != "xhtml") return; 27 28 $meta = p_get_metadata($cache->page, 'plugin_davcard'); 29 if($meta === null) 30 return; 31 // Force re-caching if the webdavclient has synced 32 if(isset($meta['webdavclient'])) 33 { 34 $wdc =& plugin_load('helper', 'webdavclient'); 35 if(is_null($wdc)) 36 return; 37 foreach($meta['webdavclient'] as $connectionId) 38 { 39 $cache->depends['files'][] = $wdc->getLastSyncChangeFileForConnection($connectionId); 40 } 41 } 42 // Disable caching if there is a tabular addressbook 43 if(isset($meta['addressbooks']) && in_array($cache->page, $meta['addressbooks']['id'])) 44 { 45 $event->preventDefault(); 46 $event->stopPropagation(); 47 $event->result = false; 48 } 49 } 50 51} 52 53 54