1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
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 | |
---|
17 | $p_file = ''; |
---|
18 | $p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null; |
---|
19 | $popup = (integer) !empty($_REQUEST['popup']); |
---|
20 | |
---|
21 | if ($popup) { |
---|
22 | $open_f = array('dcPage','openPopup'); |
---|
23 | $close_f = array('dcPage','closePopup'); |
---|
24 | } else { |
---|
25 | $open_f = array('dcPage','open'); |
---|
26 | $close_f = array('dcPage','close'); |
---|
27 | } |
---|
28 | |
---|
29 | if ($core->plugins->moduleExists($p)) { |
---|
30 | $p_file = $core->plugins->moduleRoot($p).'/index.php'; |
---|
31 | } |
---|
32 | |
---|
33 | if (file_exists($p_file)) |
---|
34 | { |
---|
35 | # Loading plugin |
---|
36 | $p_info = $core->plugins->getModules($p); |
---|
37 | |
---|
38 | $p_url = 'plugin.php?p='.$p; |
---|
39 | |
---|
40 | $p_title = 'no content - plugin'; |
---|
41 | $p_head = ''; |
---|
42 | $p_content = '<p>'.__('No content found on this plugin.').'</p>'; |
---|
43 | |
---|
44 | ob_start(); |
---|
45 | include $p_file; |
---|
46 | $res = ob_get_contents(); |
---|
47 | ob_end_clean(); |
---|
48 | |
---|
49 | if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { |
---|
50 | if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { |
---|
51 | $p_title = $mt[1]; |
---|
52 | } |
---|
53 | |
---|
54 | if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { |
---|
55 | foreach ($ms[1] as $v) { |
---|
56 | $p_head .= $v."\n"; |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { |
---|
61 | foreach ($ms[1] as $v) { |
---|
62 | $p_head .= $v."\n"; |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { |
---|
67 | foreach ($ms[1] as $v) { |
---|
68 | $p_head .= $v."\n"; |
---|
69 | } |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { |
---|
74 | $p_content = $m[1]; |
---|
75 | } |
---|
76 | |
---|
77 | call_user_func($open_f,$p_title,$p_head); |
---|
78 | echo $p_content; |
---|
79 | call_user_func($close_f); |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | call_user_func($open_f,__('Plugin not found'),'', |
---|
84 | dcPage::breadcrumb( |
---|
85 | array( |
---|
86 | __('System') => '', |
---|
87 | '<span class="page-title">'.__('Plugin not found').'</span>' => '' |
---|
88 | )) |
---|
89 | ); |
---|
90 | |
---|
91 | echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>'; |
---|
92 | |
---|
93 | call_user_func($close_f); |
---|
94 | } |
---|
95 | ?> |
---|