|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Inji\View\Page; |
|
4
|
|
|
|
|
5
|
|
|
use Inji\App; |
|
6
|
|
|
use Inji\View\Page; |
|
7
|
|
|
|
|
8
|
|
|
class Head { |
|
9
|
|
|
/** |
|
10
|
|
|
* @var Page |
|
11
|
|
|
*/ |
|
12
|
|
|
public $page; |
|
13
|
|
|
|
|
14
|
|
|
function __construct(Page $page) { |
|
15
|
|
|
$this->page = $page; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function generate() { |
|
19
|
|
|
$html = ''; |
|
20
|
|
|
foreach ($this->elements() as $el) { |
|
21
|
|
|
$html .= call_user_func_array(['Inji\Html', 'el'], $el) . "\n"; |
|
22
|
|
|
} |
|
23
|
|
|
return $html; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function elements() { |
|
27
|
|
|
$els = [ |
|
28
|
|
|
['title', $this->page->title], |
|
29
|
|
|
['link', '', ['rel' => 'shortcut icon', 'href' => $this->faviconPath()], null] |
|
30
|
|
|
]; |
|
31
|
|
|
foreach ($this->getMetaTags() as $meta) { |
|
32
|
|
|
$els[] = ['meta', $meta, '', null]; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
if (empty($this->page->template->config['noInjects']) && !empty(\Inji::$config['assets']['js'])) { |
|
36
|
|
|
foreach (\Inji::$config['assets']['js'] as $js) { |
|
37
|
|
|
$this->customAsset('js', $js); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$this->checkNeedLibs(); |
|
|
|
|
|
|
42
|
|
|
$this->parseCss(); |
|
|
|
|
|
|
43
|
|
|
echo "\n <script src='" . Statics::file("/static/system/js/Inji.js") . "'></script>"; |
|
|
|
|
|
|
44
|
|
|
return $els; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function customAsset($type, $asset, $lib = false) { |
|
48
|
|
|
if (!$lib) { |
|
49
|
|
|
$this->dynAssets[$type][] = $asset; |
|
|
|
|
|
|
50
|
|
|
} else { |
|
51
|
|
|
if (empty($this->libAssets[$type][$lib]) || !in_array($asset, $this->libAssets[$type][$lib])) { |
|
52
|
|
|
$this->libAssets[$type][$lib][] = $asset; |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function faviconPath() { |
|
58
|
|
|
if (!empty(App::$primary->config['site']['favicon']) && file_exists(App::$primary->path . '/' . App::$primary->config['site']['favicon'])) { |
|
59
|
|
|
return App::$primary->config['site']['favicon']; |
|
60
|
|
|
} |
|
61
|
|
|
if (!empty($this->page->template->config['favicon']) && file_exists($this->page->template->path . "/{$this->page->template->config['favicon']}")) { |
|
62
|
|
|
return $this->page->template->name . '/' . $this->page->template->config['favicon']; |
|
63
|
|
|
} |
|
64
|
|
|
if (!empty($this->page->template->config['favicon']) && file_exists($this->page->app->path . "/static/images/{$this->page->template->config['favicon']}")) { |
|
65
|
|
|
return '/static/images/' . $this->page->template->config['favicon']; |
|
66
|
|
|
} |
|
67
|
|
|
if (file_exists($this->page->app->path . '/static/images/favicon.ico')) { |
|
68
|
|
|
return '/static/images/favicon.ico'; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getMetaTags() { |
|
73
|
|
|
$metas = []; |
|
74
|
|
|
|
|
75
|
|
|
if (!empty($this->page->app->config['site']['keywords'])) { |
|
76
|
|
|
$metas['metaName:keywords'] = ['name' => 'keywords', 'content' => $this->page->app->config['site']['keywords']]; |
|
77
|
|
|
} |
|
78
|
|
|
if (!empty($this->page->app->config['site']['description'])) { |
|
79
|
|
|
$metas['metaName:description'] = ['name' => 'description', 'content' => $this->page->app->config['site']['description']]; |
|
80
|
|
|
} |
|
81
|
|
|
if (!empty($this->page->app->config['site']['metatags'])) { |
|
82
|
|
|
foreach ($this->page->app->config['site']['metatags'] as $meta) { |
|
83
|
|
|
if (!empty($meta['name'])) { |
|
84
|
|
|
$metas['metaName:' . $meta['name']] = $meta; |
|
85
|
|
|
} elseif (!empty($meta['property'])) { |
|
86
|
|
|
$metas['metaProperty:' . $meta['property']] = $meta; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
if ($this->dynMetas) { |
|
|
|
|
|
|
91
|
|
|
$metas = array_merge($metas, $this->dynMetas); |
|
92
|
|
|
} |
|
93
|
|
|
return $metas; |
|
94
|
|
|
} |
|
95
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.