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