aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Cache/CacheParser.php
diff options
context:
space:
mode:
authorAndreas Gohr <gohr@cosmocode.de>2019-10-10 09:55:14 +0200
committerAndreas Gohr <gohr@cosmocode.de>2019-10-10 09:55:14 +0200
commit31a58aba4c24b34c34ad5764d1a35b7c398c3a2c (patch)
tree7f4d1546fbb69863a7d366fc1ff647f784853b68 /inc/Cache/CacheParser.php
parentaf7ba5aa0bd10fc0ad9ef983006305b4c5a8ed42 (diff)
parentc0c77cd20b23921c9e893bb70b99f38be153875a (diff)
downloaddokuwiki-31a58aba4c24b34c34ad5764d1a35b7c398c3a2c.tar.gz
dokuwiki-31a58aba4c24b34c34ad5764d1a35b7c398c3a2c.zip
Merge branch 'psr2'
* psr2: (160 commits) fixed merge error Moved parts of the Asian word handling to its own class ignore snake_case error of substr_replace fixed some line length errors ignore PSR2 in the old form class fix PSR2 error in switch statement replaced deprecated utf8 functions formatting cleanup mark old utf8 functions deprecated some more PSR2 cleanup Some cleanup for the UTF-8 stuff Moved all utf8 methods to their own namespaced classes Create separate table files for UTF-8 handling Ignore mixed concerns in loader Use type safe comparisons in loader Remove obsolete include adjust phpcs exclude patterns for new plugin classes 🚚 Move Subscription class to deprecated.php ♻️ Split up ChangesSubscriptionSender into multiple classes Minor optimizations in PluginController ...
Diffstat (limited to 'inc/Cache/CacheParser.php')
-rw-r--r--inc/Cache/CacheParser.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/inc/Cache/CacheParser.php b/inc/Cache/CacheParser.php
new file mode 100644
index 000000000..86453bed5
--- /dev/null
+++ b/inc/Cache/CacheParser.php
@@ -0,0 +1,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->_event = '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();
+ }
+
+}