forked from cosmocode/changes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.php
More file actions
57 lines (50 loc) · 1.58 KB
/
action.php
File metadata and controls
57 lines (50 loc) · 1.58 KB
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
<?php
/**
* Changes Plugin: List the most recent changes of the wiki
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Mykola Ostrovskyy <spambox03@mail.ru>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');
class action_plugin_changes extends DokuWiki_Action_Plugin {
/**
* Return some info
*/
function getInfo() {
return confToHash(dirname(__FILE__).'/plugin.info.txt');
}
/**
* Register callbacks
*/
function register($controller) {
$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'beforeParserCacheUse');
}
/**
* Handle PARSER_CACHE_USE:BEFORE event
*/
function beforeParserCacheUse($event, $param) {
global $ID;
$cache = $event->data;
if(isset($cache->mode) && ($cache->mode == 'xhtml')){
$depends = p_get_metadata($ID, 'relation depends');
if(!empty($depends) && isset($depends['rendering'])){
$this->addDependencies($cache, array_keys($depends['rendering']));
}
}
}
/**
* Add extra dependencies to the cache
*/
function addDependencies($cache, $depends) {
foreach($depends as $file){
if(!in_array($file, $cache->depends['files']) && @file_exists($file)){
$cache->depends['files'][] = $file;
}
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :