@@ -58,7 +58,9 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function parsePageViews ($pageViewFolders) |
| 60 | 60 | { |
| 61 | - if (empty($pageViewFolders)) { return; } |
|
| 61 | + if (empty($pageViewFolders)) |
|
| 62 | + { |
|
| 63 | +return; } |
|
| 62 | 64 | |
| 63 | 65 | /** |
| 64 | 66 | * The name of the folder where PageViews are located |
@@ -109,7 +111,9 @@ discard block |
||
| 109 | 111 | */ |
| 110 | 112 | public function prepareDynamicPageViews ($collections) |
| 111 | 113 | { |
| 112 | - if (empty($collections)) { return; } |
|
| 114 | + if (empty($collections)) |
|
| 115 | + { |
|
| 116 | +return; } |
|
| 113 | 117 | |
| 114 | 118 | foreach ($this->dynamicPageViews as $pageView) |
| 115 | 119 | { |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function parseDataItems ($folders) |
| 66 | 66 | { |
| 67 | - if ($folders === null) { return; } |
|
| 67 | + if ($folders === null) |
|
| 68 | + { |
|
| 69 | +return; } |
|
| 68 | 70 | |
| 69 | 71 | foreach ($folders as $folder) |
| 70 | 72 | { |
@@ -84,7 +86,9 @@ discard block |
||
| 84 | 86 | */ |
| 85 | 87 | public function parseDataSets ($dataSets) |
| 86 | 88 | { |
| 87 | - if ($dataSets === null) { return; } |
|
| 89 | + if ($dataSets === null) |
|
| 90 | + { |
|
| 91 | +return; } |
|
| 88 | 92 | |
| 89 | 93 | /** |
| 90 | 94 | * The information which each DataSet has from the configuration file |
@@ -25,7 +25,9 @@ |
||
| 25 | 25 | $highlighted = $this->highlighter->highlight($language, $block['element']['text']['text']); |
| 26 | 26 | $block['element']['text']['text'] = $highlighted->value; |
| 27 | 27 | } |
| 28 | - catch (\DomainException $exception) {} |
|
| 28 | + catch (\DomainException $exception) |
|
| 29 | + { |
|
| 30 | +} |
|
| 29 | 31 | } |
| 30 | 32 | |
| 31 | 33 | return $block; |
@@ -168,7 +168,8 @@ discard block |
||
| 168 | 168 | $listener = $watcher->watch(getcwd()); |
| 169 | 169 | $targetPath = $this->getConfiguration()->getTargetFolder(); |
| 170 | 170 | |
| 171 | - $listener->onModify(function($resource, $path) use ($targetPath) { |
|
| 171 | + $listener->onModify(function($resource, $path) use ($targetPath) |
|
| 172 | + { |
|
| 172 | 173 | $filePath = $this->fs->getRelativePath($path); |
| 173 | 174 | |
| 174 | 175 | if ((substr($filePath, 0, strlen($targetPath)) === $targetPath) || |
@@ -229,7 +230,9 @@ discard block |
||
| 229 | 230 | { |
| 230 | 231 | $filePath = ltrim($filePath, DIRECTORY_SEPARATOR); |
| 231 | 232 | $pageViewDirs = $this->configuration->getPageViewFolders(); |
| 232 | - $collectionDirs = array_map(function ($a) { return $a["folder"]; }, $this->configuration->getCollectionsFolders()); |
|
| 233 | + $collectionDirs = array_map(function ($a) |
|
| 234 | + { |
|
| 235 | +return $a["folder"]; }, $this->configuration->getCollectionsFolders()); |
|
| 233 | 236 | |
| 234 | 237 | $_paths = explode(DIRECTORY_SEPARATOR, $filePath); |
| 235 | 238 | |
@@ -427,7 +430,9 @@ discard block |
||
| 427 | 430 | */ |
| 428 | 431 | private function copyToCompiledSite ($file, $prefix = "") |
| 429 | 432 | { |
| 430 | - if (!$this->fs->exists($file)) { return; } |
|
| 433 | + if (!$this->fs->exists($file)) |
|
| 434 | + { |
|
| 435 | +return; } |
|
| 431 | 436 | |
| 432 | 437 | $filePath = $file->getRealPath(); |
| 433 | 438 | $pathToStrip = $this->fs->appendPath(getcwd(), $prefix); |
@@ -177,10 +177,13 @@ discard block |
||
| 177 | 177 | break; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if (!is_null($pd)) // No parser needed |
|
| 180 | + if (!is_null($pd)) |
|
| 181 | + { |
|
| 182 | + // No parser needed |
|
| 181 | 183 | { |
| 182 | 184 | $this->bodyContent = $pd->parse($this->bodyContent); |
| 183 | 185 | } |
| 186 | + } |
|
| 184 | 187 | |
| 185 | 188 | $this->bodyContentEvaluated = true; |
| 186 | 189 | } |
@@ -217,13 +220,15 @@ discard block |
||
| 217 | 220 | */ |
| 218 | 221 | final public function getPermalink () |
| 219 | 222 | { |
| 220 | - if ($this->permalinkEvaluated) { |
|
| 223 | + if ($this->permalinkEvaluated) |
|
| 224 | + { |
|
| 221 | 225 | return $this->frontMatter['permalink']; |
| 222 | 226 | } |
| 223 | 227 | |
| 224 | 228 | $permalink = $this->frontMatter['permalink']; |
| 225 | 229 | |
| 226 | - if (empty($permalink)) { |
|
| 230 | + if (empty($permalink)) |
|
| 231 | + { |
|
| 227 | 232 | $permalink = $this->getPathPermalink(); |
| 228 | 233 | } |
| 229 | 234 | |
@@ -243,7 +248,8 @@ discard block |
||
| 243 | 248 | $extension = $this->fs->getExtension($this->getPermalink()); |
| 244 | 249 | $targetFile = $this->getPermalink(); |
| 245 | 250 | |
| 246 | - if (empty($extension)) { |
|
| 251 | + if (empty($extension)) |
|
| 252 | + { |
|
| 247 | 253 | $targetFile = rtrim($this->getPermalink(), '/') . '/index.html'; |
| 248 | 254 | } |
| 249 | 255 | |
@@ -359,7 +365,8 @@ discard block |
||
| 359 | 365 | // Check the first folder and see if it's a data folder (starts with an underscore) intended for stakx |
| 360 | 366 | $folders = explode('/', $cleanPath); |
| 361 | 367 | |
| 362 | - if (substr($folders[0], 0, 1) === '_') { |
|
| 368 | + if (substr($folders[0], 0, 1) === '_') |
|
| 369 | + { |
|
| 363 | 370 | array_shift($folders); |
| 364 | 371 | } |
| 365 | 372 | |
@@ -389,12 +396,14 @@ discard block |
||
| 389 | 396 | // Handle unnecessary extensions |
| 390 | 397 | $extensionsToStrip = array('twig'); |
| 391 | 398 | |
| 392 | - if (in_array($this->fs->getExtension($permalink), $extensionsToStrip)) { |
|
| 399 | + if (in_array($this->fs->getExtension($permalink), $extensionsToStrip)) |
|
| 400 | + { |
|
| 393 | 401 | $permalink = $this->fs->removeExtension($permalink); |
| 394 | 402 | } |
| 395 | 403 | |
| 396 | 404 | // Remove a special './' combination from the beginning of a path |
| 397 | - if (substr($permalink, 0, 2) === './') { |
|
| 405 | + if (substr($permalink, 0, 2) === './') |
|
| 406 | + { |
|
| 398 | 407 | $permalink = substr($permalink, 2); |
| 399 | 408 | } |
| 400 | 409 | |
@@ -36,13 +36,17 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -if (function_exists('mb_get_info')) { |
|
| 39 | +if (function_exists('mb_get_info')) |
|
| 40 | +{ |
|
| 40 | 41 | function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
| 41 | 42 | { |
| 42 | - if (mb_strlen($value, $env->getCharset()) > $length) { |
|
| 43 | - if ($preserve) { |
|
| 43 | + if (mb_strlen($value, $env->getCharset()) > $length) |
|
| 44 | + { |
|
| 45 | + if ($preserve) |
|
| 46 | + { |
|
| 44 | 47 | // If breakpoint is on the last word, return the value without separator. |
| 45 | - if (false === ($breakpoint = mb_strpos($value, ' ', $length, $env->getCharset()))) { |
|
| 48 | + if (false === ($breakpoint = mb_strpos($value, ' ', $length, $env->getCharset()))) |
|
| 49 | + { |
|
| 46 | 50 | return $value; |
| 47 | 51 | } |
| 48 | 52 | |
@@ -65,8 +69,10 @@ discard block |
||
| 65 | 69 | $pieces = mb_split($separator, $value); |
| 66 | 70 | mb_regex_encoding($previous); |
| 67 | 71 | |
| 68 | - foreach ($pieces as $piece) { |
|
| 69 | - while (!$preserve && mb_strlen($piece, $env->getCharset()) > $length) { |
|
| 72 | + foreach ($pieces as $piece) |
|
| 73 | + { |
|
| 74 | + while (!$preserve && mb_strlen($piece, $env->getCharset()) > $length) |
|
| 75 | + { |
|
| 70 | 76 | $sentences[] = mb_substr($piece, 0, $length, $env->getCharset()); |
| 71 | 77 | $piece = mb_substr($piece, $length, 2048, $env->getCharset()); |
| 72 | 78 | } |
@@ -76,12 +82,17 @@ discard block |
||
| 76 | 82 | |
| 77 | 83 | return implode($separator, $sentences); |
| 78 | 84 | } |
| 79 | -} else { |
|
| 85 | +} |
|
| 86 | +else |
|
| 87 | +{ |
|
| 80 | 88 | function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
| 81 | 89 | { |
| 82 | - if (strlen($value) > $length) { |
|
| 83 | - if ($preserve) { |
|
| 84 | - if (false !== ($breakpoint = strpos($value, ' ', $length))) { |
|
| 90 | + if (strlen($value) > $length) |
|
| 91 | + { |
|
| 92 | + if ($preserve) |
|
| 93 | + { |
|
| 94 | + if (false !== ($breakpoint = strpos($value, ' ', $length))) |
|
| 95 | + { |
|
| 85 | 96 | $length = $breakpoint; |
| 86 | 97 | } |
| 87 | 98 | } |
@@ -8,13 +8,18 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __invoke ($array, $key, $order = "ASC") |
| 10 | 10 | { |
| 11 | - usort($array, function ($a, $b) use ($key, $order) { |
|
| 11 | + usort($array, function ($a, $b) use ($key, $order) |
|
| 12 | + { |
|
| 12 | 13 | $a = ($a instanceof ContentItem) ? $a->getFrontMatter() : $a; |
| 13 | 14 | $b = ($b instanceof ContentItem) ? $b->getFrontMatter() : $b; |
| 14 | 15 | |
| 15 | - if ($a[$key] == $b[$key]) return 0; |
|
| 16 | + if ($a[$key] == $b[$key]) |
|
| 17 | + { |
|
| 18 | + return 0; |
|
| 19 | + } |
|
| 16 | 20 | |
| 17 | - if (strtolower($order) === "desc") { |
|
| 21 | + if (strtolower($order) === "desc") |
|
| 22 | + { |
|
| 18 | 23 | return ($a[$key] < $b[$key]) ? 1 : -1; |
| 19 | 24 | } |
| 20 | 25 | |