Changeset 2199 for plugins/dcAdvancedCleaner/index.php
- Timestamp:
- 04/16/10 16:51:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcAdvancedCleaner/index.php
r1980 r2199 3 3 # This file is part of dcAdvancedCleaner, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # … … 14 14 15 15 if (!$core->auth->isSuperAdmin()){return;} 16 17 # Lists 18 function drawDcAdvancedCleanerLists($core,$type) 19 { 20 $combo_funcs = array( 21 'settings' => array('dcAdvancedCleaner','getSettings'), 22 'tables' => array('dcAdvancedCleaner','getTables'), 23 'plugins' => array('dcAdvancedCleaner','getPlugins'), 24 'themes' => array('dcAdvancedCleaner','getThemes'), 25 'caches' => array('dcAdvancedCleaner','getCaches'), 26 'versions' => array('dcAdvancedCleaner','getVersions') 27 ); 28 $combo_actions = array( 29 'settings' => array( 30 __('delete global settings') => 'delete_global', 31 __('delete blog settings') => 'delete_local', 32 __('delete all settings') =>'delete_all' 33 ), 34 'tables' => array( 35 __('delete') => 'delete', 36 __('empty') => 'empty' 37 ), 38 'plugins' => array( 39 __('delete') => 'delete', 40 __('empty') => 'empty' 41 ), 42 'themes' => array( 43 __('delete') => 'delete', 44 __('empty') => 'empty' 45 ), 46 'caches' => array( 47 __('delete') => 'delete', 48 __('empty') => 'empty' 49 ), 50 'versions' => array( 51 __('delete') => 'delete' 52 ) 53 ); 54 $combo_help = array( 55 'settings' => __('Namespaces registered in dcSettings'), 56 'tables' => __('All database tables of Dotclear'), 57 'plugins' => __('Folders from plugins directories'), 58 'themes' => __('Folders from blog themes directory'), 59 'caches' => __('Folders from cache directory'), 60 'versions' => __('Versions registered in table "version" of Dotclear') 61 ); 62 63 if (!isset($combo_funcs[$type])) return ''; 64 65 $s = dcAdvancedCleanerSettings($core); 66 $rs = call_user_func($combo_funcs[$type],$core); 67 68 echo 69 '<div class="listDcAdvancedCleaner">'. 70 '<p class="form-note">'.$combo_help[$type].'</p>'; 71 72 if (empty($rs)) { 73 echo 74 '<p>'.sprintf(__('There is no %s'),__(substr($type,0,-1))).'</p>'; 75 } else { 76 77 echo 78 '<p>'.sprintf(__('There are %s %s'),count($rs),__($type)).'</p>'. 79 '<form method="post" action="plugin.php?p=dcAdvancedCleaner&tab=lists&part='.$type.'">'. 80 '<table><thead><tr>'. 81 '<th>'.__('Name').'</th><th>'.__('Objects').'</th>'. 82 '</tr></thead><tbody>'; 83 84 foreach($rs as $k => $v) 85 { 86 $offline = in_array($v['key'],dcAdvancedCleaner::$dotclear[$type]); 87 88 if ($s->dcAdvancedCleaner_dcproperty_hide && $offline) continue; 89 90 echo 91 '<tr class="line'. 92 ($offline ? ' offline' : ''). 93 '">'. 94 '<td class="nowrap"><label class="classic">'. 95 form::checkbox(array('entries['.$k.']'),html::escapeHTML($v['key'])).' '.$v['key'].'</label></td>'. 96 '<td class="nowrap">'.$v['value'].'</td>'. 97 '</tr>'; 98 } 99 100 echo 101 '</tbody></table>'. 102 '<p>'.__('Action on selected rows:').'<br />'. 103 form::combo(array('action'),$combo_actions[$type]). 104 '<input type="submit" value="'.__('ok').'" />'. 105 form::hidden(array('p'),'dcAdvancedCleaner'). 106 form::hidden(array('tab'),'lists'). 107 form::hidden(array('part'),$type). 108 form::hidden(array('type'),$type). 109 $core->formNonce().'</p>'. 110 '</form>'; 111 } 112 echo 113 '<div>'; 114 } 16 115 17 116 # Localized l10n … … 38 137 39 138 # vars 40 $p_url = 'plugin.php?p=dcAdvancedCleaner';41 139 $msg = isset($_GET['msg']) ? true : false; 42 $ for = isset($_GET['for']) ? $_GET['for'] : '';43 $ tab = isset($_REQUEST['t']) ? $_REQUEST['t'] : 'records';140 $tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'dcac'; 141 $part = isset($_REQUEST['part']) ? $_REQUEST['part'] : 'caches'; 44 142 $entries = isset($_POST['entries']) ? $_POST['entries'] : ''; 45 143 $action = isset($_POST['action']) ? $_POST['action'] : ''; 46 144 $type = isset($_POST['type']) ? $_POST['type'] : ''; 145 $s = dcAdvancedCleanerSettings($core); 47 146 48 147 # Combos 49 $combo_settings = array( 50 __('delete global settings') => 'delete_global', 51 __('delete blog settings') => 'delete_local', 52 __('delete all settings') =>'delete_all' 148 $combo_title = array( 149 'settings' => __('Settings'), 150 'tables' => __('Tables'), 151 'plugins' => __('Extensions'), 152 'themes' => __('Themes'), 153 'caches' => __('Cache'), 154 'versions' => __('Versions') 53 155 ); 54 $combo_bi = array( 55 __('delete') => 'delete', 56 __('empty') => 'empty' 57 ); 58 $combo_delete = array( 59 __('delete') => 'delete' 60 ); 156 61 157 $combo_type = array( 62 158 'settings' => array('delete_global','delete_local','delete_all'), … … 67 163 'versions' => array('delete') 68 164 ); 69 $combo_help = array(70 'settings' => __('Namespaces registered in dcSettings'),71 'tables' => __('All database tables of Dotclear'),72 'plugins' => __('Folders from plugins directories'),73 'themes' => __('Folders from blog themes directory'),74 'caches' => __('Folders from cache directory'),75 'versions' => __('Versions registered in table "version" of Dotclear')76 );77 165 78 166 # This plugin settings 79 if ($action == 'dcadvancedcleaner_settings') { 80 81 $core->blog->settings->setNameSpace('dcAdvancedCleaner'); 82 $core->blog->settings->put('dcadvancedcleaner_behavior_active', 83 isset($_POST['dcadvancedcleaner_behavior_active']),'boolean'); 84 $core->blog->settings->put('dcadvancedcleaner_dcproperty_hide', 85 isset($_POST['dcadvancedcleaner_dcproperty_hide']),'boolean'); 86 $core->blog->settings->setNameSpace('system'); 87 88 http::redirect($p_url.'&t=dcb&msg=1'); 167 if ($tab == 'dcac' && $action == 'dcadvancedcleaner_settings') 168 { 169 try { 170 $s->put('dcAdvancedCleaner_behavior_active',isset($_POST['dcadvancedcleaner_behavior_active']),'boolean'); 171 $s->put('dcAdvancedCleaner_dcproperty_hide',isset($_POST['dcadvancedcleaner_dcproperty_hide']),'boolean'); 172 173 http::redirect($p_url.'&tab=dcac&part=dcac&part=&msg=done'); 174 } 175 catch(Exception $e) { 176 $core->error->add($e->getMessage()); 177 } 89 178 } 90 179 91 180 # Actions 92 if ( !empty($entries)181 if ($tab == 'lists' && !empty($entries) 93 182 && isset($combo_type[$type]) 94 183 && in_array($action,$combo_type[$type])) { … … 99 188 } 100 189 101 # Redirection on success 102 http::redirect($p_url.'&t='.$tab.'&msg=done'); 190 http::redirect($p_url.'&tab=lists&part='.$part.'&msg=done'); 103 191 } 104 192 catch(Exception $e) { … … 107 195 } 108 196 109 # Lists 110 $settings = dcAdvancedCleaner::getSettings($core); 111 $tables = dcAdvancedCleaner::getTables($core); 112 $plugins = dcAdvancedCleaner::getPlugins($core); 113 $themes = dcAdvancedCleaner::getThemes($core); 114 $caches = dcAdvancedCleaner::getCaches($core); 115 $versions = dcAdvancedCleaner::getVersions($core); 116 117 ?> 118 <html> 119 <head> 120 <title><?php echo __('Advanced cleaner'); ?></title> 121 <style type="text/css"> 122 .listDcAdvancedCleaner { 123 float:left; 124 padding:10px; 125 margin:10px 10px 0 0; 126 border:1px solid #CCCCCC; 127 background-color: #FCFCFC; 128 } 129 .bombDcAdvancedCleaner { 130 padding:14px 0 2px 36px; 131 background:url(index.php?pf=dcAdvancedCleaner/icon-b.png) no-repeat; 132 } 133 </style> 134 <?php echo dcPage::jsToolBar().dcPage::jsPageTabs($tab); ?> 135 136 <?php 197 echo ' 198 <html><head> 199 <title>'.__('Advanced cleaner').'</title> 200 <link rel="stylesheet" type="text/css" href="index.php?pf=dcAdvancedCleaner/style.css" />'. 201 dcPage::jsToolBar(). 202 dcPage::jsPageTabs($tab).' 203 </style>'; 137 204 138 205 # --BEHAVIOR-- dcAdvancedCleanerAdminHeader 139 206 $core->callBehavior('dcAdvancedCleanerAdminHeader',$core,$p_url,$tab); 140 207 141 ?> 142 </head>143 <body> 144 <h2 class="bombDcAdvancedCleaner"><?php echo html::escapeHTML($core->blog->name).' › '.__('Advanced cleaner'); ?></h2>145 <p class="static-msg"><?php echo __('Beware: All actions done here are irreversible and are directly applied'); ?></p> 146 <?php if (!empty($msg)) { echo '<p class="message">'.__('Action successfully done').'</p>'; } ?> 147 148 <div class="multi-part" id="records" title="<?php echo __('Records'); ?>"> 149 <?php 150 drawDcAdvancedCleanerLists('settings',$settings,$combo_settings,$combo_help['settings'],'records');151 drawDcAdvancedCleanerLists('tables',$tables,$combo_bi,$combo_help['tables'],'records'); 152 drawDcAdvancedCleanerLists('versions',$versions,$combo_delete,$combo_help['versions'],'records'); 153 ?> 154 </div> 155 156 <div class="multi-part" id="folders" title="<?php echo __('Folders'); ?>"> 157 <?php 158 drawDcAdvancedCleanerLists('plugins',$plugins,$combo_bi,$combo_help['plugins'],'foldlers'); 159 drawDcAdvancedCleanerLists('themes',$themes,$combo_bi,$combo_help['themes'],'folders'); 160 drawDcAdvancedCleanerLists('caches',$caches,$combo_bi,$combo_help['caches'],'folders');161 ?> 162 </div> 163 164 <?php 208 echo ' 209 </head><body> 210 <h2 class="bombDcAdvancedCleaner">'.html::escapeHTML($core->blog->name). 211 ' › '.__('Advanced cleaner').'</h2> 212 <p class="static-msg">'.__('Beware: All actions done here are irreversible and are directly applied').'</p>'; 213 214 if (!empty($msg)) { echo '<p class="message">'.__('Action successfully done').'</p>'; } 215 216 echo '<div class="multi-part" id="lists" title="'.__('Records and folders').'">'. 217 '<p>'; 218 foreach($combo_title as $k => $v) 219 { 220 echo '<a class="button" href="'.$p_url.'&tab=lists&part='.$k.'">'.$v.'</a> '; 221 } 222 echo '</p>'; 223 224 # Load "part" page 225 if (isset($combo_title[$part])) 226 { 227 echo '<fieldset><legend>'.$combo_title[$part].'</legend>'; 228 drawDcAdvancedCleanerLists($core,$part); 229 echo '</fieldset>'; 230 } 231 echo '</div>'; 165 232 166 233 # --BEHAVIOR-- dcAdvancedCleanerAdminTabs 167 234 $core->callBehavior('dcAdvancedCleanerAdminTabs',$core,$p_url); 168 235 236 echo ' 237 <div class="multi-part" id="dcac" title="'.__('This plugin settings').'"> 238 <fieldset><legend>'.__('This plugin settings').'</legend> 239 <form method="post" action="'.$p_url.'&tab=dcac&part="> 240 <p class="field"><label>'. 241 form::checkbox(array('dcadvancedcleaner_behavior_active'),'1', 242 $s->dcAdvancedCleaner_behavior_active). 243 __('Activate behaviors').'</label></p> 244 <p class="form-note">'.__('Enable actions set in _uninstall.php files.').'</p> 245 <p class="field"><label>'. 246 form::checkbox(array('dcadvancedcleaner_dcproperty_hide'),'1', 247 $s->dcAdvancedCleaner_dcproperty_hide). 248 __('Hide Dotclear default properties in actions tabs').' 249 </label></p> 250 <p class="form-note">'.__('Prevent from deleting Dotclear important properties.').'</p> 251 <p><input type="submit" name="submit" value="'.__('Save').'" />'. 252 form::hidden(array('p'),'dcAdvancedCleaner'). 253 form::hidden(array('tab'),'dcac'). 254 form::hidden(array('part'),''). 255 form::hidden(array('action'),'dcadvancedcleaner_settings'). 256 $core->formNonce().'</p> 257 </form> 258 </fieldset> 259 </div>'; 260 261 dcPage::helpBlock('dcAdvancedCleaner'); 262 echo ' 263 <hr class="clear"/> 264 <p class="right"> 265 <a class="button" href="'.$p_url.'&part=dcac">'.__('settings').'</a> - 266 dcAdvancedCleaner - '.$core->plugins->moduleInfo('dcAdvancedCleaner','version').' 267 <img alt="dcMiniUrl" src="index.php?pf=dcAdvancedCleaner/icon.png" /> 268 </p> 269 </body></html>'; 169 270 ?> 170 171 <div class="multi-part" id="dcb" title="<?php echo __('Settings'); ?>">172 <form method="post" action="plugin.php">173 <p>174 <label class="classic"><?php echo175 form::checkbox(array('dcadvancedcleaner_behavior_active'),'1',176 $core->blog->settings->dcadvancedcleaner_behavior_active).' '.177 __('Activate behaviors'); ?>178 </label>179 </p>180 <p class="form-note"><?php echo __('Enable actions set in _uninstall.php files.'); ?></p>181 <p>182 <label class="classic"><?php echo183 form::checkbox(array('dcadvancedcleaner_dcproperty_hide'),'1',184 $core->blog->settings->dcadvancedcleaner_dcproperty_hide).' '.185 __('Hide Dotclear default properties in actions tabs'); ?>186 </label>187 </p>188 <p class="form-note"><?php echo __('Prevent from deleting Dotclear important properties.'); ?></p>189 <p>190 <input type="submit" name="submit" value="<?php echo __('Save'); ?>" />191 <?php echo192 form::hidden(array('p'),'dcAdvancedCleaner').193 form::hidden(array('t'),'dcb').194 form::hidden(array('action'),'dcadvancedcleaner_settings').195 $core->formNonce();196 ?>197 </p>198 </form>199 </div>200 201 <?php echo dcPage::helpBlock('dcAdvancedCleaner'); ?>202 203 <p class="clear"> </p>204 <hr class="clear"/>205 <p class="right">206 dcAdvancedCleaner - <?php echo $core->plugins->moduleInfo('dcAdvancedCleaner','version'); ?> 207 <img alt="dcMiniUrl" src="index.php?pf=dcAdvancedCleaner/icon.png" />208 </p>209 </body>210 </html>211 <?php212 213 function drawDcAdvancedCleanerLists($type,$rs,$actions,$help='',$tab='records')214 {215 echo216 '<div class="listDcAdvancedCleaner">'.217 '<h2>'.__(ucfirst($type)).'</h2>'.218 '<p class="form-note">'.$help.'</p>';219 220 if (empty($rs)) {221 echo222 '<p>'.sprintf(__('There is no %s'),__(substr($type,0,-1))).'</p>';223 } else {224 225 echo226 '<p>'.sprintf(__('There are %s %s'),count($rs),__($type)).'</p>'.227 '<form method="post" action="plugin.php">'.228 '<table><thead><tr>'.229 '<th>'.__('Name').'</th><th>'.__('Objects').'</th>'.230 '</tr></thead><tbody>';231 232 foreach($rs as $k => $v) {233 234 $offline = in_array($v['key'],dcAdvancedCleaner::$dotclear[$type]);235 236 if ($GLOBALS['core']->blog->settings->dcadvancedcleaner_dcproperty_hide && $offline)237 continue;238 239 echo240 '<tr class="line'.241 ($offline ? ' offline' : '').242 '">'.243 '<td class="nowrap"><label class="classic">'.244 form::checkbox(array('entries['.$k.']'),html::escapeHTML($v['key'])).' '.$v['key'].'</label></td>'.245 '<td class="nowrap">'.$v['value'].'</td>'.246 '</tr>';247 }248 249 echo250 '</tbody></table>'.251 '<p>'.__('Action on selected rows:').'<br />'.252 form::combo(array('action'),$actions).253 '<input type="submit" value="'.__('ok').'" />'.254 form::hidden(array('p'),'dcAdvancedCleaner').255 form::hidden(array('t'),$tab).256 form::hidden(array('type'),$type).257 $GLOBALS['core']->formNonce().'</p>'.258 '</form>';259 }260 echo261 '</div>';262 }263 ?>
Note: See TracChangeset
for help on using the changeset viewer.