Completed
Push — master ( 308a3c...ebb499 )
by Alexey
08:08
created

View::paramsParse()   C

Complexity

Conditions 9
Paths 48

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 13
nc 48
nop 1
dl 0
loc 24
rs 5.3563
c 0
b 0
f 0
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
    public $template = null;
17
    public $libAssets = ['css' => [], 'js' => []];
18
    public $dynAssets = ['css' => [], 'js' => []];
19
    public $dynMetas = [];
20
    public $viewedContent = '';
21
    public $contentData = [];
22
    public $templatesPath = '';
23
    public $loadedCss = [];
24
    public $loadedJs = [];
25
26
    public function init() {
27
        if (!empty($this->app->config['site']['name'])) {
28
            $this->title = $this->app->config['site']['name'];
29
        }
30
        $this->resolveTemplate();
31
    }
32
33
    public function resolveTemplate() {
34
        $templateName = 'default';
35
        if (!empty($this->config[$this->app->type]['current'])) {
36
            $templateName = $this->config[$this->app->type]['current'];
37
            if (!empty($this->config[$this->app->type]['installed'][$templateName]['location'])) {
38
                $this->templatesPath = App::$primary->path . "/templates";
39
            }
40
        }
41
        if (!$this->templatesPath) {
42
            $this->templatesPath = $this->app->path . "/templates";
43
        }
44
        $this->template = \View\Template::get($templateName, $this->app, $this->templatesPath);
45
        if (!$this->template) {
46
            $this->template = new \View\Template([
47
                'name' => 'default',
48
                'path' => $this->templatesPath . '/default',
49
                'app' => $this->app
50
            ]);
51
        }
52
    }
53
54
    public function page($params = []) {
55
        $this->paramsParse($params);
56
        if (file_exists($this->template->pagePath)) {
57
            $source = file_get_contents($this->template->pagePath);
58
            if (strpos($source, 'BODYEND') === false) {
59
                $source = str_replace('</body>', '{BODYEND}</body>', $source);
60
            }
61
            $this->parseSource($source);
62
        } else {
63
            $this->content();
64
        }
65
    }
66
67
    public function paramsParse($params) {
68
        // set template
69
        if (!empty($params['template']) && $params['template'] != 'current') {
70
            $this->template = \View\Template::get($params['template']);
71
        }
72
        //set page
73
        if (!empty($params['page']) && $params['page'] != 'current') {
74
            $this->template->setPage($params['page']);
75
        }
76
        //set module
77
        if (!empty($params['module'])) {
78
            $this->template->setModule($params['module']);
79
        }
80
        //set content
81
        if (!empty($params['content'])) {
82
            $this->template->setContent($params['content']);
83
        } elseif (!$this->template->contentPath) {
84
            $this->template->setContent();
85
        }
86
        //set data
87
        if (!empty($params['data'])) {
88
            $this->contentData = array_merge($this->contentData, $params['data']);
89
        }
90
    }
91
92
    public function content($params = []) {
93
94
        $this->paramsParse($params);
95
96
        if (empty($this->template->config['noSysMsgAutoShow'])) {
97
            Msg::show();
98
        }
99
        if (!file_exists($this->template->contentPath)) {
100
            echo 'Content not found';
101
        } else {
102
            extract($this->contentData);
103
            include $this->template->contentPath;
104
        }
105
    }
106
107
    public function parentContent($contentName = '') {
108
        if (!$contentName) {
109
            $contentName = $this->template->content;
110
        }
111
112
        $paths = $this->template->getContentPaths($contentName);
113
114
        $data = [];
115
        $exist = false;
116
        foreach ($paths as $type => $path) {
117
            if (substr($path, 0, strrpos($path, '/')) == substr($this->template->contentPath, 0, strrpos($this->template->contentPath, '/'))) {
118
                $exist = true;
119
                continue;
120
            }
121
            if (file_exists($path) && $exist) {
122
                $data['contentPath'] = $path;
123
                $data['content'] = $contentName;
124
                break;
125
            }
126
        }
127
        if (!$data) {
128
            echo 'Content not found';
129
        } else {
130
            extract($this->contentData);
131
            include $data['contentPath'];
132
        }
133
    }
134
135
    private function parseRaw($source) {
136
        if (!$source)
137
            return [];
138
139
        preg_match_all("|{([^}]+)}|", $source, $result);
140
        return $result[1];
141
    }
142
143
    public function parseSource($source) {
144
        $tags = $this->parseRaw($source);
145
        foreach ($tags as $rawTag) {
146
            $tag = explode(':', $rawTag);
147
            switch ($tag[0]) {
148
                case 'CONTENT':
149
                    $source = $this->cutTag($source, $rawTag);
150
                    $this->content();
151
                    break;
152
                case 'TITLE':
153
                    $source = $this->cutTag($source, $rawTag);
154
                    echo $this->title;
155
                    break;
156
                case 'WIDGET':
157
                    $source = $this->cutTag($source, $rawTag);
158
                    $params = array_slice($tag, 2);
159
                    $this->widget($tag[1], ['params' => $params], ':' . implode(':', $params));
160
                    break;
161
                case 'HEAD':
162
                    $source = $this->cutTag($source, $rawTag);
163
                    $this->head();
164
                    break;
165
                case 'PAGE':
166
                    $source = $this->cutTag($source, $rawTag);
167
                    $this->page(['page' => $tag[1]]);
168
                    break;
169
                case 'BODYEND':
170
                    $source = $this->cutTag($source, $rawTag);
171
                    $this->bodyEnd();
172
                    break;
173
            }
174
        }
175
        echo $source;
176
    }
177
178
    public function cutTag($source, $rawTag) {
179
        $pos = strpos($source, $rawTag) - 1;
180
        echo substr($source, 0, $pos);
181
        return substr($source, ( $pos + strlen($rawTag) + 2));
182
    }
183
184
    public function getHref($type, $params) {
185
        $href = '';
186
        if (is_string($params)) {
187
            $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params;
188
        } elseif (empty($params['template']) && !empty($params['file'])) {
189
            $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params['file'];
190
        } elseif (!empty($params['template']) && !empty($params['file'])) {
191
            $href = $this->app->templatesPath . "/{$this->template->name}/{$type}/{$params['file']}";
192
        }
193
        return $href;
194
    }
195
196
    public function checkNeedLibs() {
197
        if (!empty($this->template->config['libs'])) {
198
            foreach ($this->template->config['libs'] as $libName => $libOptions) {
199
                if (!is_array($libOptions)) {
200
                    $libName = $libOptions;
201
                    $libOptions = [];
202
                }
203
                $this->app->libs->loadLib($libName, $libOptions);
204
            }
205
        }
206 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...
207
            if (is_array($asset) && !empty($asset['libs'])) {
208
                foreach ($asset['libs'] as $libName) {
209
                    $this->app->libs->loadLib($libName);
210
                }
211
            }
212
        }
213 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...
214
            if (is_array($asset) && !empty($asset['libs'])) {
215
                foreach ($asset['libs'] as $libName) {
216
                    $this->app->libs->loadLib($libName);
217
                }
218
            }
219
        }
220
    }
221
222
    public function head() {
223
224
        echo "<title>{$this->title}</title>\n";
225
226
        if (!empty($this->template->config['favicon']) && file_exists($this->template->path . "/{$this->template->config['favicon']}")) {
227
            echo "        <link rel='shortcut icon' href='/templates/{$this->template->name}/{$this->template->config['favicon']}' />";
228
        } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path . "/static/images/{$this->template->config['favicon']}")) {
229
            echo "        <link rel='shortcut icon' href='/static/images/{$this->template->config['favicon']}' />";
230
        } elseif (file_exists($this->app->path . '/static/images/favicon.ico')) {
231
            echo "        <link rel='shortcut icon' href='/static/images/favicon.ico' />";
232
        }
233
234
        foreach ($this->getMetaTags() as $meta) {
235
            echo "\n        " . Html::el('meta', $meta, '', null);
236
        }
237
238
        if (!empty(Inji::$config['assets']['js'])) {
239
            foreach (Inji::$config['assets']['js'] as $js) {
240
                $this->customAsset('js', $js);
241
            }
242
        }
243
244
        $this->checkNeedLibs();
245
        $this->parseCss();
246
        echo "\n        <script src='" . Statics::file(($this->app->type != 'app' ? '/' . $this->app->name : '' ) . "/static/system/js/Inji.js") . "'></script>";
247
    }
248
249
    public function parseCss() {
250
        $css = $this->getCss();
251
        $urls = [];
252
        $timeStr = '';
253
        $cssAll = '';
254
        $exclude = ['^http:', '^https:', '^//'];
255
        foreach ($css as $href) {
256
            if (!empty($this->loadedCss[$href])) {
257
                continue;
258
            }
259
            foreach ($exclude as $item) {
260
                if (preg_match("!{$item}!", $href)) {
261
                    echo "\n        <link href='{$href}' rel='stylesheet' type='text/css' />";
262
                    continue;
263
                }
264
            }
265
            $path = $this->app->staticLoader->parsePath($href);
266
            if (file_exists($path)) {
267
                $this->loadedCss[$href] = $href;
268
                $urls[$href] = $path;
269
                $timeStr.=filemtime($path);
270
            } else {
271
                echo "\n        <link href='{$href}' rel='stylesheet' type='text/css' />";
272
            }
273
        }
274
        $timeMd5 = md5($timeStr);
275
        $cacheDir = Cache::getDir('static');
276
        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.css')) {
277
            foreach ($urls as $primaryUrl => $url) {
278
                $source = file_get_contents($url);
279
                $rootPath = substr($primaryUrl, 0, strrpos($primaryUrl, '/'));
280
                $levelUpPath = substr($rootPath, 0, strrpos($rootPath, '/'));
281
                $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1' . $levelUpPath, $source);
282
                $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1' . $rootPath, $source);
283
                $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1' . $rootPath . '/$2', $source);
284
                $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url(' . $rootPath . '/$1$2', $source);
285
                $cssAll .= $source;
286
            }
287
            file_put_contents($cacheDir . '/all' . $timeMd5 . '.css', $cssAll);
288
        }
289
        echo "\n        <link href='/{$cacheDir}/all{$timeMd5}.css' rel='stylesheet' type='text/css' />";
290
    }
291
292 View Code Duplication
    public function getCss() {
293
        $css = [];
294
        if (!empty($this->libAssets['css'])) {
295
            $this->ResolveCssHref($this->libAssets['css'], 'libs', $css);
296
        }
297
        if (!empty($this->template->config['css'])) {
298
            $this->ResolveCssHref($this->template->config['css'], 'template', $css);
299
        }
300
        if (!empty($this->dynAssets['css'])) {
301
            $this->ResolveCssHref($this->dynAssets['css'], 'custom', $css);
302
        }
303
        return $css;
304
    }
305
306
    public function ResolveCssHref($cssArray, $type = 'custom', &$hrefs) {
307
        switch ($type) {
308 View Code Duplication
            case'libs':
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...
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
309
                foreach ($cssArray as $css) {
310
                    if (is_array($css)) {
311
                        $this->ResolveCssHref($css, $type, $hrefs);
312
                        continue;
313
                    }
314
                    if (strpos($css, '//') !== false)
315
                        $href = $css;
316
                    else
317
                        $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css;
318
                    $hrefs[$href] = $href;
319
                }
320
                break;
321 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...
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
322
                foreach ($cssArray as $css) {
323
                    if (is_array($css)) {
324
                        $this->ResolveCssHref($css, $type, $hrefs);
325
                        continue;
326
                    }
327
                    if (strpos($css, '://') !== false)
328
                        $href = $css;
329
                    else
330
                        $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}";
331
                    $hrefs[$href] = $href;
332
                }
333
                break;
334 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...
335
                foreach ($cssArray as $css) {
336
                    if (is_array($css)) {
337
                        $this->ResolveCssHref($css, $type, $hrefs);
338
                        continue;
339
                    }
340
                    if (strpos($css, '//') !== false)
341
                        $href = $css;
342
                    else
343
                        $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css;
344
                    $hrefs[$href] = $href;
345
                }
346
                break;
347
        }
348
    }
349
350
    public function getMetaTags() {
351
        $metas = [];
352
353 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...
354
            $metas['metaName:keywords'] = ['name' => 'keywords', 'content' => $this->app->config['site']['keywords']];
355
        }
356 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...
357
            $metas['metaName:description'] = ['name' => 'description', 'content' => $this->app->config['site']['description']];
358
        }
359
        if (!empty($this->app->config['site']['metatags'])) {
360
            foreach ($this->app->config['site']['metatags'] as $meta) {
361
                if (!empty($meta['name'])) {
362
                    $metas['metaName:' . $meta['name']] = $meta;
363
                } elseif (!empty($meta['property'])) {
364
                    $metas['metaProperty:' . $meta['property']] = $meta;
365
                }
366
            }
367
        }
368
        if ($this->dynMetas) {
369
            $metas = array_merge($metas, $this->dynMetas);
370
        }
371
        return $metas;
372
    }
373
374
    public function addMetaTag($meta) {
375
        if (!empty($meta['name'])) {
376
            $this->dynMetas['metaName:' . $meta['name']] = $meta;
377
        } elseif (!empty($meta['property'])) {
378
            $this->dynMetas['metaProperty:' . $meta['property']] = $meta;
379
        }
380
    }
381
382
    public function bodyEnd() {
383
        $this->checkNeedLibs();
384
        $this->parseCss();
385
        $scripts = $this->getScripts();
386
        $onLoadModules = [];
387
        $scriptAll = '';
388
        $urls = [];
389
        $nativeUrl = [];
390
        $timeStr = '';
391
        $noParsedScripts = [];
392
        foreach ($scripts as $script) {
393
            if (is_string($script)) {
394
                if (!empty($urls[$script]))
395
                    continue;
396
397
                $path = $this->app->staticLoader->parsePath($script);
398
                if (file_exists($path)) {
399
                    $nativeUrl[$script] = $script;
400
                    $urls[$script] = $path;
401
                    $timeStr.=filemtime($path);
402
                } else {
403
                    $noParsedScripts[$script] = $script;
404
                }
405
            } elseif (!empty($script['file'])) {
406
                if (!empty($urls[$script['file']]))
407
                    continue;
408
409
                $path = $this->app->staticLoader->parsePath($script['file']);
410
                if (file_exists($path)) {
411
                    $nativeUrl[$script['file']] = $script['file'];
412
                    $urls[$script['file']] = $path;
413
                    if (!empty($script['name'])) {
414
                        $onLoadModules[$script['name']] = $script['name'];
415
                    }
416
                    $timeStr.=filemtime($path);
417
                } else {
418
                    $noParsedScripts[$script] = $script;
419
                }
420
            }
421
        }
422
423
        $timeMd5 = md5($timeStr);
424
        $cacheDir = Cache::getDir('static');
425
        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.js')) {
426
            foreach ($urls as $url) {
427
                $scriptAll .= ';' . file_get_contents($url);
428
            }
429
            file_put_contents($cacheDir . '/all' . $timeMd5 . '.js', $scriptAll);
430
        }
431
        $options = [
432
            'scripts' => array_values($noParsedScripts),
433
            'compresedScripts' => $nativeUrl,
434
            'styles' => [],
435
            'appRoot' => $this->app->type == 'app' ? '/' : '/' . $this->app->name . '/',
436
            'onLoadModules' => $onLoadModules
437
        ];
438
        $options['scripts'][] = '/' . $cacheDir . '/all' . $timeMd5 . '.js';
439
        $this->widget('View\bodyEnd', compact('options'));
440
    }
441
442 View Code Duplication
    public function getScripts() {
443
        $scripts = [];
444
        if (!empty($this->libAssets['js'])) {
445
            $this->genScriptArray($this->libAssets['js'], 'libs', $scripts);
446
        }
447
        if (!empty($this->dynAssets['js'])) {
448
            $this->genScriptArray($this->dynAssets['js'], 'custom', $scripts);
449
        }
450
        if (!empty($this->template->config['js'])) {
451
            $this->genScriptArray($this->template->config['js'], 'template', $scripts);
452
        }
453
        return $scripts;
454
    }
455
456
    public function genScriptArray($jsArray, $type = 'custom', &$resultArray) {
457
        switch ($type) {
458
            case 'libs':
459
                foreach ($jsArray as $js) {
460
                    if (is_array($js)) {
461
                        $this->genScriptArray($js, $type, $resultArray);
462
                        continue;
463
                    }
464
                    if (strpos($js, '//') !== false)
465
                        $href = $js;
466
                    else
467
                        $href = $this->getHref('js', $js);
468
                    if (!$href)
469
                        continue;
470
471
                    $resultArray[] = $href;
472
                }
473
                break;
474 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...
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

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