/**
* Functions related to XHTML code generation
*
*
* This file is part of queXS
*
* queXS 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.
*
* queXS 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 queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage functions
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Display a valid XHTML Strict header
*
* @param string $title HTML title
* @param bool $body True if to display the end of the head/body
* @param bool|array $css False for no CSS otherwise array of CSS include files
* @param bool|array $javascript False for no Javascript otherwise array of Javascript include files
* @param string $bodytext Space in the body element: good for onload='top.close()' to close validly
* @param bool|int $refresh False or 0 for no refresh otherwise the number of seconds to refresh
* @param bool $clearrefresh False if we want to pass on any GET request in header, True to clear
*
* @see xhtml_foot()
*/
function xhtml_head($title="",$body=true,$css=false,$javascript=false,$bodytext=false,$refresh=false,$clearrefresh=false)
{
?>
if (empty($title)) print "queXS"; else print "queXS: $title"; ?>
if ($css)
foreach ($css as $c) print "";
if ($javascript)
foreach ($javascript as $j) print "";
if ($refresh)
{
print "
";
}
if (!$body) return;
?>
if ($bodytext) print ""; else print "";
}
/**
* Display a valid XHTML Strict footer
*
* @see xhtml_head()
*/
function xhtml_foot()
{
?>
}
/**
* Display a valid XHTML Strict table
*
* @param array $content Content from database usually an array of arrays
* @param array $fields The names of fields to display
* @param bool|array $head False if no header otherwise array of header titles
* @param string $class Table CSS class
* @param bool|array $highlight False if nothing to highlight else an array containing the field to highlight
*
*/
function xhtml_table($content,$fields,$head = false,$class = "tclass",$highlight=false)
{
print "
";
if ($head)
{
print "
";
foreach ($head as $e)
print"
$e
";
print "
";
}
foreach($content as $row)
{
if ($highlight && isset($row[key($highlight)]) && $row[key($highlight)] == current($highlight))
print "
";
else
print "
";
foreach ($fields as $e)
print "
{$row[$e]}
";
print "
";
}
print "
";
}
/**
* Display a drop down list based on a given array
*
* Example SQL:
* SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
* FROM questionnaire
*
*
* @param array $elements An array of arrays containing a value and a description and if selected (3 elements)
* @param string $selectid The ID of the element
* @param string $var The var name of the return string
* @param bool $useblank Add a blank element to the start of the list
* @param string|bool $pass Anything to pass along in the return string (remember to separate with &)
* @param bool $js Whether to use JS or not
* @param bool $indiv Whether to display in a div or not
*
*/
function display_chooser($elements, $selectid, $var, $useblank = true, $pass = false, $js = true, $indiv = true)
{
if ($indiv) print "