[0] | 1 | <?php |
---|
[3731] | 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 | |
---|
[3730] | 12 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
---|
[0] | 13 | |
---|
[3730] | 14 | function listImportExportModules($core, $modules) |
---|
[840] | 15 | { |
---|
[3730] | 16 | $res = ''; |
---|
| 17 | foreach ($modules as $id) { |
---|
| 18 | $o = new $id($core); |
---|
[2566] | 19 | |
---|
[3730] | 20 | $res .= |
---|
| 21 | '<dt><a href="' . $o->getURL(true) . '">' . html::escapeHTML($o->name) . '</a></dt>' . |
---|
| 22 | '<dd>' . html::escapeHTML($o->description) . '</dd>'; |
---|
[2566] | 23 | |
---|
[3730] | 24 | unset($o); |
---|
| 25 | } |
---|
| 26 | return '<dl class="modules">' . $res . '</dl>'; |
---|
[840] | 27 | } |
---|
[0] | 28 | |
---|
[3874] | 29 | $modules = new ArrayObject(['import' => [], 'export' => []]); |
---|
[0] | 30 | |
---|
| 31 | # --BEHAVIOR-- importExportModules |
---|
[2095] | 32 | $core->callBehavior('importExportModules', $modules, $core); |
---|
[0] | 33 | |
---|
| 34 | $type = null; |
---|
[3874] | 35 | if (!empty($_REQUEST['type']) && in_array($_REQUEST['type'], ['export', 'import'])) { |
---|
[3730] | 36 | $type = $_REQUEST['type']; |
---|
[0] | 37 | } |
---|
| 38 | |
---|
[840] | 39 | $module = null; |
---|
| 40 | if ($type && !empty($_REQUEST['module'])) { |
---|
| 41 | |
---|
[3730] | 42 | if (isset($modules[$type]) && in_array($_REQUEST['module'], $modules[$type])) { |
---|
[2566] | 43 | |
---|
[3730] | 44 | $module = new $_REQUEST['module']($core); |
---|
| 45 | $module->init(); |
---|
| 46 | } |
---|
[0] | 47 | } |
---|
| 48 | |
---|
[3730] | 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 | } |
---|
[0] | 55 | } |
---|
[840] | 56 | |
---|
| 57 | $title = __('Import/Export'); |
---|
| 58 | |
---|
| 59 | echo ' |
---|
[0] | 60 | <html> |
---|
| 61 | <head> |
---|
[3730] | 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> |
---|
[0] | 68 | </head> |
---|
[840] | 69 | <body>'; |
---|
[0] | 70 | |
---|
[840] | 71 | if ($type && $module !== null) { |
---|
[3730] | 72 | echo dcPage::breadcrumb( |
---|
[3874] | 73 | [ |
---|
[3730] | 74 | __('Plugins') => '', |
---|
| 75 | $title => $p_url, |
---|
| 76 | html::escapeHTML($module->name) => '' |
---|
[3874] | 77 | ]) . |
---|
[3730] | 78 | dcPage::notices(); |
---|
[1339] | 79 | |
---|
[3730] | 80 | echo |
---|
| 81 | '<div id="ie-gui">'; |
---|
[2566] | 82 | |
---|
[3730] | 83 | $module->gui(); |
---|
[2566] | 84 | |
---|
[3730] | 85 | echo '</div>'; |
---|
| 86 | } else { |
---|
| 87 | echo dcPage::breadcrumb( |
---|
[3874] | 88 | [ |
---|
[3730] | 89 | __('Plugins') => '', |
---|
| 90 | $title => '' |
---|
[3874] | 91 | ]) . |
---|
[3730] | 92 | dcPage::notices(); |
---|
[1339] | 93 | |
---|
[3730] | 94 | echo '<h3>' . __('Import') . '</h3>' . listImportExportModules($core, $modules['import']); |
---|
[2476] | 95 | |
---|
[3730] | 96 | echo |
---|
| 97 | '<h3>' . __('Export') . '</h3>' . |
---|
| 98 | '<p class="info">' . sprintf( |
---|
| 99 | __('Export functions are in the page %s.'), |
---|
[3874] | 100 | '<a href="' . $core->adminurl->get('admin.plugin.maintenance', ['tab' => 'backup']) . '#backup">' . __('Maintenance') . '</a>' |
---|
[3730] | 101 | ) . '</p>'; |
---|
[0] | 102 | } |
---|
| 103 | |
---|
[2322] | 104 | dcPage::helpBlock('import'); |
---|
| 105 | |
---|
| 106 | echo '</body></html>'; |
---|