[0] | 1 | <?php |
---|
[3731] | 2 | /** |
---|
| 3 | * @package Dotclear |
---|
| 4 | * @subpackage Backend |
---|
| 5 | * |
---|
| 6 | * @copyright Olivier Meunier & Association Dotclear |
---|
| 7 | * @copyright GPL-2.0-only |
---|
| 8 | */ |
---|
[0] | 9 | |
---|
[3730] | 10 | require dirname(__FILE__) . '/../inc/admin/prepend.php'; |
---|
[0] | 11 | |
---|
| 12 | dcPage::check('usage,contentadmin'); |
---|
| 13 | |
---|
| 14 | $p_file = ''; |
---|
[3730] | 15 | $p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null; |
---|
| 16 | $popup = (integer) !empty($_REQUEST['popup']); |
---|
[0] | 17 | |
---|
| 18 | if ($popup) { |
---|
[3730] | 19 | $open_f = array('dcPage', 'openPopup'); |
---|
| 20 | $close_f = array('dcPage', 'closePopup'); |
---|
[0] | 21 | } else { |
---|
[3730] | 22 | $open_f = array('dcPage', 'open'); |
---|
| 23 | $close_f = array('dcPage', 'close'); |
---|
[0] | 24 | } |
---|
| 25 | |
---|
| 26 | if ($core->plugins->moduleExists($p)) { |
---|
[3730] | 27 | $p_file = $core->plugins->moduleRoot($p) . '/index.php'; |
---|
[0] | 28 | } |
---|
| 29 | |
---|
[3730] | 30 | if (file_exists($p_file)) { |
---|
| 31 | # Loading plugin |
---|
| 32 | $p_info = $core->plugins->getModules($p); |
---|
[2566] | 33 | |
---|
[3730] | 34 | $p_name = $p; |
---|
| 35 | $p_url = 'plugin.php?p=' . $p; |
---|
[2566] | 36 | |
---|
[3730] | 37 | $p_title = 'no content - plugin'; |
---|
| 38 | $p_head = ''; |
---|
| 39 | $p_content = '<p>' . __('No content found on this plugin.') . '</p>'; |
---|
[2566] | 40 | |
---|
[3730] | 41 | ob_start(); |
---|
| 42 | include $p_file; |
---|
| 43 | $res = ob_get_contents(); |
---|
| 44 | ob_end_clean(); |
---|
[2566] | 45 | |
---|
[3730] | 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 | } |
---|
[2566] | 50 | |
---|
[3730] | 51 | if (preg_match_all('|(<script.*?>.*?</script>)|ms', $m[1], $ms)) { |
---|
| 52 | foreach ($ms[1] as $v) { |
---|
| 53 | $p_head .= $v . "\n"; |
---|
| 54 | } |
---|
| 55 | } |
---|
[2566] | 56 | |
---|
[3730] | 57 | if (preg_match_all('|(<style.*?>.*?</style>)|ms', $m[1], $ms)) { |
---|
| 58 | foreach ($ms[1] as $v) { |
---|
| 59 | $p_head .= $v . "\n"; |
---|
| 60 | } |
---|
| 61 | } |
---|
[2566] | 62 | |
---|
[3730] | 63 | if (preg_match_all('|(<link.*?/>)|ms', $m[1], $ms)) { |
---|
| 64 | foreach ($ms[1] as $v) { |
---|
| 65 | $p_head .= $v . "\n"; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | } |
---|
[2566] | 69 | |
---|
[3730] | 70 | if (preg_match('|<body.*?>(.+)</body>|ms', $res, $m)) { |
---|
| 71 | $p_content = $m[1]; |
---|
| 72 | } |
---|
[2566] | 73 | |
---|
[3730] | 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 | array( |
---|
| 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); |
---|
[0] | 96 | } |
---|