@@ -63,7 +63,7 @@ |
||
63 | 63 | /** |
64 | 64 | * Build translate array. |
65 | 65 | * @param $translateArray |
66 | - * @return array |
|
66 | + * @return string |
|
67 | 67 | */ |
68 | 68 | private function buildTranslateArray(array $translateArray) { |
69 | 69 | $tmpArray = []; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | private function buildTranslateArray(array $translateArray) { |
69 | 69 | $tmpArray = []; |
70 | 70 | foreach ($translateArray as $key => $value) { |
71 | - $tmpArray['@'.$key] = $value; |
|
71 | + $tmpArray['@' . $key] = $value; |
|
72 | 72 | } |
73 | 73 | return $tmpArray; |
74 | 74 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | $relative_path = $data; |
87 | 87 | foreach ($params as $param => $value) { |
88 | 88 | if (strpos($param, ':') === strlen($param)-1) { |
89 | - $relative_path = preg_replace('/{'.$param.'(.*?)}/msi', $value, $relative_path); |
|
89 | + $relative_path = preg_replace('/{' . $param . '(.*?)}/msi', $value, $relative_path); |
|
90 | 90 | } else { |
91 | - $relative_path = str_replace('{'.$param.'}', $value, $relative_path); |
|
91 | + $relative_path = str_replace('{' . $param . '}', $value, $relative_path); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | return $this->config['base_url'] . "/" . $relative_path; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | throw new InvalidArgumentException($templateFileBasename . ' template file not found! ' . $widgetNameStr |
127 | 127 | . '_' . $widgetActionStr . ' needs a main template file at:' . $templateFullPath); |
128 | 128 | } |
129 | - $templateFile = '_widgets/' |
|
129 | + $templateFile = '_widgets/' |
|
130 | 130 | . $this->toSnakeCase->transform($widgetNameStr) . '/' . $templateFileBasename; |
131 | 131 | $widgetData = $widgetInstance->{$widgetAction}(); |
132 | 132 | return $this->twig->render($templateFile, $widgetData); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $filter = new \Twig_SimpleFunction( |
142 | 142 | 'queryParams', |
143 | 143 | function($queryParams, $prefix = '?') { |
144 | - $params = $prefix . http_build_query($queryParams); |
|
144 | + $params = $prefix . http_build_query($queryParams); |
|
145 | 145 | return $params; |
146 | 146 | }, |
147 | 147 | array('is_safe' => array('html')) |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | $linkItemTemplate = '<a href="(href)" class="(link_class)">(text)</a>', |
187 | 187 | $ellipsesTemplate = '<li><a>...</a></li>' |
188 | 188 | ) { |
189 | - $items = ''; |
|
189 | + $items = ''; |
|
190 | 190 | $pageGroupLimit = 3; |
191 | - $useEllipses = ($total >10) ? 1 : 0; |
|
191 | + $useEllipses = ($total > 10) ? 1 : 0; |
|
192 | 192 | $renderedEllipses = 0; |
193 | 193 | $values = [ |
194 | 194 | '(item_class)' => '', |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | '(link_class)' => '', |
197 | 197 | '(text)' => '' |
198 | 198 | ]; |
199 | - for ($i=1; $i <= $total; $i++) { |
|
199 | + for ($i = 1; $i <= $total; $i++) { |
|
200 | 200 | $values['(link_class)'] = ''; |
201 | 201 | $values['(item_class)'] = ''; |
202 | 202 | if ($i == $current) { |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | $useLink = 1; |
210 | 210 | if ($useEllipses === 1) { |
211 | 211 | $useLink = 0; |
212 | - if ( ($i <= $pageGroupLimit) || ($i >= ($current-1) && $i <= ($current+1)) || ($i >= ($total-2)) ) { |
|
212 | + if (($i <= $pageGroupLimit) || ($i >= ($current-1) && $i <= ($current+1)) || ($i >= ($total-2))) { |
|
213 | 213 | $useLink = 1; |
214 | 214 | $renderedEllipses = 0; |
215 | 215 | } else { |
216 | 216 | |
217 | - if($renderedEllipses === 0) { |
|
217 | + if ($renderedEllipses === 0) { |
|
218 | 218 | $items .= $ellipsesTemplate; |
219 | 219 | } |
220 | 220 | $renderedEllipses = 1; |
221 | 221 | } |
222 | 222 | } |
223 | - if($useLink === 1 ) { |
|
223 | + if ($useLink === 1) { |
|
224 | 224 | $thisItemTemplate = str_replace( |
225 | 225 | array('(link)'), |
226 | 226 | array($link), |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | ]; |
18 | 18 | public function __construct($config, $queryParams) |
19 | 19 | { |
20 | - $this->config = array_merge($this->config,$config); |
|
20 | + $this->config = array_merge($this->config, $config); |
|
21 | 21 | $loader = new \Twig_Loader_Filesystem($this->config['templates_dir']); |
22 | 22 | $this->twig = new \Twig_Environment($loader, [ |
23 | 23 | 'cache' => $this->config['cache_dir'], |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $this->twig->addGlobal($name, $value); |
35 | 35 | } |
36 | 36 | |
37 | - public function render(string $templateFile, array $parameters=[]) |
|
37 | + public function render(string $templateFile, array $parameters = []) |
|
38 | 38 | { |
39 | 39 | $output = $this->twig->render($templateFile, $parameters); |
40 | 40 | preg_match('/{{(\s*)Widget\_/msi', $output, $matches); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * Load functions that will be used in the templates |
15 | 15 | */ |
16 | - protected function loadFunctions(){ |
|
16 | + protected function loadFunctions() { |
|
17 | 17 | $this->extendForTranslation(); |
18 | 18 | $this->extendForWidget(); |
19 | 19 | $this->extendForPagination(); |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * Load extensions of templating engines |
29 | 29 | */ |
30 | - protected function loadExtensions(){} |
|
30 | + protected function loadExtensions() {} |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Extend for function _t that translates using defined global lang variable |
34 | 34 | * $lang = ['name' => 'Selami'] |
35 | 35 | * {{ _t('Hello @name',lang) }} produces Hello Selami |
36 | 36 | */ |
37 | - protected function extendForTranslation(){} |
|
37 | + protected function extendForTranslation() {} |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Extend for function getUrl that returns url path for an alias. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * and $baseUrl = 'http://127.0.0.1' and $page_lang = 'en_US' |
49 | 49 | * {{ getUrl('about', {'lang': page_lang}) }} produces http://127.0.0.1/en_US/about-us |
50 | 50 | */ |
51 | - protected function extendForGetUrl(){} |
|
51 | + protected function extendForGetUrl() {} |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Extend for wildcard Widget functions. Widget function determines the class and method that will be called. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * } |
60 | 60 | * )(); |
61 | 61 | */ |
62 | - protected function extendForWidget(){} |
|
62 | + protected function extendForWidget() {} |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Extend for queryParams function that returns http_build_query result using passed parameters. |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * {{ queryParams({'param1':1,'param2':2}, $prefix) }} returns ?param1=1¶m2=2 |
68 | 68 | * |
69 | 69 | */ |
70 | - protected function extendForQueryParams(){} |
|
70 | + protected function extendForQueryParams() {} |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Extend for function siteUrl that returns defined baseUrl of the site |
74 | 74 | * Let's say $baseUrl = 'http://127.0.0.1'; |
75 | 75 | * {{ siteUrl('/home') }} produces http://127.0.0.1/home |
76 | 76 | */ |
77 | - protected function extendForSiteUrl(){} |
|
77 | + protected function extendForSiteUrl() {} |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Extend for function varDump. Just outputs var_dump of passed parameter. |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * Use it for debugging purposes. |
83 | 83 | * |
84 | 84 | */ |
85 | - protected function extendForVarDump(){} |
|
85 | + protected function extendForVarDump() {} |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Extend for function Pagination. This function builds pagination html. |
@@ -117,5 +117,5 @@ discard block |
||
117 | 117 | * <li><a href="/list?page_num=20" class="">3</a></li> |
118 | 118 | * </ul> |
119 | 119 | */ |
120 | - protected function extendForPagination(){} |
|
120 | + protected function extendForPagination() {} |
|
121 | 121 | } |
122 | 122 | \ No newline at end of file |
@@ -7,5 +7,5 @@ |
||
7 | 7 | { |
8 | 8 | public function addGlobal(string $name, $value); |
9 | 9 | |
10 | - public function render(string $templateFile, array $parameters=[]); |
|
10 | + public function render(string $templateFile, array $parameters = []); |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |