@@ -19,12 +19,12 @@ |
||
19 | 19 | $this->collections = array(); |
20 | 20 | } |
21 | 21 | |
22 | - public function getCollections () |
|
22 | + public function getCollections() |
|
23 | 23 | { |
24 | 24 | return $this->collections; |
25 | 25 | } |
26 | 26 | |
27 | - public function parseCollections ($folders) |
|
27 | + public function parseCollections($folders) |
|
28 | 28 | { |
29 | 29 | if ($folders === null) |
30 | 30 | { |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | abstract class ArrayUtilities |
6 | 6 | { |
7 | - public static function array_merge_defaults (array &$array1, array &$array2, $keyField) |
|
7 | + public static function array_merge_defaults(array &$array1, array &$array2, $keyField) |
|
8 | 8 | { |
9 | 9 | $merged = $array1; |
10 | 10 |
@@ -20,18 +20,15 @@ |
||
20 | 20 | $valueMerged = true; |
21 | 21 | |
22 | 22 | break; |
23 | - } |
|
24 | - else if ($mergedKey == $key) |
|
23 | + } else if ($mergedKey == $key) |
|
25 | 24 | { |
26 | 25 | if (is_numeric($mergedKey)) |
27 | 26 | { |
28 | 27 | $merged[] = $value; |
29 | - } |
|
30 | - else if (is_array($item)) |
|
28 | + } else if (is_array($item)) |
|
31 | 29 | { |
32 | 30 | $item = array_unique(array_merge($item, $value)); |
33 | - } |
|
34 | - else |
|
31 | + } else |
|
35 | 32 | { |
36 | 33 | $item = $value; |
37 | 34 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | protected $highlighter; |
10 | 10 | |
11 | - public function __construct () |
|
11 | + public function __construct() |
|
12 | 12 | { |
13 | 13 | $this->highlighter = new Highlighter(); |
14 | 14 | } |
@@ -24,8 +24,7 @@ |
||
24 | 24 | { |
25 | 25 | $highlighted = $this->highlighter->highlight($language, $block['element']['text']['text']); |
26 | 26 | $block['element']['text']['text'] = $highlighted->value; |
27 | - } |
|
28 | - catch (\DomainException $exception) {} |
|
27 | + } catch (\DomainException $exception) {} |
|
29 | 28 | } |
30 | 29 | |
31 | 30 | return $block; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param ConsoleInterface|OutputInterface|null $output |
25 | 25 | */ |
26 | - public function __construct ($output = null) |
|
26 | + public function __construct($output = null) |
|
27 | 27 | { |
28 | 28 | $this->logger = null; |
29 | 29 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return OutputInterface |
41 | 41 | */ |
42 | - public function getOutputInterface () |
|
42 | + public function getOutputInterface() |
|
43 | 43 | { |
44 | 44 | return $this->output; |
45 | 45 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return null |
55 | 55 | */ |
56 | - public function log ($level, $message, array $context = array()) |
|
56 | + public function log($level, $message, array $context = array()) |
|
57 | 57 | { |
58 | 58 | if (!is_null($this->output)) |
59 | 59 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string|array $messages The message as an array of lines of a single string |
68 | 68 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
69 | 69 | */ |
70 | - public function writeln ($messages, $options = 0) |
|
70 | + public function writeln($messages, $options = 0) |
|
71 | 71 | { |
72 | 72 | $this->output->writeln($messages, $options); |
73 | 73 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param OutputInterface $output |
107 | 107 | */ |
108 | - public function __construct (OutputInterface $output) |
|
108 | + public function __construct(OutputInterface $output) |
|
109 | 109 | { |
110 | 110 | $this->output = new ConsoleInterface($output); |
111 | 111 | $this->cm = new CollectionManager(); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @param bool $cleanDirectory Clean the target directing before rebuilding |
121 | 121 | */ |
122 | - public function build ($cleanDirectory) |
|
122 | + public function build($cleanDirectory) |
|
123 | 123 | { |
124 | 124 | // Parse DataItems |
125 | 125 | $this->dm->setConsoleOutput($this->output); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | - public function watch () |
|
162 | + public function watch() |
|
163 | 163 | { |
164 | 164 | $this->build(true); |
165 | 165 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @throws \LogicException |
209 | 209 | */ |
210 | - public function setConfiguration ($configFile) |
|
210 | + public function setConfiguration($configFile) |
|
211 | 211 | { |
212 | 212 | if (!$this->fs->exists($configFile) && !$this->getConfLess()) |
213 | 213 | { |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | $this->configuration = new Configuration($configFile, $this->output); |
226 | 226 | } |
227 | 227 | |
228 | - public function handleSingleFile ($filePath) |
|
228 | + public function handleSingleFile($filePath) |
|
229 | 229 | { |
230 | 230 | $filePath = ltrim($filePath, DIRECTORY_SEPARATOR); |
231 | 231 | $pageViewDirs = $this->configuration->getPageViewFolders(); |
232 | - $collectionDirs = array_map(function ($a) { return $a["folder"]; }, $this->configuration->getCollectionsFolders()); |
|
232 | + $collectionDirs = array_map(function($a) { return $a["folder"]; }, $this->configuration->getCollectionsFolders()); |
|
233 | 233 | |
234 | 234 | $_paths = explode(DIRECTORY_SEPARATOR, $filePath); |
235 | 235 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool True when being built with no configuration file |
250 | 250 | */ |
251 | - public function getConfLess () |
|
251 | + public function getConfLess() |
|
252 | 252 | { |
253 | 253 | return $this->confLess; |
254 | 254 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @param bool $status True when a website should be built without a configuration |
260 | 260 | */ |
261 | - public function setConfLess ($status) |
|
261 | + public function setConfLess($status) |
|
262 | 262 | { |
263 | 263 | $this->confLess = $status; |
264 | 264 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return bool True when the website is being built in safe mode |
272 | 272 | */ |
273 | - public function getSafeMode () |
|
273 | + public function getSafeMode() |
|
274 | 274 | { |
275 | 275 | return $this->safeMode; |
276 | 276 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @param bool $bool True if a website should be built in safe mode |
282 | 282 | */ |
283 | - public function setSafeMode ($bool) |
|
283 | + public function setSafeMode($bool) |
|
284 | 284 | { |
285 | 285 | $this->safeMode = $bool; |
286 | 286 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param bool $cleanDirectory Clean the target directory |
292 | 292 | */ |
293 | - private function createFolderStructure ($cleanDirectory) |
|
293 | + private function createFolderStructure($cleanDirectory) |
|
294 | 294 | { |
295 | 295 | $tarDir = $this->fs->absolutePath($this->configuration->getTargetFolder()); |
296 | 296 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @todo Load custom Twig extensions from _config.yml |
312 | 312 | */ |
313 | - private function configureTwig () |
|
313 | + private function configureTwig() |
|
314 | 314 | { |
315 | 315 | $loader = new Twig_Loader_Filesystem(array( |
316 | 316 | getcwd() |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | /** |
363 | 363 | * Copy static files from a theme to the compiled website |
364 | 364 | */ |
365 | - private function copyThemeAssets () |
|
365 | + private function copyThemeAssets() |
|
366 | 366 | { |
367 | 367 | $theme = $this->configuration->getTheme(); |
368 | 368 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * - Does not start with an underscore or is inside of a directory starting with an underscore |
405 | 405 | * - Does not start with a period or is inside of a directory starting with a period |
406 | 406 | */ |
407 | - private function copyStaticFiles () |
|
407 | + private function copyStaticFiles() |
|
408 | 408 | { |
409 | 409 | $finder = $this->fs->getFinder( |
410 | 410 | $this->getConfiguration()->getIncludes(), |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param SplFileInfo $file The relative path of the file to be copied |
426 | 426 | * @param string $prefix |
427 | 427 | */ |
428 | - private function copyToCompiledSite ($file, $prefix = "") |
|
428 | + private function copyToCompiledSite($file, $prefix = "") |
|
429 | 429 | { |
430 | 430 | if (!$this->fs->exists($file)) { return; } |
431 | 431 |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | try |
183 | 183 | { |
184 | 184 | $this->build(false); |
185 | - } |
|
186 | - catch (\Exception $e) |
|
185 | + } catch (\Exception $e) |
|
187 | 186 | { |
188 | 187 | $this->output->error(sprintf("Your website failed to build with the following error: %s", |
189 | 188 | $e->getMessage() |
@@ -236,8 +235,7 @@ discard block |
||
236 | 235 | if (count($_paths) > 1 && (in_array($_paths[0], $collectionDirs) || in_array($_paths[0], $pageViewDirs))) |
237 | 236 | { |
238 | 237 | |
239 | - } |
|
240 | - else |
|
238 | + } else |
|
241 | 239 | { |
242 | 240 | $this->copyToCompiledSite($filePath); |
243 | 241 | } |
@@ -324,8 +322,7 @@ discard block |
||
324 | 322 | try |
325 | 323 | { |
326 | 324 | $loader->addPath($this->fs->absolutePath('_themes', $this->configuration->getTheme())); |
327 | - } |
|
328 | - catch (\Twig_Error_Loader $e) |
|
325 | + } catch (\Twig_Error_Loader $e) |
|
329 | 326 | { |
330 | 327 | $this->output->error("The following theme could not be loaded: {theme}", array( |
331 | 328 | "theme" => $theme |
@@ -436,8 +433,7 @@ discard block |
||
436 | 433 | try |
437 | 434 | { |
438 | 435 | $this->outputDirectory->copyFile($filePath, $siteTargetPath); |
439 | - } |
|
440 | - catch (\Exception $e) |
|
436 | + } catch (\Exception $e) |
|
441 | 437 | { |
442 | 438 | $this->output->error($e->getMessage()); |
443 | 439 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @return string Twig body |
9 | 9 | */ |
10 | - public function getContent () |
|
10 | + public function getContent() |
|
11 | 11 | { |
12 | 12 | return $this->bodyContent; |
13 | 13 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @return bool |
19 | 19 | */ |
20 | - public function isDynamicPage () |
|
20 | + public function isDynamicPage() |
|
21 | 21 | { |
22 | 22 | return isset($this->frontMatter['collection']); |
23 | 23 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return mixed|null |
123 | 123 | */ |
124 | - public function __get ($name) |
|
124 | + public function __get($name) |
|
125 | 125 | { |
126 | 126 | return (array_key_exists($name, $this->frontMatter) ? $this->frontMatter[$name] : null); |
127 | 127 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return bool |
136 | 136 | */ |
137 | - public function __isset ($name) |
|
137 | + public function __isset($name) |
|
138 | 138 | { |
139 | 139 | return array_key_exists($name, $this->frontMatter); |
140 | 140 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @param array|null $variables An array of YAML variables to use in evaluating the `$permalink` value |
144 | 144 | */ |
145 | - public function evaluateFrontMatter ($variables = null) |
|
145 | + public function evaluateFrontMatter($variables = null) |
|
146 | 146 | { |
147 | 147 | if (!is_null($variables)) |
148 | 148 | { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function getContent () |
|
160 | + public function getContent() |
|
161 | 161 | { |
162 | 162 | if (!$this->bodyContentEvaluated) |
163 | 163 | { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $this->bodyContentEvaluated = true; |
186 | 186 | } |
187 | 187 | |
188 | - return (string)$this->bodyContent; |
|
188 | + return (string) $this->bodyContent; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return array |
197 | 197 | */ |
198 | - final public function getFrontMatter ($evaluateYaml = true) |
|
198 | + final public function getFrontMatter($evaluateYaml = true) |
|
199 | 199 | { |
200 | 200 | if ($this->frontMatter === null) |
201 | 201 | { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - final public function getPermalink () |
|
218 | + final public function getPermalink() |
|
219 | 219 | { |
220 | 220 | if ($this->permalinkEvaluated) { |
221 | 221 | return $this->frontMatter['permalink']; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string |
240 | 240 | */ |
241 | - final public function getTargetFile () |
|
241 | + final public function getTargetFile() |
|
242 | 242 | { |
243 | 243 | $extension = $this->fs->getExtension($this->getPermalink()); |
244 | 244 | $targetFile = $this->getPermalink(); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return string |
257 | 257 | */ |
258 | - final public function getFilePath () |
|
258 | + final public function getFilePath() |
|
259 | 259 | { |
260 | 260 | return $this->filePath; |
261 | 261 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @throws YamlVariableUndefinedException A FrontMatter variable used does not exist |
269 | 269 | */ |
270 | - final protected function evaluateYaml (&$yaml) |
|
270 | + final protected function evaluateYaml(&$yaml) |
|
271 | 271 | { |
272 | 272 | foreach ($yaml as $key => $value) |
273 | 273 | { |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @throws YamlVariableUndefinedException A FrontMatter variable used does not exist |
294 | 294 | */ |
295 | - final protected static function evaluateYamlVar ($string, $yaml) |
|
295 | + final protected static function evaluateYamlVar($string, $yaml) |
|
296 | 296 | { |
297 | 297 | $variables = array(); |
298 | 298 | $varRegex = '/(%[a-zA-Z]+)/'; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | /** |
321 | 321 | * Handle special front matter values that need special treatment or have special meaning to a Content Item |
322 | 322 | */ |
323 | - private function handleSpecialFrontMatter () |
|
323 | + private function handleSpecialFrontMatter() |
|
324 | 324 | { |
325 | 325 | if (isset($this->frontMatter['date'])) |
326 | 326 | { |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - private function getPathPermalink () |
|
353 | + private function getPathPermalink() |
|
354 | 354 | { |
355 | 355 | // Remove the protocol of the path, if there is one and prepend a '/' to the beginning |
356 | 356 | $cleanPath = preg_replace('/[\w|\d]+:\/\//', '', $this->filePath); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @return string $permalink The sanitized permalink |
377 | 377 | */ |
378 | - private function sanitizePermalink ($permalink) |
|
378 | + private function sanitizePermalink($permalink) |
|
379 | 379 | { |
380 | 380 | // Remove multiple '/' together |
381 | 381 | $permalink = preg_replace('/\/+/', '/', $permalink); |
@@ -177,10 +177,12 @@ discard block |
||
177 | 177 | break; |
178 | 178 | } |
179 | 179 | |
180 | - if (!is_null($pd)) // No parser needed |
|
180 | + if (!is_null($pd)) { |
|
181 | + // No parser needed |
|
181 | 182 | { |
182 | 183 | $this->bodyContent = $pd->parse($this->bodyContent); |
183 | 184 | } |
185 | + } |
|
184 | 186 | |
185 | 187 | $this->bodyContentEvaluated = true; |
186 | 188 | } |
@@ -200,8 +202,7 @@ discard block |
||
200 | 202 | if ($this->frontMatter === null) |
201 | 203 | { |
202 | 204 | $this->frontMatter = array(); |
203 | - } |
|
204 | - else if (!$this->frontMatterEvaluated && $evaluateYaml && !empty($evaluateYaml)) |
|
205 | + } else if (!$this->frontMatterEvaluated && $evaluateYaml && !empty($evaluateYaml)) |
|
205 | 206 | { |
206 | 207 | $this->evaluateYaml($this->frontMatter); |
207 | 208 | $this->frontMatterEvaluated = true; |
@@ -274,8 +275,7 @@ discard block |
||
274 | 275 | if (is_array($yaml[$key])) |
275 | 276 | { |
276 | 277 | $this->evaluateYaml($yaml[$key]); |
277 | - } |
|
278 | - else |
|
278 | + } else |
|
279 | 279 | { |
280 | 280 | $yaml[$key] = $this->evaluateYamlVar($value, $this->frontMatter); |
281 | 281 | } |
@@ -328,8 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | // Coming from a string variable |
330 | 330 | $itemDate = new \DateTime($this->frontMatter['date']); |
331 | - } |
|
332 | - catch (\Exception $e) |
|
331 | + } catch (\Exception $e) |
|
333 | 332 | { |
334 | 333 | // YAML has parsed them to Epoch time |
335 | 334 | $itemDate = \DateTime::createFromFormat('U', $this->frontMatter['date']); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | class WhereFilter |
6 | 6 | { |
7 | - public function __invoke ($array, $key, $comparison, $value) |
|
7 | + public function __invoke($array, $key, $comparison, $value) |
|
8 | 8 | { |
9 | 9 | $results = array(); |
10 | 10 | $this->search_r($array, $key, $comparison, $value, $results); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | return new \Twig_SimpleFilter('where', new self()); |
18 | 18 | } |
19 | 19 | |
20 | - private function search_r ($array, $key, $comparison, $value, &$results) |
|
20 | + private function search_r($array, $key, $comparison, $value, &$results) |
|
21 | 21 | { |
22 | 22 | if (!is_array($array)) |
23 | 23 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - private function compare ($array, $key, $comparison, $value) |
|
38 | + private function compare($array, $key, $comparison, $value) |
|
39 | 39 | { |
40 | 40 | if ($comparison === "==") |
41 | 41 | { |
@@ -40,24 +40,19 @@ |
||
40 | 40 | if ($comparison === "==") |
41 | 41 | { |
42 | 42 | return (isset($array[$key]) && $array[$key] === $value); |
43 | - } |
|
44 | - elseif ($comparison === "!=") |
|
43 | + } elseif ($comparison === "!=") |
|
45 | 44 | { |
46 | 45 | return (isset($array[$key]) && $array[$key] !== $value); |
47 | - } |
|
48 | - elseif ($comparison === ">") |
|
46 | + } elseif ($comparison === ">") |
|
49 | 47 | { |
50 | 48 | return (isset($array[$key]) && $array[$key] > $value); |
51 | - } |
|
52 | - elseif ($comparison === ">=") |
|
49 | + } elseif ($comparison === ">=") |
|
53 | 50 | { |
54 | 51 | return (isset($array[$key]) && $array[$key] >= $value); |
55 | - } |
|
56 | - elseif ($comparison === "<") |
|
52 | + } elseif ($comparison === "<") |
|
57 | 53 | { |
58 | 54 | return (isset($array[$key]) && $array[$key] < $value); |
59 | - } |
|
60 | - elseif ($comparison === "<=") |
|
55 | + } elseif ($comparison === "<=") |
|
61 | 56 | { |
62 | 57 | return (isset($array[$key]) && $array[$key] <= $value); |
63 | 58 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | class TwigExtension extends \Twig_Extension |
6 | 6 | { |
7 | - public function getFilters () |
|
7 | + public function getFilters() |
|
8 | 8 | { |
9 | 9 | return array( |
10 | 10 | GroupByFilter::get(), |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | ); |
14 | 14 | } |
15 | 15 | |
16 | - public function getFunctions () |
|
16 | + public function getFunctions() |
|
17 | 17 | { |
18 | 18 | return array( |
19 | 19 | BaseUrlFunction::get(), |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string The extension name |
28 | 28 | */ |
29 | - public function getName () |
|
29 | + public function getName() |
|
30 | 30 | { |
31 | 31 | return 'stakx_core_extension'; |
32 | 32 | } |