@@ -1,7 +1,5 @@ |
||
1 | 1 | <?php namespace VojtaSvoboda\TwigExtensions; |
2 | 2 | |
3 | -use App; |
|
4 | -use Backend; |
|
5 | 3 | use Carbon\Carbon; |
6 | 4 | use System\Classes\PluginBase; |
7 | 5 | use Twig_Extension_StringLoader; |
@@ -406,7 +406,6 @@ |
||
406 | 406 | * |
407 | 407 | * See: https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/25 |
408 | 408 | * |
409 | - * @param string $filename Filename of the asset file |
|
410 | 409 | * |
411 | 410 | * @return string |
412 | 411 | */ |
@@ -419,14 +419,14 @@ |
||
419 | 419 | $filename_ = trim(preg_replace('/^' . preg_quote($prefix, '/') . '/', '', $filename), '/'); |
420 | 420 | if (file_exists($filename_)) |
421 | 421 | { |
422 | - $timestamp = filemtime($filename_); |
|
423 | - $prepend = ($format) ? date($fomat, $timestamp) : $timestamp; |
|
424 | - return $filename . "?" . $prepend; |
|
422 | + $timestamp = filemtime($filename_); |
|
423 | + $prepend = ($format) ? date($fomat, $timestamp) : $timestamp; |
|
424 | + return $filename . "?" . $prepend; |
|
425 | 425 | }else |
426 | 426 | { |
427 | - return $filename; |
|
427 | + return $filename; |
|
428 | 428 | } |
429 | 429 | }, |
430 | - ]; |
|
430 | + ]; |
|
431 | 431 | } |
432 | 432 | } |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | |
374 | 374 | // if we want just unprotected link |
375 | 375 | if (!$protected) { |
376 | - return $link ? '<a href="mailto:' . $email . '">' . $linkText . '</a>' : $linkText; |
|
376 | + return $link ? '<a href="mailto:'.$email.'">'.$linkText.'</a>' : $linkText; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | // turn on protection |
380 | 380 | $character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; |
381 | 381 | $key = str_shuffle($character_set); |
382 | 382 | $cipher_text = ''; |
383 | - $id = 'e' . rand(1, 999999999); |
|
383 | + $id = 'e'.rand(1, 999999999); |
|
384 | 384 | for ($i = 0; $i < strlen($email); $i += 1) $cipher_text .= $key[strpos($character_set, $email[$i])]; |
385 | - $script = 'var a="' . $key . '";var b=a.split("").sort().join("");var c="' . $cipher_text . '";var d="";'; |
|
385 | + $script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";'; |
|
386 | 386 | $script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));'; |
387 | 387 | $script .= 'var y = d;'; |
388 | 388 | if ($text !== null) { |
389 | 389 | $script .= 'var y = "'.$text.'";'; |
390 | 390 | } |
391 | 391 | if ($link) { |
392 | - $script .= 'document.getElementById("' . $id . '").innerHTML="<a href=\\"mailto:"+d+"\\">"+y+"</a>"'; |
|
392 | + $script .= 'document.getElementById("'.$id.'").innerHTML="<a href=\\"mailto:"+d+"\\">"+y+"</a>"'; |
|
393 | 393 | } else { |
394 | - $script .= 'document.getElementById("' . $id . '").innerHTML=y'; |
|
394 | + $script .= 'document.getElementById("'.$id.'").innerHTML=y'; |
|
395 | 395 | } |
396 | - $script = "eval(\"" . str_replace(array("\\", '"'), array("\\\\", '\"'), $script) . "\")"; |
|
397 | - $script = '<script type="text/javascript">/*<![CDATA[*/' . $script . '/*]]>*/</script>'; |
|
396 | + $script = "eval(\"".str_replace(array("\\", '"'), array("\\\\", '\"'), $script)."\")"; |
|
397 | + $script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>'; |
|
398 | 398 | |
399 | - return '<span id="' . $id . '">[javascript protected email address]</span>' . $script; |
|
399 | + return '<span id="'.$id.'">[javascript protected email address]</span>'.$script; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | private function getFileRevision() |
414 | 414 | { |
415 | 415 | return [ |
416 | - 'revision' => function($filename, $format = null){ |
|
416 | + 'revision' => function($filename, $format = null) { |
|
417 | 417 | // Remove http/web address from the file name if there is one to load it locally |
418 | 418 | $prefix = url("/"); |
419 | - $filename_ = trim(preg_replace('/^' . preg_quote($prefix, '/') . '/', '', $filename), '/'); |
|
419 | + $filename_ = trim(preg_replace('/^'.preg_quote($prefix, '/').'/', '', $filename), '/'); |
|
420 | 420 | if (file_exists($filename_)) |
421 | 421 | { |
422 | 422 | $timestamp = filemtime($filename_); |
423 | 423 | $prepend = ($format) ? date($fomat, $timestamp) : $timestamp; |
424 | - return $filename . "?" . $prepend; |
|
425 | - }else |
|
424 | + return $filename."?".$prepend; |
|
425 | + } else |
|
426 | 426 | { |
427 | 427 | return $filename; |
428 | 428 | } |
@@ -381,7 +381,9 @@ discard block |
||
381 | 381 | $key = str_shuffle($character_set); |
382 | 382 | $cipher_text = ''; |
383 | 383 | $id = 'e' . rand(1, 999999999); |
384 | - for ($i = 0; $i < strlen($email); $i += 1) $cipher_text .= $key[strpos($character_set, $email[$i])]; |
|
384 | + for ($i = 0; $i < strlen($email); $i += 1) { |
|
385 | + $cipher_text .= $key[strpos($character_set, $email[$i])]; |
|
386 | + } |
|
385 | 387 | $script = 'var a="' . $key . '";var b=a.split("").sort().join("");var c="' . $cipher_text . '";var d="";'; |
386 | 388 | $script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));'; |
387 | 389 | $script .= 'var y = d;'; |
@@ -422,7 +424,7 @@ discard block |
||
422 | 424 | $timestamp = filemtime($filename_); |
423 | 425 | $prepend = ($format) ? date($fomat, $timestamp) : $timestamp; |
424 | 426 | return $filename . "?" . $prepend; |
425 | - }else |
|
427 | + } else |
|
426 | 428 | { |
427 | 429 | return $filename; |
428 | 430 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | { |
8 | 8 | public function trans($id, array $parameters = [], $domain = 'messages', $locale = null) |
9 | 9 | { |
10 | - return $this->get('vojtasvoboda.twigextensions::lang.' . $id, $parameters, $locale); |
|
10 | + return $this->get('vojtasvoboda.twigextensions::lang.'.$id, $parameters, $locale); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null) |
14 | 14 | { |
15 | - return $this->choice('vojtasvoboda.twigextensions::lang.' . $id, $number, $parameters, $locale); |
|
15 | + return $this->choice('vojtasvoboda.twigextensions::lang.'.$id, $number, $parameters, $locale); |
|
16 | 16 | } |
17 | 17 | } |
@@ -1,6 +1,5 @@ |
||
1 | 1 | <?php namespace VojtaSvoboda\TwigExtensions\Classes; |
2 | 2 | |
3 | -use App; |
|
4 | 3 | use October\Rain\Translation\Translator; |
5 | 4 | use Symfony\Component\Translation\TranslatorInterface; |
6 | 5 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Twig_Environment; |
10 | 10 | use VojtaSvoboda\TwigExtensions\Classes\TimeDiffTranslator; |
11 | 11 | |
12 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
12 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
13 | 13 | |
14 | 14 | class PluginTest extends PluginTestCase |
15 | 15 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $twig = $this->getTwig(); |
117 | 117 | |
118 | 118 | $now = Carbon::now()->subMinute(); |
119 | - $template = "{{ '" . $now->format('Y-m-d H:i:s') . "' | time_diff }}"; |
|
119 | + $template = "{{ '".$now->format('Y-m-d H:i:s')."' | time_diff }}"; |
|
120 | 120 | |
121 | 121 | // this test fails at TravisCI and I don't know why |
122 | 122 | $twigTemplate = $twig->createTemplate($template); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $key = 'app.custom.key'; |
317 | 317 | $value = 'test value'; |
318 | 318 | Config::set($key, $value); |
319 | - $template = "{{ config('" . $key . "') }}"; |
|
319 | + $template = "{{ config('".$key."') }}"; |
|
320 | 320 | |
321 | 321 | $twigTemplate = $twig->createTemplate($template); |
322 | 322 | $this->assertEquals($twigTemplate->render([]), $value); |