Templates for help section
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 25 Aug 2006 21:36:14 +0000 (21:36 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 25 Aug 2006 21:36:14 +0000 (21:36 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11643 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/help.php
templates/default/help_chapter.tpl [new file with mode: 0644]
templates/default/help_toc.tpl [new file with mode: 0644]
templates/default/stylesheet.tpl

index 2c0798c7d9cd671e8d5912ef17698e5b1b5adc42..8490961a0611a6b79361e7bb66763cefee336bce 100644 (file)
@@ -92,18 +92,8 @@ function get_info($doc, $pos) {
 
 /**************[ END HELP FUNCTIONS ]******************/
 
-echo html_tag( 'table',
-        html_tag( 'tr',
-            html_tag( 'td','<div style="text-align: center;"><b>' . _("Help") .'</b></div>', 'center', $color[0] )
-        ) ,
-    'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
-
 do_hook('help_top');
 
-echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
-        html_tag( 'tr' ) .
-            html_tag( 'td' );
-
 if (!isset($squirrelmail_language)) {
     $squirrelmail_language = 'en_US';
 }
@@ -169,25 +159,21 @@ if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) {
         }
     }
 
-    // Write the TOC header
-    echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) .
-         html_tag( 'tr' ) .
-         html_tag( 'td' ) .
-         '<div style="text-align: center;"><b>' . _("Table of Contents") . '</b></div><br />';
-    echo html_tag( 'ol' );
-
-    // Write the TOC chapters.
-    // FIXME: HTML code is not compliant.
-    for ($i=0, $cnt = count($toc); $i < $cnt; $i++) {
-        echo '<li><a href="../src/help.php?chapter=' . $toc[$i][0]. '">' .
-            $toc[$i][1] . '</a>' . html_tag( 'ul', $toc[$i][2] );
-    }
-
     // Provide hook for external help scripts.
     do_hook('help_chapter');
-
-    // Write the TOC footer.
-    echo '</ol></td></tr></table>';
+    $new_toc = array();
+    foreach ($toc as $ch) {
+        $a = array();
+        $a['Chapter'] = $ch[0];
+        $a['Title'] = $ch[1];
+        $a['Summary'] = trim($ch[2]);
+        $new_toc[] = $a;
+    }
+    
+    $oTemplate->assign('toc', $new_toc);
+    
+    $oTemplate->display('help_toc.tpl');
 } else {
     // Initialise the needed variables.
     $display_chapter = TRUE;
@@ -206,61 +192,49 @@ if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) {
         $display_chapter = FALSE;
     }
 
-    // Write the chpater header.
-    echo '<div style="text-align: center;"><small>';
-    if ($chapter <= 1){
-        echo '<font color="' . $color[9] . '">' . _("Previous")
-             . '</font> | ';
-    } else {
-        echo '<a href="../src/help.php?chapter=' . ($chapter-1)
-             . '">' . _("Previous") . '</a> | ';
-    }
-    echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
-    if ($chapter >= count($helpdir)){
-        echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
-    } else {
-        echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
-             . '">' . _("Next") . '</a>';
-    }
-    echo '</small></div><br />';
-
     // Write the chapter.
     if ($display_chapter) {
         // If there is a valid chapter, display it.
         $help_info = get_info($doc, 0);
-        echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
-            . '</b></font><br /><br />';
-
-        if (isset($help_info[1]) && $help_info[1]) {
-            echo $help_info[1];
-        } else {
-            echo html_tag( 'p', $help_info[2], 'left' );
-        }
-
+        $ch = array();
+        $ch['Chapter'] = $chapter;
+        $ch['Title'] = $help_info[0];
+        $ch['Summary'] = isset($help_info[1]) && $help_info[1] ? trim($help_info[1]) : $help_info[2];
+        $ch['Sections'] = array();
         $section = 0;
         for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++) {
             $section++;
             $help_info = get_info($doc, $n);
-            echo "<b>$chapter.$section - $help_info[0]</b>" .
-                $help_info[1];
             $n = $help_info[3];
-        }
 
-        echo '<br /><div style="text-align: center;"><a href="#pagetop">' . _("Top") . '</a></div>';
+            $a = array();
+            $a['SectionNumber'] = $section;
+            $a['SectionTitle'] = $help_info[0];
+            $a['SectionText'] = isset($help_info[1]) ? trim($help_info[1]) : '';;
+            
+            $ch['Sections'][] = $a;
+        }
+        
+        $oTemplate->assign('chapter_number', $chapter);
+        $oTemplate->assign('chapter_count', count($helpdir));
+        $oTemplate->assign('chapter_title', $ch['Title']);
+        $oTemplate->assign('chapter_summary', $ch['Summary']);
+        $oTemplate->assign('sections', $ch['Sections']);
+        $oTemplate->assign('error_msg', NULL);
     } else {
-        // If the help file went MIA, display an error message.
-        error_box(sprintf(_("For some reason, chapter %s is not available."), $chapter));
+        // If the help file went MIA, trigger an error message.
+        $oTemplate->assign('chapter_number', $chapter);
+        $oTemplate->assign('chapter_count', count($helpdir));
+        $oTemplate->assign('chapter_title', '');
+        $oTemplate->assign('chapter_summary', '');
+        $oTemplate->assign('sections', array());
+        $oTemplate->assign('error_msg', sprintf(_("For some reason, chapter %s is not available."), $chapter));
     }
+    
+    $oTemplate->display('help_chapter.tpl');
 }
 
 do_hook('help_bottom');
 
-echo html_tag( 'tr',
-            html_tag( 'td', '&nbsp;', 'left', $color[0] )
-        );
-
-?>
-</table>
-<?php
 $oTemplate->display('footer.tpl');
 ?>
\ No newline at end of file
diff --git a/templates/default/help_chapter.tpl b/templates/default/help_chapter.tpl
new file mode 100644 (file)
index 0000000..9336651
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+/**
+ * help_chapter.tpl
+ *
+ * Template to display help chapter
+ * 
+ * The following variables are available in this template:
+ *      $chapter_number     - current chapter number.  Empty on error.
+ *      $chapter_count      - total number of chapters in the help.  Empty on error.
+ *      $chapter_title      - title of this chapter.  Empty on error.
+ *      $chapter_summary    - summary of this chapter.  Empty on error.
+ *      $error_msg          - Error message if an error is generated.  NULL if
+ *                            no error is thrown.
+ *      $sections           - array containing all secionts of this chapter.  Each
+ *                            element contains the following fields:
+ *          $el['SectionNumber']    - the number of each section
+ *          $el['SectionTitle']     - the title of this section
+ *          $el['SectionText']      - the text for this section
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage templates
+ */
+
+/** add required includes **/
+
+/** extract template variables **/
+extract($t);
+
+/** Begin template **/
+?>
+<div id="help">
+<a name="pagetop"></a>
+<table cellspacing="0" class="table1">
+ <tr>
+  <td class="header1">
+   <?php echo _("Help"); ?>
+  </td>
+ </tr>
+ <tr>
+  <td class="nav">
+   <small>
+   <?php
+    if ($chapter_number == 1) {
+        echo _("Previous");
+    } else {
+        ?>
+   <a href="../src/help.php?chapter=<?php echo $chapter_number - 1; ?>"><?php echo _("Previous"); ?></a>
+        <?php
+    }
+   ?>
+   |
+   <a href="../src/help.php"><?php echo _("Table of Contents"); ?></a>
+   |
+   <?php
+    if ($chapter_number < $chapter_count) {
+        ?>
+   <a href="../src/help.php?chapter=<?php echo $chapter_number + 1; ?>"><?php echo _("Next"); ?></a>
+        <?php
+    } else {
+        echo _("Next");
+    }
+   ?>
+   </small>
+  </td>
+ </tr>
+ <tr>
+  <td class="help">
+   <?php
+    if (!is_null($error_msg)) {
+        error_box($error_msg);
+    } else {
+        ?>
+   <h1>
+    <?php echo $chapter_number; ?> - <?php echo $chapter_title; ?>
+   </h1>
+   <h2>
+    <?php echo $chapter_summary; ?>
+   </h2>
+   <?php
+        foreach ($sections as $section) {
+            ?>
+   <h3>
+    <?php echo $chapter_number; ?>.<?php echo $section['SectionNumber']; ?> - <?php echo $section['SectionTitle']; ?>
+   </h3>
+   <?php echo $section['SectionText']; ?>
+            <?php
+        }
+    }
+   ?>
+  </td>
+ </tr>
+ <tr>
+  <td class="nav">
+   <small><a href="#pagetop"><?php echo _("Top"); ?></a></small>
+  </td>
+ </tr>
+</table>
+</dib>
\ No newline at end of file
diff --git a/templates/default/help_toc.tpl b/templates/default/help_toc.tpl
new file mode 100644 (file)
index 0000000..5db2be8
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * help_toc.tpl
+ *
+ * Help Table of Contents template
+ * 
+ * The following variables are available in this template:
+ *      $toc        - array containing table of contents.  Each element is an
+ *                    array representing a chapter with the following fields:
+ *          $el['Chapter']  - integer chapter Number
+ *          $el['Title']    - string title of the chapter
+ *          $el['Summary']  - string description of the chapter
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage templates
+ */
+
+/** add required includes **/
+
+/** extract template variables **/
+extract($t);
+
+/** Begin template **/
+?>
+<div id="help">
+<table cellspacing="0" class="table1">
+ <tr>
+  <td class="header1">
+   <?php echo _("Help"); ?>
+  </td>
+ </tr>
+ <tr>
+  <td class="header3">
+   <?php echo _("Table of Contents"); ?>
+  </td>
+ </tr>
+ <tr>
+  <td class="help">
+   <ol>
+    <?php
+        foreach ($toc as $chapter) {
+            ?>
+    <li>
+     <a href="../src/help.php?chapter=<?php echo $chapter['Chapter']; ?>"><?php echo $chapter['Title']; ?></a>
+     <ul><?php echo $chapter['Summary']; ?></ul>
+    </li>
+            <?php
+        } 
+    ?>
+   </ol>
+  </td>
+ </tr>
+</table>
+</div>
\ No newline at end of file
index e54e8ac3adaeb7dc35c45de6e35c70dee1f0b94d..4abb858738d7f196d4d1846f8435251e52a35b4d 100644 (file)
@@ -157,6 +157,13 @@ td.header2  {
     padding-bottom: 4px;
 }
 
+td.header3  {
+    text-align: center;
+    font-weight: bold;
+    padding-top: 4px;
+    padding-bottom: 4px;
+}
+
 tr.even {
     background: <?php echo $color[12]; ?>;
 }
@@ -632,3 +639,59 @@ tr.odd  {
     margin-left: auto;
     margin-right: auto;
 }
+
+/* help defs */
+#help   {
+    text-align: center;
+}
+
+#help   td.help  {
+    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
+}
+
+#help   li  {
+    padding-left: 0px;
+}
+
+#help   ul  {
+    padding-left: 20px;
+    padding-right: 75px;
+}
+
+#help   td.nav  {
+    text-align: center;
+    color: <?php echo $color[0]; ?>;
+    padding-top: 15px;
+    padding-bottom: 5px;
+}
+
+#help   h1  {
+    font-size: 14pt;
+    font-weight: bold;
+    margin-top: 2px;
+    margin-bottom: 0px;
+}
+
+#help   h2  {
+    font-size: 10pt;
+    font-weight: normal;
+    margin-bottom: 2px;
+    margin-top: 0;
+}
+
+#help   h3  {
+    font-weight: bold;
+    font-size: 10pt;
+    margin: 0;
+    padding: 0;
+}
+
+#help   td.help p   {
+    margin-top: 2px;
+    margin-bottom: 10px;
+}
+
+#help   td.help  li   {
+    margin-left: 10px;
+}
+