Dotclear

source: plugins/importExport/index.php @ 3874:ab8368569446

Revision 3874:ab8368569446, 2.6 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

short notation for array (array() → [])

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::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
71if ($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
104dcPage::helpBlock('import');
105
106echo '</body></html>';
Note: See TracBrowser for help on using the repository browser.

Sites map