401 lines
13 KiB
PHP
Executable File
401 lines
13 KiB
PHP
Executable File
<?php
|
|
#########################################################
|
|
# #
|
|
# Functions the print HTML #
|
|
# written by benjamin ramey #
|
|
# bsr@rameydesign.net #
|
|
# #
|
|
# best viewed with: #
|
|
# resolution = 1280x960 #
|
|
# tab = 4 spaces #
|
|
# indent = 8 spaces #
|
|
# #
|
|
###################################################################################################### displays a page
|
|
# parameters: none
|
|
# returns: nothing
|
|
function html_switchboard()
|
|
{
|
|
global $_LANG,$_CMDS,$_DOC_ROOT,$_ERRORS;
|
|
$file_prefix = $_DOC_ROOT."/html/html_";
|
|
|
|
include 'html/html_header.php'; // standard header (language choices made inside)
|
|
|
|
switch($_CMDS['query'][0]) {
|
|
case 'trainer':
|
|
if(isset($_CMDS['query'][1])) { // the name of the trainer must be present
|
|
include $file_prefix.'trainer.php'; // or a call to "trainer" will just show them all
|
|
break; // just like 'whoarewe' does
|
|
}
|
|
else { $_CMDS['query'][0] = 'whoarewe'; }
|
|
case 'course':
|
|
if(isset($_CMDS['query'][1])) { // if the second query field is not set (the name of the course)
|
|
include $file_prefix.'course.php'; // don't break and so just display all the courses
|
|
break;
|
|
}
|
|
case 'whatdowedo':
|
|
if(isset($_CMDS['query'][1])) {
|
|
include $file_prefix.$_CMDS['query'][1].'.php';
|
|
}
|
|
else { include $file_prefix.'whatdowedo.php'; }
|
|
break;
|
|
case 'seminars':
|
|
if(isset($_CMDS['query'][1])) {
|
|
include $file_prefix.$_CMDS['query'][1].'.php';
|
|
}
|
|
else { include $file_prefix.'seminars.php'; }
|
|
break;
|
|
default:
|
|
include $file_prefix.$_CMDS['query'][0].'.php';
|
|
break;
|
|
}
|
|
|
|
include 'html/html_footer.php'; // standard footer (language choices made inside)
|
|
}
|
|
|
|
###################################################################################################### gets the correct login message
|
|
# parameters: none
|
|
# returns: the correct login message to display
|
|
function html_get_login_message()
|
|
{
|
|
global $_LANG,$_LOGIN,$_PATH_PREFIX,$_WORDS;
|
|
if(isset($_SESSION['_loggedin']) and $_SESSION['_loggedin']) {
|
|
return($_LOGIN['mesg_loggedin']
|
|
." || <a href='$_PATH_PREFIX/{$_LANG}/user/logout' class='blue_bg'>"
|
|
.$_LOGIN['logout'].'</a>'
|
|
." || <a href='$_PATH_PREFIX/{$_LANG}/user/panel' class='blue_bg'>"
|
|
.$_WORDS['administrate'].'</a>');
|
|
}
|
|
else {
|
|
return($_LOGIN['mesg_loggedout']
|
|
." || <a href='$_PATH_PREFIX/{$_LANG}/user/login' class='blue_bg'>"
|
|
.$_LOGIN['login']
|
|
.'</a>');
|
|
}
|
|
}
|
|
|
|
###################################################################################################### gets the page title
|
|
# parameters: none
|
|
# returns: correct title of page
|
|
function html_get_page_title()
|
|
{
|
|
global $_MENU,$_CMDS;
|
|
|
|
$title = isset($_CMDS['query'][0]) ? $_MENU[$_CMDS['query'][0]] : $_MENU['home'];
|
|
|
|
return($title);
|
|
}
|
|
|
|
###################################################################################################### gets the ouline of the page
|
|
# parameters: none
|
|
# returns: the html for the current page's outline
|
|
function html_get_page_outline()
|
|
{
|
|
global $_LANG,$_CMDS,$_DOC_ROOT,$_PATH_PREFIX;
|
|
|
|
$html = '';
|
|
$file = $_DOC_ROOT."/data/outlines/{$_LANG}_ol-{$_CMDS['query'][0]}.txt";
|
|
|
|
if(!file_exists($file)) {
|
|
return;
|
|
}
|
|
|
|
$outline = file_get_contents($file); // get the outline for this page
|
|
|
|
if(empty($outline)) { // each page needs a file, but it can be empty
|
|
return;
|
|
}
|
|
|
|
$outline = explode("\n",$outline); // break the outline file contents apart by line
|
|
|
|
foreach($outline as $line) {
|
|
$line = ltrim(rtrim($line));
|
|
if(empty($line)) {
|
|
continue;
|
|
}
|
|
list($type,$text,$link) = explode('=',$line);
|
|
|
|
if(preg_match("/^(\[#([\w_]+)\])/",$link,$matches)) {
|
|
$replacement = '';
|
|
eval('$replacement = $'.$matches[2].';');
|
|
$link = str_replace($matches[1],$replacement,$link);
|
|
}
|
|
|
|
if($type == 'section') {
|
|
$html .= "~ <a href='$link' class='blue_bg'>$text</a><br />\n";
|
|
}
|
|
else if($type == 'subsection') {
|
|
$html .= " - <a href='$link' class='blue_bg'>$text</a><br />\n";
|
|
}
|
|
else { $html .= $text; }
|
|
}
|
|
|
|
return($html);
|
|
}
|
|
|
|
###################################################################################################### gets the select box to choose the language
|
|
# parameters: none
|
|
# returns: the html for the select box for language selection
|
|
function html_get_lang_select()
|
|
{
|
|
global $_LANG,$_CONFIG,$_CLEAN_PATH,$_LANG_LONG;
|
|
$select_box = "<span id='lang_select'>[ ";
|
|
|
|
foreach($_CONFIG['langs'] as $lang) {
|
|
if($_LANG == $lang) { continue; }
|
|
$lang_path = preg_replace("/^\/?$_LANG/","$lang",$_CLEAN_PATH); // replace the current language with this selectable language
|
|
//$lang_path = str_replace('.php','',$lang_path); // take out the .php in pae.php (only works when MultiViews works
|
|
$select_box .= "<a href='/$lang_path' class='blue_bg'>{$_LANG_LONG[$lang]}</a>\n";
|
|
}
|
|
|
|
$select_box .= "]</span><img src='/graphics/spacer.gif' width='6' height='1' />";
|
|
return($select_box);
|
|
}
|
|
|
|
###################################################################################################### prints a trainer's biography
|
|
# parameters: 1) path to bios; 2) name of specific bio
|
|
# returns: nothing
|
|
function html_print_bio($bios_path,$bio,$type)
|
|
{
|
|
global $_PATH_PREFIX,$_TRAINERS,$_MENU,$_WORDS,$_LANG,$_DOC_ROOT;
|
|
$bio_data = xml_parse_file($bios_path.$bio); // parse this trainer's xml file
|
|
$bio_name = str_replace('.xml','',$bio); // the name for the link will be the same as the file name without the extension
|
|
$desc = '<p>'.$_TRAINERS['default_desc'].'</p>'; // if no description in the current language is found
|
|
|
|
if(!empty($bio_data['trainer']['biography'])) {
|
|
if(isset($bio_data['trainer']['biography'][0])) { // if there are several language present
|
|
foreach($bio_data['trainer']['biography'] as $biography) { // step through each biography (in a different language)
|
|
if($biography['lang'] == $_LANG) { // if there is one for the current language
|
|
$desc = "<p>{$biography['paragraph'][0]}</p>";
|
|
$c = 1;
|
|
while((250 - strlen($desc)) > 20) { // we just want a snippet for the who we are page, not the whole biography
|
|
$desc .= "<p>{$biography['paragraph'][$c]}</p>"; // but we also want whole paragraphs, so we don't end in the middle of one
|
|
$c++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else { // if only one language is present
|
|
if($bio_data['trainer']['biography']['lang'] == $_LANG) {
|
|
$desc = "<p>{$bio_data['trainer']['biography']['paragraph'][0]}</p>"; // same as above for many languages
|
|
$c = 1;
|
|
while((250 - strlen($desc)) > 20) {
|
|
$desc .= "<p>{$bio_data['trainer']['biography']['paragraph'][$c]}</p>";
|
|
$c++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$img = $_DOC_ROOT."/data/trainer_pics/thumb_{$bio_data['trainer']['portrait']}"; // the picture file indicated in the xml doc
|
|
$height = 80; // default height of each trainers div
|
|
if(file_exists($img)) { // make sure the image file exists
|
|
list($width,$height) = getimagesize($img); // get the image size, all we will use is the height
|
|
$img = "<img src='/pae.co.at/data/trainer_pics/thumb_{$bio_data['trainer']['portrait']}'
|
|
align='left' class='bio_picture_small' />"; // $img is now the html for the bio image
|
|
}
|
|
else { $img = ''; }
|
|
|
|
$notes = '';
|
|
if(!empty($bio_data['trainer']['note'])) { // add notes to the details, if they are present
|
|
$note = '';
|
|
if(isset($bio_data['trainer']['note'][0])) {
|
|
foreach($bio_data['trainer']['note'] as $note_info) {
|
|
if($note_info['lang'] == $_LANG) {
|
|
$note = $note_info;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if($bio_data['trainer']['note']['lang'] == $_LANG) {
|
|
$note = $bio_data['trainer']['note'];
|
|
}
|
|
}
|
|
$notes .= "
|
|
<span class='bio_note'>
|
|
({$note['content']})
|
|
</span>\n";
|
|
}
|
|
|
|
if($type == 'trainer') { // bio summaries must be printed slightly different for staff and trainers
|
|
$name_degrees = $bio_data['trainer']['name'];
|
|
if(!empty($bio_data['trainer']['degrees']))
|
|
{
|
|
$name_degrees .= ', '.$bio_data['trainer']['degrees'];
|
|
}
|
|
print "
|
|
<div class='text_div'>
|
|
<div class='text_header' id='{$bio_data['trainer']['name']}'>
|
|
{$name_degrees}
|
|
</div>
|
|
<div class='text' style='min-height:{$height}px;'>
|
|
$img
|
|
$desc
|
|
<a href='$_PATH_PREFIX/$_LANG/display/trainer/$bio_name'>{$_WORDS['readmore']}</a>
|
|
</div>
|
|
</div>";
|
|
}
|
|
else if($type == 'staff') {
|
|
print "
|
|
<div class='text_div'>
|
|
<div class='text_header' id='{$bio_data['trainer']['name']}'>
|
|
{$bio_data['trainer']['name']}, {$bio_data['trainer']['title'][$_LANG]}
|
|
$notes
|
|
</div>
|
|
<div class='text' style='min-height:{$height}px;'>
|
|
$img
|
|
$desc
|
|
<a href='$_PATH_PREFIX/$_LANG/display/trainer/$bio_name'>{$_WORDS['readmore']}</a>
|
|
|
|
|
<a href='$_PATH_PREFIX/$_LANG/display/trainer/$bio_name'>{$_WORDS['contactme']}</a>
|
|
</div>
|
|
</div>";
|
|
}
|
|
}
|
|
|
|
###################################################################################################### gets a random panorama image
|
|
# parameters: 1) path to pictures
|
|
# returns: the html for the select box for language selection
|
|
function html_get_random_img($path)
|
|
{
|
|
$pictures = scandir($path);
|
|
$pictures = filesys_remove_unwanted_children($pictures,$path,'folders');
|
|
|
|
$num_pics = count($pictures);
|
|
$rand_pic = $pictures[floor(rand(0,$num_pics - 1))];
|
|
|
|
return($rand_pic);
|
|
}
|
|
|
|
###################################################################################################### print a page from xml data array
|
|
# parameters: 1) array of data from xml file
|
|
# returns: the html for the select box for language selection
|
|
function html_print_xml_page($data)
|
|
{
|
|
$page_name = $data['name'];
|
|
$page_content = '';
|
|
$sections = 0;
|
|
$paras = 0;
|
|
|
|
isset($data['content']['section'])
|
|
? $sections = 1
|
|
: $paras = 1;
|
|
|
|
if($sections ) {
|
|
$contents = xml_force_array($data['content']['section']);
|
|
$page_content = html_print_sections($contents);
|
|
}
|
|
else if($paras) {
|
|
$contents = xml_force_array($data['content']['para']);
|
|
$page_content = html_print_paragraphs($contents);
|
|
}
|
|
|
|
print "<div class='page_subtitle'>$page_name</div>\n";
|
|
print "<div class='page_content'>\n";
|
|
print $page_content;
|
|
print "</div>\n";
|
|
}
|
|
|
|
###################################################################################################### print sections of an xml page
|
|
# parameters: 1) array of sections to print
|
|
# returns: the html for the sections
|
|
function html_print_sections(&$sections)
|
|
{
|
|
$page_content = '';
|
|
|
|
foreach($sections as $sec) {
|
|
$page_content .= "<div class='text_div'>\n";
|
|
$page_content .= "<div class='text_header' id='{$sec['name']}'>{$sec['name']}</div>\n";
|
|
$page_content .= "<div class='text'>\n";
|
|
|
|
$paras = xml_force_array($sec['text']['para']);
|
|
|
|
$page_content .= html_print_paragraphs($paras);
|
|
|
|
$page_content .= "</div>\n";
|
|
$page_content .= "</div>\n";
|
|
}
|
|
|
|
return $page_content;
|
|
}
|
|
|
|
###################################################################################################### print paragraphs of an xml page
|
|
# parameters: 1) array of paragraphs to print
|
|
# returns: the html for the paragraphs
|
|
function html_print_paragraphs(&$paragraphs)
|
|
{
|
|
$page_content = '';
|
|
|
|
foreach($paragraphs as $para) {
|
|
$page_content .= '<p>';
|
|
|
|
if(is_array($para)) {
|
|
foreach($para as $key => $value) {
|
|
switch($key) {
|
|
case 'line':
|
|
if(is_array($value)) {
|
|
foreach($value as $line) { $page_content .= '<br />'.$line; }
|
|
}
|
|
else { $page_content .= '<br />'.$value; }
|
|
break;
|
|
case 'paracontent':
|
|
$page_content .= $value;
|
|
break;
|
|
case 'list':
|
|
$page_content .= "<ul>\n";
|
|
foreach($para['list']['listitem'] as $item) {
|
|
$page_content .= "<li>$item</li>\n";
|
|
}
|
|
$page_content .= "</ul>\n";
|
|
break;
|
|
case 'heading':
|
|
$page_content .= "<strong>$value</strong>\n";
|
|
break;
|
|
case 'link':
|
|
if(is_array($value)) {
|
|
$page_content .= " <a href='{$value['href']}'>{$value['linktext']}</a>";
|
|
}
|
|
else { $page_content .= " <a href='$value'>$value</a>"; }
|
|
break;
|
|
case 'image':
|
|
$images = xml_force_array($para['image']);
|
|
$page_content .= html_print_images($images);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else { $page_content .= $para; }
|
|
|
|
$page_content .= "</p>\n";
|
|
}
|
|
|
|
return $page_content;
|
|
}
|
|
|
|
###################################################################################################### print images of an xml page
|
|
# parameters: 1) array of images to print
|
|
# returns: the html for the images
|
|
function html_print_images(&$images)
|
|
{
|
|
$page_content = '';
|
|
|
|
foreach($images as $image) {
|
|
if(is_array($image)) {
|
|
foreach($image as $key => $value) {
|
|
switch($key) {
|
|
case 'link':
|
|
$page_content .= "<a href='$value'><img src='/pae.co.at/graphics/{$image['path']}' ";
|
|
$page_content .= "target='_blank' border='0' /></a>\n";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else { $page_content .= "<img src='/pae.co.at/graphics/{$image}' border='0' align='right' />\n"; }
|
|
}
|
|
|
|
return $page_content;
|
|
}
|
|
?>
|