PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.6
Responsive Menu – Create Mobile-Friendly Menu v3.0.6
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.6, at src/app/Controllers/Admin.php

59 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 as View;
5 use ResponsiveMenu\Services\OptionService as 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 $this->view->render('main', [
16 'options' => $this->service->updateOptions(array_merge($default_options, array_filter($new_options))),
17 'flash' => ['success' => __('Responsive Menu Options Updated Successfully', 'responsive-menu')]
18 ]);
19 }
20
21 public function reset($default_options) {
22 $this->view->render('main', [
23 'options' => $this->service->updateOptions($default_options),
24 'flash' => ['success' => __('Responsive Menu Options Reset Successfully', 'responsive-menu')]
25 ]);
26 }
27
28 public function index() {
29 $this->view->render('main', ['options' => $this->service->all()]);
30 }
31
32 public function import($default_options, $file) {
33 if(!empty($file['tmp_name'])):
34 $file = file_get_contents($file['tmp_name']);
35 $decoded = json_decode($file);
36 $options = $this->service->updateOptions(array_merge($default_options, array_filter($decoded)));
37 $flash['success'] = __('Responsive Menu Options Reset Successfully', 'responsive-menu');
38 else:
39 $flash['errors'][] = __('No file selected', 'responsive-menu');
40 $options = $this->service->all();
41 endif;
42
43 $this->view->render('main', ['options' => $options, 'flash' => $flash]);
44 }
45
46 public function export() {
47 nocache_headers();
48 header( 'Content-Type: application/json; charset=utf-8' );
49 header( 'Content-Disposition: attachment; filename=export.json' );
50 header( "Expires: 0" );
51 $final = [];
52 foreach($this->service->all()->all() as $option)
53 $final[$option->getName()] = $option->getValue();
54 echo json_encode($final);
55 exit();
56 }
57
58 }
59