* @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 * @param bool|string $subtitle False if we want no subtitle otherwise display a subtitle * @param bool $displayinnertitle Whether to display the inner title or not * * @see xhtml_foot() */ function xhtml_head($title="",$body=true,$css=false,$javascript=false,$bodytext=false,$refresh=false,$clearrefresh=false,$subtitle=false,$displayinnertitle=true) { print ""; ?> <?php if (empty($title)) print "queXS"; else print "queXS: $title"; ?> "; if ($javascript) foreach ($javascript as $j) print ""; if ($refresh && ALLOW_PAGE_REFRESH) { print " "; } if (!$body) return; ?> "; else print ""; if ($displayinnertitle) { print "

" . "$title" . "  " . "$subtitle" . "

"; } /* Let's print header that equals to menu item and page title !!!, move previous headers to "subtitles"*/ } /** * Display a valid XHTML Strict footer * * @see xhtml_head() */ function xhtml_foot($javascript = false){ //added javascript files array to the footer if ($javascript) foreach ($javascript as $j) print ""; ?> for @value $class = "tclass" added "Bootstrap" table classes * AD:> added @param string $id - > to transfer table ID if required * AD:> added @param string $name - > to transfer table name if required */ function xhtml_table($content,$fields,$head = false,$class = "tclass",$highlight=false,$total=false,$id=false,$name=false) { $tot = array(); $row = array(); if ($class == "tclass") $class = "table-hover table-bordered table-condensed tclass"; print ""; if ($head) { print ""; foreach ($head as $e) print""; print ""; } print ""; foreach($content as $row) { if ($highlight && isset($row[key($highlight)]) && $row[key($highlight)] == current($highlight)) print ""; else print ""; foreach ($fields as $e) { print ""; if ($total && in_array($e,$total)) { if (!isset($tot[$e])) $tot[$e] = 0; $tot[$e] += $row[$e]; } } print ""; } if ($total) { print ""; foreach ($fields as $e) { print ""; } print ""; } else{ print ""; } print "
$e
"; if (isset($row[$e])) print $row[$e]; print "
"; if (in_array($e,$total)) print $tot[$e]; 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 * @param array|bool $select The element to select manually (element,string) (not using selected=\'selected\' in array) * @param bool $print Default is true, print the chooser otherwise return as a string * */ function display_chooser($elements, $selectid, $var, $useblank = true, $pass = false, $js = true, $indiv = true, $selected = false, $print = true, $divclass=false, $selectclass="form-control") { $out = ""; if ($indiv) $out .= "
"; $out .= ""; if ($indiv) $out .= "
"; if ($print) print $out; else return $out; } function xhtml_object($data, $id, $class="embeddedobject") { if (browser_ie()) print ''; else print '

Error while loading data from ' . "$data" . ', try with Frefox

'; } /** * Detect if the user is running on internet explorer * * @return bool True if MSIE is detected otherwise false */ function browser_ie() { if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; } ?>