1 | <?php |
---|
2 | /** |
---|
3 | * @brief importExport, a plugin for Dotclear 2 |
---|
4 | * |
---|
5 | * @package Dotclear |
---|
6 | * @subpackage Plugins |
---|
7 | * |
---|
8 | * @copyright Olivier Meunier & Association Dotclear |
---|
9 | * @copyright GPL-2.0-only |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
---|
13 | |
---|
14 | function listImportExportModules($core, $modules) |
---|
15 | { |
---|
16 | $res = ''; |
---|
17 | foreach ($modules as $id) { |
---|
18 | $o = new $id($core); |
---|
19 | |
---|
20 | $res .= |
---|
21 | '<dt><a href="' . $o->getURL(true) . '">' . html::escapeHTML($o->name) . '</a></dt>' . |
---|
22 | '<dd>' . html::escapeHTML($o->description) . '</dd>'; |
---|
23 | |
---|
24 | unset($o); |
---|
25 | } |
---|
26 | return '<dl class="modules">' . $res . '</dl>'; |
---|
27 | } |
---|
28 | |
---|
29 | $modules = new ArrayObject(['import' => [], 'export' => []]); |
---|
30 | |
---|
31 | # --BEHAVIOR-- importExportModules |
---|
32 | $core->callBehavior('importExportModules', $modules, $core); |
---|
33 | |
---|
34 | $type = null; |
---|
35 | if (!empty($_REQUEST['type']) && in_array($_REQUEST['type'], ['export', 'import'])) { |
---|
36 | $type = $_REQUEST['type']; |
---|
37 | } |
---|
38 | |
---|
39 | $module = null; |
---|
40 | if ($type && !empty($_REQUEST['module'])) { |
---|
41 | |
---|
42 | if (isset($modules[$type]) && in_array($_REQUEST['module'], $modules[$type])) { |
---|
43 | |
---|
44 | $module = new $_REQUEST['module']($core); |
---|
45 | $module->init(); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | if ($type && $module !== null && !empty($_REQUEST['do'])) { |
---|
50 | try { |
---|
51 | $module->process($_REQUEST['do']); |
---|
52 | } catch (Exception $e) { |
---|
53 | $core->error->add($e->getMessage()); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | $title = __('Import/Export'); |
---|
58 | |
---|
59 | echo ' |
---|
60 | <html> |
---|
61 | <head> |
---|
62 | <title>' . $title . '</title>' . |
---|
63 | dcPage::cssLoad(dcPage::getPF('importExport/style.css')) . |
---|
64 | dcPage::jsLoad(dcPage::getPF('importExport/js/script.js')) . |
---|
65 | '<script type="text/javascript"> |
---|
66 | ' . dcPage::jsVar('dotclear.msg.please_wait', __('Please wait...')) . ' |
---|
67 | </script> |
---|
68 | </head> |
---|
69 | <body>'; |
---|
70 | |
---|
71 | if ($type && $module !== null) { |
---|
72 | echo dcPage::breadcrumb( |
---|
73 | [ |
---|
74 | __('Plugins') => '', |
---|
75 | $title => $p_url, |
---|
76 | html::escapeHTML($module->name) => '' |
---|
77 | ]) . |
---|
78 | dcPage::notices(); |
---|
79 | |
---|
80 | echo |
---|
81 | '<div id="ie-gui">'; |
---|
82 | |
---|
83 | $module->gui(); |
---|
84 | |
---|
85 | echo '</div>'; |
---|
86 | } else { |
---|
87 | echo dcPage::breadcrumb( |
---|
88 | [ |
---|
89 | __('Plugins') => '', |
---|
90 | $title => '' |
---|
91 | ]) . |
---|
92 | dcPage::notices(); |
---|
93 | |
---|
94 | echo '<h3>' . __('Import') . '</h3>' . listImportExportModules($core, $modules['import']); |
---|
95 | |
---|
96 | echo |
---|
97 | '<h3>' . __('Export') . '</h3>' . |
---|
98 | '<p class="info">' . sprintf( |
---|
99 | __('Export functions are in the page %s.'), |
---|
100 | '<a href="' . $core->adminurl->get('admin.plugin.maintenance', ['tab' => 'backup']) . '#backup">' . __('Maintenance') . '</a>' |
---|
101 | ) . '</p>'; |
---|
102 | } |
---|
103 | |
---|
104 | dcPage::helpBlock('import'); |
---|
105 | |
---|
106 | echo '</body></html>'; |
---|