blob: ed476f4719cd6fd654e3f5eaa2946ff3c343ed1b (
plain)
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
60
61
62
63
64
|
<?php
namespace dokuwiki\Cache;
/**
* Parser caching
*/
class CacheParser extends Cache
{
public $file = ''; // source file for cache
public $mode = ''; // input mode (represents the processing the input file will undergo)
public $page = '';
/**
*
* @param string $id page id
* @param string $file source file for cache
* @param string $mode input mode
*/
public function __construct($id, $file, $mode)
{
if ($id) {
$this->page = $id;
}
$this->file = $file;
$this->mode = $mode;
$this->setEvent('PARSER_CACHE_USE');
parent::__construct($file . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . $mode);
}
/**
* method contains cache use decision logic
*
* @return bool see useCache()
*/
public function makeDefaultCacheDecision()
{
if (!file_exists($this->file)) {
return false;
} // source exists?
return parent::makeDefaultCacheDecision();
}
protected function addDependencies()
{
// parser cache file dependencies ...
$files = array(
$this->file, // ... source
DOKU_INC . 'inc/parser/Parser.php', // ... parser
DOKU_INC . 'inc/parser/handler.php', // ... handler
);
$files = array_merge($files, getConfigFiles('main')); // ... wiki settings
$this->depends['files'] = !empty($this->depends['files']) ?
array_merge($files, $this->depends['files']) :
$files;
parent::addDependencies();
}
}
|