squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

help.php
Go to the documentation of this file.
1 <?php
2 
15 define('PAGE_NAME', 'help');
16 
21 define('SM_PATH','../');
22 
23 /* SquirrelMail required files. */
24 require_once(SM_PATH . 'include/validate.php');
25 require_once(SM_PATH . 'functions/global.php');
26 require_once(SM_PATH . 'functions/display_messages.php');
27 
28 displayPageHeader($color, 'None' );
29 
30 $helpdir[0] = 'basic.hlp';
31 $helpdir[1] = 'main_folder.hlp';
32 $helpdir[2] = 'read_mail.hlp';
33 $helpdir[3] = 'compose.hlp';
34 $helpdir[4] = 'addresses.hlp';
35 $helpdir[5] = 'folders.hlp';
36 $helpdir[6] = 'options.hlp';
37 $helpdir[7] = 'search.hlp';
38 $helpdir[8] = 'FAQ.hlp';
39 
40 /****************[ HELP FUNCTIONS ]********************/
41 
48 function get_info($doc, $pos) {
49  $ary = array(0,0,0);
50 
51  $cntdoc = count($doc);
52 
53  for ($n=$pos; $n < $cntdoc; $n++) {
54  if (trim(strtolower($doc[$n])) == '<chapter>'
55  || trim(strtolower($doc[$n])) == '<section>') {
56  for ($n++; $n < $cntdoc
57  && (trim(strtolower($doc[$n])) != '</section>')
58  && (trim(strtolower($doc[$n])) != '</chapter>'); $n++) {
59  if (trim(strtolower($doc[$n])) == '<title>') {
60  $n++;
61  $ary[0] = trim($doc[$n]);
62  }
63  if (trim(strtolower($doc[$n])) == '<description>') {
64  $ary[1] = '';
65  for ($n++;$n < $cntdoc
66  && (trim(strtolower($doc[$n])) != '</description>');
67  $n++) {
68  $ary[1] .= $doc[$n];
69  }
70  }
71  if (trim(strtolower($doc[$n])) == '<summary>') {
72  $ary[2] = '';
73  for ($n++; $n < $cntdoc
74  && (trim(strtolower($doc[$n])) != '</summary>');
75  $n++) {
76  $ary[2] .= $doc[$n];
77  }
78  }
79  }
80  if (isset($ary)) {
81  $ary[3] = $n;
82  } else {
83  $ary[0] = _("ERROR: Help files are not in the right format!");
84  $ary[1] = $ary[0];
85  $ary[2] = $ary[0];
86  }
87  return( $ary );
88  } else if (!trim(strtolower($doc[$n]))) {
89  $ary[0] = '';
90  $ary[1] = '';
91  $ary[2] = '';
92  $ary[3] = $n;
93  }
94  }
95  $ary[0] = _("ERROR: Help files are not in the right format!");
96  $ary[1] = $ary[0];
97  $ary[2] = $ary[0];
98  $ary[3] = $n;
99  return( $ary );
100 }
101 
102 /**************[ END HELP FUNCTIONS ]******************/
103 
104 echo html_tag( 'table',
105  html_tag( 'tr',
106  html_tag( 'td','<div style="text-align: center;"><b>' . _("Help") .'</b></div>', 'center', $color[0] )
107  ) ,
108  'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
109 
110 do_hook('help_top');
111 
112 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
113  html_tag( 'tr' ) .
114  html_tag( 'td' );
115 
116 if (!isset($squirrelmail_language)) {
117  $squirrelmail_language = 'en_US';
118 }
119 
120 if (file_exists("../help/$squirrelmail_language")) {
121  $user_language = $squirrelmail_language;
122 } else if (file_exists('../help/en_US')) {
123  error_box(_("Help is not available in the selected language. It will be displayed in English instead."), $color);
124  echo '<br />';
125  $user_language = 'en_US';
126 } else {
127  error_box( _("Help is not available. Please contact your system administrator for assistance."), $color );
128  echo '</td></tr></table>';
129  exit;
130 }
131 
132 
133 /* take the chapternumber from the GET-vars,
134  * else see if we can get a relevant chapter from the referer */
136 
137 if ( sqgetGlobalVar('chapter', $temp, SQ_GET) ) {
138  $chapter = (int) $temp;
139 } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER) ) {
140  $ref = strtolower($temp);
141 
142  $contexts = array ( 'src/compose' => 4, 'src/addr' => 5,
143  'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2,
144  'src/read_body' => 3, 'src/search' => 8 );
145 
146  foreach($contexts as $path => $chap) {
147  if(strpos($ref, $path)) {
148  $chapter = $chap;
149  break;
150  }
151  }
152 }
153 
154 if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) {
155  // Initialise the needed variables.
156  $toc = array();
157 
158  // Get the chapter numbers, title and decriptions.
159  for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++) {
160  if (file_exists("../help/$user_language/$helpdir[$i]")) {
161  // First try the selected language.
162  $doc = file("../help/$user_language/$helpdir[$i]");
163  $help_info = get_info($doc, 0);
164  $toc[] = array($i+1, $help_info[0], $help_info[2]);
165  } elseif (file_exists("../help/en_US/$helpdir[$i]")) {
166  // If the selected language can't be found, try English.
167  $doc = file("../help/en_US/$helpdir[$i]");
168  $help_info = get_info($doc, 0);
169  $toc[] = array($i+1, $help_info[0],
170  _("This chapter is not available in the selected language. It will be displayed in English instead.") .
171  '<br />' . $help_info[2]);
172  } else {
173  // If English can't be found, the chapter went MIA.
174  $toc[] = array($i+1, _("This chapter is missing"),
175  sprintf(_("For some reason, chapter %s is not available."), $i+1));
176  }
177  }
178 
179  // Write the TOC header
180  echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) .
181  html_tag( 'tr' ) .
182  html_tag( 'td' ) .
183  '<div style="text-align: center;"><b>' . _("Table of Contents") . '</b></div><br />';
184  echo html_tag( 'ol' );
185 
186  // Write the TOC chapters.
187  // FIXME: HTML code is not compliant.
188  for ($i=0, $cnt = count($toc); $i < $cnt; $i++) {
189  echo '<li><a href="../src/help.php?chapter=' . $toc[$i][0]. '">' .
190  $toc[$i][1] . '</a>' . html_tag( 'ul', $toc[$i][2] );
191  }
192 
193  // Provide hook for external help scripts.
194  do_hook('help_chapter');
195 
196  // Write the TOC footer.
197  echo '</ol></td></tr></table>';
198 } else {
199  // Initialise the needed variables.
200  $display_chapter = TRUE;
201 
202  // Get the chapter.
203  if (file_exists("../help/$user_language/" . $helpdir[$chapter-1])) {
204  // First try the selected language.
205  $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
206  } elseif (file_exists("../help/en_US/" . $helpdir[$chapter-1])) {
207  // If the selected language can't be found, try English.
208  $doc = file("../help/en_US/" . $helpdir[$chapter-1]);
209  error_box(_("This chapter is not available in the selected language. It will be displayed in English instead."), $color);
210  echo '<br />';
211  } else {
212  // If English can't be found, the chapter went MIA.
213  $display_chapter = FALSE;
214  }
215 
216  // Write the chpater header.
217  echo '<div style="text-align: center;"><small>';
218  if ($chapter <= 1){
219  echo '<font color="' . $color[9] . '">' . _("Previous")
220  . '</font> | ';
221  } else {
222  echo '<a href="../src/help.php?chapter=' . ($chapter-1)
223  . '">' . _("Previous") . '</a> | ';
224  }
225  echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
226  if ($chapter >= count($helpdir)){
227  echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
228  } else {
229  echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
230  . '">' . _("Next") . '</a>';
231  }
232  echo '</small></div><br />';
233 
234  // Write the chapter.
235  if ($display_chapter) {
236  // If there is a valid chapter, display it.
237  $help_info = get_info($doc, 0);
238  echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
239  . '</b></font><br /><br />';
240 
241  if (isset($help_info[1]) && $help_info[1]) {
242  echo $help_info[1];
243  } else {
244  echo html_tag( 'p', $help_info[2], 'left' );
245  }
246 
247  $section = 0;
248  for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++) {
249  $section++;
250  $help_info = get_info($doc, $n);
251  echo "<b>$chapter.$section - $help_info[0]</b>" .
252  $help_info[1];
253  $n = $help_info[3];
254  }
255 
256  echo '<br /><div style="text-align: center;"><a href="#pagetop">' . _("Top") . '</a></div>';
257  } else {
258  // If the help file went MIA, display an error message.
259  error_box(sprintf(_("For some reason, chapter %s is not available."), $chapter), $color);
260  }
261 }
262 
263 do_hook('help_bottom');
264 
265 echo html_tag( 'tr',
266  html_tag( 'td', '&nbsp;', 'left', $color[0] )
267  );
268 
269 ?>
270 </table></body></html>
elseif
if(! sqgetGlobalVar('sound', $sound, SQ_GET)) elseif($sound=='(none)')
Definition: testsound.php:25
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$chapter
$chapter
Definition: help.php:135
$cnt
$cnt
Definition: options_identities.php:86
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
sprintf
powered by Systran sprintf(_("Number of supported language pairs: %s"), '36').' '
Definition: options.php:107
get_info
get_info($doc, $pos)
Definition: help.php:48
html
Definition: html.class.php:18
do_hook
do_hook($name)
Definition: plugin.php:42
SM_PATH
const SM_PATH
Definition: help.php:21
$helpdir
$helpdir[0]
Definition: help.php:30
SQ_GET
const SQ_GET
Definition: global.php:16
SQ_SERVER
const SQ_SERVER
Definition: global.php:20
exit
exit
Definition: help.php:128
_
_($str)
Definition: gettext.php:160
$color
$color
Definition: load_prefs.php:28
$squirrelmail_language
global $squirrelmail_language
Definition: i18n.php:774
error_box
error_box($string, $color)
Definition: display_messages.php:116