Completed
Push — master ( 6003a8...5df053 )
by Alexey
06:22
created
system/modules/View/View.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
         if (!empty($this->config[$this->app->type]['current'])) {
38 38
             $templateName = $this->config[$this->app->type]['current'];
39 39
             if (!empty($this->config[$this->app->type]['installed'][$templateName]['location'])) {
40
-                $this->templatesPath = App::$primary->path . "/templates";
40
+                $this->templatesPath = App::$primary->path."/templates";
41 41
             }
42 42
         }
43 43
         if (!$this->templatesPath) {
44
-            $this->templatesPath = $this->app->path . "/templates";
44
+            $this->templatesPath = $this->app->path."/templates";
45 45
         }
46 46
         $this->template = \View\Template::get($templateName, $this->app, $this->templatesPath);
47 47
         if (!$this->template) {
48 48
             $this->template = new \View\Template([
49 49
                 'name' => 'default',
50
-                'path' => $this->templatesPath . '/default',
50
+                'path' => $this->templatesPath.'/default',
51 51
                 'app' => $this->app
52 52
             ]);
53 53
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 case 'WIDGET':
165 165
                     $source = $this->cutTag($source, $rawTag);
166 166
                     $params = array_slice($tag, 2);
167
-                    $this->widget($tag[1], ['params' => $params], ':' . implode(':', $params));
167
+                    $this->widget($tag[1], ['params' => $params], ':'.implode(':', $params));
168 168
                     break;
169 169
                 case 'HEAD':
170 170
                     $source = $this->cutTag($source, $rawTag);
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
     {
188 188
         $pos = strpos($source, $rawTag) - 1;
189 189
         echo substr($source, 0, $pos);
190
-        return substr($source, ( $pos + strlen($rawTag) + 2));
190
+        return substr($source, ($pos + strlen($rawTag) + 2));
191 191
     }
192 192
 
193 193
     public function getHref($type, $params)
194 194
     {
195 195
         $href = '';
196 196
         if (is_string($params)) {
197
-            $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params;
197
+            $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$params;
198 198
         } elseif (empty($params['template']) && !empty($params['file'])) {
199
-            $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params['file'];
199
+            $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$params['file'];
200 200
         } elseif (!empty($params['template']) && !empty($params['file'])) {
201
-            $href = $this->app->templatesPath . "/{$this->template->name}/{$type}/{$params['file']}";
201
+            $href = $this->app->templatesPath."/{$this->template->name}/{$type}/{$params['file']}";
202 202
         }
203 203
         return $href;
204 204
     }
@@ -235,16 +235,16 @@  discard block
 block discarded – undo
235 235
 
236 236
         echo "<title>{$this->title}</title>\n";
237 237
 
238
-        if (!empty($this->template->config['favicon']) && file_exists($this->template->path . "/{$this->template->config['favicon']}")) {
238
+        if (!empty($this->template->config['favicon']) && file_exists($this->template->path."/{$this->template->config['favicon']}")) {
239 239
             echo "        <link rel='shortcut icon' href='/templates/{$this->template->name}/{$this->template->config['favicon']}' />";
240
-        } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path . "/static/images/{$this->template->config['favicon']}")) {
240
+        } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path."/static/images/{$this->template->config['favicon']}")) {
241 241
             echo "        <link rel='shortcut icon' href='/static/images/{$this->template->config['favicon']}' />";
242
-        } elseif (file_exists($this->app->path . '/static/images/favicon.ico')) {
242
+        } elseif (file_exists($this->app->path.'/static/images/favicon.ico')) {
243 243
             echo "        <link rel='shortcut icon' href='/static/images/favicon.ico' />";
244 244
         }
245 245
 
246 246
         foreach ($this->getMetaTags() as $meta) {
247
-            echo "\n        " . Html::el('meta', $meta, '', null);
247
+            echo "\n        ".Html::el('meta', $meta, '', null);
248 248
         }
249 249
 
250 250
         if (!empty(Inji::$config['assets']['js'])) {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
         $this->checkNeedLibs();
257 257
         $this->parseCss();
258
-        echo "\n        <script src='" . Statics::file(($this->app->type != 'app' ? '/' . $this->app->name : '' ) . "/static/system/js/Inji.js") . "'></script>";
258
+        echo "\n        <script src='".Statics::file(($this->app->type != 'app' ? '/'.$this->app->name : '')."/static/system/js/Inji.js")."'></script>";
259 259
     }
260 260
 
261 261
     public function parseCss()
@@ -279,25 +279,25 @@  discard block
 block discarded – undo
279 279
             if (file_exists($path)) {
280 280
                 $this->loadedCss[$href] = $href;
281 281
                 $urls[$href] = $path;
282
-                $timeStr.=filemtime($path);
282
+                $timeStr .= filemtime($path);
283 283
             } else {
284 284
                 echo "\n        <link href='{$href}' rel='stylesheet' type='text/css' />";
285 285
             }
286 286
         }
287 287
         $timeMd5 = md5($timeStr);
288 288
         $cacheDir = Cache::getDir('static');
289
-        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.css')) {
289
+        if (!file_exists($cacheDir.'/all'.$timeMd5.'.css')) {
290 290
             foreach ($urls as $primaryUrl => $url) {
291 291
                 $source = file_get_contents($url);
292 292
                 $rootPath = substr($primaryUrl, 0, strrpos($primaryUrl, '/'));
293 293
                 $levelUpPath = substr($rootPath, 0, strrpos($rootPath, '/'));
294
-                $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1' . $levelUpPath, $source);
295
-                $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1' . $rootPath, $source);
296
-                $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1' . $rootPath . '/$2', $source);
297
-                $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url(' . $rootPath . '/$1$2', $source);
294
+                $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1'.$levelUpPath, $source);
295
+                $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1'.$rootPath, $source);
296
+                $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1'.$rootPath.'/$2', $source);
297
+                $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url('.$rootPath.'/$1$2', $source);
298 298
                 $cssAll .= $source;
299 299
             }
300
-            file_put_contents($cacheDir . '/all' . $timeMd5 . '.css', $cssAll);
300
+            file_put_contents($cacheDir.'/all'.$timeMd5.'.css', $cssAll);
301 301
         }
302 302
         echo "\n        <link href='/{$cacheDir}/all{$timeMd5}.css' rel='stylesheet' type='text/css' />";
303 303
     }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                     if (strpos($css, '//') !== false)
330 330
                         $href = $css;
331 331
                     else
332
-                        $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css;
332
+                        $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$css;
333 333
                     $hrefs[$href] = $href;
334 334
                 }
335 335
                 break;
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
                     if (strpos($css, '://') !== false)
343 343
                         $href = $css;
344 344
                     else
345
-                        $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}";
345
+                        $href = $this->app->templatesPath."/{$this->template->name}/css/{$css}";
346 346
                     $hrefs[$href] = $href;
347 347
                 }
348 348
                 break;
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                     if (strpos($css, '//') !== false)
356 356
                         $href = $css;
357 357
                     else
358
-                        $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css;
358
+                        $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$css;
359 359
                     $hrefs[$href] = $href;
360 360
                 }
361 361
                 break;
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
         if (!empty($this->app->config['site']['metatags'])) {
376 376
             foreach ($this->app->config['site']['metatags'] as $meta) {
377 377
                 if (!empty($meta['name'])) {
378
-                    $metas['metaName:' . $meta['name']] = $meta;
378
+                    $metas['metaName:'.$meta['name']] = $meta;
379 379
                 } elseif (!empty($meta['property'])) {
380
-                    $metas['metaProperty:' . $meta['property']] = $meta;
380
+                    $metas['metaProperty:'.$meta['property']] = $meta;
381 381
                 }
382 382
             }
383 383
         }
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
     public function addMetaTag($meta)
391 391
     {
392 392
         if (!empty($meta['name'])) {
393
-            $this->dynMetas['metaName:' . $meta['name']] = $meta;
393
+            $this->dynMetas['metaName:'.$meta['name']] = $meta;
394 394
         } elseif (!empty($meta['property'])) {
395
-            $this->dynMetas['metaProperty:' . $meta['property']] = $meta;
395
+            $this->dynMetas['metaProperty:'.$meta['property']] = $meta;
396 396
         }
397 397
     }
398 398
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                 if (file_exists($path)) {
417 417
                     $nativeUrl[$script] = $script;
418 418
                     $urls[$script] = $path;
419
-                    $timeStr.=filemtime($path);
419
+                    $timeStr .= filemtime($path);
420 420
                 } else {
421 421
                     $noParsedScripts[$script] = $script;
422 422
                 }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                     if (!empty($script['name'])) {
432 432
                         $onLoadModules[$script['name']] = $script['name'];
433 433
                     }
434
-                    $timeStr.=filemtime($path);
434
+                    $timeStr .= filemtime($path);
435 435
                 } else {
436 436
                     $noParsedScripts[$script] = $script;
437 437
                 }
@@ -440,20 +440,20 @@  discard block
 block discarded – undo
440 440
 
441 441
         $timeMd5 = md5($timeStr);
442 442
         $cacheDir = Cache::getDir('static');
443
-        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.js')) {
443
+        if (!file_exists($cacheDir.'/all'.$timeMd5.'.js')) {
444 444
             foreach ($urls as $url) {
445
-                $scriptAll .= ';' . file_get_contents($url);
445
+                $scriptAll .= ';'.file_get_contents($url);
446 446
             }
447
-            file_put_contents($cacheDir . '/all' . $timeMd5 . '.js', $scriptAll);
447
+            file_put_contents($cacheDir.'/all'.$timeMd5.'.js', $scriptAll);
448 448
         }
449 449
         $options = [
450 450
             'scripts' => array_values($noParsedScripts),
451 451
             'compresedScripts' => $nativeUrl,
452 452
             'styles' => [],
453
-            'appRoot' => $this->app->type == 'app' ? '/' : '/' . $this->app->name . '/',
453
+            'appRoot' => $this->app->type == 'app' ? '/' : '/'.$this->app->name.'/',
454 454
             'onLoadModules' => $onLoadModules
455 455
         ];
456
-        $options['scripts'][] = '/' . $cacheDir . '/all' . $timeMd5 . '.js';
456
+        $options['scripts'][] = '/'.$cacheDir.'/all'.$timeMd5.'.js';
457 457
         $this->widget('View\bodyEnd', compact('options'));
458 458
     }
459 459
 
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
                     if (strpos($js, '//') !== false)
501 501
                         $href = $js;
502 502
                     else
503
-                        $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}";
503
+                        $href = $this->app->templatesPath."/{$this->template->name}/js/{$js}";
504 504
                     $resultArray[] = $href;
505 505
                 }
506 506
                 break;
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     {
538 538
         if ($add && !empty($this->app->config['site']['name'])) {
539 539
             if ($title) {
540
-                $this->title = $title . ' - ' . $this->app->config['site']['name'];
540
+                $this->title = $title.' - '.$this->app->config['site']['name'];
541 541
             } else {
542 542
                 $this->title = $this->app->config['site']['name'];
543 543
             }
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                     }
567 567
                 }
568 568
                 if (!$paramArray)
569
-                    $lineParams = ':' . implode(':', $_params);
569
+                    $lineParams = ':'.implode(':', $_params);
570 570
             }
571 571
         }
572 572
         echo "<!--start:{WIDGET:{$_widgetName}{$lineParams}}-->\n";
@@ -585,24 +585,24 @@  discard block
 block discarded – undo
585 585
         if (strpos($widgetName, '\\')) {
586 586
             $widgetName = explode('\\', $widgetName);
587 587
 
588
-            $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName[0] . '/' . $widgetName[1] . '/' . $widgetName[1] . '.php';
589
-            $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName[0] . '/' . $widgetName[1] . '.php';
588
+            $paths['templatePath_widgetDir'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName[0].'/'.$widgetName[1].'/'.$widgetName[1].'.php';
589
+            $paths['templatePath'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName[0].'/'.$widgetName[1].'.php';
590 590
             App::$cur->$widgetName[0];
591 591
             $modulePaths = Module::getModulePaths(ucfirst($widgetName[0]));
592 592
             foreach ($modulePaths as $pathName => $path) {
593
-                $paths[$pathName . '_widgetDir'] = $path . '/widgets/' . $widgetName[1] . '/' . $widgetName[1] . '.php';
594
-                $paths[$pathName] = $path . '/widgets/' . $widgetName[1] . '.php';
593
+                $paths[$pathName.'_widgetDir'] = $path.'/widgets/'.$widgetName[1].'/'.$widgetName[1].'.php';
594
+                $paths[$pathName] = $path.'/widgets/'.$widgetName[1].'.php';
595 595
             }
596 596
             return $paths;
597 597
         } else {
598
-            $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '/' . $widgetName . '.php';
599
-            $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '.php';
598
+            $paths['templatePath_widgetDir'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName.'/'.$widgetName.'.php';
599
+            $paths['templatePath'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName.'.php';
600 600
 
601
-            $paths['curAppPath_widgetDir'] = $this->app->path . '/widgets/' . $widgetName . '/' . $widgetName . '.php';
602
-            $paths['curAppPath'] = $this->app->path . '/widgets/' . $widgetName . '.php';
601
+            $paths['curAppPath_widgetDir'] = $this->app->path.'/widgets/'.$widgetName.'/'.$widgetName.'.php';
602
+            $paths['curAppPath'] = $this->app->path.'/widgets/'.$widgetName.'.php';
603 603
 
604
-            $paths['systemPath_widgetDir'] = INJI_SYSTEM_DIR . '/widgets/' . $widgetName . '/' . $widgetName . '.php';
605
-            $paths['systemPath'] = INJI_SYSTEM_DIR . '/widgets/' . $widgetName . '.php';
604
+            $paths['systemPath_widgetDir'] = INJI_SYSTEM_DIR.'/widgets/'.$widgetName.'/'.$widgetName.'.php';
605
+            $paths['systemPath'] = INJI_SYSTEM_DIR.'/widgets/'.$widgetName.'.php';
606 606
         }
607 607
         return $paths;
608 608
     }
Please login to merge, or discard this patch.