Changeset 1955:b0bef03695c0 for plugins/maintenance
- Timestamp:
- 09/19/13 01:08:39 (12 years ago)
- Branch:
- default
- Children:
- 1956:d272c079e6e5, 1964:bfde9296c3c5
- Location:
- plugins/maintenance
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/maintenance/_admin.php
r1940 r1955 43 43 * @param $tasks <b>arrayObject</b> Array of tasks to register 44 44 * @param $groups <b>arrayObject</b> Array of groups to register 45 * @param $tabs <b>arrayObject</b> Array of tabs to register 45 46 */ 46 public static function register($core, $tasks, $groups )47 public static function register($core, $tasks, $groups, $tabs) 47 48 { 49 $tabs['maintenance'] = __('Servicing'); 50 $tabs['backup'] = __('Backup'); 51 48 52 $groups['optimize'] = __('Optimize'); 49 53 $groups['index'] = __('Count and index'); 50 54 $groups['purge'] = __('Purge'); 51 55 $groups['other'] = __('Other'); 56 $groups['zipblog'] = __('Compressed file for current blog'); 57 $groups['zipfull'] = __('Compressed file for all blogs'); 52 58 53 59 $tasks[] = 'dcMaintenanceCache'; … … 57 63 $tasks[] = 'dcMaintenanceLogs'; 58 64 $tasks[] = 'dcMaintenanceVacuum'; 65 $tasks[] = 'dcMaintenanceZipmedia'; 66 $tasks[] = 'dcMaintenanceZiptheme'; 59 67 } 60 68 -
plugins/maintenance/_prepend.php
r1925 r1955 24 24 $__autoload['dcMaintenanceLogs'] = dirname(__FILE__).'/inc/tasks/class.dc.maintenance.logs.php'; 25 25 $__autoload['dcMaintenanceVacuum'] = dirname(__FILE__).'/inc/tasks/class.dc.maintenance.vacuum.php'; 26 $__autoload['dcMaintenanceZipmedia'] = dirname(__FILE__).'/inc/tasks/class.dc.maintenance.zipmedia.php'; 27 $__autoload['dcMaintenanceZiptheme'] = dirname(__FILE__).'/inc/tasks/class.dc.maintenance.ziptheme.php'; 26 28 27 29 $this->core->rest->addFunction('dcMaintenanceStep', array('dcMaintenanceRest', 'step')); -
plugins/maintenance/inc/class.dc.maintenance.php
r1940 r1955 27 27 private $core; 28 28 private $tasks = array(); 29 private $tabs = array(); 29 30 private $groups = array(); 30 31 … … 41 42 42 43 $tasks = new ArrayObject(); 44 $tabs = new ArrayObject(); 43 45 $groups = new ArrayObject(); 44 46 45 47 # --BEHAVIOR-- dcMaintenanceRegister 46 $core->callBehavior('dcMaintenanceRegister', $core, $tasks, $groups );47 48 $this->init($tasks, $groups );48 $core->callBehavior('dcMaintenanceRegister', $core, $tasks, $groups, $tabs); 49 50 $this->init($tasks, $groups, $tabs); 49 51 } 50 52 … … 54 56 * @param tasks <b>arrayObject</b> Array of task to register 55 57 * @param groups <b>arrayObject</b> Array of groups to add 56 */ 57 public function init($tasks, $groups) 58 * @param tabs <b>arrayObject</b> Array of tabs to add 59 */ 60 public function init($tasks, $groups, $tabs) 58 61 { 59 62 $this->tasks = $this->groups = array(); … … 79 82 $this->groups[(string) $id] = (string) $name; 80 83 } 84 85 foreach($tabs as $id => $name) 86 { 87 $this->tabs[(string) $id] = (string) $name; 88 } 89 } 90 91 /** 92 * Get a tab name. 93 * 94 * @param id <b>string</b> Tab ID 95 * @return <b>mixed</b> tab name or null if not exists 96 */ 97 public function getTab($id) 98 { 99 return array_key_exists($id, $this->tabs) ? $this->tabs[$id] : null; 100 } 101 102 /** 103 * Get tabs. 104 * 105 * @return <b>array</b> Array of tabs ID and name 106 */ 107 public function getTabs() 108 { 109 return $this->tabs; 81 110 } 82 111 -
plugins/maintenance/inc/class.dc.maintenance.task.php
r1940 r1955 28 28 protected $id; 29 29 protected $name; 30 protected $tab = 'maintenance'; 30 31 protected $group = 'other'; 31 32 … … 115 116 116 117 /** 118 * Get task tab. 119 * 120 * @return <b>mixed</b> Task tab ID or null 121 */ 122 public function tab() 123 { 124 return $this->tab; 125 } 126 127 /** 117 128 * Get task group. 118 129 * … … 211 222 return null; 212 223 } 224 225 /** 226 * Log task execution. 227 * 228 * Sometimes we need to log task execution 229 * direct from task itself. 230 * 231 */ 232 protected function log() 233 { 234 $maintenance = new dcMaintenance($this->core); 235 $maintenance->setLog($this->id); 236 } 213 237 } -
plugins/maintenance/index.php
r1940 r1955 70 70 dcPage::jsPageTabs($tab); 71 71 72 if ( $task) {72 if (0){//$task) { 73 73 echo 74 74 '<script type="text/javascript">'."\n". … … 137 137 // Simple task (with only a button to start it) 138 138 139 echo 140 '<div id="maintenance" class="multi-part" title="'.__('Maintenance').'">'. 141 '<h3>'.__('Maintenance').'</h3>'. 142 '<form action="'.$p_url.'" method="post">'; 143 144 foreach($maintenance->getGroups($core) as $g_id => $g_name) 139 foreach($maintenance->getTabs() as $tab_id => $tab_name) 145 140 { 146 $res = '';147 foreach($maintenance->get Tasks($core) as $t)141 $res_group = ''; 142 foreach($maintenance->getGroups($core) as $group_id => $group_name) 148 143 { 149 if ($t->group() != $g_id) { 150 continue; 144 $res_task = ''; 145 foreach($maintenance->getTasks($core) as $t) 146 { 147 if ($t->group() != $group_id || $t->tab() != $tab_id) { 148 continue; 149 } 150 151 $res_task .= 152 '<p>'.form::radio(array('task', $t->id()), $t->id()).' '. 153 '<label class="classic" for="'.$t->id().'">'. 154 html::escapeHTML($t->task()).'</label>'; 155 156 if (array_key_exists($t->id(), $expired)) { 157 $res_task .= 158 ' <span class="clear form-note warn">'.sprintf( 159 __('Last execution of this task was on %s. You should execute it again.'), 160 dt::dt2str(__('%Y-%m-%d %H:%M'), $expired[$t->id()]) 161 ).'</span>'; 162 } 163 164 $res_task .= '</p>'; 151 165 } 152 166 153 $res .= 154 '<p>'.form::radio(array('task', $t->id()), $t->id()).' '. 155 '<label class="classic" for="'.$t->id().'">'. 156 html::escapeHTML($t->task()).'</label>'; 157 158 if (array_key_exists($t->id(), $expired)) { 159 $res .= 160 ' <span class="clear form-note warn">'.sprintf( 161 __('Last execution of this task was on %s. You should execute it again.'), 162 dt::dt2str(__('%Y-%m-%d %H:%M'), $expired[$t->id()]) 163 ).'</span>'; 167 if (!empty($res_task)) { 168 $res_group .= 169 '<div class="fieldset">'. 170 '<h4 id="'.$group_id.'">'.$group_name.'</h4>'. 171 $res_task. 172 '</div>'; 164 173 } 165 166 $res .= '</p>'; 167 }168 169 if (!empty($res)) {170 echo '<div class="fieldset"><h4 id="'.$g_id.'">'.$g_name.'</h4>'.$res.'</div>';171 }172 }173 174 echo175 '<p><input type="submit" value="'.__('Execute task').'" />'.176 form::hidden(array('tab'), 'maintenance').177 $core->formNonce().'</p>'.178 '<p class="form-note info">'.__('This may take a very long time').'.</p>'.179 '</form>'.180 '</div>';174 } 175 176 if (!empty($res_group)) { 177 echo 178 '<div id="'.$tab_id.'" class="multi-part" title="'.$tab_name.'">'. 179 '<h3>'.$tab_name.'</h3>'. 180 '<form action="'.$p_url.'" method="post">'. 181 $res_group. 182 '<p><input type="submit" value="'.__('Execute task').'" /> '. 183 form::hidden(array('tab'), $tab_id). 184 $core->formNonce().'</p>'. 185 '<p class="form-note info">'.__('This may take a very long time').'.</p>'. 186 '</form>'. 187 '</div>'; 188 } 189 } 181 190 182 191 // Advanced tasks (that required a tab)
Note: See TracChangeset
for help on using the changeset viewer.