Dotclear

source: admin/plugin.php @ 3874:ab8368569446

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

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

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10require dirname(__FILE__) . '/../inc/admin/prepend.php';
11
12dcPage::check('usage,contentadmin');
13
14$p_file = '';
15$p      = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null;
16$popup  = (integer) !empty($_REQUEST['popup']);
17
18if ($popup) {
19    $open_f  = ['dcPage', 'openPopup'];
20    $close_f = ['dcPage', 'closePopup'];
21} else {
22    $open_f  = ['dcPage', 'open'];
23    $close_f = ['dcPage', 'close'];
24}
25
26if ($core->plugins->moduleExists($p)) {
27    $p_file = $core->plugins->moduleRoot($p) . '/index.php';
28}
29
30if (file_exists($p_file)) {
31    # Loading plugin
32    $p_info = $core->plugins->getModules($p);
33
34    $p_name = $p;
35    $p_url  = 'plugin.php?p=' . $p;
36
37    $p_title   = 'no content - plugin';
38    $p_head    = '';
39    $p_content = '<p>' . __('No content found on this plugin.') . '</p>';
40
41    ob_start();
42    include $p_file;
43    $res = ob_get_contents();
44    ob_end_clean();
45
46    if (preg_match('|<head>(.*?)</head|ms', $res, $m)) {
47        if (preg_match('|<title>(.*?)</title>|ms', $m[1], $mt)) {
48            $p_title = $mt[1];
49        }
50
51        if (preg_match_all('|(<script.*?>.*?</script>)|ms', $m[1], $ms)) {
52            foreach ($ms[1] as $v) {
53                $p_head .= $v . "\n";
54            }
55        }
56
57        if (preg_match_all('|(<style.*?>.*?</style>)|ms', $m[1], $ms)) {
58            foreach ($ms[1] as $v) {
59                $p_head .= $v . "\n";
60            }
61        }
62
63        if (preg_match_all('|(<link.*?/>)|ms', $m[1], $ms)) {
64            foreach ($ms[1] as $v) {
65                $p_head .= $v . "\n";
66            }
67        }
68    }
69
70    if (preg_match('|<body.*?>(.+)</body>|ms', $res, $m)) {
71        $p_content = $m[1];
72    }
73
74    call_user_func($open_f, $p_title, $p_head);
75    echo $p_content;
76    if (!$popup) {
77        // Add direct links to plugin settings if any
78        $settings = adminModulesList::getSettingsUrls($core, $p, true, false);
79        if (!empty($settings)) {
80            echo '<hr class="clear"/><p class="right modules">' . implode(' - ', $settings) . '</p>';
81        }
82    }
83    call_user_func($close_f);
84} else {
85    call_user_func($open_f, __('Plugin not found'), '',
86        dcPage::breadcrumb(
87            [
88                __('System')           => '',
89                __('Plugin not found') => ''
90            ])
91    );
92
93    echo '<p>' . __('The plugin you reached does not exist or does not have an admin page.') . '</p>';
94
95    call_user_func($close_f);
96}
Note: See TracBrowser for help on using the repository browser.

Sites map