Changeset 1070:64699c5b7cc9 for admin
- Timestamp:
- 12/17/12 00:15:04 (13 years ago)
- Branch:
- twig
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/plugin.php
r500 r1070 15 15 dcPage::check('usage,contentadmin'); 16 16 17 //* TODO: Do it better later, required by some javascripts 18 $some_globals = array( 19 'rtl' => l10n::getTextDirection($_lang) == 'rtl', 20 'Nonce' => $core->getNonce(), 21 'sess_id' => session_id(), 22 'sess_uid' => $_SESSION['sess_browser_uid'], 23 'media_manage' => $core->auth->check('media,media_admin',$core->blog->id), 24 'enable_wysiwyg' => isset($core->auth) && $core->auth->getOption('enable_wysiwyg'), 25 'edit_size' => $core->auth->getOption('edit_size') 26 ); 27 foreach($some_globals as $name => $value) { 28 $_ctx->$name = $value; 29 }; 30 //*/ 31 32 $has_content = false; 17 33 $p_file = ''; 18 34 $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 } 35 $popup = $_ctx->popup = (integer) !empty($_REQUEST['popup']); 28 36 29 37 if ($core->plugins->moduleExists($p)) { 30 38 $p_file = $core->plugins->moduleRoot($p).'/index.php'; 31 39 } 40 if (file_exists($p_file)) { 32 41 33 if (file_exists($p_file)) 34 { 35 # Loading plugin 42 //* Keep this for old style plugins using dcPage 43 if ($popup) { 44 $open_f = array('dcPage','openPopup'); 45 $close_f = array('dcPage','closePopup'); 46 } else { 47 $open_f = array('dcPage','open'); 48 $close_f = array('dcPage','close'); 49 } 50 36 51 $p_info = $core->plugins->getModules($p); 37 38 52 $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 53 $p_title = $p_head = $p_content = ''; 54 //*/ 55 # Get page content 44 56 ob_start(); 45 57 include $p_file; 46 58 $res = ob_get_contents(); 47 59 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 } 60 61 //* Keep this for old style plugins using dcPage 62 if (!$_ctx->hasPageTitle()) { 53 63 54 if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 55 foreach ($ms[1] as $v) { 56 $p_head .= $v."\n"; 64 if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 65 if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 66 $p_title = $mt[1]; 67 } 68 69 if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 70 foreach ($ms[1] as $v) { 71 $p_head .= $v."\n"; 72 } 73 } 74 75 if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 76 foreach ($ms[1] as $v) { 77 $p_head .= $v."\n"; 78 } 79 } 80 81 if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 82 foreach ($ms[1] as $v) { 83 $p_head .= $v."\n"; 84 } 57 85 } 58 86 } 59 87 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 } 88 if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 89 $p_content = $m[1]; 90 91 call_user_func($open_f,$p_title,$p_head); 92 echo $p_content; 93 call_user_func($close_f); 94 95 $has_content = true; 70 96 } 71 97 } 72 73 if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 74 $p_content = $m[1]; 98 //*/ 99 # Check context and display 100 if ($_ctx->hasPageTitle() && !empty($res)) { 101 $has_content = true; 102 echo $res; 75 103 } 76 77 call_user_func($open_f,$p_title,$p_head);78 echo $p_content;79 call_user_func($close_f);80 104 } 81 else 82 { 83 call_user_func($open_f,__('Plugin not found')); 84 85 echo '<h2 class="page-title">'.__('Plugin not found').'</h2>'; 86 87 echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>'; 88 89 call_user_func($close_f); 105 # No plugin or content found 106 if (!$has_content) { 107 $_ctx->setPageTitle(__('Plugin not found')); 108 $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 109 $core->tpl->display('plugin.html.twig'); 90 110 } 91 111 ?>
Note: See TracChangeset
for help on using the changeset viewer.