[dev] [patch] maintenance interface rework
Vilius Šumskas
vilius at lnk.lt
Wed Nov 3 06:59:51 PST 2004
Hello again,
I didn't liked maintenance confirmation screen before so I decided to improve it
a bit. So here it is. In a process I simplified some code. It think it is
possible to write it even more cleaner but I missed switch tag in horde
templates. File maintenance.html attached must be put into
/horde/templates/maintenance/, all other templates in this directory isn't used
anymore. Tell me if you'd like it.
--
Best Regards,
Vilius Šumskas
LNK TV system administrator
mob.: +370 614 75713
http://www.lnk.lt
-------------- next part --------------
Index: services/maintenance.php
===================================================================
RCS file: /repository/horde/services/maintenance.php,v
retrieving revision 1.30
diff -u -r1.30 maintenance.php
--- services/maintenance.php 21 Oct 2004 19:11:35 -0000 1.30
+++ services/maintenance.php 3 Nov 2004 14:43:14 -0000
@@ -13,6 +13,8 @@
@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Maintenance.php';
+require_once 'Horde/Template.php';
+$template = &new Horde_Template();
/* Make sure there is a user logged in. */
if (!Auth::getAuth()) {
@@ -29,52 +31,60 @@
Horde::fatal(PEAR::raiseError(_("The Maintenance:: class did not load successfully")), __FILE__, __LINE__);
}
-/* Have the maintenance module do all necessary processing. */
-list($action, $tasks) = $maint->runMaintenancePage();
+/* Cache this call. */
+$module = $registry->get('name', $module);
-/* Print top elements of confirmation page. */
-require HORDE_TEMPLATES . '/common-header.inc';
-require HORDE_TEMPLATES . '/maintenance/maintenance_top.inc';
+/* Have the maintenance module do all necessary processing. */
+list($action, $tasklist) = $maint->runMaintenancePage();
+$action = MAINTENANCE_OUTPUT_NOTICE;
if ($action == MAINTENANCE_OUTPUT_CONFIRM) {
/* Confirmation-style output. */
- require HORDE_TEMPLATES . '/maintenance/confirm_top.inc';
-
- if ($browser->hasFeature('javascript')) {
- require HORDE_TEMPLATES . '/maintenance/javascript.inc';
- }
-
- /* $pref, $descrip, & $checked need to be set for the templates. */
- foreach ($tasks as $pref) {
- list($descrip, $checked) = $maint->infoMaintenance($pref);
- require HORDE_TEMPLATES . '/maintenance/confirm_middle.inc';
- }
+ $template->set('confirm', true, true);
+ $template->set('agree', false, true);
+ $template->set('notice', false, true);
+
+ $template->set('javascript', $browser->hasFeature('javascript'), true);
+
+ $notification->push(sprintf(_("%s is ready to perform the maintenance operations checked below. Check the box for any operation(s) you want to perform at this time."), $module), 'horde.message');
+ $template->set('header', sprintf(_("%s Maintenance Operations - Confirmation"), $module));
- require HORDE_TEMPLATES . '/maintenance/confirm_bottom.inc';
} elseif ($action == MAINTENANCE_OUTPUT_AGREE) {
/* Agreement-style output. */
- require HORDE_TEMPLATES . '/maintenance/agreement_top.inc';
+ $template->set('confirm', false, true);
+ $template->set('agree', true, true);
+ $template->set('notice', false, true);
+
+ $notification->push(_("Please read the following text. You MUST agree with the terms to use the system."), 'horde.message');
+ $template->set('header', sprintf(_("%s Terms of Agreement"), $module));
- /* $pref & $descrip need to be set for the templates. */
- foreach ($tasks as $pref) {
- list($descrip, $checked) = $maint->infoMaintenance($pref);
- require HORDE_TEMPLATES . '/maintenance/agreement_middle.inc';
- }
-
- require HORDE_TEMPLATES . '/maintenance/agreement_bottom.inc';
} elseif ($action == MAINTENANCE_OUTPUT_NOTICE) {
/* Notice-style output */
- require HORDE_TEMPLATES . '/maintenance/notice_top.inc';
+ $template->set('confirm', false, true);
+ $template->set('agree', false, true);
+ $template->set('notice', true, true);
- /* $pref & $descrip need to be set for the templates. */
- foreach ($tasks as $pref) {
- list($descrip, $checked) = $maint->infoMaintenance($pref);
- require HORDE_TEMPLATES . '/maintenance/notice_middle.inc';
- }
+ $template->set('header', sprintf(_("%s - Notice"), $module));
+}
- require HORDE_TEMPLATES . '/maintenance/notice_bottom.inc';
+/* Make variable array needed for templates. */
+$tasks = array();
+foreach ($tasklist as $pref) {
+ list($descrip, $checked) = $maint->infoMaintenance($pref);
+ $tasks[] = array(
+ 'pref' => $pref,
+ 'descrip' => $descrip,
+ 'checked' => $checked ? ' checked="checked"' : '',
+ );
}
-/* Print bottom elements of maintenance page. */
-require HORDE_TEMPLATES . '/maintenance/maintenance_bottom.inc';
+$template->setOption('gettext', true);
+$template->set('tasks', $tasks);
+$template->set('maint_url', $maint->getMaintenanceFormURL());
+$template->set('maint_postdata', $maint->getPostData());
+$template->set('notify', Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')));
+
+require HORDE_TEMPLATES . '/common-header.inc';
+echo $template->fetch(HORDE_TEMPLATES . '/maintenance/maintenance.html');
require HORDE_TEMPLATES . '/common-footer.inc';
-------------- next part --------------
<div class="menu"> </div>
<br style="font-size:5px" />
<tag:notify />
<form method="post" action="<tag:maint_url />" name="maint_confirm">
<input type="hidden" name="frameset" value="" />
<tag:maint_postdata />
<if:javascript>
<script language="JavaScript" type="text/javascript">
<!--
function uncheckAll()
{
for (var i = 0; i < document.maint_confirm.elements.length; i++) {
document.maint_confirm.elements[i].checked = false;
}
}
//-->
</script>
</if:javascript>
<table border="0" align="center" width="95%" cellpadding="3" cellspacing="2">
<tr class="header">
<td class="header">
<b><tag:header /></b>
</td>
</tr>
<tr><td> </td></tr>
<loop:tasks>
<tr>
<td class="light">
<if:confirm>
<input type="checkbox" name="<tag:tasks.pref />_confirm"<tag:tasks.checked />>
 
</if:confirm>
<if:agree>
<input type="hidden" name="<tag:tasks.pref />_confirm" value="1" />
</if:agree>
<if:notice>
<input type="hidden" name="<tag:tasks.pref />_confirm" value="1" />
</if:notice>
<tag:tasks.descrip />
</td>
</tr>
</loop:tasks>
<tr>
<td> </td>
</tr>
<tr>
<td>
<if:confirm>
<input type="submit" class="button" value="<gettext>Perform Maintenance Operations</gettext>" onclick="document.maint_confirm.submit();" />
<if:javascript>
<input type="button" class="button" value="<gettext>Skip Maintenance</gettext>" onclick="uncheckAll(); document.maint_confirm.submit();" />
</if:javascript>
</if:confirm>
<if:agree>
<input type="submit" name="agree" class="button" value="<gettext>Yes, I Agree</gettext>" onclick="document.maint_confirm.submit();" />
<input type="submit" name="not_agree" class="button" value="<gettext>NO, I Do NOT Agree</gettext>" onclick="document.maint_confirm.submit();" />
</if:agree>
<if:notice>
<input type="submit" class="button" value="<gettext>Click to Continue</gettext>" onclick="document.maint_confirm.submit();" />
</if:notice>
</td>
</tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">
<!--
if (window.parent.frames.horde_menu) document.maint_confirm.frameset.value = 1;
//-->
</script>
More information about the dev
mailing list