<?php
if($_SERVER["SCRIPT_FILENAME"] == __FILE__)
{
exit("No Access on this File!");
//Tue Aug 02 16:30:01 CEST 2005 16:30:01
}
/**
* SOK Tempalte Class
*
* @Name SOKt
* @version 0.0.5
* @Copyright 2005 by Maximilian R. Passarello
**/
class sokt
{
/**
* Ansprechungs Methode und erzeuger des Headers und Footers
*
* @param $_TITLE string
* @param $_HTML_TYP string
* @param $_CSS true/false
* @param $_HEADER_EDIT
* @param $_HEADER_LOAD
* @return
**/
function sokt($_TITLE='NoNAME',$_HTML_TYP='html',$_CSS=false,$_HEADER_EDIT=false,$_HEADER_LOAD=false) {
$GLOBALS['templateforsoktdata']['_TITLE']=$_TITLE;
$GLOBALS['templateforsoktdata']['_HTML_TYP']=$_HTML_TYP;
if ($_HEADER_LOAD)
$header_load=file_get_contents('./templates/header.tpl');
if ($_CSS)
$css='<link rel="stylesheet" type="text/css" href="./templates/css.css" />';
switch ($GLOBALS['templateforsoktdata']['_HTML_TYP']) {
case html:
$GLOBALS['templateforsoktdata']['_HTML_HEAD']='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>{TITLE}</title>
'.$css.'
</head><body>
'.$header_load.'';
break;
case 'xhtml1.0':
$GLOBALS['templateforsoktdata']['_HTML_HEAD']='<?xml version="1.0" encoding="iso-8859-1"?>
<!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">
<head>
<meta name="Createt by" content="SOKt Version 1.3" />
<title>{TITLE}</title>
'.$css.'
</head><body>
'.$header_load.'';
if ($_HEADER_EDIT==true) {
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' &&
isset($_SERVER['HTTP_ACCEPT']) &&
preg_match('|application/xhtml\+xml(?!\s*;\s*q=0)|', $_SERVER['HTTP_ACCEPT'])) {
header('Content-Type: application/xhtml+xml; charset=iso-8859-1', TRUE);
header('Vary: Negotiate,Accept', TRUE);
} else {
header('Content-Type: text/html; charset=iso-8859-1', TRUE);
header('Vary: Negotiate,Accept', TRUE);
}
} break;
case 'xhtml1.1':
$GLOBALS['templateforsoktdata']['_HTML_HEAD']='<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{TITLE}</title>
'.$css.'
</head><body>
'.$header_load.'';
if ($_HEADER_EDIT==true) {
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' &&
isset($_SERVER['HTTP_ACCEPT']) &&
preg_match('|application/xhtml\+xml(?!\s*;\s*q=0)|', $_SERVER['HTTP_ACCEPT'])) {
header('Content-Type: application/xhtml+xml; charset=iso-8859-1', TRUE);
header('Vary: Negotiate,Accept', TRUE);
} else {
header('Content-Type: text/html; charset=iso-8859-1', TRUE);
header('Vary: Negotiate,Accept', TRUE);
}
}
break;
}
}
/**
* Setzt eine Variable für die Templates
*
* @param $NAME all
* @param $VALUE all
* @return
**/
function setvar( $NAME, $VALUE )
{
$i = count( $GLOBALS['templateforsokt'] );
if ( count( $GLOBALS['templateforsokt'] ) != 0 )
{
$i++;
}
$GLOBALS['templateforsokt']['' . $i . '']['name'] = $NAME;
$GLOBALS['templateforsokt']['' . $i . '']['value'] = $VALUE;
}
/**
* Setzt ein Array für die Templates
*
* @param $NAME all
* @param $VALUE all
* @param $BN boalen
* @return
**/
function setarray( $NAME, $VALUE, $BN = false )
{
if ( $BN == FALSE ) {
$BN = 0;
}
if ( $BN == TRUE ) {
$BN = 1;
}
if ( $BN == FALSE )
{
$i = count( $GLOBALS['templateforsokt']['array' . $BN . ''] );
if ( count( $GLOBALS['templateforsokt']['array' . $BN . ''] ) != 0 )
{
$i++;
}
$GLOBALS['templateforsokt']['array' . $BN . '']['' . $i . '']['name'] = $NAME;
$GLOBALS['templateforsokt']['array' . $BN . '']['' . $i . '']['value'] = $VALUE;
}
if ( $BN == TRUE )
{
$i = count( $GLOBALS['templateforsokt']['array' . $BN . ''] );
if ( count( $GLOBALS['templateforsokt']['array' . $BN . ''] ) != 0 )
{
$i++;
}
$GLOBALS['templateforsokt']['array' . $BN . '']['' . $i . '']['name'] = $NAME;
$GLOBALS['templateforsokt']['array' . $BN . '']['' . $i . '']['value'] = $VALUE;
}
}
/**
* Gibt ein Template aus
*
* @param $tpl_name all
* @param $tpl_title = "{PHP_SELF}" all
* @return
**/
function display( $tpl_name, $tpl_title="{PHP_SELF}" )
{
$fp = fopen ( "./templates/" . $tpl_name . ".tpl", "r" ) or die("Kann das Template ".$tpl_name." nicht finden.");
$filesize=filesize ( "./templates/" . $tpl_name . ".tpl" );
if ($filesize==0) {
$filesize=1;
}
$str = fread ( $fp, $filesize );
$templates = $str;
$templates = preg_replace( "/{\*.*\*\}\}*/U", "", $templates);
$count = count( $GLOBALS['templateforsokt'] );
$i = 0;
while ( $i <= $count )
{
$templates = str_replace( '{$' . $GLOBALS['templateforsokt']['' . $i . '']['name'] . '}', '' . $GLOBALS['templateforsokt']['' . $i . '']['value'] . '', $templates );
$i++;
} // while
$count = count( $GLOBALS['templateforsokt']['array0'] );
$i = 0;
error_reporting(0);
while( $i <= $count ){
$name=$GLOBALS['templateforsokt']['array0']['' . $i . '']['name'];
$value = $GLOBALS['templateforsokt']['array0']['' . $i . '']['value'];
foreach ($value as $a => $b)
{
$templates = str_replace( '{$' . $name . '.' . $a . '}' , '' . $b . '', $templates );
}
$i++;
} // while
$count = count( $GLOBALS['templateforsokt']['array1'] );
$i = 0;
while( $i <= $count ){
$name=$GLOBALS['templateforsokt']['array1']['' . $i . '']['name'];
$value = $GLOBALS['templateforsokt']['array1']['' . $i . '']['value'];
$count = count( $value );
$xc = 0;
foreach ( $value as $a => $b )
{
$templates = str_replace( '{$' . $name . '.' . $xc . '}' , '' . $b . '', $templates );
$xc++;
}
$i++;
} // while
$standartplatzhalter=array
(
"{HEADER}" => $GLOBALS['templateforsoktdata']['_HTML_HEAD'],
"{FOOTER}" => '</body></html>',
"{TITLE}" => $GLOBALS['templateforsoktdata']['_TITLE'],
"{tpl_title}" => $tpl_title,
"{PHP_SELF}" => $_SERVER['PHP_SELF'],
"ä" => "ä",
"ö" => "ö",
"ü" => "ü",
"Ä" => "Ä",
"Ö" => "Ö",
"Ü" => "Ü",
"<br>" => "<br />",
"<hr>" => "<hr />"
);
foreach ( $standartplatzhalter as $a => $b )
{
$templates = str_replace( $a , $b , $templates );
}
echo( $templates );
fclose($fp);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
}
/**
* Gibt den geparsten Inhalt eines Templates zurük
*
* @param $tpl_name all
* @param $tpl_title = "{PHP_SELF}" all
* @return $templates all
**/
function out( $tpl_name, $tpl_title="{PHP_SELF}" )
{
$fp = fopen ( "./templates/" . $tpl_name . ".tpl", "r" ) or die("Kann das Template ".$tpl_name." nicht finden.");
$filesize=filesize ( "./templates/" . $tpl_name . ".tpl" );
if ($filesize==0) {
$filesize=1;
}
$str = fread ( $fp, $filesize );
$templates = $str;
$templates = preg_replace( "/{\*.*\*\}\}*/U", "", $templates);
$count = count( $GLOBALS['templateforsokt'] );
$i = 0;
while ( $i <= $count )
{
$templates = str_replace( '{$' . $GLOBALS['templateforsokt']['' . $i . '']['name'] . '}', '' . $GLOBALS['templateforsokt']['' . $i . '']['value'] . '', $templates );
$i++;
} // while
$count = count( $GLOBALS['templateforsokt']['array0'] );
$i = 0;
error_reporting(0);
while( $i <= $count ){
$name=$GLOBALS['templateforsokt']['array0']['' . $i . '']['name'];
$value = $GLOBALS['templateforsokt']['array0']['' . $i . '']['value'];
foreach ($value as $a => $b)
{
$templates = str_replace( '{$' . $name . '.' . $a . '}' , '' . $b . '', $templates );
}
$i++;
} // while
$count = count( $GLOBALS['templateforsokt']['array1'] );
$i = 0;
while( $i <= $count ){
$name=$GLOBALS['templateforsokt']['array1']['' . $i . '']['name'];
$value = $GLOBALS['templateforsokt']['array1']['' . $i . '']['value'];
$count = count( $value );
$xc = 0;
foreach ( $value as $a => $b )
{
$templates = str_replace( '{$' . $name . '.' . $xc . '}' , '' . $b . '', $templates );
$xc++;
}
$i++;
} // while
$standartplatzhalter=array
(
"{HEADER}" => $GLOBALS['templateforsoktdata']['_HTML_HEAD'],
"{FOOTER}" => '</body></html>',
"{TITLE}" => $GLOBALS['templateforsoktdata']['_TITLE'],
"{tpl_title}" => $tpl_title,
"{PHP_SELF}" => $_SERVER['PHP_SELF'],
"ä" => "ä",
"ö" => "ö",
"ü" => "ü",
"Ä" => "Ä",
"Ö" => "Ö",
"Ü" => "Ü",
"<br>" => "<br />",
"<hr>" => "<hr />"
);
foreach ( $standartplatzhalter as $a => $b )
{
$templates = str_replace( $a , $b , $templates );
}
fclose($fp);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
return $templates;
}
}
?>