| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * help.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * Displays help for the user |
| 10 | * |
| 11 | * @version $Id$ |
| 12 | * @package squirrelmail |
| 13 | */ |
| 14 | |
| 15 | /** |
| 16 | * Path for SquirrelMail required files. |
| 17 | * @ignore |
| 18 | */ |
| 19 | define('SM_PATH','../'); |
| 20 | |
| 21 | /* SquirrelMail required files. */ |
| 22 | require_once(SM_PATH . 'include/validate.php'); |
| 23 | require_once(SM_PATH . 'functions/global.php'); |
| 24 | require_once(SM_PATH . 'functions/display_messages.php'); |
| 25 | |
| 26 | displayPageHeader($color, 'None' ); |
| 27 | |
| 28 | $helpdir[0] = 'basic.hlp'; |
| 29 | $helpdir[1] = 'main_folder.hlp'; |
| 30 | $helpdir[2] = 'read_mail.hlp'; |
| 31 | $helpdir[3] = 'compose.hlp'; |
| 32 | $helpdir[4] = 'addresses.hlp'; |
| 33 | $helpdir[5] = 'folders.hlp'; |
| 34 | $helpdir[6] = 'options.hlp'; |
| 35 | $helpdir[7] = 'search.hlp'; |
| 36 | $helpdir[8] = 'FAQ.hlp'; |
| 37 | |
| 38 | /****************[ HELP FUNCTIONS ]********************/ |
| 39 | |
| 40 | /** |
| 41 | * parses through and gets the information from the different documents. |
| 42 | * this returns one section at a time. You must keep track of the position |
| 43 | * so that it knows where to start to look for the next section. |
| 44 | */ |
| 45 | |
| 46 | function get_info($doc, $pos) { |
| 47 | $ary = array(0,0,0); |
| 48 | |
| 49 | $cntdoc = count($doc); |
| 50 | |
| 51 | for ($n=$pos; $n < $cntdoc; $n++) { |
| 52 | if (trim(strtolower($doc[$n])) == '<chapter>' |
| 53 | || trim(strtolower($doc[$n])) == '<section>') { |
| 54 | for ($n++; $n < $cntdoc |
| 55 | && (trim(strtolower($doc[$n])) != '</section>') |
| 56 | && (trim(strtolower($doc[$n])) != '</chapter>'); $n++) { |
| 57 | if (trim(strtolower($doc[$n])) == '<title>') { |
| 58 | $n++; |
| 59 | $ary[0] = trim($doc[$n]); |
| 60 | } |
| 61 | if (trim(strtolower($doc[$n])) == '<description>') { |
| 62 | $ary[1] = ''; |
| 63 | for ($n++;$n < $cntdoc |
| 64 | && (trim(strtolower($doc[$n])) != '</description>'); |
| 65 | $n++) { |
| 66 | $ary[1] .= $doc[$n]; |
| 67 | } |
| 68 | } |
| 69 | if (trim(strtolower($doc[$n])) == '<summary>') { |
| 70 | $ary[2] = ''; |
| 71 | for ($n++; $n < $cntdoc |
| 72 | && (trim(strtolower($doc[$n])) != '</summary>'); |
| 73 | $n++) { |
| 74 | $ary[2] .= $doc[$n]; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | if (isset($ary)) { |
| 79 | $ary[3] = $n; |
| 80 | } else { |
| 81 | $ary[0] = _("ERROR: Help files are not in the right format!"); |
| 82 | $ary[1] = $ary[0]; |
| 83 | $ary[2] = $ary[0]; |
| 84 | } |
| 85 | return( $ary ); |
| 86 | } else if (!trim(strtolower($doc[$n]))) { |
| 87 | $ary[0] = ''; |
| 88 | $ary[1] = ''; |
| 89 | $ary[2] = ''; |
| 90 | $ary[3] = $n; |
| 91 | } |
| 92 | } |
| 93 | $ary[0] = _("ERROR: Help files are not in the right format!"); |
| 94 | $ary[1] = $ary[0]; |
| 95 | $ary[2] = $ary[0]; |
| 96 | $ary[3] = $n; |
| 97 | return( $ary ); |
| 98 | } |
| 99 | |
| 100 | /**************[ END HELP FUNCTIONS ]******************/ |
| 101 | |
| 102 | |
| 103 | echo html_tag( 'table', |
| 104 | html_tag( 'tr', |
| 105 | html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] ) |
| 106 | ) , |
| 107 | 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' ); |
| 108 | |
| 109 | do_hook('help_top'); |
| 110 | |
| 111 | echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) . |
| 112 | html_tag( 'tr' ) . |
| 113 | html_tag( 'td' ); |
| 114 | |
| 115 | if (!isset($squirrelmail_language)) { |
| 116 | $squirrelmail_language = 'en_US'; |
| 117 | } |
| 118 | |
| 119 | if (file_exists("../help/$squirrelmail_language")) { |
| 120 | $user_language = $squirrelmail_language; |
| 121 | } else if (file_exists('../help/en_US')) { |
| 122 | echo "<center><font color=\"$color[2]\">"; |
| 123 | printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']); |
| 124 | echo '</font></center><br />'; |
| 125 | $user_language = 'en_US'; |
| 126 | } else { |
| 127 | error_box( _("Some or all of the help documents are not present!"), $color ); |
| 128 | exit; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | /* take the chapternumber from the GET-vars, |
| 133 | * else see if we can get a relevant chapter from the referer */ |
| 134 | $chapter = 0; |
| 135 | |
| 136 | if ( sqgetGlobalVar('chapter', $temp, SQ_GET) ) { |
| 137 | $chapter = (int) $temp; |
| 138 | } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER) ) { |
| 139 | $ref = strtolower($temp); |
| 140 | |
| 141 | $contexts = array ( 'src/compose' => 4, 'src/addr' => 5, |
| 142 | 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2, |
| 143 | 'src/read_body' => 3, 'src/search' => 8 ); |
| 144 | |
| 145 | foreach($contexts as $path => $chap) { |
| 146 | if(strpos($ref, $path)) { |
| 147 | $chapter = $chap; |
| 148 | break; |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) { |
| 154 | echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) . |
| 155 | html_tag( 'tr' ) . |
| 156 | html_tag( 'td' ) . |
| 157 | '<center><b>' . _("Table of Contents") . '</b></center><br />'; |
| 158 | echo html_tag( 'ol' ); |
| 159 | for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++) { |
| 160 | $doc = file("../help/$user_language/$helpdir[$i]"); |
| 161 | $help_info = get_info($doc, 0); |
| 162 | echo '<li><a href="../src/help.php?chapter=' . ($i+1) |
| 163 | . '">' . $help_info[0] . '</a>' . |
| 164 | html_tag( 'ul', $help_info[2] ); |
| 165 | } |
| 166 | do_hook('help_chapter'); |
| 167 | echo '</ol></td></tr></table>'; |
| 168 | } else { |
| 169 | $doc = file("../help/$user_language/" . $helpdir[$chapter-1]); |
| 170 | $help_info = get_info($doc, 0); |
| 171 | echo '<center><small>'; |
| 172 | if ($chapter <= 1){ |
| 173 | echo '<font color="' . $color[9] . '">' . _("Previous") |
| 174 | . '</font> | '; |
| 175 | } else { |
| 176 | echo '<a href="../src/help.php?chapter=' . ($chapter-1) |
| 177 | . '">' . _("Previous") . '</a> | '; |
| 178 | } |
| 179 | echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>'; |
| 180 | if ($chapter >= count($helpdir)){ |
| 181 | echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>'; |
| 182 | } else { |
| 183 | echo ' | <a href="../src/help.php?chapter=' . ($chapter+1) |
| 184 | . '">' . _("Next") . '</a>'; |
| 185 | } |
| 186 | echo '</small></center><br />'; |
| 187 | |
| 188 | echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0] |
| 189 | . '</b></font><br /><br />'; |
| 190 | |
| 191 | if (isset($help_info[1]) && $help_info[1]) { |
| 192 | echo $help_info[1]; |
| 193 | } else { |
| 194 | echo html_tag( 'p', $help_info[2], 'left' ); |
| 195 | } |
| 196 | |
| 197 | $section = 0; |
| 198 | for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++) { |
| 199 | $section++; |
| 200 | $help_info = get_info($doc, $n); |
| 201 | echo "<b>$chapter.$section - $help_info[0]</b>" . |
| 202 | html_tag( 'ul', $help_info[1] ); |
| 203 | $n = $help_info[3]; |
| 204 | } |
| 205 | |
| 206 | echo '<br /><center><a href="#pagetop">' . _("Top") . '</a></center>'; |
| 207 | } |
| 208 | |
| 209 | do_hook('help_bottom'); |
| 210 | |
| 211 | echo html_tag( 'tr', |
| 212 | html_tag( 'td', ' ', 'left', $color[0] ) |
| 213 | ); |
| 214 | ?> |
| 215 | </table></body></html> |