getTask($_REQUEST['task']); if ($task === null) { $core->error->add('Unknow task ID'); } $task->code($code); } // Execute task if ($task && !empty($_POST['task']) && $task->id() == $_POST['task']) { try { $code = $task->execute(); if (false === $code) { throw new Exception($task->error()); } if (true === $code) { $maintenance->setLog($task->id()); http::redirect($p_url.'&task='.$task->id().'&done=1&tab='.$tab); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } // Get expired tasks $user_options = $core->auth->getOptions(); if (!empty($user_options['user_maintenance_expired'])) { $expired = $maintenance->getExpired(); } // Display page echo ' '.__('Maintenance').''. dcPage::jsPageTabs($tab); if (0){//$task) { echo ''. dcPage::jsLoad('index.php?pf=maintenance/js/dc.maintenance.js'); } echo $maintenance->getHeaders().' '; // Success message if ($task && !empty($_GET['done'])) { dcPage::success($task->success()); } if ($task && ($res = $task->step()) !== null) { // Page title echo dcPage::breadcrumb( array( __('Plugins') => '', ''.__('Maintenance').'' => '', ''.html::escapeHTML($task->name()).'' => '' ) ); // Intermediate task (task required several steps) echo '
'. '

'.html::escapeHTML($task->name()).'

'. '
'. '

'. $res. '

'. '

'. ' '. form::hidden(array('task'), $task->id()). form::hidden(array('code'), (integer) $code). $core->formNonce(). '

'. '
'. '

'. ''.__('Back').''. '

'. '
'; } else { // Page title echo dcPage::breadcrumb( array( __('Plugins') => '', ''.__('Maintenance').'' => '' ) ); // Simple task (with only a button to start it) foreach($maintenance->getTabs() as $tab_id => $tab_name) { $res_group = ''; foreach($maintenance->getGroups($core) as $group_id => $group_name) { $res_task = ''; foreach($maintenance->getTasks($core) as $t) { if ($t->group() != $group_id || $t->tab() != $tab_id) { continue; } $res_task .= '

'.form::radio(array('task', $t->id()), $t->id()).' '. ''; if (array_key_exists($t->id(), $expired)) { $res_task .= ' '.sprintf( __('Last execution of this task was on %s. You should execute it again.'), dt::dt2str(__('%Y-%m-%d %H:%M'), $expired[$t->id()]) ).''; } $res_task .= '

'; } if (!empty($res_task)) { $res_group .= '
'. '

'.$group_name.'

'. $res_task. '
'; } } if (!empty($res_group)) { echo '
'. '

'.$tab_name.'

'. '
'. $res_group. '

'. form::hidden(array('tab'), $tab_id). $core->formNonce().'

'. '

'.__('This may take a very long time').'.

'. '
'. '
'; } } // Advanced tasks (that required a tab) foreach($maintenance->getTasks($core) as $t) { if ($t->group() !== null) { continue; } echo '
'. '

'.$t->name().'

'. '
'. $t->content(). '

'. form::hidden(array('task'), $t->id()). form::hidden(array('tab'), $t->id()). $core->formNonce().'

'. '
'. '
'; } } dcPage::helpBlock('maintenance'); echo '';