Source for file html.php
Documentation is available at html.php
* Tools for HTML generation
* @author Jean-Philippe Brunon <jp75018@free.fr>
* @copyright 2007-2009 Jean-Philippe Brunon
* @license http://www.opensource.org/licenses/gpl-license.php GPL
* @version $Id: html.php 68 2009-03-28 22:57:30Z jp75018 $
* General configuration file
require_once ('conf/config.php');
* Output is language dependant
require_once ('lang/strings_' .
$GLOBALS['lang'] .
'.inc.php');
* Display HTML page header
* @param string $title Page title
* @param array $options Associative array of options :
* - 'ajax_tips' : true to use Ajax tips, else false (default)
* - 'show_menu' : true to display user menu (default), else false
* (only if user logged in)
* - 'hide_home' : true to hide home button, else false (default)
* - 'keywords' : META tag string : List of keywords
* - 'description' : META tag string : Page description
* - 'onload' : Java script to call after loading HTML page
header(sprintf("Content-type: text/html; Charset=%s", $GLOBALS['charset']));
echo
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"%s\">\n",
printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n",
printf("<meta http-equiv=\"content-language\" content=\"%s\" />\n",
if ($options['keywords'])
printf("<meta http-equiv=\"keywords\" content=\"%s\" />\n",
if ($options['description'])
printf("<meta http-equiv=\"description\" content=\"%s\" />\n",
echo
"<link rel=\"SHORTCUT ICON\" href=\"favicon.ico\" />\n";
echo
"<title>$title</title>\n";
$css =
$GLOBALS['css_default_file'];
echo
"<link href=\"css/$css\" rel=\"stylesheet\" type=\"text/css\" />\n";
echo
"<script src=\"js/tools.js\" type=\"text/javascript\"></script>\n";
if ($options['ajax_tips'])
echo
"<script src=\"js/ajax_functions.js\" type=\"text/javascript\"></script>\n";
$onload_list =
array('setBrowserWidthCookie()');
if ($options['ajax_tips'])
if ($options['show_menu'] !==
false)
{ echo
html_main_menu($options['ajax_tips'], $options['hide_home']); }
* Display HTML page footer
* @param boolean $ajax_tips true to enable Ajax tips, else false
* @param boolean $hide_home true to hide home button, else false
* @return string Buffer containing HTML menu
$buffer =
sprintf("<table class=\"menu_table%s\"><tr>",
$_SESSION['my_user_id'] ?
'_logged' :
'');
// Home button if not hidden
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\"",
$buffer .=
sprintf("<td width=\"%d\"><a href=\"home.php\"><img src=\"img/home.png\" border=\"0\" width=\"%d\" height=\"%d\"%s /></a></td>",
if ($_SESSION['my_user_id'])
// Welcome message or nickname (if logged in)
$user_text =
sprintf($GLOBALS['str_welcome_message'],
$_SESSION['user_firstname'] ?
$_SESSION['user_firstname'] :
$_SESSION['user_nickname']);
{ $user_text =
$_SESSION['user_nickname']; }
$buffer .=
sprintf("<td align=\"center\" width=\"%d\"><b>%s</b></td>",
// Calendar button (if logged in)
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\"",
str_replace('\'', '\\\'', $GLOBALS['str_my_training_booknote']));
$buffer .=
sprintf("<td width=\"%d\"><a href=\"calendar.php?uid=%d\"><img src=\"img/calendar.png\" border=\"0\" width=\"%d\" height=\"%d\"%s /></a></td>",
// Upload button (if logged in)
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\"",
str_replace('\'', '\\\'', $GLOBALS['str_upload_files']));
$buffer .=
sprintf("<td width=\"%d\"><a href=\"upload.php\"><img src=\"img/upload.png\" border=\"0\" width=\"%d\" height=\"%d\"%s /></a></td>",
// Data manager button (if logged in)
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\"",
str_replace('\'', '\\\'', $GLOBALS['str_data_manager']));
$buffer .=
sprintf("<td width=\"%d\"><a href=\"data_manager.php\"><img src=\"img/data_mgr.png\" border=\"0\" width=\"%d\" height=\"%d\"%s /></a></td>",
// User profile button (if logged in)
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\"",
str_replace('\'', '\\\'', $GLOBALS['str_my_profile_and_pref']));
$buffer .=
sprintf("<td width=\"%d\"><a href=\"user_profile.php\"><img src=\"img/profile.png\" border=\"0\" width=\"%d\" height=\"%d\"%s /></a></td>",
// Fill remaining horizontal space
// Language select / flag (only if > 1 language available)
$lang_tab =
explode(',', $GLOBALS['all_lang']);
if (count($lang_tab) >
1)
for ($i =
0; $i <
count($lang_tab); $i++
)
$select_opts .=
sprintf("<option value=\"%s\"%s>%s</option>",
$lang, ($lang ==
$_SESSION['lang']) ?
' selected' :
'', $lang);
$buffer .=
sprintf("<td align=\"right\" width=\"200\"><form method=\"post\" action=\"\"><select name=\"lang\" onchange=\"submit();\">%s</select></form></td>",
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\"",
ucfirst($GLOBALS['val_lang'][$GLOBALS['lang']])));
$buffer .=
sprintf("<td width=\"%d\"><img src=\"img/lang_%s.png\" width=\"%d\" height=\"%d\"%s /></td>",
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax();\"",
sprintf($GLOBALS['str_about_package_text'],
$buffer .=
sprintf("<td align=\"right\" width=\"%d\"><a href=\"http://%s\" target=\"phpendurance_org\"><img src=\"img/about.png\" border=\"0\" width=\"%d\" height=\"%d\"%s /></a></td>",
if ($_SESSION['my_user_id'])
// Disconnect button (if logged in)
$buffer .=
sprintf("<td align=\"right\" width=\"%d\">%s</td>",
$buffer .=
"</tr></table>\n";
* Display HTML page footer
* @param integer $break_lines Number of <br /> to display to avoid
* scroll problem with tips
* @param boolean $footer true to display footer content, else false
// Contact webmaster by email
if ($GLOBALS['webmaster_email'])
printf("<hr /><a href=\"mailto:%s\">%s</a>", $GLOBALS['webmaster_email'],
$GLOBALS['str_email_webmaster']);
for ($i =
0; $i <
$break_lines; $i++
)
* Generate HTML login form
* @param string $action Page to navigate to (default : current page)
* @param boolean $ajax_tips true to use Ajax tips, else false (default)
* @param string $email To fill email input value instead of
* $_POST['email'] if not null
* @param string $password To fill password input value if not null
* @return string Buffer containing HTML
$email =
null, $password =
null)
$buffer =
"<form method=\"post\" action=\"$action\">\n";
$buffer .=
"<input type=\"hidden\" name=\"login\" value=\"1\" />\n";
$buffer .=
"<table class=\"login_table\">\n";
$buffer .=
sprintf("<tr><td>%s :</td><td><input type=\"text\" size=\"30\" name=\"email\" value=\"%s\" tabindex=\"1\" /></td><td rowspan=\"2\">\n",
ucfirst($GLOBALS['str_email']), $email ?
$email :
$_POST['email']);
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\" onclick=\"submit();\"",
$buffer .=
sprintf("<input type=\"image\" name=\"login\" src=\"img/login.png\" width=\"%d\" height=\"%d\"%s tabindex=\"3\" />\n",
$buffer .=
sprintf("</td></tr>\n<tr><td>%s :</td><td><input type=\"password\" size=\"30\" name=\"password\" value=\"%s\" tabindex=\"2\" /></td></tr>\n",
ucfirst($GLOBALS['str_password']), $password);
$buffer .=
sprintf("<tr><td align=\"right\"><input type=\"checkbox\" name=\"email_cookie\" value=\"1\"%s /></td><td colspan=\"2\">%s</td></tr>\n",
isset
($_COOKIE['email']) ?
' checked' :
'',
$GLOBALS['str_remember_my_email']);
$buffer .=
sprintf("<tr><td align=\"right\"><input type=\"checkbox\" name=\"password_cookie\" value=\"1\"%s /></td><td colspan=\"2\">%s</td></tr>\n",
isset
($_COOKIE['password']) ?
' checked' :
'',
$GLOBALS['str_remember_my_password']);
* Generate HTML logout form
* @param string $action Page to navigate to (default : current page)
* @param boolean $ajax_tips true to use Ajax tips, else false (default)
* @return string Buffer containing HTML
$buffer =
"<form method=\"post\" action=\"$action\">\n";
$buffer .=
"<input type=\"hidden\" name=\"logout\" value=\"1\" />\n";
$tip =
sprintf(" onmouseover=\"doAjaxText('tip_picto',event,'%s' )\" onmouseout=\"closeAjax()\" onclick=\"submit();\"",
$buffer .=
sprintf("<input type=\"image\" name=\"logout\" src=\"img/logout.png\" width=\"%d\" height=\"%d\"%s />\n",
* Output format is : [[<h>h]<m>']<s>"<t>
* @param integer $elapsed_10 Duration in seconds * 10
* @return string Duration formatted string
$elapsed =
floor($elapsed_10 /
10);
$str_elapsed =
sprintf("%dh%02d'%02d\"",
floor($elapsed/
3600), floor($elapsed/
60) %
60, $elapsed%
60);
{ $str_elapsed =
sprintf("%d'%02d\"", floor($elapsed/
60), $elapsed%
60); }
{ $str_elapsed =
sprintf("%02d\"", $elapsed); }
$str_elapsed .=
$elapsed_10 %
10;
* Add a number of days to a date
* @param string $date Input date (format : YYYY-MM-DD, must be valid)
* @param integer $nb Number of days to add
* @return string Result date
$ts =
mktime(12, 0, 0, $month, $day, $year) +
$nb *
86400;
return sprintf("%04d-%02d-%02d", $tab['year'], $tab['mon'], $tab['mday']);
Documentation generated on Sat, 28 Mar 2009 23:15:25 +0000 by phpDocumentor 1.4.1