|
@@ -36,7 +36,7 @@ discard block |
|
|
block discarded – undo |
|
36
|
36
|
|
|
37
|
37
|
$cachedOutput = $this->loadTemplate(); |
|
38
|
38
|
//To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does |
|
39
|
|
- $template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>' . $cachedOutput['body'] . '</template>' ); |
|
|
39
|
+ $template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>'.$cachedOutput['body'].'</template>'); |
|
40
|
40
|
|
|
41
|
41
|
//Allow $time to be set via arguments to spoof time passage during tests |
|
42
|
42
|
foreach ($this->getRules($template) as $rule) { |
|
@@ -92,11 +92,11 @@ discard block |
|
|
block discarded – undo |
|
92
|
92
|
//N.b. only files can be cached |
|
93
|
93
|
private function getRules($template) { |
|
94
|
94
|
if (is_file($this->tss)) { |
|
95
|
|
- $this->baseDir = dirname(realpath($this->tss)) . DIRECTORY_SEPARATOR; |
|
|
95
|
+ $this->baseDir = dirname(realpath($this->tss)).DIRECTORY_SEPARATOR; |
|
96
|
96
|
//The cache for the key: the filename and template prefix |
|
97
|
97
|
//Each template may have a different prefix which changes the parsed TSS, |
|
98
|
98
|
//Because of this the cache needs to be generated for each template prefix. |
|
99
|
|
- $key = $this->tss . $template->getPrefix() . $this->baseDir; |
|
|
99
|
+ $key = $this->tss.$template->getPrefix().$this->baseDir; |
|
100
|
100
|
//Try to load the cached rules, if not set in the cache (or expired) parse the supplied sheet |
|
101
|
101
|
$rules = $this->cache->load($key, filemtime($this->tss)); |
|
102
|
102
|
if (!$rules) return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
@@ -111,8 +111,8 @@ discard block |
|
|
block discarded – undo |
|
111
|
111
|
|
|
112
|
112
|
private function getLocale() { |
|
113
|
113
|
if (is_array($this->locale)) return $this->locale; |
|
114
|
|
- else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true); |
|
115
|
|
- else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
|
114
|
+ else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'Formatter'.DIRECTORY_SEPARATOR.'Locale'.DIRECTORY_SEPARATOR.$this->locale.'.json'), true); |
|
|
115
|
+ else return json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'Formatter'.DIRECTORY_SEPARATOR.'Locale'.DIRECTORY_SEPARATOR.'enGB.json'), true); |
|
116
|
116
|
} |
|
117
|
117
|
|
|
118
|
118
|
public function registerProperty($name, Property $property) { |