1<?php 2/** 3 * DokuWiki Plugin log (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Adrian Lang <lang@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once DOKU_PLUGIN.'log/common.php'; 17require_once DOKU_PLUGIN.'action.php'; 18 19class action_plugin_log extends DokuWiki_Action_Plugin { 20 21 function register(Doku_Event_Handler $controller) { 22 $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_action_act_preprocess'); 23 $controller->register_hook('PARSER_CACHE_USE','BEFORE', $this, 'handle_cache_prepare'); 24 } 25 26 function handle_cache_prepare(&$event, $param) { 27 $cache =& $event->data; 28 29 // we're only interested in wiki pages 30 if (!isset($cache->page)) return; 31 32 // get meta data 33 if (!p_get_metadata($cache->page, 'relation logplugin')) { 34 // No log used 35 return; 36 } 37 38 $cache->depends['files'][] = wikiFN(log_get_log_page($this, $cache->page)); 39 } 40 41 function handle_action_act_preprocess(&$event, $param) { 42 if ($event->data !== 'log_new') { 43 return; 44 } 45 $this->handle(); 46 global $ACT; 47 $ACT = 'show'; 48 } 49 50 private function handle() { 51 try { 52 log_add_log_entry($this); 53 } catch (Exception $e) { 54 msg($e->getMessage(), -1); 55 } 56 } 57} 58 59// vim:ts=4:sw=4:et:enc=utf-8: 60