/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright ©2006 by sTEFANs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This file contains functions that prints HTML tags for several purposes.
* @copyright Copyright ©2006 by sTEFANs
* @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
include_once('inc/var.inc.php');
* Prints a common header for any HTML page.
* A HTML opened with this function can be closed
* with <b>PrintPageFooter</b>
* @param string $title Page title
* @param string $style Body style
* @param string $on_load_js Javascript for body onOpen.
function PrintPageHeader($title =
NULL, $style =
NULL, $on_load_js =
NULL){
$style_arg =
($style !=
NULL ?
'class="'.
$style.
'"' :
'');
$js_arg =
($on_load_js !=
NULL ?
'onLoad="'.
$on_load_js.
'"' :
'');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="content-language" content="'.
$language_code.
'" />
<meta name="robots" content="noindex" />
<meta name="revisit-after" content="10 days" />
<meta name="revisit" content="10 days" />
<meta name="distribution" content="global" />
<meta name="audience" content="internal" />
<!-- IMPORTANT: THE FOLLOWING TWO LINES MUST NOT BE CHANGED OR REMOVED!! -->
<meta name="author" content="Stefan Schraml" />
<meta name="copyright" content="2006, sTEFANs" />
<meta name="description" content="SVN Control System for Webapp Development" />
<!-- STYLESHEETS AND OTHER INCLUDES -->
<link rel="stylesheet" href="'.
$styles.
'" type="text/css" />
<title>'.
($title ==
NULL ?
'SVN Web Control' :
$title).
'</title>
<body '.
$style_arg.
$js_arg.
'>';
* Prints HTML tags for a submit button and additional form arguments
* (hidden fields) without surrounding table cell.
* Can be used between <b>OpenFormCell</b>
* and <b>CloseFormCell</b>.
* @param string $button_text Button text
* @param array $button_actions Array (or array of arrays) containing
* action name at index 0 and action value at index 1. An array
* containing array with format above can also be applied.
* For every name/value pair a hidden field for the form
* @param boolean $selected True if button should be rendered as selected.
* @param boolean $enabled True if button should be rendered as enabled.
* @param boolean $submit_btn True if button should be a submit button of a form.
* (CSS class button.selected).
$selected =
false, $enabled =
true, $submit_btn =
true){
if ($button_actions !=
NULL &&
count($button_actions) >
0) {
//PrintDebugArray($button_actions, 'Buttons');
foreach($button_actions as $action){
if (count($button_actions) >
1){
<input type="hidden" name="'.
$button_actions[IDX_NAME].
'" value="'.
$button_actions[IDX_VALUE].
'"/>';
$style_arg =
($selected ?
'button_hot' :
'button');
$style_arg =
($enabled ?
$style_arg :
'button_disabled');
$style_arg =
' class="'.
$style_arg.
'"';
$button_type =
($submit_btn ?
'submit' :
'button');
<input type="'.
$button_type.
'"'.
$style_arg.
' value="'.
$button_text.
'"/>';
* Prints HTML tags for a text field form element
* including label but no surrounding cell or form.
* Can be used between <b>OpenFormCell</b>
* and <b>CloseFormCell</b>.
* @param string $label Label for the text field.
* @param string $name Text field form name, index for text field value
* @param int $size Size in characters of the text field.
* @param string $text Initial text of the text field If NULL, text field keeps empty.
* @param int $max_length Maximum numbers of characters that can inputed into the text field.
* @param string $text_field_style CSS style class for the text field.
$max_length =
0, $text_field_style =
NULL){
$label_arg =
($label !=
NULL ?
$label.
' ' :
'');
$name_arg =
($name !=
NULL ?
' name="'.
$name.
'"' :
'');
$size_arg =
($size >
0 ?
' size="'.
$size.
'"' :
'');
$text_arg =
($text !=
NULL ?
' value="'.
$text.
'"' :
'');
$max_length_arg =
($max_length >
0 ?
' maxlength="'.
$max_length.
'"' :
'');
<input type="text"'.
$name_arg.
$size_arg.
$text_arg.
$max_length_arg.
'/>';
* Prints HTML tags to open a table and opens a row. A table
* opened with this statement must be closed via <b>CloseTable</b>.
* @param int $border Table border width.
* @param int $cellspacing Table cellspacing.
* @param int $cellpadding Table cellpadding.
* @param string $style CSS class name for table style.
function OpenTable($border =
0, $cellspacing =
0, $cellpadding =
0, $style =
NULL){
$style_arg =
($style !=
NULL ?
'class="'.
$style.
'"' :
'');
<table '.
$style_arg.
' border="'.
$border.
'" cellspacing="'.
$cellspacing.
'" cellpadding="'.
$cellspacing.
'">
* Prints HTML tags close a HTML table row and open
* a new one. Can be used between <b>OpenTable</b>
* Prints HTML tags for a entire table cell.
* Can be used between <b>OpenTable</b>
* @param string $content Cell content.
* @param string $style CSS style class for cell.
* @param int $colspan Cell HTML colspan.
* @param int $rowspan Cell HTML rowspan.
* @param string $valign HTML vertical cell content alignment.
function PrintTableCell($content, $style =
NULL, $colspan =
0, $rowspan =
0, $valign =
NULL){
$cs_arg =
($colspan !=
0 ?
' colspan="'.
$colspan.
'"' :
'');
$rs_arg =
($rowspan !=
0 ?
' rowspan="'.
$rowspan.
'"' :
'');
* Prints HTML tags for empty table cells.
* Can be used between <b>OpenTable</b>
* @param int $colspan Cell HTML colspan.
* @param int $rowspan Cell HTML rowspan.
* Prints HTML tags to open a table cell.
* A table cell opened with this function must
* be closed with <b>CloseTableCell</b>.
* Can be used between <b>OpenTable</b>
* @param string $style CSS style class for cell.
* @param int $colspan Cell HTML colspan.
* @param int $rowspan Cell HTML rowspan.
* @param string $valign HTML vertical cell content alignment.
function OpenTableCell($style =
NULL, $colspan =
0, $rowspan =
0, $valign =
NULL){
$style_arg =
($style !=
NULL ?
' class="'.
$style.
'"' :
'');
$cs_arg =
($colspan >
0 ?
' colspan="'.
$colspan.
'"' :
'');
$rs_arg =
($rowspan >
0 ?
' rowspan="'.
$rowspan.
'"' :
'');
$valign_arg =
($valign !=
NULL ?
' valign="'.
$valign.
'"' :
'');
<td'.
$cs_arg.
$rs_arg.
$valign_arg.
$style_arg.
'>';
* Prints HTML tags to close a table cell
* which has been opened with <b>OpenTableCell</b>.
* Can be used between <b>OpenTable</b>
* Prints HTML tags to open a tabel cell and a form without content.
* A form cell opened this way must be close via <b>CloseFormCell</b>.
* @param string $form_action Action (URL) for form.
* @param string $form_method Method of form action.
* @param string $form_target Target of form action.
* @param string $cell_style CSS style class for cell
* @param int $colspan Cell HTML colspan
* @param int $rowspan Cell HTML rowspan
* @param string $valign HTML vertical cell content alignment
function OpenFormCell($form_action, $cell_style =
NULL, $colspan =
0, $rowspan =
0,
$valign =
NULL, $form_method=
'post', $form_target =
'_self'){
<form action="'.
$url.
'" method="'.
$form_method.
'" target="'.
$form_target.
'">';
* Prints HTML tags to close a form that has been opened
* via <b>OpenFormCell</b>.
* @param string $form_action Action (URL) for form.
* @param string $form_method Method of form action.
* @param string $form_target Target of form action.
* Prints HTML tags for a entire table cell
* encapsulated within a form to relize a single
* Can be used between <b>OpenTable</b>
* @param string $button_text Button text.
* @param string $form_action Action (URL) for form.
* @param array $button_actions Array (or array of arrays) containing
* action name at index 0 and action value at index 1. An array
* containing array with format above can also be applied.
* For every name/value pair a hidden field for the form
* @param string $cell_style CSS style class for cell.
* @param boolean $selected True if button should be rendered as selected.
* @param boolean $enabled True if button should be rendered as enabled.
* (CSS class button.selected)
* @param string $form_method Method of form action.
* @param string $form_target Target of form action.
$button_actions, $cell_style =
NULL,
$selected =
false, $enabled =
true,
$form_method=
'post', $form_target =
'_self'){
OpenFormCell($form_action, $cell_style, 0, 0, NULL, $form_method, $form_target);
PrintFormButton($button_text, $button_actions, $selected, $enabled, ($button_actions !=
NULL));
* Prints HTML tags for two entire table cells
* encapsulated within a form to relize a
* selection list and a single submit button.
* Can be used between <b>OpenTable</b>
* @param string $title Title text.
* @param string $button_text Button text.
* @param string $form_action Action (URL) for form.
* @param strnig $selected_item Value of the selected item
* If the value corespond to an item value given in
* $items[IDX_VALUE] this item is preselected in the list.
* @param array $items Array of arrays of items containing
* selection name at index IDX_NAME and selection value at index
* IDX_VALUE. An array containing array with format above
* @param string $selection_name Name for selection list.
* @param int $selection_size Number of visible list entries.
* @param string $cell_style CSS style class for cell.
* @param string $selection_style CSS style class for selection list.
* @param boolean $selected True if button should be rendered as selected.
* @param boolean $enabled True if button should be rendered as enabled.
* (CSS class button.selected)
* @param int $colspan Cell HTML colspan.
* @param int $rowspan Cell HTML rowspan.
* @param string $form_method Method of form action.
* @param string $form_target Target of form action.
$selection_name, $selection_size =
1,
$cell_style =
NULL, $selection_style =
NULL,
$colspan =
0, $rowspan =
0,
$form_method=
'post', $form_target =
'_self'){
$style_arg =
($selection_style !=
NULL ?
' class="'.
$selection_style.
'"' :
'');
$name_arg =
($selection_name !=
NULL ?
' name="'.
$selection_name.
'"' :
'');
$size_arg =
($selection_size !=
0 ?
' size="'.
$selection_size.
'"' :
'');
OpenFormCell($form_action, $cell_style, $colspan, $rowspan, NULL, $form_method, $form_target);
<select'.
$name_arg.
$size_arg.
$style_arg.
' onchange="this.form.submit();return true;">';
foreach($items as $item){
if ($selected_item !=
NULL){
$sel =
($selected_item ==
$item[IDX_VALUE] ?
' selected="selected"' :
'');
* Prints HTML tags for one entire table cell
* encapsulated within a form to relize a
* selection list and a single submit button.
* Can be used between <b>OpenTable</b>
* @param string $title Title text.
* @param string $button_text Button text.
* @param string $form_action Action (URL) for form.
* @param array $selections Array of arrays containing
* selection name at index IDX_NAME and selection value at index
* IDX_VALUE. An array containing array with format above
* @param array $button_actions Array (or array of arrays) containing
* action name at index 0 and action value at index 1. An array
* containing array with format above can also be applied.
* For every name/value pair a hidden field for the form
* @param string $selection_name Name for selection list.
* @param int $selection_size Number of visible list entries.
* @param string $cell_style CSS style class for cell.
* @param string $selection_style CSS style class for selection list.
* @param boolean $selected True if button should be rendered as selected.
* @param boolean $enabled True if button should be rendered as enabled.
* (CSS class button.selected).
* @param string $form_method Method of form action.
* @param string $form_target Target of form action.
$selections, $button_actions,
$selection_name, $selection_size =
1,
$cell_style =
NULL, $selection_style =
NULL,
$selected =
false, $enabled =
true,
$form_method=
'post', $form_target =
'_self'){
$style_arg =
($selection_style !=
NULL ?
' class="'.
$selection_style.
'"' :
'');
$name_arg =
($selection_name !=
NULL ?
' name="'.
$selection_name.
'"' :
'');
$size_arg =
($selection_size !=
0 ?
' size="'.
$selection_size.
'"' :
'');
OpenFormCell($form_action, $cell_style, 0, 0, NULL, $form_method, $form_target);
<select'.
$name_arg.
$size_arg.
$style_arg.
'>';
foreach($selections as $select){
* Prints HTML tags for one table cell which
* encapsulates an HTML iFrame.
* @param string $src iFrame source URL.
* @param string $name iFrame name.
* @param int $width Width of the frame.
* @param int $height Height of the frame.
* @param int $colspan Cell HTML colspan.
* @param int $rowspan Cell HTML rowspan.
* @param boolean $draw_border True of frame border
* should be drawn, false otherwise.
* @param string $cell_style CSS style class for cell.
* @param string $desc Description of the frame.
$width =
NULL, $height =
NULL,
$colspan =
0, $rowspan =
0,
$draw_border =
false, $cell_style =
NULL,
$name_arg =
($name !=
NULL ?
' name="'.
$name.
'"' :
'');
$width_arg =
($width !=
NULL ?
' width="'.
$width.
'"' :
'');
$height_arg =
($height !=
NULL ?
' height="'.
$height.
'"' :
'');
$border_arg =
' frameborder="'.
($draw_border ?
'1' :
'0').
'"';
$desc_arg =
($desc !=
NULL ?
' longdesc="'.
$desc.
'"' :
'');
<iframe src="'.
$src.
'"'.
$name_arg.
' scrolling="auto"'.
$width_arg.
$height_arg.
$border_arg.
$desc_arg.
'>
* Prints HTML tags for one table cell
* encapsulated within a form to relize an
* immediate executed checkbox.
* Can be used between <b>OpenTable</b>
* @param string $label Checkbox label.
* @param string $name Checkbox name, index for checkbox value.
* @param string $form_action Action (URL) for form.
* @param array $hidden_fields Array (or array of arrays) containing
* action name at index 0 and action value at index 1. An array
* containing array with format above can also be applied.
* For every name/value pair a hidden field for the form
* @param string $cell_style CSS style class for cell.
* @param string $checkbox_style CSS style class for selection list.
* @param boolean $checked True if checkbox should initially be selected.
* @param string $form_method Method of form action.
* @param string $form_target Target of form action.
$cell_style =
NULL, $checkbox_style =
NULL, $checked =
false,
$form_method=
'post', $form_target =
'_self', $no_form =
false){
$style_arg =
($checkbox_style !=
NULL ?
' class="'.
$checkbox_style.
'"' :
'');
$checked_arg =
($checked ?
' checked="checked"' :
'');
OpenFormCell($form_action, $cell_style, 0, 0, NULL, $form_method, $form_target);
$checkbox_name =
'chkbx_'.
$name;
// Workaround for IE and others: Allow immideate submit
$js_check_val =
($checked ?
'true' :
'false');
$js_new_val =
($checked ?
'0' :
'1');
$submit =
($no_form ?
'' :
'this.form.submit(); ');
<input type="checkbox" id="'.
$checkbox_name.
'" name="'.
$checkbox_name.
'"'.
$style_arg.
$checked_arg.
'
onchange="this.form.'.
$name.
'.value=((this.form.'.
$checkbox_name.
'.checked == true) ? \'1\' : \'0\'); '.
$submit.
'return true;"/>
<input type="hidden" name="'.
$name.
'" value="'.
($checked ?
'1' :
'0').
'"/>';
if (count($hidden_fields) >
0){
foreach($hidden_fields as $field){
} else if (count($hidden_fields) >
1){
<input type="hidden" name="'.
$hidden_fields[IDX_NAME].
'" value="'.
$hidden_fields[IDX_VALUE].
'"/>';
<label for="'.
$checkbox_name.
'">'.
$label.
'</label>';
* Prints HTML tags for one table cell
* Can be used between <b>OpenTable</b>
* @param string $url Link url.
* @param string $label Link label.
* @param string $target Link target.
* @param string $cell_style CSS style class for cell.
* @param int $colspan Cell HTML colspan.
* @param int $rowspan Cell HTML rowspan.
$cell_style =
NULL, $colspan =
0, $rowspan =
0){
$target_arg =
($target !=
NULL ?
' target="'.
$target.
'"' :
'');
$label_arg =
($label !=
NULL ?
$label :
$url);
<a href="'.
$url.
'"'.
$target_arg.
'>'.
$label_arg.
'</a>';
* Prints HTML tags to close a table
* which was opened with <b>OpenTable</b>.
* Attaches the session ID argument to the given URL
* if sessions are not handled via cookies. The session
* ID is only added to relative URLs (without any scheme).
* @param string $url URL to which the session argument is attached.
* @return string URL containing the session ID argument in a wellformed
* way or the untouched URL if sessions are handled via cookies.
if (($sid !=
NULL &&
$sid !=
'') &&
(!isset
($url_parts['query']) ||
$url_parts['query'] ==
'' ||
$url_parts['query'] ==
NULL)){
if (isset
($url_parts['query'])){
parse_str($url_parts['query'], $query_parts);
foreach ($session_vals as $key =>
$val){
$query_parts[$key] =
$val;
if ($query !=
NULL &&
$query !=
''){
if (strpos($url, '?') !==
false){
* Prints HTML footer for the page which
* has been opened with <b>PrintPageHeader</b>.