Dotclear

source: plugins/importExport/index.php @ 3993:c402c96de044

Revision 3993:c402c96de044, 2.5 KB checked in by franck <carnet.franck.paul@…>, 6 years ago (diff)

Switching from inline JS variables to JSON script, import/export plugin

Line 
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
12if (!defined('DC_CONTEXT_ADMIN')) {return;}
13
14function 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;
35if (!empty($_REQUEST['type']) && in_array($_REQUEST['type'], ['export', 'import'])) {
36    $type = $_REQUEST['type'];
37}
38
39$module = null;
40if ($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
49if ($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
59echo '
60<html>
61<head>
62    <title>' . $title . '</title>' .
63dcPage::cssLoad(dcPage::getPF('importExport/style.css')) .
64dcPage::jsJson('ie_msg', ['please_wait' => __('Please wait...')]) .
65dcPage::jsLoad(dcPage::getPF('importExport/js/script.js')) .
66'</head>
67<body>';
68
69if ($type && $module !== null) {
70    echo dcPage::breadcrumb(
71        [
72            __('Plugins')                   => '',
73            $title                          => $p_url,
74            html::escapeHTML($module->name) => ''
75        ]) .
76    dcPage::notices();
77
78    echo
79        '<div id="ie-gui">';
80
81    $module->gui();
82
83    echo '</div>';
84} else {
85    echo dcPage::breadcrumb(
86        [
87            __('Plugins') => '',
88            $title        => ''
89        ]) .
90    dcPage::notices();
91
92    echo '<h3>' . __('Import') . '</h3>' . listImportExportModules($core, $modules['import']);
93
94    echo
95    '<h3>' . __('Export') . '</h3>' .
96    '<p class="info">' . sprintf(
97        __('Export functions are in the page %s.'),
98        '<a href="' . $core->adminurl->get('admin.plugin.maintenance', ['tab' => 'backup']) . '#backup">' . __('Maintenance') . '</a>'
99    ) . '</p>';
100}
101
102dcPage::helpBlock('import');
103
104echo '</body></html>';
Note: See TracBrowser for help on using the repository browser.

Sites map