/** * 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; } }
# # This file is part of Dotclear 2. # # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear # Licensed under the GPL version 2.0 license. # See LICENSE file or # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # # -- END LICENSE BLOCK ----------------------------------------- if (!defined('DC_CONTEXT_ADMIN')) { return; } // Set env $core->blog->settings->addNamespace('maintenance'); $maintenance = new dcMaintenance($core); $tasks = $maintenance->getTasks(); $headers = ''; $p_url = $core->adminurl->get('admin.plugin.maintenance'); $task = null; $expired = array(); $code = empty($_POST['code']) ? null : (int) $_POST['code']; $tab = empty($_REQUEST['tab']) ? '' : $_REQUEST['tab']; // Get task object if (!empty($_REQUEST['task'])) { $task = $maintenance->getTask($_REQUEST['task']); if ($task === null) { $core->error->add('Unknow task ID'); } $task->code($code); } // Execute task