|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace dokuwiki\Cache; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Parser caching |
|
7
|
|
|
*/ |
|
8
|
|
|
class CacheParser extends Cache |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
public $file = ''; // source file for cache |
|
12
|
|
|
public $mode = ''; // input mode (represents the processing the input file will undergo) |
|
13
|
|
|
public $page = ''; |
|
14
|
|
|
|
|
15
|
|
|
public $_event = 'PARSER_CACHE_USE'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* |
|
19
|
|
|
* @param string $id page id |
|
20
|
|
|
* @param string $file source file for cache |
|
21
|
|
|
* @param string $mode input mode |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct($id, $file, $mode) |
|
24
|
|
|
{ |
|
25
|
|
|
if ($id) { |
|
26
|
|
|
$this->page = $id; |
|
27
|
|
|
} |
|
28
|
|
|
$this->file = $file; |
|
29
|
|
|
$this->mode = $mode; |
|
30
|
|
|
|
|
31
|
|
|
parent::__construct($file . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . $mode); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* method contains cache use decision logic |
|
36
|
|
|
* |
|
37
|
|
|
* @return bool see useCache() |
|
38
|
|
|
*/ |
|
39
|
|
|
public function _useCache() |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
if (!file_exists($this->file)) { |
|
43
|
|
|
return false; |
|
44
|
|
|
} // source exists? |
|
45
|
|
|
return parent::_useCache(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
protected function _addDependencies() |
|
49
|
|
|
{ |
|
50
|
|
|
|
|
51
|
|
|
// parser cache file dependencies ... |
|
52
|
|
|
$files = array( |
|
53
|
|
|
$this->file, // ... source |
|
54
|
|
|
DOKU_INC . 'inc/parser/Parser.php', // ... parser |
|
55
|
|
|
DOKU_INC . 'inc/parser/handler.php', // ... handler |
|
56
|
|
|
); |
|
57
|
|
|
$files = array_merge($files, getConfigFiles('main')); // ... wiki settings |
|
58
|
|
|
|
|
59
|
|
|
$this->depends['files'] = !empty($this->depends['files']) ? |
|
60
|
|
|
array_merge($files, $this->depends['files']) : |
|
61
|
|
|
$files; |
|
62
|
|
|
parent::_addDependencies(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|