|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Inji\View; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
class Content { |
|
8
|
|
|
public $name = ''; |
|
9
|
|
|
public $path = ''; |
|
10
|
|
|
public $data = []; |
|
11
|
|
|
/** |
|
12
|
|
|
* @var Page |
|
13
|
|
|
*/ |
|
14
|
|
|
public $page; |
|
15
|
|
|
|
|
16
|
|
|
function __construct($params, ?Page $page) { |
|
|
|
|
|
|
17
|
|
|
$this->name = $params['name'] ?? 'index'; |
|
18
|
|
|
$this->setPath($params['path'] ?? false); |
|
19
|
|
|
$this->setData($params['data'] ?? []); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
function setData($data = []) { |
|
|
|
|
|
|
23
|
|
|
if ($data) { |
|
24
|
|
|
$this->data = array_merge($this->data, $data); |
|
25
|
|
|
} |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
function setPath($path = false) { |
|
|
|
|
|
|
29
|
|
|
if ($path) { |
|
30
|
|
|
$this->path = $path; |
|
31
|
|
|
} elseif (!$this->path) { |
|
32
|
|
|
$this->path = \Inji\Tools::pathsResolve($this->getPaths($this->name), $this->path); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function getPaths($content = '') { |
|
38
|
|
|
if (!$content) { |
|
39
|
|
|
$content = $this->name; |
|
40
|
|
|
} |
|
41
|
|
|
$paths = []; |
|
42
|
|
|
if ($this->page && $this->page->module) { |
|
43
|
|
|
if (\Inji\Controller::$cur) { |
|
44
|
|
|
$paths['templateModuleController'] = $this->path . "/modules/{$this->page->module->name}/" . \Inji\Controller::$cur->name . "/{$content}.php"; |
|
45
|
|
|
} |
|
46
|
|
|
$paths['templateModule'] = $this->path . "/modules/{$this->page->module->name}/{$content}.php"; |
|
47
|
|
|
} |
|
48
|
|
|
if (\Inji\Module::$cur) { |
|
49
|
|
|
if (\Inji\Controller::$cur) { |
|
50
|
|
|
$paths['templateCurModuleController'] = $this->path . "/modules/" . \Inji\Module::$cur->name . "/" . \Inji\Controller::$cur->name . "/{$content}.php"; |
|
51
|
|
|
} |
|
52
|
|
|
$paths['templateCurModule'] = $this->path . "/modules/" . \Inji\Module::$cur->name . "/{$content}.php"; |
|
53
|
|
|
} |
|
54
|
|
|
if (\Inji\Controller::$cur) { |
|
55
|
|
|
$modulePaths = \Inji\Module::getModulePaths(\Inji\Controller::$cur->module->name); |
|
56
|
|
|
foreach ($modulePaths as $key => $modulePath) { |
|
57
|
|
|
$paths['module_' . $key . '_appType'] = $modulePath . '/views/' . \Inji\Controller::$cur->module->app->type . '/' . \Inji\Controller::$cur->name . "/{$content}.php"; |
|
58
|
|
|
$paths['module_' . $key . '_appType_controllerName'] = $modulePath . '/views/' . \Inji\Controller::$cur->module->app->type . "/{$content}.php"; |
|
59
|
|
|
$paths['module_' . $key] = $modulePath . '/views/' . "/{$content}.php"; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if ($this->page->module) { |
|
64
|
|
|
if (\Inji\Controller::$cur) { |
|
65
|
|
|
$paths['customModuleTemplateControllerContentController'] = $this->path . "/modules/" . $this->page->module->name . "/" . \Inji\Controller::$cur->name . "/{$content}.php"; |
|
66
|
|
|
} |
|
67
|
|
|
$paths['customModuleTemplateControllerContent'] = $this->path . "/modules/" . $this->page->module->name . "/{$content}.php"; |
|
68
|
|
|
} |
|
69
|
|
|
if ($this->page->module && \Inji\Controller::$cur) { |
|
70
|
|
|
$paths['customModuleControllerContentController'] = $this->page->module->path . '/' . \Inji\Controller::$cur->module->app->type . "Controllers/content/" . \Inji\Controller::$cur->name . "/{$content}.php"; |
|
71
|
|
|
$paths['customModuleControllerContent'] = $this->page->module->path . '/' . \Inji\Controller::$cur->module->app->type . "Controllers/content/{$content}.php"; |
|
72
|
|
|
} |
|
73
|
|
|
return $paths; |
|
74
|
|
|
} |
|
75
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.