@@ -18,374 +18,374 @@ |
||
18 | 18 | */ |
19 | 19 | abstract class View extends Base |
20 | 20 | { |
21 | - /** @var \App\Viewer Viewer object. */ |
|
22 | - protected $viewer; |
|
21 | + /** @var \App\Viewer Viewer object. */ |
|
22 | + protected $viewer; |
|
23 | 23 | |
24 | - /** {@inheritdoc} */ |
|
25 | - public function __construct(\App\Request $request) |
|
26 | - { |
|
27 | - parent::__construct($request); |
|
28 | - $this->loadJsConfig($request); |
|
29 | - $this->viewer = new \App\Viewer(); |
|
30 | - $this->viewer->assign('MODULE_NAME', $this->getModuleNameFromRequest($this->request)); |
|
31 | - $this->viewer->assign('VIEW', $this->request->getByType('view', \App\Purifier::ALNUM)); |
|
32 | - $this->viewer->assign('NONCE', \App\Session::get('CSP_TOKEN')); |
|
33 | - $this->viewer->assign('LANGUAGE', \App\Language::getLanguage()); |
|
34 | - $this->viewer->assign('LANG', \App\Language::getShortLanguageName()); |
|
35 | - $this->viewer->assign('USER', \App\User::getUser()); |
|
36 | - $this->viewer->assign('ACTION_NAME', $this->request->getAction()); |
|
37 | - } |
|
24 | + /** {@inheritdoc} */ |
|
25 | + public function __construct(\App\Request $request) |
|
26 | + { |
|
27 | + parent::__construct($request); |
|
28 | + $this->loadJsConfig($request); |
|
29 | + $this->viewer = new \App\Viewer(); |
|
30 | + $this->viewer->assign('MODULE_NAME', $this->getModuleNameFromRequest($this->request)); |
|
31 | + $this->viewer->assign('VIEW', $this->request->getByType('view', \App\Purifier::ALNUM)); |
|
32 | + $this->viewer->assign('NONCE', \App\Session::get('CSP_TOKEN')); |
|
33 | + $this->viewer->assign('LANGUAGE', \App\Language::getLanguage()); |
|
34 | + $this->viewer->assign('LANG', \App\Language::getShortLanguageName()); |
|
35 | + $this->viewer->assign('USER', \App\User::getUser()); |
|
36 | + $this->viewer->assign('ACTION_NAME', $this->request->getAction()); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Check permission. |
|
41 | - * |
|
42 | - * @throws \App\Exceptions\NoPermitted |
|
43 | - * |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function checkPermission(): void |
|
47 | - { |
|
48 | - $this->getModuleNameFromRequest($this->request); |
|
49 | - if (!\App\User::getUser()->isPermitted($this->moduleName)) { |
|
50 | - throw new \App\Exceptions\AppException('ERR_MODULE_PERMISSION_DENIED'); |
|
51 | - } |
|
52 | - } |
|
39 | + /** |
|
40 | + * Check permission. |
|
41 | + * |
|
42 | + * @throws \App\Exceptions\NoPermitted |
|
43 | + * |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function checkPermission(): void |
|
47 | + { |
|
48 | + $this->getModuleNameFromRequest($this->request); |
|
49 | + if (!\App\User::getUser()->isPermitted($this->moduleName)) { |
|
50 | + throw new \App\Exceptions\AppException('ERR_MODULE_PERMISSION_DENIED'); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** {@inheritdoc} */ |
|
55 | - public function preProcess($display = true): void |
|
56 | - { |
|
57 | - if ($this->loginRequired()) { |
|
58 | - $this->viewer->assign('MENU', \YF\Modules\Base\Model\Menu::getInstance($this->viewer->getTemplateVars('MODULE_NAME'))->getMenu()); |
|
59 | - } |
|
60 | - $this->viewer->assign('PAGE_TITLE', (\Conf\Config::$siteName ?: \App\Language::translate('LBL_CUSTOMER_PORTAL')) . ' ' . $this->getPageTitle()); |
|
61 | - $this->viewer->assign('CSS_FILE', $this->getHeaderCss()); |
|
62 | - $this->viewer->assign('USER_QUICK_MENU', $this->getUserQuickMenuLinks()); |
|
63 | - if ($display) { |
|
64 | - $this->preProcessDisplay(); |
|
65 | - } |
|
66 | - } |
|
54 | + /** {@inheritdoc} */ |
|
55 | + public function preProcess($display = true): void |
|
56 | + { |
|
57 | + if ($this->loginRequired()) { |
|
58 | + $this->viewer->assign('MENU', \YF\Modules\Base\Model\Menu::getInstance($this->viewer->getTemplateVars('MODULE_NAME'))->getMenu()); |
|
59 | + } |
|
60 | + $this->viewer->assign('PAGE_TITLE', (\Conf\Config::$siteName ?: \App\Language::translate('LBL_CUSTOMER_PORTAL')) . ' ' . $this->getPageTitle()); |
|
61 | + $this->viewer->assign('CSS_FILE', $this->getHeaderCss()); |
|
62 | + $this->viewer->assign('USER_QUICK_MENU', $this->getUserQuickMenuLinks()); |
|
63 | + if ($display) { |
|
64 | + $this->preProcessDisplay(); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Get page title. |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function getPageTitle(): string |
|
74 | - { |
|
75 | - $title = \App\Language::translateModule($this->moduleName); |
|
76 | - $pageTitle = $this->getBreadcrumbTitle(); |
|
77 | - if (isset($this->pageTitle)) { |
|
78 | - $pageTitle = \App\Language::translate($this->pageTitle); |
|
79 | - } |
|
80 | - if ($pageTitle) { |
|
81 | - $title .= ' - ' . $pageTitle; |
|
82 | - } |
|
83 | - return $title; |
|
84 | - } |
|
68 | + /** |
|
69 | + * Get page title. |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function getPageTitle(): string |
|
74 | + { |
|
75 | + $title = \App\Language::translateModule($this->moduleName); |
|
76 | + $pageTitle = $this->getBreadcrumbTitle(); |
|
77 | + if (isset($this->pageTitle)) { |
|
78 | + $pageTitle = \App\Language::translate($this->pageTitle); |
|
79 | + } |
|
80 | + if ($pageTitle) { |
|
81 | + $title .= ' - ' . $pageTitle; |
|
82 | + } |
|
83 | + return $title; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get breadcrumb title. |
|
88 | - * |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function getBreadcrumbTitle(): string |
|
92 | - { |
|
93 | - if (!empty($this->pageTitle)) { |
|
94 | - return $this->pageTitle; |
|
95 | - } |
|
96 | - return ''; |
|
97 | - } |
|
86 | + /** |
|
87 | + * Get breadcrumb title. |
|
88 | + * |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function getBreadcrumbTitle(): string |
|
92 | + { |
|
93 | + if (!empty($this->pageTitle)) { |
|
94 | + return $this->pageTitle; |
|
95 | + } |
|
96 | + return ''; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Convert scripts path. |
|
101 | - * |
|
102 | - * @param array $files |
|
103 | - * @param string $fileExtension |
|
104 | - * |
|
105 | - * @return array |
|
106 | - */ |
|
107 | - public function convertScripts(array $files, string $fileExtension): array |
|
108 | - { |
|
109 | - $scriptsInstances = []; |
|
110 | - foreach ($files as $file) { |
|
111 | - [$fileName, $isOptional] = array_pad($file, 2, false); |
|
112 | - $path = ROOT_DIRECTORY . "/public_html/$fileName"; |
|
113 | - $script = new \App\Script(); |
|
114 | - $script->set('type', $fileExtension); |
|
115 | - $minFilePath = str_replace('.' . $fileExtension, '.min.' . $fileExtension, $fileName); |
|
116 | - if (\App\Config::$minScripts && file_exists(ROOT_DIRECTORY . "/public_html/$minFilePath")) { |
|
117 | - $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $minFilePath . self::getTime($path)); |
|
118 | - } elseif (file_exists($path)) { |
|
119 | - $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $fileName . self::getTime($path)); |
|
120 | - } elseif (!$isOptional) { |
|
121 | - \App\Log::warning('File not found: ' . $path); |
|
122 | - } |
|
123 | - } |
|
124 | - return $scriptsInstances; |
|
125 | - } |
|
99 | + /** |
|
100 | + * Convert scripts path. |
|
101 | + * |
|
102 | + * @param array $files |
|
103 | + * @param string $fileExtension |
|
104 | + * |
|
105 | + * @return array |
|
106 | + */ |
|
107 | + public function convertScripts(array $files, string $fileExtension): array |
|
108 | + { |
|
109 | + $scriptsInstances = []; |
|
110 | + foreach ($files as $file) { |
|
111 | + [$fileName, $isOptional] = array_pad($file, 2, false); |
|
112 | + $path = ROOT_DIRECTORY . "/public_html/$fileName"; |
|
113 | + $script = new \App\Script(); |
|
114 | + $script->set('type', $fileExtension); |
|
115 | + $minFilePath = str_replace('.' . $fileExtension, '.min.' . $fileExtension, $fileName); |
|
116 | + if (\App\Config::$minScripts && file_exists(ROOT_DIRECTORY . "/public_html/$minFilePath")) { |
|
117 | + $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $minFilePath . self::getTime($path)); |
|
118 | + } elseif (file_exists($path)) { |
|
119 | + $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $fileName . self::getTime($path)); |
|
120 | + } elseif (!$isOptional) { |
|
121 | + \App\Log::warning('File not found: ' . $path); |
|
122 | + } |
|
123 | + } |
|
124 | + return $scriptsInstances; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Gets file modification time. |
|
129 | - * |
|
130 | - * @param string $path |
|
131 | - * |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public static function getTime(string $path): string |
|
135 | - { |
|
136 | - $url = ''; |
|
137 | - if ($fs = filemtime($path)) { |
|
138 | - $url = '?s=' . $fs; |
|
139 | - } |
|
140 | - return $url; |
|
141 | - } |
|
127 | + /** |
|
128 | + * Gets file modification time. |
|
129 | + * |
|
130 | + * @param string $path |
|
131 | + * |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public static function getTime(string $path): string |
|
135 | + { |
|
136 | + $url = ''; |
|
137 | + if ($fs = filemtime($path)) { |
|
138 | + $url = '?s=' . $fs; |
|
139 | + } |
|
140 | + return $url; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * Retrieves css styles that need to loaded in the page. |
|
145 | - * |
|
146 | - * @return \App\Script[] |
|
147 | - */ |
|
148 | - public function getHeaderCss(): array |
|
149 | - { |
|
150 | - return $this->convertScripts([ |
|
151 | - ['libraries/@fortawesome/fontawesome-free/css/all.css'], |
|
152 | - ['libraries/@mdi/font/css/materialdesignicons.css'], |
|
153 | - ['libraries/chosen-js/chosen.css'], |
|
154 | - ['libraries/bootstrap-chosen/bootstrap-chosen.css'], |
|
155 | - ['libraries/jQuery-Validation-Engine/css/validationEngine.jquery.css'], |
|
156 | - ['libraries/bootstrap-tabdrop/css/tabdrop.css'], |
|
157 | - ['libraries/select2/dist/css/select2.css'], |
|
158 | - ['libraries/datatables.net-bs4/css/dataTables.bootstrap4.css'], |
|
159 | - ['libraries/datatables.net-responsive-bs4/css/responsive.bootstrap4.css'], |
|
160 | - ['libraries/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css'], |
|
161 | - ['libraries/bootstrap-daterangepicker/daterangepicker.css'], |
|
162 | - ['libraries/clockpicker/dist/bootstrap4-clockpicker.css'], |
|
163 | - ['libraries/jstree-bootstrap-theme/dist/themes/proton/style.css'], |
|
164 | - ['libraries/jstree/dist/themes/default/style.css'], |
|
165 | - ['libraries/@pnotify/core/dist/PNotify.css'], |
|
166 | - ['libraries/@pnotify/confirm/dist/PNotifyConfirm.css'], |
|
167 | - ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.css'], |
|
168 | - ['libraries/@pnotify/mobile/dist/PNotifyMobile.css'], |
|
169 | - ['libraries/@pnotify/desktop/dist/PNotifyDesktop.css'], |
|
170 | - ['libraries/jquery-ui-dist/jquery-ui.css'], |
|
171 | - ['libraries/perfect-scrollbar/css/perfect-scrollbar.css'], |
|
172 | - ['layouts/resources/icons/additionalIcons.css'], |
|
173 | - ['layouts/resources/icons/yfm.css'], |
|
174 | - ['layouts/resources/icons/yfi.css'], |
|
175 | - ['layouts/' . \App\Viewer::getLayoutName() . '/skins/basic/Main.css'], |
|
176 | - ], 'css'); |
|
177 | - } |
|
143 | + /** |
|
144 | + * Retrieves css styles that need to loaded in the page. |
|
145 | + * |
|
146 | + * @return \App\Script[] |
|
147 | + */ |
|
148 | + public function getHeaderCss(): array |
|
149 | + { |
|
150 | + return $this->convertScripts([ |
|
151 | + ['libraries/@fortawesome/fontawesome-free/css/all.css'], |
|
152 | + ['libraries/@mdi/font/css/materialdesignicons.css'], |
|
153 | + ['libraries/chosen-js/chosen.css'], |
|
154 | + ['libraries/bootstrap-chosen/bootstrap-chosen.css'], |
|
155 | + ['libraries/jQuery-Validation-Engine/css/validationEngine.jquery.css'], |
|
156 | + ['libraries/bootstrap-tabdrop/css/tabdrop.css'], |
|
157 | + ['libraries/select2/dist/css/select2.css'], |
|
158 | + ['libraries/datatables.net-bs4/css/dataTables.bootstrap4.css'], |
|
159 | + ['libraries/datatables.net-responsive-bs4/css/responsive.bootstrap4.css'], |
|
160 | + ['libraries/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css'], |
|
161 | + ['libraries/bootstrap-daterangepicker/daterangepicker.css'], |
|
162 | + ['libraries/clockpicker/dist/bootstrap4-clockpicker.css'], |
|
163 | + ['libraries/jstree-bootstrap-theme/dist/themes/proton/style.css'], |
|
164 | + ['libraries/jstree/dist/themes/default/style.css'], |
|
165 | + ['libraries/@pnotify/core/dist/PNotify.css'], |
|
166 | + ['libraries/@pnotify/confirm/dist/PNotifyConfirm.css'], |
|
167 | + ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.css'], |
|
168 | + ['libraries/@pnotify/mobile/dist/PNotifyMobile.css'], |
|
169 | + ['libraries/@pnotify/desktop/dist/PNotifyDesktop.css'], |
|
170 | + ['libraries/jquery-ui-dist/jquery-ui.css'], |
|
171 | + ['libraries/perfect-scrollbar/css/perfect-scrollbar.css'], |
|
172 | + ['layouts/resources/icons/additionalIcons.css'], |
|
173 | + ['layouts/resources/icons/yfm.css'], |
|
174 | + ['layouts/resources/icons/yfi.css'], |
|
175 | + ['layouts/' . \App\Viewer::getLayoutName() . '/skins/basic/Main.css'], |
|
176 | + ], 'css'); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Pre process display. |
|
181 | - * |
|
182 | - * @return void |
|
183 | - */ |
|
184 | - protected function preProcessDisplay(): void |
|
185 | - { |
|
186 | - if (\App\Session::has('systemError')) { |
|
187 | - $this->viewer->assign('ERRORS', \App\Session::get('systemError')); |
|
188 | - \App\Session::unset('systemError'); |
|
189 | - } |
|
190 | - $this->viewer->view($this->preProcessTplName(), $this->moduleName); |
|
191 | - } |
|
179 | + /** |
|
180 | + * Pre process display. |
|
181 | + * |
|
182 | + * @return void |
|
183 | + */ |
|
184 | + protected function preProcessDisplay(): void |
|
185 | + { |
|
186 | + if (\App\Session::has('systemError')) { |
|
187 | + $this->viewer->assign('ERRORS', \App\Session::get('systemError')); |
|
188 | + \App\Session::unset('systemError'); |
|
189 | + } |
|
190 | + $this->viewer->view($this->preProcessTplName(), $this->moduleName); |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Get preprocess tpl name. |
|
195 | - * |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - protected function preProcessTplName(): string |
|
199 | - { |
|
200 | - return 'Header.tpl'; |
|
201 | - } |
|
193 | + /** |
|
194 | + * Get preprocess tpl name. |
|
195 | + * |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + protected function preProcessTplName(): string |
|
199 | + { |
|
200 | + return 'Header.tpl'; |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * Get process tpl name. |
|
205 | - * |
|
206 | - * @return string |
|
207 | - */ |
|
208 | - protected function processTplName(): string |
|
209 | - { |
|
210 | - return $this->request->getAction() . '/Index.tpl'; |
|
211 | - } |
|
203 | + /** |
|
204 | + * Get process tpl name. |
|
205 | + * |
|
206 | + * @return string |
|
207 | + */ |
|
208 | + protected function processTplName(): string |
|
209 | + { |
|
210 | + return $this->request->getAction() . '/Index.tpl'; |
|
211 | + } |
|
212 | 212 | |
213 | - /** {@inheritdoc} */ |
|
214 | - protected function postProcessTplName(): string |
|
215 | - { |
|
216 | - return 'Footer.tpl'; |
|
217 | - } |
|
213 | + /** {@inheritdoc} */ |
|
214 | + protected function postProcessTplName(): string |
|
215 | + { |
|
216 | + return 'Footer.tpl'; |
|
217 | + } |
|
218 | 218 | |
219 | - /** {@inheritdoc} */ |
|
220 | - public function postProcess(): void |
|
221 | - { |
|
222 | - if (null === $this->viewer->getTemplateVars('SHOW_FOOTER_BAR')) { |
|
223 | - $this->viewer->assign('SHOW_FOOTER_BAR', true); |
|
224 | - } |
|
225 | - $this->viewer->assign('JS_FILE', $this->getFooterScripts()); |
|
226 | - if (\App\Config::$debugApi && \App\Session::has('debugApi') && \App\Session::get('debugApi')) { |
|
227 | - $this->viewer->assign('DEBUG_API', \App\Session::get('debugApi')); |
|
228 | - $this->viewer->view('DebugApi.tpl', $this->moduleName); |
|
229 | - \App\Session::set('debugApi', false); |
|
230 | - } |
|
231 | - $this->viewer->view($this->postProcessTplName(), $this->moduleName); |
|
232 | - } |
|
219 | + /** {@inheritdoc} */ |
|
220 | + public function postProcess(): void |
|
221 | + { |
|
222 | + if (null === $this->viewer->getTemplateVars('SHOW_FOOTER_BAR')) { |
|
223 | + $this->viewer->assign('SHOW_FOOTER_BAR', true); |
|
224 | + } |
|
225 | + $this->viewer->assign('JS_FILE', $this->getFooterScripts()); |
|
226 | + if (\App\Config::$debugApi && \App\Session::has('debugApi') && \App\Session::get('debugApi')) { |
|
227 | + $this->viewer->assign('DEBUG_API', \App\Session::get('debugApi')); |
|
228 | + $this->viewer->view('DebugApi.tpl', $this->moduleName); |
|
229 | + \App\Session::set('debugApi', false); |
|
230 | + } |
|
231 | + $this->viewer->view($this->postProcessTplName(), $this->moduleName); |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * Scripts. |
|
236 | - * |
|
237 | - * @param bool $loadForModule |
|
238 | - * |
|
239 | - * @return \App\Script[] |
|
240 | - */ |
|
241 | - public function getFooterScripts(bool $loadForModule = true): array |
|
242 | - { |
|
243 | - $action = $this->request->getAction(); |
|
244 | - $languageHandlerShortName = \App\Language::getShortLanguageName(); |
|
245 | - $fileName = ["libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-$languageHandlerShortName.js"]; |
|
246 | - if (!file_exists(ROOT_DIRECTORY . "/public_html/{$fileName[0]}")) { |
|
247 | - $fileName = ['libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-en.js']; |
|
248 | - } |
|
249 | - $files = [ |
|
250 | - ['libraries/jquery/dist/jquery.js'], |
|
251 | - ['libraries/jquery.class.js/jquery.class.js'], |
|
252 | - ['libraries/block-ui/jquery.blockUI.js'], |
|
253 | - ['libraries/@pnotify/core/dist/PNotify.js'], |
|
254 | - ['libraries/@pnotify/mobile/dist/PNotifyMobile.js'], |
|
255 | - ['libraries/@pnotify/desktop/dist/PNotifyDesktop.js'], |
|
256 | - ['libraries/@pnotify/confirm/dist/PNotifyConfirm.js'], |
|
257 | - ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.js'], |
|
258 | - ['libraries/@pnotify/font-awesome5/dist/PNotifyFontAwesome5.js'], |
|
259 | - ['libraries/perfect-scrollbar/dist/perfect-scrollbar.js'], |
|
260 | - ['libraries/jquery-ui-dist/jquery-ui.js'], |
|
261 | - ['libraries/popper.js/dist/umd/popper.js'], |
|
262 | - ['vendor/ckeditor/ckeditor/ckeditor.js'], |
|
263 | - ['vendor/ckeditor/ckeditor/adapters/jquery.js'], |
|
264 | - ['libraries/bootstrap/dist/js/bootstrap.js'], |
|
265 | - ['libraries/bootstrap-tabdrop/js/bootstrap-tabdrop.js'], |
|
266 | - ['libraries/bootstrap-datepicker/dist/js/bootstrap-datepicker.js'], |
|
267 | - ['libraries/moment/min/moment.min.js'], |
|
268 | - ['libraries/bootstrap-daterangepicker/daterangepicker.js'], |
|
269 | - ['libraries/chosen-js/chosen.jquery.js'], |
|
270 | - ['libraries/select2/dist/js/select2.full.js'], |
|
271 | - ['libraries/inputmask/dist/jquery.inputmask.js'], |
|
272 | - ['libraries/datatables.net/js/jquery.dataTables.js'], |
|
273 | - ['libraries/datatables.net-bs4/js/dataTables.bootstrap4.js'], |
|
274 | - ['libraries/datatables.net-responsive/js/dataTables.responsive.js'], |
|
275 | - ['libraries/datatables.net-responsive-bs4/js/responsive.bootstrap4.js'], |
|
276 | - ['libraries/jQuery-Validation-Engine/js/jquery.validationEngine.js'], |
|
277 | - $fileName, |
|
278 | - ['libraries/jstree/dist/jstree.js'], |
|
279 | - ['libraries/clockpicker/dist/bootstrap4-clockpicker.js'], |
|
280 | - ['libraries/blueimp-file-upload/js/jquery.fileupload.js'], |
|
281 | - ['layouts/resources/validator/BaseValidator.js'], |
|
282 | - ['layouts/resources/validator/FieldValidator.js'], |
|
283 | - ['layouts/resources/helper.js'], |
|
284 | - ['layouts/resources/Field.js'], |
|
285 | - ['layouts/resources/Connector.js'], |
|
286 | - ['layouts/resources/app.js'], |
|
287 | - ['layouts/resources/MultiImage.js'], |
|
288 | - ['layouts/resources/Fields.js'], |
|
289 | - ['layouts/resources/ProgressIndicator.js'], |
|
290 | - ['layouts/' . \App\Viewer::getLayoutName() . '/modules/Base/resources/Header.js'], |
|
291 | - ['layouts/' . \App\Viewer::getLayoutName() . "/modules/Base/resources/{$action}.js"], |
|
292 | - ]; |
|
293 | - if ($loadForModule) { |
|
294 | - $moduleName = $this->getModuleNameFromRequest(); |
|
295 | - $files[] = ['layouts/' . \App\Viewer::getLayoutName() . "/modules/{$moduleName}/resources/{$action}.js", true]; |
|
296 | - } |
|
297 | - return $this->convertScripts($files, 'js'); |
|
298 | - } |
|
234 | + /** |
|
235 | + * Scripts. |
|
236 | + * |
|
237 | + * @param bool $loadForModule |
|
238 | + * |
|
239 | + * @return \App\Script[] |
|
240 | + */ |
|
241 | + public function getFooterScripts(bool $loadForModule = true): array |
|
242 | + { |
|
243 | + $action = $this->request->getAction(); |
|
244 | + $languageHandlerShortName = \App\Language::getShortLanguageName(); |
|
245 | + $fileName = ["libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-$languageHandlerShortName.js"]; |
|
246 | + if (!file_exists(ROOT_DIRECTORY . "/public_html/{$fileName[0]}")) { |
|
247 | + $fileName = ['libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-en.js']; |
|
248 | + } |
|
249 | + $files = [ |
|
250 | + ['libraries/jquery/dist/jquery.js'], |
|
251 | + ['libraries/jquery.class.js/jquery.class.js'], |
|
252 | + ['libraries/block-ui/jquery.blockUI.js'], |
|
253 | + ['libraries/@pnotify/core/dist/PNotify.js'], |
|
254 | + ['libraries/@pnotify/mobile/dist/PNotifyMobile.js'], |
|
255 | + ['libraries/@pnotify/desktop/dist/PNotifyDesktop.js'], |
|
256 | + ['libraries/@pnotify/confirm/dist/PNotifyConfirm.js'], |
|
257 | + ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.js'], |
|
258 | + ['libraries/@pnotify/font-awesome5/dist/PNotifyFontAwesome5.js'], |
|
259 | + ['libraries/perfect-scrollbar/dist/perfect-scrollbar.js'], |
|
260 | + ['libraries/jquery-ui-dist/jquery-ui.js'], |
|
261 | + ['libraries/popper.js/dist/umd/popper.js'], |
|
262 | + ['vendor/ckeditor/ckeditor/ckeditor.js'], |
|
263 | + ['vendor/ckeditor/ckeditor/adapters/jquery.js'], |
|
264 | + ['libraries/bootstrap/dist/js/bootstrap.js'], |
|
265 | + ['libraries/bootstrap-tabdrop/js/bootstrap-tabdrop.js'], |
|
266 | + ['libraries/bootstrap-datepicker/dist/js/bootstrap-datepicker.js'], |
|
267 | + ['libraries/moment/min/moment.min.js'], |
|
268 | + ['libraries/bootstrap-daterangepicker/daterangepicker.js'], |
|
269 | + ['libraries/chosen-js/chosen.jquery.js'], |
|
270 | + ['libraries/select2/dist/js/select2.full.js'], |
|
271 | + ['libraries/inputmask/dist/jquery.inputmask.js'], |
|
272 | + ['libraries/datatables.net/js/jquery.dataTables.js'], |
|
273 | + ['libraries/datatables.net-bs4/js/dataTables.bootstrap4.js'], |
|
274 | + ['libraries/datatables.net-responsive/js/dataTables.responsive.js'], |
|
275 | + ['libraries/datatables.net-responsive-bs4/js/responsive.bootstrap4.js'], |
|
276 | + ['libraries/jQuery-Validation-Engine/js/jquery.validationEngine.js'], |
|
277 | + $fileName, |
|
278 | + ['libraries/jstree/dist/jstree.js'], |
|
279 | + ['libraries/clockpicker/dist/bootstrap4-clockpicker.js'], |
|
280 | + ['libraries/blueimp-file-upload/js/jquery.fileupload.js'], |
|
281 | + ['layouts/resources/validator/BaseValidator.js'], |
|
282 | + ['layouts/resources/validator/FieldValidator.js'], |
|
283 | + ['layouts/resources/helper.js'], |
|
284 | + ['layouts/resources/Field.js'], |
|
285 | + ['layouts/resources/Connector.js'], |
|
286 | + ['layouts/resources/app.js'], |
|
287 | + ['layouts/resources/MultiImage.js'], |
|
288 | + ['layouts/resources/Fields.js'], |
|
289 | + ['layouts/resources/ProgressIndicator.js'], |
|
290 | + ['layouts/' . \App\Viewer::getLayoutName() . '/modules/Base/resources/Header.js'], |
|
291 | + ['layouts/' . \App\Viewer::getLayoutName() . "/modules/Base/resources/{$action}.js"], |
|
292 | + ]; |
|
293 | + if ($loadForModule) { |
|
294 | + $moduleName = $this->getModuleNameFromRequest(); |
|
295 | + $files[] = ['layouts/' . \App\Viewer::getLayoutName() . "/modules/{$moduleName}/resources/{$action}.js", true]; |
|
296 | + } |
|
297 | + return $this->convertScripts($files, 'js'); |
|
298 | + } |
|
299 | 299 | |
300 | - /** {@inheritdoc} */ |
|
301 | - public function validateRequest() |
|
302 | - { |
|
303 | - $this->request->validateReadAccess(); |
|
304 | - } |
|
300 | + /** {@inheritdoc} */ |
|
301 | + public function validateRequest() |
|
302 | + { |
|
303 | + $this->request->validateReadAccess(); |
|
304 | + } |
|
305 | 305 | |
306 | - /** {@inheritdoc} */ |
|
307 | - public function postProcessAjax() |
|
308 | - { |
|
309 | - } |
|
306 | + /** {@inheritdoc} */ |
|
307 | + public function postProcessAjax() |
|
308 | + { |
|
309 | + } |
|
310 | 310 | |
311 | - /** {@inheritdoc} */ |
|
312 | - public function preProcessAjax() |
|
313 | - { |
|
314 | - } |
|
311 | + /** {@inheritdoc} */ |
|
312 | + public function preProcessAjax() |
|
313 | + { |
|
314 | + } |
|
315 | 315 | |
316 | - /** |
|
317 | - * Get module name from request. |
|
318 | - * |
|
319 | - * @return string |
|
320 | - */ |
|
321 | - protected function getModuleNameFromRequest(): string |
|
322 | - { |
|
323 | - if (empty($this->moduleName)) { |
|
324 | - $this->moduleName = $this->request->getModule(); |
|
325 | - } |
|
326 | - return $this->moduleName; |
|
327 | - } |
|
316 | + /** |
|
317 | + * Get module name from request. |
|
318 | + * |
|
319 | + * @return string |
|
320 | + */ |
|
321 | + protected function getModuleNameFromRequest(): string |
|
322 | + { |
|
323 | + if (empty($this->moduleName)) { |
|
324 | + $this->moduleName = $this->request->getModule(); |
|
325 | + } |
|
326 | + return $this->moduleName; |
|
327 | + } |
|
328 | 328 | |
329 | - /** |
|
330 | - * Load js config. |
|
331 | - * |
|
332 | - * @param \App\Request $request |
|
333 | - */ |
|
334 | - public function loadJsConfig(\App\Request $request): void |
|
335 | - { |
|
336 | - $jsEnv = [ |
|
337 | - 'siteUrl' => \App\Utils::getPublicUrl('', true), |
|
338 | - 'langPrefix' => \App\Language::getLanguage(), |
|
339 | - 'langKey' => \App\Language::getShortLanguageName(), |
|
340 | - 'parentModule' => $request->getByType('parent', 2), |
|
341 | - ]; |
|
342 | - foreach ($jsEnv as $key => $value) { |
|
343 | - \App\Config::setJsEnv($key, $value); |
|
344 | - } |
|
345 | - } |
|
329 | + /** |
|
330 | + * Load js config. |
|
331 | + * |
|
332 | + * @param \App\Request $request |
|
333 | + */ |
|
334 | + public function loadJsConfig(\App\Request $request): void |
|
335 | + { |
|
336 | + $jsEnv = [ |
|
337 | + 'siteUrl' => \App\Utils::getPublicUrl('', true), |
|
338 | + 'langPrefix' => \App\Language::getLanguage(), |
|
339 | + 'langKey' => \App\Language::getShortLanguageName(), |
|
340 | + 'parentModule' => $request->getByType('parent', 2), |
|
341 | + ]; |
|
342 | + foreach ($jsEnv as $key => $value) { |
|
343 | + \App\Config::setJsEnv($key, $value); |
|
344 | + } |
|
345 | + } |
|
346 | 346 | |
347 | - /** |
|
348 | - * Get the list of user quick menu links. |
|
349 | - * |
|
350 | - * @return array |
|
351 | - */ |
|
352 | - protected function getUserQuickMenuLinks(): array |
|
353 | - { |
|
354 | - $user = \App\User::getUser(); |
|
355 | - $links = [ |
|
356 | - [ |
|
357 | - 'label' => 'LBL_CHANGE_PASSWORD', |
|
358 | - 'moduleName' => 'Users', |
|
359 | - 'data' => ['url' => 'index.php?module=Users&view=PasswordChangeModal'], |
|
360 | - 'icon' => 'yfi yfi-change-passowrd', |
|
361 | - 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
362 | - 'btnClass' => ' ', |
|
363 | - 'href' => '#', |
|
364 | - 'showLabel' => true, |
|
365 | - ], |
|
366 | - [ |
|
367 | - 'label' => 'BTN_YOUR_ACCOUNT_ACCESS_HISTORY', |
|
368 | - 'moduleName' => 'Users', |
|
369 | - 'data' => ['url' => 'index.php?module=Users&view=AccessActivityHistoryModal'], |
|
370 | - 'icon' => 'yfi yfi-login-history', |
|
371 | - 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
372 | - 'btnClass' => ' ', |
|
373 | - 'href' => '#', |
|
374 | - 'showLabel' => true, |
|
375 | - ], |
|
376 | - ]; |
|
377 | - if ('PLL_PASSWORD_2FA' === $user->get('login_method') && !$user->isEmpty('authy_methods')) { |
|
378 | - $links[] = [ |
|
379 | - 'label' => 'BTN_2FA_TOTP_QR_CODE', |
|
380 | - 'moduleName' => 'Users', |
|
381 | - 'data' => ['url' => 'index.php?module=Users&view=TwoFactorAuthenticationModal'], |
|
382 | - 'icon' => 'fas fa-key', |
|
383 | - 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
384 | - 'btnClass' => ' ', |
|
385 | - 'href' => '#', |
|
386 | - 'showLabel' => true, |
|
387 | - ]; |
|
388 | - } |
|
389 | - return $links; |
|
390 | - } |
|
347 | + /** |
|
348 | + * Get the list of user quick menu links. |
|
349 | + * |
|
350 | + * @return array |
|
351 | + */ |
|
352 | + protected function getUserQuickMenuLinks(): array |
|
353 | + { |
|
354 | + $user = \App\User::getUser(); |
|
355 | + $links = [ |
|
356 | + [ |
|
357 | + 'label' => 'LBL_CHANGE_PASSWORD', |
|
358 | + 'moduleName' => 'Users', |
|
359 | + 'data' => ['url' => 'index.php?module=Users&view=PasswordChangeModal'], |
|
360 | + 'icon' => 'yfi yfi-change-passowrd', |
|
361 | + 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
362 | + 'btnClass' => ' ', |
|
363 | + 'href' => '#', |
|
364 | + 'showLabel' => true, |
|
365 | + ], |
|
366 | + [ |
|
367 | + 'label' => 'BTN_YOUR_ACCOUNT_ACCESS_HISTORY', |
|
368 | + 'moduleName' => 'Users', |
|
369 | + 'data' => ['url' => 'index.php?module=Users&view=AccessActivityHistoryModal'], |
|
370 | + 'icon' => 'yfi yfi-login-history', |
|
371 | + 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
372 | + 'btnClass' => ' ', |
|
373 | + 'href' => '#', |
|
374 | + 'showLabel' => true, |
|
375 | + ], |
|
376 | + ]; |
|
377 | + if ('PLL_PASSWORD_2FA' === $user->get('login_method') && !$user->isEmpty('authy_methods')) { |
|
378 | + $links[] = [ |
|
379 | + 'label' => 'BTN_2FA_TOTP_QR_CODE', |
|
380 | + 'moduleName' => 'Users', |
|
381 | + 'data' => ['url' => 'index.php?module=Users&view=TwoFactorAuthenticationModal'], |
|
382 | + 'icon' => 'fas fa-key', |
|
383 | + 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
384 | + 'btnClass' => ' ', |
|
385 | + 'href' => '#', |
|
386 | + 'showLabel' => true, |
|
387 | + ]; |
|
388 | + } |
|
389 | + return $links; |
|
390 | + } |
|
391 | 391 | } |