Check for conflicting imported classes with local classes.
1 | <?php |
||
2 | |||
3 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
4 | /** @var \Apps\Model\Install\Main\EntityCheck $check */ |
||
5 | /** @var array $stats */ |
||
6 | /** @var boolean $tokenActive */ |
||
7 | /** @var array $yandexCfg */ |
||
8 | /** @var array|null $visits */ |
||
9 | /** @var array|null $sources */ |
||
10 | |||
11 | use Ffcms\Core\Helper\Date; |
||
12 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
13 | |||
14 | $this->layout('_layouts/default', [ |
||
15 | 'title' => __('Main') |
||
16 | ]) |
||
17 | ?> |
||
18 | |||
19 | <?php $this->start('body'); ?> |
||
20 | |||
21 | <h1><?= __('Main dashboard') ?></h1> |
||
22 | <hr /> |
||
23 | <div class="row"> |
||
24 | <div class="col-md-4"> |
||
25 | <h3><?= __('Server info') ?></h3> |
||
26 | <div class="table-responsive"> |
||
27 | <?= $this->table(['class' => 'table']) |
||
28 | ->row([ |
||
29 | ['text' => __('FFCMS version')], |
||
30 | ['text' => $stats['ff_version']] |
||
31 | ]) |
||
32 | ->row([ |
||
33 | ['text' => __('PHP version')], |
||
34 | ['text' => $stats['php_version']] |
||
35 | ]) |
||
36 | ->row([ |
||
37 | ['text' => __('OS name')], |
||
38 | ['text' => $stats['os_name']] |
||
39 | ]) |
||
40 | ->row([ |
||
41 | ['text' => __('Database')], |
||
42 | ['text' => $stats['database_name']] |
||
43 | ]) |
||
44 | ->row([ |
||
45 | ['text' => __('Files size')], |
||
46 | ['text' => $stats['file_size']] |
||
47 | ]) |
||
48 | ->row([ |
||
49 | ['text' => __('Load average')], |
||
50 | ['text' => $stats['load_avg']] |
||
51 | ]) |
||
52 | ->display(); ?> |
||
53 | </div> |
||
54 | </div> |
||
55 | <div class="col-md-4"> |
||
56 | <h3><?= __('Directories and files') ?></h3> |
||
57 | <?php |
||
58 | foreach ($check->chmodCheck as $dir => $status) { |
||
59 | echo $this->bootstrap()->badge(($status ? 'success' : 'danger'), $dir) . " "; |
||
60 | } |
||
61 | ?> |
||
62 | <hr /> |
||
63 | <p><?= __('All directories and files in this list required to be readable and writable.') ?></p> |
||
64 | <hr /> |
||
65 | <?= $this->bootstrap()->button('a', __('Clear cache'), ['href' => Url::to('main/cache'), 'class' => 'btn-warning']) ?> |
||
66 | <?= $this->bootstrap()->button('a', __('Clear sessions'), ['href' => Url::to('main/sessions'), 'class' => 'btn-info']) ?> |
||
67 | </div> |
||
68 | <div class="col-md-4"> |
||
69 | <h3><?= __('FFCMS News') ?></h3> |
||
70 | <ul id="ffcms-news-list"> |
||
71 | <li>No internet connection</li> |
||
72 | </ul> |
||
73 | </div> |
||
74 | </div> |
||
75 | |||
76 | <div class="row"> |
||
77 | <div class="col-md"> |
||
78 | <h2 class="mt-2"><?= __('Yandex.Metrika') ?></h2> |
||
79 | <hr /> |
||
80 | <?php if (!$tokenActive): ?> |
||
81 | <?= $this->bootstrap()->button('a', __('Connect Yandex.Metrika'), [ |
||
82 | 'href' => Url::to('main/yandexconnect'), |
||
83 | 'class' => 'btn-danger' |
||
84 | ]) ?> |
||
85 | <?php else: ?> |
||
86 | <div class="row"> |
||
87 | <div class="col-md-8"> |
||
88 | <canvas id="visitChart" width="100%" height="50"></canvas> |
||
89 | </div> |
||
90 | <div class="col-md-4"> |
||
91 | <canvas id="sourcesChart" width="100%" height="90"></canvas> |
||
92 | </div> |
||
93 | </div> |
||
94 | <?php endif; ?> |
||
95 | </div> |
||
96 | </div> |
||
97 | |||
98 | <?php $this->stop() ?> |
||
99 | |||
100 | <?php $this->push('javascript') ?> |
||
101 | <?php if ($tokenActive): ?> |
||
102 | <script type="text/javascript" src="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/node_modules/chart.js/dist/Chart.min.js"></script> |
||
103 | <?php |
||
104 | // visit chart |
||
105 | $dates = []; |
||
106 | $views = []; |
||
107 | $users = []; |
||
108 | $bounce = []; |
||
109 | foreach ($visits as $date => $info) { |
||
110 | $dates[] = Date::convertToDatetime($date, Date::FORMAT_TO_DAY); |
||
111 | $views[] = $info['views']; |
||
112 | $users[] = $info['users']; |
||
113 | $bounce[] = $info['bounce']; |
||
114 | } |
||
115 | |||
116 | // sources chart |
||
117 | $sourceTypes = array_keys($sources); |
||
118 | $sourceUsers = array_values($sources); |
||
119 | |||
120 | ?> |
||
121 | <script> |
||
122 | var visitElement = $('#visitChart').get(0); |
||
123 | var sourcesElement = $('#sourcesChart').get(0); |
||
124 | var chartColors = { |
||
125 | red: 'rgb(255, 99, 132)', |
||
126 | orange: 'rgb(255, 159, 64)', |
||
127 | yellow: 'rgb(255, 205, 86)', |
||
128 | green: 'rgb(75, 192, 192)', |
||
129 | blue: 'rgb(54, 162, 235)', |
||
130 | purple: 'rgb(153, 102, 255)', |
||
131 | grey: 'rgb(231,233,237)' |
||
132 | }; |
||
133 | |||
134 | var visitChart = new Chart(visitElement, { |
||
135 | type: 'line', |
||
136 | data: { |
||
137 | labels: [<?php foreach ($dates as $date){ echo '"' . $date . '", '; } ?>], |
||
138 | datasets: [{ |
||
139 | yAxisID: 'units', |
||
140 | label: '<?= __('Views') ?>', |
||
141 | borderColor: chartColors.blue, |
||
142 | fill: false, // no background color |
||
143 | data: [<?= implode(',', $views) ?>] |
||
144 | }, { |
||
145 | yAxisID: 'units', |
||
146 | label: '<?= __('Users') ?>', |
||
147 | borderColor: chartColors.green, |
||
148 | fill: false, // no background color |
||
149 | data: [<?= implode(',', $users) ?>] |
||
150 | }, { |
||
151 | yAxisID: 'percentage', |
||
152 | label: '<?= __('Bounces, %') ?>', |
||
153 | borderColor: chartColors.red, |
||
154 | fill: false, // no background color |
||
155 | data: [<?= implode(',', $bounce) ?>] |
||
156 | }] |
||
157 | }, |
||
158 | options: { |
||
159 | responsive: true, |
||
160 | legend: { |
||
161 | display: true |
||
162 | }, |
||
163 | title: { |
||
164 | display: true, |
||
165 | text: '<?= __('Users, page views, bounces - 30 days') ?>' |
||
166 | }, |
||
167 | scales: { |
||
168 | yAxes: [{ |
||
169 | id: 'units', |
||
170 | type: 'linear', |
||
171 | position: 'left' |
||
172 | }, { |
||
173 | id: 'percentage', |
||
174 | type: 'linear', |
||
175 | position: 'right' |
||
176 | }] |
||
177 | } |
||
178 | } |
||
179 | }); |
||
180 | |||
181 | var sourceChart = new Chart(sourcesElement, { |
||
182 | type: 'pie', |
||
183 | data: { |
||
184 | labels: [<?php foreach ($sourceTypes as $type){ echo '"' . $type . '", '; } ?>], |
||
185 | datasets: [{ |
||
186 | data: [<?= implode(',', $sourceUsers) ?>], |
||
187 | label: 'Users', |
||
188 | backgroundColor: Object.values(chartColors) |
||
189 | }] |
||
190 | }, |
||
191 | options: { |
||
192 | responsive: true, |
||
193 | title: { |
||
194 | display: true, |
||
195 | text: '<?= __('Traffic sources - 30 days') ?>' |
||
196 | } |
||
197 | } |
||
198 | }); |
||
199 | </script> |
||
200 | <?php endif; ?> |
||
201 | <script> |
||
202 | $(document).ready(function(){ |
||
203 | $.getJSON(script_url + '/api/main/news?lang=' + script_lang, function (resp) { |
||
204 | if (resp.status !== 1) { |
||
205 | return; |
||
206 | } |
||
207 | $('#ffcms-news-list').empty(); |
||
208 | $.each(resp.data, function (key, news) { |
||
209 | $('<li>').html($('<a>', { |
||
210 | href: news.url, |
||
211 | target: '_blank', |
||
212 | text: news.title |
||
213 | })).appendTo('#ffcms-news-list'); |
||
214 | }); |
||
215 | }); |
||
216 | }); |
||
217 | </script> |
||
218 | <?php $this->stop() ?> |
||
219 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: