Exemple #1
0
 /**
  * Build a well sorted help for tasks.
  *
  * This method is not so good if used with lot of tranlsations
  * as it grows memory usage and translations files size,
  * it is better to use help ressource files
  * but keep it for exemple of how to use behavior adminPageHelpBlock.
  * Cheers, JC
  *
  * @param	$block	<b>arrayObject</b>	Called helpblocks
  */
 public static function adminPageHelpBlock($blocks)
 {
     $found = false;
     foreach ($blocks as $block) {
         if ($block == 'maintenancetasks') {
             $found = true;
             break;
         }
     }
     if (!$found) {
         return null;
     }
     $maintenance = new dcMaintenance($GLOBALS['core']);
     $res_tab = '';
     foreach ($maintenance->getTabs() as $tab_obj) {
         $res_group = '';
         foreach ($maintenance->getGroups() as $group_obj) {
             $res_task = '';
             foreach ($maintenance->getTasks() as $t) {
                 if ($t->group() != $group_obj->id() || $t->tab() != $tab_obj->id()) {
                     continue;
                 }
                 if (($desc = $t->description()) != '') {
                     $res_task .= '<dt>' . $t->task() . '</dt>' . '<dd>' . $desc . '</dd>';
                 }
             }
             if (!empty($res_task)) {
                 $desc = $group_obj->description ? $group_obj->description : $group_obj->summary;
                 $res_group .= '<h5>' . $group_obj->name() . '</h5>' . ($desc ? '<p>' . $desc . '</p>' : '') . '<dl>' . $res_task . '</dl>';
             }
         }
         if (!empty($res_group)) {
             $desc = $tab_obj->description ? $tab_obj->description : $tab_obj->summary;
             $res_tab .= '<h4>' . $tab_obj->name() . '</h4>' . ($desc ? '<p>' . $desc . '</p>' : '') . $res_group;
         }
     }
     if (!empty($res_tab)) {
         $res = new ArrayObject();
         $res->content = $res_tab;
         $blocks[] = $res;
     }
 }
Exemple #2
0
    return null;
}
if ($task && ($res = $task->step()) !== null) {
    // Page title
    echo dcPage::breadcrumb(array(__('Plugins') => '', '<a href="' . $p_url . '">' . __('Maintenance') . '</a>' => '', html::escapeHTML($task->name()) => '')) . dcPage::notices();
    // content
    if (substr($res, 0, 1) != '<') {
        $res = sprintf('<p class="step-msg">%s</p>', $res);
    }
    // Intermediate task (task required several steps)
    echo '<div class="step-box" id="' . $task->id() . '">' . '<p class="step-back">' . '<a class="back" href="' . $p_url . '&amp;tab=' . $task->tab() . '#' . $task->tab() . '">' . __('Back') . '</a>' . '</p>' . '<h3>' . html::escapeHTML($task->name()) . '</h3>' . '<form action="' . $p_url . '" method="post">' . $res . '<p class="step-submit">' . '<input type="submit" value="' . $task->task() . '" /> ' . form::hidden(array('task'), $task->id()) . form::hidden(array('code'), (int) $code) . $core->formNonce() . '</p>' . '</form>' . '</div>';
} else {
    // Page title
    echo dcPage::breadcrumb(array(__('Plugins') => '', __('Maintenance') => '')) . dcPage::notices();
    // Simple task (with only a button to start it)
    foreach ($maintenance->getTabs() as $tab_obj) {
        $res_group = '';
        foreach ($maintenance->getGroups() as $group_obj) {
            $res_task = '';
            foreach ($tasks as $t) {
                if (!$t->id() || $t->group() != $group_obj->id() || $t->tab() != $tab_obj->id()) {
                    continue;
                }
                $res_task .= '<p>' . form::radio(array('task', $t->id()), $t->id()) . ' ' . '<label class="classic" for="' . $t->id() . '">' . html::escapeHTML($t->task()) . '</label>';
                // Expired task alert message
                $ts = $t->expired();
                if ($core->blog->settings->maintenance->plugin_message && $ts !== false) {
                    if ($ts === null) {
                        $res_task .= '<br /> <span class="warn">' . __('This task has never been executed.') . ' ' . __('You should execute it now.') . '</span>';
                    } else {
                        $res_task .= '<br /> <span class="warn">' . sprintf(__('Last execution of this task was on %s.'), dt::str($core->blog->settings->system->date_format, $ts) . ' ' . dt::str($core->blog->settings->system->time_format, $ts)) . ' ' . __('You should execute it now.') . '</span>';