Changeset 1984:0b0cb9cd7da7 for plugins/maintenance/_admin.php
- Timestamp:
- 09/21/13 23:52:08 (12 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/maintenance/_admin.php
r1969 r1984 23 23 // Admin behaviors 24 24 $core->addBehavior('dcMaintenanceRegister', array('dcMaintenanceAdmin', 'dcMaintenanceRegister')); 25 $core->addBehavior('adminPreferencesHeaders', array('dcMaintenanceAdmin', 'adminPreferencesHeaders'));26 25 $core->addBehavior('adminDashboardFavs', array('dcMaintenanceAdmin', 'adminDashboardFavs')); 27 26 $core->addBehavior('adminDashboardFavsIcon', array('dcMaintenanceAdmin', 'adminDashboardFavsIcon')); 28 27 $core->addBehavior('adminDashboardItems', array('dcMaintenanceAdmin', 'adminDashboardItems')); 29 $core->addBehavior('admin PreferencesForm', array('dcMaintenanceAdmin', 'adminPreferencesForm'));30 $core->addBehavior('admin BeforeUserOptionsUpdate', array('dcMaintenanceAdmin', 'adminBeforeUserOptionsUpdate'));28 $core->addBehavior('adminDashboardOptionsForm', array('dcMaintenanceAdmin', 'adminDashboardOptionsForm')); 29 $core->addBehavior('adminAfterDashboardOptionsUpdate', array('dcMaintenanceAdmin', 'adminAfterDashboardOptionsUpdate')); 31 30 32 31 /** … … 60 59 61 60 $tasks[] = 'dcMaintenanceCache'; 61 $tasks[] = 'dcMaintenanceIndexposts'; 62 $tasks[] = 'dcMaintenanceIndexcomments'; 62 63 $tasks[] = 'dcMaintenanceCountcomments'; 63 $tasks[] = 'dcMaintenanceIndexcomments';64 $tasks[] = 'dcMaintenanceIndexposts';65 64 $tasks[] = 'dcMaintenanceLogs'; 66 65 $tasks[] = 'dcMaintenanceVacuum'; 67 66 $tasks[] = 'dcMaintenanceZipmedia'; 68 67 $tasks[] = 'dcMaintenanceZiptheme'; 69 }70 71 /**72 * Dashboard headers.73 *74 * Add ajavascript to toggle tasks list.75 */76 public static function adminPreferencesHeaders()77 {78 return dcPage::jsLoad('index.php?pf=maintenance/js/preferences.js');79 68 } 80 69 … … 122 111 // Check expired tasks 123 112 $maintenance = new dcMaintenance($core); 124 $expired = $maintenance->getExpired(); 125 $expired = count($expired); 126 if (!$expired) { 127 return null; 128 } 129 130 $icon[0] .= '<br />'.sprintf(__('One task to update', '%s tasks to update', $expired), $expired); 113 $count = 0; 114 foreach($maintenance->getTasks() as $t) 115 { 116 if ($t->expired() !== false){ 117 $count++; 118 } 119 } 120 121 if (!$count) { 122 return null; 123 } 124 125 $icon[0] .= '<br />'.sprintf(__('One task to execute', '%s tasks to execute', $count), $count); 131 126 } 132 127 … … 145 140 146 141 $maintenance = new dcMaintenance($core); 147 $tasks = $maintenance->getExpired();148 if (empty($tasks)) {149 return null;150 }151 142 152 143 $lines = array(); 153 foreach($tasks as $id => $ts) { 154 $lines[$ts] = 155 '<li title="'.sprintf(__('Last updated on %s'), 156 dt::dt2str($core->blog->settings->system->date_format, $ts).' '. 157 dt::dt2str($core->blog->settings->system->time_format, $ts) 158 ).'">'.$maintenance->getTask($id)->task().'</li>'; 159 } 160 ksort($lines); 144 foreach($maintenance->getTasks() as $t) 145 { 146 $ts = $t->expired(); 147 if ($ts === false){ 148 continue; 149 } 150 151 $lines[] = 152 '<li title="'.($ts === null ? 153 __('This task has never been executed.') 154 : 155 sprintf(__('Last execution of this task was on %s.'), 156 dt::dt2str($core->blog->settings->system->date_format, $ts).' '. 157 dt::dt2str($core->blog->settings->system->time_format, $ts) 158 ) 159 ).'">'.$t->task().'</li>'; 160 } 161 162 if (empty($lines)) { 163 return null; 164 } 161 165 162 166 $items[] = new ArrayObject(array( 163 167 '<div id="maintenance-expired">'. 164 168 '<h3><img src="index.php?pf=maintenance/icon.png" alt="" /> '.__('Maintenance').'</h3>'. 165 '<p >'.sprintf(__('There is a task to update.', 'There are %s tasks to update.', count($tasks)), count($tasks)).'</p>'.169 '<p class="warn">'.sprintf(__('There is a task to execute.', 'There are %s tasks to execute.', count($lines)), count($lines)).'</p>'. 166 170 '<ul>'.implode('',$lines).'</ul>'. 167 '<p><a href="plugin.php?p=maintenance">'.__('Manage task ').'</a></p>'.171 '<p><a href="plugin.php?p=maintenance">'.__('Manage tasks').'</a></p>'. 168 172 '</div>' 169 173 )); … … 178 182 * @param $args <b>object</b> dcCore instance or record 179 183 */ 180 public static function adminPreferencesForm($core) 181 { 182 $core->auth->user_prefs->addWorkspace('maintenance'); 183 $maintenance = new dcMaintenance($core); 184 185 $tasks = $maintenance->getTasks(); 186 if (empty($tasks)) { 187 return null; 188 } 189 190 $full_combo_ts = array_merge(array( 191 __('Use different periods for each task') => 'seperate'), 192 self::comboTs() 193 ); 194 195 $task_combo_ts = array_merge(array( 196 __('Never') => 0), 197 self::comboTs() 198 ); 184 public static function adminDashboardOptionsForm($core) 185 { 186 $core->auth->user_prefs->addWorkspace('maintenance'); 199 187 200 188 echo … … 202 190 '<h4>'.__('Maintenance').'</h4>'. 203 191 204 '<div class="two-boxes">'.205 206 192 '<p><label for="maintenance_dashboard_icon" class="classic">'. 207 193 form::checkbox('maintenance_dashboard_icon', 1, $core->auth->user_prefs->maintenance->dashboard_icon). … … 210 196 '<p><label for="maintenance_dashboard_item" class="classic">'. 211 197 form::checkbox('maintenance_dashboard_item', 1, $core->auth->user_prefs->maintenance->dashboard_item). 212 __('Display list of expired tasks on dashboard contents').'</label></p>'. 213 214 '<p><label for="maintenance_plugin_message" class="classic">'. 215 form::checkbox('maintenance_plugin_message', 1, $core->auth->user_prefs->maintenance->plugin_message). 216 __('Display alert message of expired tasks on plugin page').'</label></p>'. 217 218 '</div>'. 219 220 '<div class="two-boxes">'. 221 222 '<p><label for="maintenance_recall_time">'.__('Recall time for all tasks').'</label>'. 223 form::combo('maintenance_recall_time', $full_combo_ts, 'seperate', 'recall-for-all'). 224 '</p>'. 225 226 '</div>'. 227 228 '<div id="maintenance-recall-time">'. 229 '<h5>'.__('Recall time per task').'</h5>'; 230 231 foreach($tasks as $task) { 232 echo 233 '<div class="two-boxes">'. 234 235 '<p><label for="maintenance_ts_'.$task->id().'">'.$task->task().'</label>'. 236 form::combo('maintenance_ts_'.$task->id(), $task_combo_ts, $task->ts(), 'recall-per-task'). 237 '</p>'. 238 239 '</div>'; 240 } 241 242 echo 243 '</div>'. 198 __('Display list of expired tasks on dashboard items').'</label></p>'. 199 244 200 '</div>'; 245 201 } … … 248 204 * User preferences update. 249 205 * 250 * @param $cur <b>cursor</b> Cursor of user options251 206 * @param $user_id <b>string</b> User ID 252 207 */ 253 public static function admin BeforeUserOptionsUpdate($cur,$user_id=null)208 public static function adminAfterDashboardOptionsUpdate($user_id=null) 254 209 { 255 210 global $core; 256 211 257 212 if (is_null($user_id)) { 258 return null;259 }260 261 $maintenance = new dcMaintenance($core);262 $tasks = $maintenance->getTasks();263 if (empty($tasks)) {264 213 return null; 265 214 } … … 268 217 $core->auth->user_prefs->maintenance->put('dashboard_icon', !empty($_POST['maintenance_dashboard_icon']), 'boolean'); 269 218 $core->auth->user_prefs->maintenance->put('dashboard_item', !empty($_POST['maintenance_dashboard_item']), 'boolean'); 270 $core->auth->user_prefs->maintenance->put('plugin_message', !empty($_POST['maintenance_plugin_message']), 'boolean');271 272 foreach($tasks as $task) {273 if ($_POST['maintenance_recall_time'] == 'seperate') {274 $ts = empty($_POST['maintenance_ts_'.$task->id()]) ? 0 : $_POST['maintenance_ts_'.$task->id()];275 }276 else {277 $ts = $_POST['maintenance_recall_time'];278 }279 $core->auth->user_prefs->maintenance->put('ts_'.$task->id(), abs((integer) $ts), 'integer');280 }281 }282 283 /* @ignore */284 public static function comboTs()285 {286 return array(287 __('Every week') => 604800,288 __('Every two weeks') => 1209600,289 __('Every month') => 2592000,290 __('Every two months') => 5184000291 );292 219 } 293 220 }
Note: See TracChangeset
for help on using the changeset viewer.