Passed
Push — master ( 10c3ba...33c6a1 )
by Alexey
12:01
created

View::parseSource()   D

Complexity

Conditions 9
Paths 9

Size

Total Lines 38
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 0
Metric Value
cc 9
eloc 35
nc 9
nop 1
dl 0
loc 38
rs 4.909
c 0
b 0
f 0
ccs 0
cts 38
cp 0
crap 90
1
<?php
2
3
/**
4
 * View module
5
 *
6
 * Rendering pages, contents and widgets
7
 *
8
 * @author Alexey Krupskiy <[email protected]>
9
 * @link http://inji.ru/
10
 * @copyright 2015 Alexey Krupskiy
11
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
12
 */
13
class View extends \Module {
14
15
    public $title = 'No title';
16
17
    /**
18
     * @var View\Template
19
     */
20
    public $template = null;
21
    public $libAssets = ['css' => [], 'js' => []];
22
    public $dynAssets = ['css' => [], 'js' => []];
23
    public $dynMetas = [];
24
    public $viewedContent = '';
25
    public $contentData = [];
26
    public $templatesPath = '';
27
    public $loadedCss = [];
28
    public $loadedJs = [];
29
30
    public function init() {
31
        if (!empty($this->app->config['site']['name'])) {
32
            $this->title = $this->app->config['site']['name'];
33
        }
34
        $this->resolveTemplate();
35
    }
36
37
    public function resolveTemplate() {
38
        $templateName = 'default';
39
        if (!empty($this->config[$this->app->type]['current'])) {
40
            $templateName = $this->config[$this->app->type]['current'];
41
            if (!empty($this->config[$this->app->type]['installed'][$templateName]['location'])) {
42
                $this->templatesPath = App::$primary->path . "/templates";
43
            }
44
        }
45
        if (!$this->templatesPath) {
46
            $this->templatesPath = $this->app->path . "/templates";
47
        }
48
        $this->template = \View\Template::get($templateName, $this->app, $this->templatesPath);
49
        if (!$this->template) {
50
            $this->template = new \View\Template([
51
                'name' => 'default',
52
                'path' => $this->templatesPath . '/default',
53
                'app' => $this->app
54
            ]);
55
        }
56
    }
57
58
    public function page($params = []) {
59
        $this->paramsParse($params);
60
        if (file_exists($this->template->pagePath)) {
61
            $source = file_get_contents($this->template->pagePath);
62
            if (strpos($source, 'BODYEND') === false) {
63
                $source = str_replace('</body>', '{BODYEND}</body>', $source);
64
            }
65
            $this->parseSource($source);
66
        } else {
67
            $this->content();
68
        }
69
    }
70
71
    public function paramsParse($params) {
72
        // set template
73
        if (!empty($params['template']) && $params['template'] != 'current') {
74
            $this->template = \View\Template::get($params['template']);
75
        }
76
        //set page
77
        if (!empty($params['page']) && $params['page'] != 'current') {
78
            $this->template->setPage($params['page']);
79
        }
80
        //set module
81
        if (!empty($params['module'])) {
82
            $this->template->setModule($params['module']);
83
        }
84
        //set content
85
        if (!empty($params['content'])) {
86
            $this->template->setContent($params['content']);
87
        } elseif (!$this->template->contentPath) {
88
            $this->template->setContent();
89
        }
90
        //set data
91
        if (!empty($params['data'])) {
92
            $this->contentData = array_merge($this->contentData, $params['data']);
93
        }
94
    }
95
96
    public function content($params = []) {
97
98
        $this->paramsParse($params);
99
100
        if (empty($this->template->config['noSysMsgAutoShow'])) {
101
            Msg::show();
102
        }
103
        if (!file_exists($this->template->contentPath)) {
104
            echo 'Content not found';
105
        } else {
106
            extract($this->contentData);
107
            include $this->template->contentPath;
108
        }
109
    }
110
111
    public function parentContent($contentName = '') {
112
        if (!$contentName) {
113
            $contentName = $this->template->content;
114
        }
115
116
        $paths = $this->template->getContentPaths($contentName);
117
118
        $data = [];
119
        $exist = false;
120
        foreach ($paths as $type => $path) {
121
            if (substr($path, 0, strrpos($path, '/')) == substr($this->template->contentPath, 0, strrpos($this->template->contentPath, '/'))) {
122
                $exist = true;
123
                continue;
124
            }
125
            if (file_exists($path) && $exist) {
126
                $data['contentPath'] = $path;
127
                $data['content'] = $contentName;
128
                break;
129
            }
130
        }
131
        if (!$data) {
132
            echo 'Content not found';
133
        } else {
134
            extract($this->contentData);
135
            include $data['contentPath'];
136
        }
137
    }
138
139
    private function parseRaw($source) {
140
        if (!$source) {
141
            return [];
142
        }
143
144
        preg_match_all("|{([^}]+)}|", $source, $result);
145
        return $result[1];
146
    }
147
148
    public function parseSource($source) {
149
        $tags = $this->parseRaw($source);
150
        foreach ($tags as $rawTag) {
151
            $tag = explode(':', $rawTag);
152
            switch ($tag[0]) {
153
                case 'CONTENT':
154
                    $source = $this->cutTag($source, $rawTag);
155
                    $this->content();
156
                    break;
157
                case 'TITLE':
158
                    $source = $this->cutTag($source, $rawTag);
159
                    echo $this->title;
160
                    break;
161
                case 'WIDGET':
162
                    $source = $this->cutTag($source, $rawTag);
163
                    $params = array_slice($tag, 2);
164
                    $this->widget($tag[1], ['params' => $params], ':' . implode(':', $params));
165
                    break;
166
                case 'HEAD':
167
                    $source = $this->cutTag($source, $rawTag);
168
                    $this->head();
169
                    break;
170
                case 'PAGE':
171
                    $source = $this->cutTag($source, $rawTag);
172
                    $this->page(['page' => $tag[1]]);
173
                    break;
174
                case 'BODYEND':
175
                    $source = $this->cutTag($source, $rawTag);
176
                    $this->bodyEnd();
177
                    break;
178
                case 'TEMPLATE_PATH':
179
                    $source = $this->cutTag($source, $rawTag);
180
                    echo "/static/templates/{$this->template->name}";
181
                    break;
182
            }
183
        }
184
        echo $source;
185
    }
186
187
    public function cutTag($source, $rawTag) {
188
        $pos = strpos($source, $rawTag) - 1;
189
        echo substr($source, 0, $pos);
190
        return substr($source, ($pos + strlen($rawTag) + 2));
191
    }
192
193
    public function getHref($type, $params) {
194
        $href = '';
195
        if (is_string($params)) {
196
            $href = $params;
197
        } elseif (empty($params['template']) && !empty($params['file'])) {
198
            $href = ($this->app->type != 'app' ? '/' . $this->app->name : '') . $params['file'];
199
        } elseif (!empty($params['template']) && !empty($params['file'])) {
200
            $href = $this->app->templatesPath . "/{$this->template->name}/{$type}/{$params['file']}";
201
        }
202
        return $href;
203
    }
204
205
    public function checkNeedLibs() {
206
        if (!empty($this->template->config['libs'])) {
207
            foreach ($this->template->config['libs'] as $libName => $libOptions) {
208
                if (!is_array($libOptions)) {
209
                    $libName = $libOptions;
210
                    $libOptions = [];
211
                }
212
                $this->app->libs->loadLib($libName, $libOptions);
213
            }
214
        }
215 View Code Duplication
        foreach ($this->dynAssets['js'] as $asset) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
            if (is_array($asset) && !empty($asset['libs'])) {
217
                foreach ($asset['libs'] as $libName) {
218
                    $this->app->libs->loadLib($libName);
219
                }
220
            }
221
        }
222 View Code Duplication
        foreach ($this->libAssets['js'] as $asset) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
223
            if (is_array($asset) && !empty($asset['libs'])) {
224
                foreach ($asset['libs'] as $libName) {
225
                    $this->app->libs->loadLib($libName);
226
                }
227
            }
228
        }
229
    }
230
231
    public function head() {
232
233
        echo "<title>{$this->title}</title>\n";
234
        if (!empty(\App::$primary->config['site']['favicon']) && file_exists(\App::$primary->path . '/' . \App::$primary->config['site']['favicon'])) {
235
            echo "        <link rel='shortcut icon' href='" . \App::$primary->config['site']['favicon'] . "' />";
236
        } elseif (!empty($this->template->config['favicon']) && file_exists($this->template->path . "/{$this->template->config['favicon']}")) {
237
            echo "        <link rel='shortcut icon' href='/templates/{$this->template->name}/{$this->template->config['favicon']}' />";
238
        } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path . "/static/images/{$this->template->config['favicon']}")) {
239
            echo "        <link rel='shortcut icon' href='/static/images/{$this->template->config['favicon']}' />";
240
        } elseif (file_exists($this->app->path . '/static/images/favicon.ico')) {
241
            echo "        <link rel='shortcut icon' href='/static/images/favicon.ico' />";
242
        }
243
244
        foreach ($this->getMetaTags() as $meta) {
245
            echo "\n        " . Html::el('meta', $meta, '', null);
246
        }
247
248
        if (!empty(Inji::$config['assets']['js'])) {
249
            foreach (Inji::$config['assets']['js'] as $js) {
250
                $this->customAsset('js', $js);
251
            }
252
        }
253
254
        $this->checkNeedLibs();
255
        $this->parseCss();
256
        echo "\n        <script src='" . Statics::file(($this->app->type != 'app' ? '/' . $this->app->name : '') . "/static/system/js/Inji.js") . "'></script>";
257
    }
258
259
    public function parseCss() {
260
        $css = $this->getCss();
261
        $urls = [];
262
        $timeStr = '';
263
        $cssAll = '';
264
        $exclude = ['^http:', '^https:', '^//'];
265
        foreach ($css as $href) {
266
            if (!empty($this->loadedCss[$href])) {
267
                continue;
268
            }
269
            foreach ($exclude as $item) {
270
                if (preg_match("!{$item}!", $href)) {
271
                    echo "\n        <link href='{$href}' rel='stylesheet' type='text/css' />";
272
                    continue;
273
                }
274
            }
275
            $path = $this->app->staticLoader->parsePath($href);
276
            if (file_exists($path)) {
277
                $this->loadedCss[$href] = $href;
278
                $urls[$href] = $path;
279
                $timeStr .= filemtime($path);
280
            } else {
281
                echo "\n        <link href='{$href}' rel='stylesheet' type='text/css' />";
282
            }
283
        }
284
        $timeMd5 = md5($timeStr);
285
        $cacheDir = Cache::getDir('static');
286
        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.css')) {
287
            foreach ($urls as $primaryUrl => $url) {
288
                $source = file_get_contents($url);
289
                $rootPath = substr($primaryUrl, 0, strrpos($primaryUrl, '/'));
290
                $levelUpPath = substr($rootPath, 0, strrpos($rootPath, '/'));
291
                $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1' . $levelUpPath, $source);
292
                $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1' . $rootPath, $source);
293
                $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1' . $rootPath . '/$2', $source);
294
                $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url(' . $rootPath . '/$1$2', $source);
295
                $cssAll .= $source . "\n";
296
            }
297
            file_put_contents($cacheDir . '/all' . $timeMd5 . '.css', $cssAll);
298
        }
299
        echo "\n        <link href='/{$cacheDir}/all{$timeMd5}.css' rel='stylesheet' type='text/css' />";
300
    }
301
302 View Code Duplication
    public function getCss() {
303
        $css = [];
304
        if (!empty($this->libAssets['css'])) {
305
            $this->ResolveCssHref($this->libAssets['css'], 'libs', $css);
306
        }
307
        if (!empty($this->template->config['css'])) {
308
            $this->ResolveCssHref($this->template->config['css'], 'template', $css);
309
        }
310
        if (!empty($this->dynAssets['css'])) {
311
            $this->ResolveCssHref($this->dynAssets['css'], 'custom', $css);
312
        }
313
        return $css;
314
    }
315
316
    public function ResolveCssHref($cssArray, $type = 'custom', &$hrefs) {
317
        switch ($type) {
318
            case 'libs':
319
                foreach ($cssArray as $css) {
320
                    if (is_array($css)) {
321
                        $this->ResolveCssHref($css, $type, $hrefs);
322
                        continue;
323
                    }
324
                    $hrefs[$css] = $css;
325
                }
326
                break;
327 View Code Duplication
            case 'template':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
328
                foreach ($cssArray as $css) {
329
                    if (is_array($css)) {
330
                        $this->ResolveCssHref($css, $type, $hrefs);
331
                        continue;
332
                    }
333
                    if (strpos($css, '://') !== false) {
334
                        $href = $css;
335
                    } else {
336
                        $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}";
337
                    }
338
                    $hrefs[$href] = $href;
339
                }
340
                break;
341 View Code Duplication
            case 'custom':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
342
                foreach ($cssArray as $css) {
343
                    if (is_array($css)) {
344
                        $this->ResolveCssHref($css, $type, $hrefs);
345
                        continue;
346
                    }
347
                    if (strpos($css, '//') !== false) {
348
                        $href = $css;
349
                    } else {
350
                        $href = ($this->app->type != 'app' ? '/' . $this->app->name : '') . $css;
351
                    }
352
                    $hrefs[$href] = $href;
353
                }
354
                break;
355
        }
356
    }
357
358
    public function getMetaTags() {
359
        $metas = [];
360
361 View Code Duplication
        if (!empty($this->app->config['site']['keywords'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
362
            $metas['metaName:keywords'] = ['name' => 'keywords', 'content' => $this->app->config['site']['keywords']];
363
        }
364 View Code Duplication
        if (!empty($this->app->config['site']['description'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
365
            $metas['metaName:description'] = ['name' => 'description', 'content' => $this->app->config['site']['description']];
366
        }
367
        if (!empty($this->app->config['site']['metatags'])) {
368
            foreach ($this->app->config['site']['metatags'] as $meta) {
369
                if (!empty($meta['name'])) {
370
                    $metas['metaName:' . $meta['name']] = $meta;
371
                } elseif (!empty($meta['property'])) {
372
                    $metas['metaProperty:' . $meta['property']] = $meta;
373
                }
374
            }
375
        }
376
        if ($this->dynMetas) {
377
            $metas = array_merge($metas, $this->dynMetas);
378
        }
379
        return $metas;
380
    }
381
382
    public function addMetaTag($meta) {
383
        if (!empty($meta['name'])) {
384
            $this->dynMetas['metaName:' . $meta['name']] = $meta;
385
        } elseif (!empty($meta['property'])) {
386
            $this->dynMetas['metaProperty:' . $meta['property']] = $meta;
387
        }
388
    }
389
390
    public function bodyEnd() {
391
        $this->checkNeedLibs();
392
        $this->parseCss();
393
        $scripts = $this->getScripts();
394
        $onLoadModules = [];
395
        $scriptAll = '';
396
        $urls = [];
397
        $nativeUrl = [];
398
        $timeStr = '';
399
        $noParsedScripts = [];
400
        foreach ($scripts as $script) {
401
            if (is_string($script)) {
402
                if (!empty($urls[$script])) {
403
                    continue;
404
                }
405
406
                $path = $this->app->staticLoader->parsePath($script);
407
                if (file_exists($path)) {
408
                    $nativeUrl[$script] = $script;
409
                    $urls[$script] = $path;
410
                    $timeStr .= filemtime($path);
411
                } else {
412
                    $noParsedScripts[$script] = $script;
413
                }
414
            } elseif (!empty($script['file'])) {
415
                if (!empty($urls[$script['file']])) {
416
                    continue;
417
                }
418
419
                $path = $this->app->staticLoader->parsePath($script['file']);
420
                if (file_exists($path)) {
421
                    $nativeUrl[$script['file']] = $script['file'];
422
                    $urls[$script['file']] = $path;
423
                    if (!empty($script['name'])) {
424
                        $onLoadModules[$script['name']] = $script['name'];
425
                    }
426
                    $timeStr .= filemtime($path);
427
                } else {
428
                    $noParsedScripts[$script] = $script;
429
                }
430
            }
431
        }
432
433
        $timeMd5 = md5($timeStr);
434
        $cacheDir = Cache::getDir('static');
435
        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.js')) {
436
            foreach ($urls as $url) {
437
                $scriptAll .= ";\n" . file_get_contents($url);
438
            }
439
            file_put_contents($cacheDir . '/all' . $timeMd5 . '.js', $scriptAll);
440
        }
441
        $options = [
442
            'scripts' => array_values($noParsedScripts),
443
            'compresedScripts' => $nativeUrl,
444
            'styles' => [],
445
            'appRoot' => $this->app->type == 'app' ? '/' : '/' . $this->app->name . '/',
446
            'onLoadModules' => $onLoadModules
447
        ];
448
        $options['scripts'][] = '/' . $cacheDir . '/all' . $timeMd5 . '.js';
449
        $this->widget('View\bodyEnd', compact('options'));
450
    }
451
452 View Code Duplication
    public function getScripts() {
453
        $scripts = [];
454
        if (!empty($this->libAssets['js'])) {
455
            $this->genScriptArray($this->libAssets['js'], 'libs', $scripts);
456
        }
457
        if (!empty($this->dynAssets['js'])) {
458
            $this->genScriptArray($this->dynAssets['js'], 'custom', $scripts);
459
        }
460
        if (!empty($this->template->config['js'])) {
461
            $this->genScriptArray($this->template->config['js'], 'template', $scripts);
462
        }
463
        return $scripts;
464
    }
465
466
    public function genScriptArray($jsArray, $type = 'custom', &$resultArray) {
467
        switch ($type) {
468
            case 'libs':
469
                foreach ($jsArray as $js) {
470
                    if (is_array($js)) {
471
                        $this->genScriptArray($js, $type, $resultArray);
472
                        continue;
473
                    }
474
                    if (strpos($js, '//') !== false) {
475
                        $href = $js;
476
                    } else {
477
                        $href = $this->getHref('js', $js);
478
                    }
479
                    if (!$href) {
480
                        continue;
481
                    }
482
483
                    $resultArray[] = $href;
484
                }
485
                break;
486 View Code Duplication
            case 'template':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
487
                foreach ($jsArray as $js) {
488
                    if (is_array($js)) {
489
                        $this->genScriptArray($js, $type, $resultArray);
490
                        continue;
491
                    }
492
                    if (strpos($js, '//') !== false) {
493
                        $href = $js;
494
                    } else {
495
                        $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}";
496
                    }
497
                    $resultArray[] = $href;
498
                }
499
                break;
500
            case 'custom':
501
                foreach ($jsArray as $js) {
502
                    if (is_array($js)) {
503
                        if (!empty($js[0]) && is_array($js[0])) {
504
                            $this->genScriptArray($js, $type, $resultArray);
505
                            continue;
506
                        }
507
                        $asset = $js;
508
                    } else {
509
                        $asset = [];
510
                    }
511
                    $asset['file'] = $this->getHref('js', $js);
512
                    if (!$asset['file']) {
513
                        continue;
514
                    }
515
                    $resultArray[] = $asset;
516
                }
517
                break;
518
        }
519
    }
520
521
    public function customAsset($type, $asset, $lib = false) {
522
        if (!$lib) {
523
            $this->dynAssets[$type][] = $asset;
524
        } else {
525
            if (empty($this->libAssets[$type][$lib]) || !in_array($asset, $this->libAssets[$type][$lib])) {
526
                $this->libAssets[$type][$lib][] = $asset;
527
            }
528
        }
529
    }
530
531
    public function setTitle($title, $add = true) {
532
        if ($add && !empty($this->app->config['site']['name'])) {
533
            if ($title) {
534
                $this->title = $title . ' - ' . $this->app->config['site']['name'];
535
            } else {
536
                $this->title = $this->app->config['site']['name'];
537
            }
538
        } else {
539
            $this->title = $title;
540
        }
541
    }
542
543
    public function widget($_widgetName, $_params = [], $lineParams = null) {
544
        $_paths = $this->getWidgetPaths($_widgetName);
545
        $find = false;
546
        foreach ($_paths as $_path) {
547
            if (file_exists($_path)) {
548
                $find = true;
549
                break;
550
            }
551
        }
552
        if ($lineParams === null) {
553
            $lineParams = '';
554
            if ($_params) {
555
                $paramArray = false;
556
                foreach ($_params as $param) {
557
                    if (is_array($param) || is_object($param)) {
558
                        $paramArray = true;
559
                    }
560
                }
561
                if (!$paramArray) {
562
                    $lineParams = ':' . implode(':', $_params);
563
                }
564
            }
565
        }
566
        echo "<!--start:{WIDGET:{$_widgetName}{$lineParams}}-->\n";
567
        if ($find) {
568
            if ($_params && is_array($_params)) {
569
                extract($_params);
570
            }
571
            include $_path;
572
        }
573
        echo "<!--end:{WIDGET:{$_widgetName}{$lineParams}}-->\n";
574
    }
575
576
    public function getWidgetPaths($widgetName) {
577
        $paths = [];
578
        if (strpos($widgetName, '\\')) {
579
            $widgetName = explode('\\', $widgetName);
580
581
            $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName[0] . '/' . $widgetName[1] . '/' . $widgetName[1] . '.php';
582
            $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName[0] . '/' . $widgetName[1] . '.php';
583
            App::$cur->$widgetName[0];
584
            $modulePaths = Module::getModulePaths(ucfirst($widgetName[0]));
585
            foreach ($modulePaths as $pathName => $path) {
586
                $paths[$pathName . '_widgetDir'] = $path . '/widgets/' . $widgetName[1] . '/' . $widgetName[1] . '.php';
587
                $paths[$pathName] = $path . '/widgets/' . $widgetName[1] . '.php';
588
            }
589
            return $paths;
590
        } else {
591
            $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '/' . $widgetName . '.php';
592
            $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '.php';
593
594
            $paths['curAppPath_widgetDir'] = $this->app->path . '/widgets/' . $widgetName . '/' . $widgetName . '.php';
595
            $paths['curAppPath'] = $this->app->path . '/widgets/' . $widgetName . '.php';
596
597
            $paths['systemPath_widgetDir'] = INJI_SYSTEM_DIR . '/widgets/' . $widgetName . '/' . $widgetName . '.php';
598
            $paths['systemPath'] = INJI_SYSTEM_DIR . '/widgets/' . $widgetName . '.php';
599
        }
600
        return $paths;
601
    }
602
}