[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
[0] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | |
---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 14 | |
---|
| 15 | dcPage::check('usage,contentadmin'); |
---|
| 16 | |
---|
[1070] | 17 | $has_content = false; |
---|
[0] | 18 | $p_file = ''; |
---|
| 19 | $p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null; |
---|
[1070] | 20 | $popup = $_ctx->popup = (integer) !empty($_REQUEST['popup']); |
---|
[0] | 21 | |
---|
| 22 | if ($core->plugins->moduleExists($p)) { |
---|
| 23 | $p_file = $core->plugins->moduleRoot($p).'/index.php'; |
---|
| 24 | } |
---|
[1070] | 25 | if (file_exists($p_file)) { |
---|
[0] | 26 | |
---|
[1070] | 27 | //* Keep this for old style plugins using dcPage |
---|
| 28 | if ($popup) { |
---|
| 29 | $open_f = array('dcPage','openPopup'); |
---|
| 30 | $close_f = array('dcPage','closePopup'); |
---|
| 31 | } else { |
---|
| 32 | $open_f = array('dcPage','open'); |
---|
| 33 | $close_f = array('dcPage','close'); |
---|
| 34 | } |
---|
| 35 | |
---|
[0] | 36 | $p_info = $core->plugins->getModules($p); |
---|
| 37 | $p_url = 'plugin.php?p='.$p; |
---|
[1070] | 38 | $p_title = $p_head = $p_content = ''; |
---|
| 39 | //*/ |
---|
| 40 | # Get page content |
---|
[0] | 41 | ob_start(); |
---|
| 42 | include $p_file; |
---|
| 43 | $res = ob_get_contents(); |
---|
| 44 | ob_end_clean(); |
---|
[1070] | 45 | |
---|
[1074] | 46 | # Check context and display |
---|
| 47 | if ($_ctx->hasPageTitle() && !empty($res)) { |
---|
| 48 | $has_content = true; |
---|
| 49 | echo $res; |
---|
| 50 | } |
---|
[1070] | 51 | //* Keep this for old style plugins using dcPage |
---|
[1074] | 52 | elseif (!$_ctx->hasPageTitle()) { |
---|
[0] | 53 | |
---|
[1070] | 54 | if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { |
---|
| 55 | if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { |
---|
| 56 | $p_title = $mt[1]; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { |
---|
| 60 | foreach ($ms[1] as $v) { |
---|
| 61 | $p_head .= $v."\n"; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { |
---|
| 66 | foreach ($ms[1] as $v) { |
---|
| 67 | $p_head .= $v."\n"; |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { |
---|
| 72 | foreach ($ms[1] as $v) { |
---|
| 73 | $p_head .= $v."\n"; |
---|
| 74 | } |
---|
[0] | 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
[1070] | 78 | if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { |
---|
| 79 | $p_content = $m[1]; |
---|
| 80 | |
---|
| 81 | call_user_func($open_f,$p_title,$p_head); |
---|
| 82 | echo $p_content; |
---|
| 83 | call_user_func($close_f); |
---|
| 84 | |
---|
| 85 | $has_content = true; |
---|
[0] | 86 | } |
---|
| 87 | } |
---|
[1070] | 88 | //*/ |
---|
[0] | 89 | } |
---|
[1070] | 90 | # No plugin or content found |
---|
| 91 | if (!$has_content) { |
---|
| 92 | $_ctx->setPageTitle(__('Plugin not found')); |
---|
| 93 | $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); |
---|
| 94 | $core->tpl->display('plugin.html.twig'); |
---|
[0] | 95 | } |
---|
| 96 | ?> |
---|