12
12
class Stub implements View
13
13
{
14
14
15
+ private $ app ;
15
16
private $ docType ;
16
17
private $ head ;
17
18
private $ body ;
@@ -29,21 +30,23 @@ class Stub implements View
29
30
public function __construct (Application $ app , BaseDefaultStubResource $ r )
30
31
{
31
32
$ this ->stringResources = $ r ;
32
- $ this ->generate ($ app );
33
+ $ this ->app = $ app ;
34
+ $ this ->generate ();
33
35
}
34
36
35
37
/**
36
38
* Выполняется генерация наполнения основных блоков HTML документа заглушки
37
- * @param Application $app
38
39
* @return void
39
40
*/
40
- private function generate (Application $ app )
41
+ private function generate ()
41
42
{
42
43
/**
43
44
* Технический комментарий
44
- * @var \Stub\Framework\Main\Assets\ BaseDefaultStubResource $r
45
+ * @var BaseDefaultStubResource $r
45
46
*/
47
+ $ app = $ this ->app ;
46
48
$ r = $ this ->stringResources ;
49
+ $ c = $ app ->getConfig ();
47
50
$ this ->docType = "<!DOCTYPE html> " ;
48
51
$ this ->head = /** @lang text */
49
52
"
@@ -57,15 +60,21 @@ private function generate(Application $app)
57
60
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,600,600i,700,700i">
58
61
59
62
<!-- Favicons -->
60
- <link href="img/favicon.png" rel="icon">
61
- <link href="img/apple-touch-icon.png" rel="apple-touch-icon">
63
+ <link href="/ img/favicon.png" rel="icon">
64
+ <link href="/ img/apple-touch-icon.png" rel="apple-touch-icon">
62
65
63
66
<!-- Vendor CSS Files -->
64
- <link href="vendor/twbs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
65
- <link href="vendor/simplerest/icofont/icofont.min.css" rel="stylesheet">
67
+ <link href="/vendor/twbs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
68
+ <link href="/vendor/simplerest/icofont/icofont.min.css" rel="stylesheet">
69
+
70
+ <!-- Flag-icons-->
71
+ <link
72
+ rel="stylesheet"
73
+ href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@6.14.0/css/flag-icons.min.css"
74
+ />
66
75
67
76
<!-- Template Main CSS File -->
68
- <link href="css/main.css" rel="stylesheet">
77
+ <link href="/ css/main.css" rel="stylesheet">
69
78
' ;
70
79
71
80
$ this ->body = /** @lang text */
@@ -78,10 +87,13 @@ private function generate(Application $app)
78
87
<a href="index.php">
79
88
<span> ' . $ r ::$ domain . ' </span>
80
89
</a>
81
- </h1>
90
+ </h1>
82
91
</div>
92
+
83
93
<div class="contact-link float-right">
84
- <a href="#contacts" class="scrollto"> ' . $ r ::$ contacts_link_text . '</a>
94
+ ' . (($ c ::IsLanguageSelectorDisabled ()) ? "" : $ this ->putLanguageSelector ($ r ::$ lang , $ c ::getLanguageSet ())) . '
95
+
96
+ <a href="#contacts" class="scrollto"><span class="fi fi- ' . $ r ::$ lang . '"></span> ' . $ r ::$ contacts_link_text . '</a>
85
97
</div>
86
98
</div>
87
99
</header>
@@ -90,7 +102,7 @@ private function generate(Application $app)
90
102
<div class="container-fluid" style="padding-right: 0; padding-left: 0;">
91
103
<!-- ======= Base Stub Section ======= -->
92
104
<section id="stub"
93
- style="background-image: url( \'img/ ' . $ r ::$ base_background . '\')">
105
+ style="background-image: url( \'/ img/ ' . $ r ::$ base_background . '\')">
94
106
<div class="stub-container">
95
107
<BR><BR>
96
108
<h1> ' . $ r ::$ base_title . "</h1>
@@ -164,7 +176,7 @@ private function generate(Application $app)
164
176
</footer><!-- End #footer -->
165
177
' ;
166
178
$ this ->endHtmlScripts = /** @lang text */
167
- '<script src="js/main.js"></script> ' ;
179
+ '<script src="/ js/main.js"></script> ' ;
168
180
}
169
181
170
182
/**
@@ -181,4 +193,26 @@ public function getDocumentResult(): string
181
193
$ this ->body ,
182
194
$ this ->endHtmlScripts );
183
195
}
196
+
197
+ private function putLanguageSelector (string $ languageCode , array $ c = array ()): string
198
+ {
199
+ $ tpl = "" ;
200
+ if (empty ($ c )) {
201
+ $ tpl .= '' ;
202
+ } elseif (count ($ c ) == 1 ) {
203
+ $ tpl .= strtoupper (key ($ c ));
204
+ } else {
205
+ $ tpl .= '<a><select onchange="window.location.href = this.options[this.selectedIndex].value"> ' ;
206
+ foreach ($ c as $ key => $ item ) {
207
+ $ tpl .= '<option value="/ ' . strtolower ($ key ) . '" ' ;
208
+ if (strtolower ($ key ) == strtolower ($ languageCode )) {
209
+ $ tpl .= 'selected="selected" ' ;
210
+ }
211
+ $ tpl .= '> ' . $ item . '</option> ' ;
212
+ }
213
+ $ tpl .= ' </select></a> ' ;
214
+ }
215
+
216
+ return $ tpl ;
217
+ }
184
218
}
0 commit comments