- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/plugin.php
r2708 r2715 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 15 15 dcPage::check('usage,contentadmin'); 16 16 17 $has_content = false; 17 18 $p_file = ''; 18 19 $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 } 20 $popup = $_ctx->popup = (integer) !empty($_REQUEST['popup']); 28 21 29 22 if ($core->plugins->moduleExists($p)) { 30 23 $p_file = $core->plugins->moduleRoot($p).'/index.php'; 31 24 } 25 if (file_exists($p_file)) { 32 26 33 if (file_exists($p_file)) 34 { 35 # Loading plugin 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 36 36 $p_info = $core->plugins->getModules($p); 37 38 37 $p_name = $p; 39 38 $p_url = 'plugin.php?p='.$p; 40 41 $p_title = 'no content - plugin'; 42 $p_head = ''; 43 $p_content = '<p>'.__('No content found on this plugin.').'</p>'; 44 39 $p_title = $p_head = $p_content = ''; 40 //*/ 41 # Get page content 45 42 ob_start(); 46 43 include $p_file; … … 48 45 ob_end_clean(); 49 46 50 if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 51 if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 52 $p_title = $mt[1]; 53 } 54 55 if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 56 foreach ($ms[1] as $v) { 57 $p_head .= $v."\n"; 47 # Check context and display 48 if ($_ctx->hasPageTitle() && !empty($res)) { 49 $has_content = true; 50 echo $res; 51 } 52 //* Keep this for old style plugins using dcPage 53 elseif (!$_ctx->hasPageTitle()) { 54 55 if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 56 if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 57 $p_title = $mt[1]; 58 } 59 60 if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 61 foreach ($ms[1] as $v) { 62 $p_head .= $v."\n"; 63 } 64 } 65 66 if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 67 foreach ($ms[1] as $v) { 68 $p_head .= $v."\n"; 69 } 70 } 71 72 if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 73 foreach ($ms[1] as $v) { 74 $p_head .= $v."\n"; 75 } 58 76 } 59 77 } 60 61 if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 62 foreach ($ms[1] as $v) { 63 $p_head .= $v."\n"; 64 } 65 } 66 67 if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 68 foreach ($ms[1] as $v) { 69 $p_head .= $v."\n"; 70 } 78 79 if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 80 $p_content = $m[1]; 81 82 call_user_func($open_f,$p_title,$p_head); 83 echo $p_content; 84 call_user_func($close_f); 85 86 $has_content = true; 71 87 } 72 88 } 73 74 if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 75 $p_content = $m[1]; 76 } 77 78 call_user_func($open_f,$p_title,$p_head); 79 echo $p_content; 80 call_user_func($close_f); 89 //*/ 81 90 } 82 else 83 { 84 call_user_func($open_f,__('Plugin not found'),'', 85 dcPage::breadcrumb( 86 array( 87 __('System') => '', 88 __('Plugin not found') => '' 89 )) 90 ); 91 92 echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>'; 93 94 call_user_func($close_f); 91 # No plugin or content found 92 if (!$has_content) { 93 $_ctx->setBreadcrumb(__('Plugin not found')); 94 $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 95 $core->tpl->display('plugin.html.twig'); 95 96 } 97 ?>
Note: See TracChangeset
for help on using the changeset viewer.