|
@@ -35,7 +35,9 @@ discard block |
|
|
block discarded – undo |
|
35
|
35
|
$time = time(); |
|
36
|
36
|
|
|
37
|
37
|
foreach ($this->getRules($template) as $rule) { |
|
38
|
|
- if ($rule->shouldRun($time)) $this->executeTssRule($rule, $template, $data); |
|
|
38
|
+ if ($rule->shouldRun($time)) { |
|
|
39
|
+ $this->executeTssRule($rule, $template, $data); |
|
|
40
|
+ } |
|
39
|
41
|
} |
|
40
|
42
|
|
|
41
|
43
|
$output = $template->output($document); |
|
@@ -47,7 +49,9 @@ discard block |
|
|
block discarded – undo |
|
47
|
49
|
private function executeTssRule($rule, $template, $data) { |
|
48
|
50
|
$rule->touch(); |
|
49
|
51
|
$hook = new Hook\Rule($rule->properties, new Hook\PseudoMatcher($rule->pseudo, $data), $data); |
|
50
|
|
- foreach ($this->registeredProperties as $properties) $hook->registerProperties($properties); |
|
|
52
|
+ foreach ($this->registeredProperties as $properties) { |
|
|
53
|
+ $hook->registerProperties($properties); |
|
|
54
|
+ } |
|
51
|
55
|
$template->addHook($rule->query, $hook); |
|
52
|
56
|
} |
|
53
|
57
|
|
|
@@ -55,8 +59,9 @@ discard block |
|
|
block discarded – undo |
|
55
|
59
|
if (trim($this->template)[0] !== '<') { |
|
56
|
60
|
$xml = $this->cache->load($this->template, filemtime($this->template)); |
|
57
|
61
|
return $xml ? $xml : $this->cache->write($this->template, ['body' => file_get_contents($this->template), 'headers' => []]); |
|
|
62
|
+ } else { |
|
|
63
|
+ return ['body' => $this->template, 'headers' => []]; |
|
58
|
64
|
} |
|
59
|
|
- else return ['body' => $this->template, 'headers' => []]; |
|
60
|
65
|
} |
|
61
|
66
|
|
|
62
|
67
|
private function getRules($template) { |
|
@@ -64,10 +69,14 @@ discard block |
|
|
block discarded – undo |
|
64
|
69
|
$this->baseDir = dirname(realpath($this->tss)) . DIRECTORY_SEPARATOR; |
|
65
|
70
|
$key = $this->tss . $template->getPrefix() . $this->baseDir; |
|
66
|
71
|
$rules = $this->cache->load($key, filemtime($this->tss)); |
|
67
|
|
- if (!$rules) return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
68
|
|
- else return $rules; |
|
|
72
|
+ if (!$rules) { |
|
|
73
|
+ return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
|
74
|
+ } else { |
|
|
75
|
+ return $rules; |
|
|
76
|
+ } |
|
|
77
|
+ } else { |
|
|
78
|
+ return (new Sheet($this->tss, $this->baseDir, $template->getPrefix()))->parse(); |
|
69
|
79
|
} |
|
70
|
|
- else return (new Sheet($this->tss, $this->baseDir, $template->getPrefix()))->parse(); |
|
71
|
80
|
} |
|
72
|
81
|
|
|
73
|
82
|
private function getBasicProperties($data, $locale, &$headers) { |
|
@@ -75,7 +84,9 @@ discard block |
|
|
block discarded – undo |
|
75
|
84
|
$basicProperties->registerFormatter(new Formatter\Number($locale)); |
|
76
|
85
|
$basicProperties->registerFormatter(new Formatter\Date($locale)); |
|
77
|
86
|
$basicProperties->registerFormatter(new Formatter\StringFormatter()); |
|
78
|
|
- foreach ($this->formatters as $formatter) $basicProperties->registerFormatter($formatter); |
|
|
87
|
+ foreach ($this->formatters as $formatter) { |
|
|
88
|
+ $basicProperties->registerFormatter($formatter); |
|
|
89
|
+ } |
|
79
|
90
|
|
|
80
|
91
|
return isset($this->userCache) ? new Hook\Cache($basicProperties, $this->userCache) : $basicProperties; |
|
81
|
92
|
} |
|
@@ -85,9 +96,13 @@ discard block |
|
|
block discarded – undo |
|
85
|
96
|
} |
|
86
|
97
|
|
|
87
|
98
|
private function getLocale() { |
|
88
|
|
- if (is_array($this->locale)) return $this->locale; |
|
89
|
|
- 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); |
|
90
|
|
- else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
|
99
|
+ if (is_array($this->locale)) { |
|
|
100
|
+ return $this->locale; |
|
|
101
|
+ } else if (strlen($this->locale) > 0) { |
|
|
102
|
+ return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true); |
|
|
103
|
+ } else { |
|
|
104
|
+ return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
|
105
|
+ } |
|
91
|
106
|
} |
|
92
|
107
|
|
|
93
|
108
|
public function registerProperties($object) { |