[dev] Patch to ease navigation in prefs UI

Mathieu CLABAUT mathieu.clabaut at free.fr
Mon Feb 24 16:14:25 PST 2003


 Hello....

  Attach is a small patch which allow people to navigate from a
  preference group to the next or previous preference group, without
  having to click on the "return to options" button.

  It's quite luxurious for a common usage, but I find the current
  navigation tedious for a first time user, who should browse all the
  option groups to set up the application to his tastes...

  Modified files are :
   horde/lib/PrefsUI.php
   Some files and templates (from imp, news,..) associated to 'url'
   preferences.

  Hope it'll be useful.... Comments (about style, way of doing this or
  that,...) are alway welcome....

-mat

--
___________________http://www.fsf.org/philosophy/no-word-attachments.html
Mathieu CLABAUT                            mailto:mathieu.clabaut at free.fr
           F2F5 442F F2AC E1D5 9D31  3EFC 842A BC4A 123B 9A65
-------------- next part --------------
Index: imp/pgp.php
===================================================================
RCS file: /repository/imp/pgp.php,v
retrieving revision 2.53
diff -u -b -B -w -u -b -B -w -r2.53 pgp.php
--- imp/pgp.php	11 Feb 2003 20:58:12 -0000	2.53
+++ imp/pgp.php	24 Feb 2003 14:53:35 -0000
@@ -349,6 +349,8 @@
 require IMP_TEMPLATES . '/common-header.inc';
 require IMP_BASE . '/menu.php';
 require IMP_BASE . '/status.php';
+require_once HORDE_BASE . '/lib/PrefsUI.php';
+require IMP_BASE . '/config/prefs.php';
 
 /* If PGP preference not active, do NOT show PGP Admin screen. */
 if ($prefs->getValue('use_pgp')) {
Index: imp/smime.php
===================================================================
RCS file: /repository/imp/smime.php,v
retrieving revision 2.18
diff -u -b -B -w -u -b -B -w -r2.18 smime.php
--- imp/smime.php	11 Feb 2003 20:58:12 -0000	2.18
+++ imp/smime.php	24 Feb 2003 14:53:35 -0000
@@ -180,6 +180,8 @@
 require IMP_TEMPLATES . '/common-header.inc';
 require IMP_BASE . '/menu.php';
 require IMP_BASE . '/status.php';
+require_once HORDE_BASE . '/lib/PrefsUI.php';
+require IMP_BASE . '/config/prefs.php';
 
 /* If S/MIME preference not active, or openssl PHP extension not available,
    do NOT show S/MIME Admin screen. */
Index: imp/templates/pgp/notactive.inc
===================================================================
RCS file: /repository/imp/templates/pgp/notactive.inc,v
retrieving revision 1.7
diff -u -b -B -w -u -b -B -w -r1.7 notactive.inc
--- imp/templates/pgp/notactive.inc	17 Jul 2002 19:01:20 -0000	1.7
+++ imp/templates/pgp/notactive.inc	24 Feb 2003 14:53:39 -0000
@@ -4,7 +4,7 @@
 <table border="0" align="center" cellpadding="3" cellspacing="0" width="100%">
   <tr>
     <td align="left" class="header" nowrap="nowrap"><b><?php echo _("PGP NOT Active") ?></b></td>
-    <td class="header">&nbsp;</td>
+    <?php  PrefsUI::generateNavigationCell("pgp"); ?>
   </tr>
   <tr>
 <?php if ($prefs->isLocked('use_pgp')): ?>
Index: imp/templates/pgp/pgp.inc
===================================================================
RCS file: /repository/imp/templates/pgp/pgp.inc,v
retrieving revision 1.21
diff -u -b -B -w -u -b -B -w -r1.21 pgp.inc
--- imp/templates/pgp/pgp.inc	3 Jan 2003 00:01:49 -0000	1.21
+++ imp/templates/pgp/pgp.inc	24 Feb 2003 14:53:39 -0000
@@ -4,7 +4,8 @@
 
 <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
   <tr>
-    <td colspan="2" align="left" class="header" nowrap="nowrap"><b><?php echo _("PGP Options") ?></b></td>
+    <td align="left" class="header" nowrap="nowrap"><b><?php echo _("PGP Options") ?></b></td>
+    <?php  PrefsUI::generateNavigationCell("pgp"); ?>
   </tr>
 
   <tr>
Index: imp/templates/smime/notactive.inc
===================================================================
RCS file: /repository/imp/templates/smime/notactive.inc,v
retrieving revision 1.4
diff -u -b -B -w -u -b -B -w -r1.4 notactive.inc
--- imp/templates/smime/notactive.inc	23 Sep 2002 16:57:13 -0000	1.4
+++ imp/templates/smime/notactive.inc	24 Feb 2003 14:53:39 -0000
@@ -4,7 +4,7 @@
 <table border="0" align="center" cellpadding="3" cellspacing="0" width="100%">
   <tr>
     <td align="left" class="header" nowrap="nowrap"><b><?php echo _("S/MIME NOT Active") ?></b></td>
-    <td class="header">&nbsp;</td>
+    <?php  PrefsUI::generateNavigationCell("pgp"); ?>
   </tr>
   <tr>
 <?php if ($prefs->isLocked('use_smime')): ?>
Index: imp/templates/smime/smime.inc
===================================================================
RCS file: /repository/imp/templates/smime/smime.inc,v
retrieving revision 1.7
diff -u -b -B -w -u -b -B -w -r1.7 smime.inc
--- imp/templates/smime/smime.inc	21 Jan 2003 21:09:25 -0000	1.7
+++ imp/templates/smime/smime.inc	24 Feb 2003 14:53:39 -0000
@@ -3,7 +3,8 @@
 
 <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
   <tr>
-    <td colspan="2" align="left" class="header" nowrap="nowrap"><b><?php echo _("S/MIME Options") ?></b></td>
+    <td align="left" class="header" nowrap="nowrap"><b><?php echo _("S/MIME Options") ?></b></td>
+    <?php  PrefsUI::generateNavigationCell("pgp"); ?>
   </tr>
 
   <tr>
Index: jonah/channels.php
===================================================================
RCS file: /repository/jonah/channels.php,v
retrieving revision 1.21
diff -u -b -B -w -u -b -B -w -r1.21 channels.php
--- jonah/channels.php	17 Feb 2003 17:13:07 -0000	1.21
+++ jonah/channels.php	24 Feb 2003 14:53:44 -0000
@@ -187,6 +187,8 @@
 $js_onLoad = null;
 require JONAH_TEMPLATES . '/common-header.inc';
 require JONAH_BASE . '/menu.php';
+require_once HORDE_BASE . '/lib/PrefsUI.php';
+require JONAH_BASE . '/config/prefs.php';
 require JONAH_TEMPLATES . '/channels/header.inc';
 
 if (count($available)) {
Index: jonah/templates/channels/header.inc
===================================================================
RCS file: /repository/jonah/templates/channels/header.inc,v
retrieving revision 1.3
diff -u -b -B -w -u -b -B -w -r1.3 header.inc
--- jonah/templates/channels/header.inc	19 Aug 2002 21:52:55 -0000	1.3
+++ jonah/templates/channels/header.inc	24 Feb 2003 14:53:44 -0000
@@ -1,5 +1,6 @@
 <table border="0" width="100%">
 <tr>
     <td class="header"><?php echo _("Edit Channel Subscriptions") ?></td>
+    <?php  PrefsUI::generateNavigationCell("news"); ?>
 </tr>
 </table>
\ No newline at end of file
Index: lib/PrefsUI.php
===================================================================
RCS file: /repository/horde/lib/PrefsUI.php,v
retrieving revision 1.17
diff -u -b -B -w -u -b -B -w -r1.17 PrefsUI.php
--- lib/PrefsUI.php	28 Jan 2003 00:01:45 -0000	1.17
+++ lib/PrefsUI.php	24 Feb 2003 14:53:57 -0000
@@ -212,6 +213,81 @@
             $span = round(100 / count($columns));
             include $registry->getParam('templates', 'horde') . '/prefs/overview.inc';
         }
+    }
+
+    /**
+     * Generate the content of the title bar navigation cell (previous | next
+     * option group) 
+     *
+     * @public
+     * 
+     * @param          string $group        Current option group.
+     * @param optional string $attributes   The optional <td> attributes.
+     *
+     */
+    function generateNavigationCell( $group,
+                                     $attributes = 'class="header" align="right"')
+    {
+        global $prefGroups;
+
+        // search for previous and next group
+        $previous = null;
+        $next = null;
+        $last = null;
+        $first = null;
+        $found = false;
+        $finish = false;
+        foreach ($prefGroups as $pgroup => $gval) {
+            if (PrefsUI::groupIsEditable($pgroup))
+            {
+                if (!$first) {
+                    $first = $pgroup;
+                }
+                if (!$found) {
+                    if ($pgroup == $group) {
+                        $previous = $last;
+                        $found = true;
+                    }
+                } else {    
+                    if (!$finish) {
+                        $finish = true;
+                        $next = $pgroup;
+                    }
+                }
+                $last = $pgroup;
+            }
+        }
+        if (!$previous) {
+            $previous = $last;
+        }
+        if (!$next) {
+            $next = $first;
+        }
+
+
+        echo "<td $attributes>";
+        if (!empty($prefGroups[$previous]['url'])) {
+            echo Horde::link(Horde::url($prefGroups[$previous]['url']),
+                             _("Previous options"),'widget'); 
+            echo $prefGroups[$previous]['label']; 
+        } else {
+            echo Horde::link(Horde::addParameter(Horde::applicationUrl('prefs.php'), 'group=' .
+                                                 $previous), 
+                             _("Previous options"), 'widget'); 
+            echo $prefGroups[$previous]['label']; 
+        }
+        echo '</a>&nbsp;|&nbsp;';
+        if (!empty($prefGroups[$next]['url'])) {
+            echo Horde::link(Horde::url($prefGroups[$next]['url']), 
+                             _("Next options"), 'widget'); 
+            echo $prefGroups[$next]['label']; 
+        } else {
+            echo Horde::link(Horde::addParameter(Horde::applicationUrl('prefs.php'), 'group=' .
+                                                 $next), 
+                             _("Next options"), 'widget'); 
+            echo $prefGroups[$next]['label']; 
+        }
+        echo '</a></td>';
     }
 
 }

Index: templates/prefs/begin.inc
===================================================================
RCS file: /repository/horde/templates/prefs/begin.inc,v
retrieving revision 1.5
diff -u -b -B -w -u -b -B -w -r1.5 begin.inc
--- templates/prefs/begin.inc	20 Jul 2002 15:18:57 -0000	1.5
+++ templates/prefs/begin.inc	24 Feb 2003 14:54:25 -0000
@@ -4,7 +4,10 @@
 <input type="hidden" name="group" value="<?php echo $group ?>" />
 
 <table border="0" align="center" width="100%" cellspacing="0" cellpadding="0">
-<tr><td class="header" align="left"><b><?php echo $prefGroups[$group]['label'] ?></b></td></tr>
+<tr><td class="header" align="left"><b><?php echo $prefGroups[$group]['label']
+?></b></td>
+<?php PrefsUI::generateNavigationCell($group); ?>
+</tr>
 </table>
 <table border="0" align="center" width="100%" cellspacing="0" cellpadding="3">
 <tr><td class="item"><table border="0"><tr valign="top"><td class="item">


More information about the dev mailing list