PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.12
Responsive Menu – Create Mobile-Friendly Menu v3.0.12
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / src / app / Controllers / Admin.php

Admin.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.12, at src/app/Controllers/Admin.php

57 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\Controllers;
4 use ResponsiveMenu\View\View;
5 use ResponsiveMenu\Services\OptionService;
6
7 class Admin {
8
9 public function __construct(OptionService $service, View $view) {
10 $this->service = $service;
11 $this->view = $view;
12 }
13
14 public function update($default_options, $new_options) {
15 $updated_options = $this->service->combineOptions($default_options, $new_options);
16 return $this->view->render('main', [
17 'options' => $this->service->updateOptions($updated_options),
18 'flash' => ['success' => __('Responsive Menu Options Updated Successfully', 'responsive-menu')]
19 ]);
20 }
21
22 public function reset($default_options) {
23 return $this->view->render('main', [
24 'options' => $this->service->updateOptions($default_options),
25 'flash' => ['success' => __('Responsive Menu Options Reset Successfully', 'responsive-menu')]
26 ]);
27 }
28
29 public function index() {
30 return $this->view->render('main', ['options' => $this->service->all()]);
31 }
32
33 public function import($default_options, $imported_options) {
34
35 if(!empty($imported_options)):
36 $updated_options = $this->service->combineOptions($default_options, $imported_options);
37 $options = $this->service->updateOptions($updated_options);
38 $flash['success'] = __('Responsive Menu Options Imported Successfully', 'responsive-menu');
39 else:
40 $flash['errors'][] = __('No file selected', 'responsive-menu');
41 $options = $this->service->all();
42 endif;
43
44 return $this->view->render('main', ['options' => $options, 'flash' => $flash]);
45 }
46
47 public function export() {
48 $this->view->noCacheHeaders();
49 $final = [];
50 foreach($this->service->all()->all() as $option)
51 $final[$option->getName()] = $option->getValue();
52 $this->view->display(json_encode($final));
53 $this->view->stopProcessing();
54 }
55
56 }
57