Initial Webfrontend checkin.

The Parser-module is from one of my older Projects


git-svn-id: file:///home/jan/tmp/wetterstation/trunk@20 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
losinshi 2006-08-16 01:40:59 +00:00
parent 448bccefab
commit af13f08de7
6 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<h3 class="mod_headline">Temparatur - {content:fill:pre:location}</h3>
<p class="mod_description">{content:fill:pre:description}</p>
<h4 class="mod_subhead">Momentane Werte</h4>
<table class="mod_temp_now_data">
<tr>
<td>Momentan:</td><td>{content:fill:pre:temp_now_val}</td><td>{content:fill:pre:temp_now_date}</td>
</tr>
<tr>
<td>Durchschnitt (halbe std.):</td><td>{content:fill:pre:temp_av_value}</td><td>&nbsp;</td>
</tr>
<tr>
<td>Tendenz (2 std.):</td><td>{content:fill:pre:temp_changing}</td><td>&nbsp;</td>
</tr>
</table>
<h4>Extrema</h4>
<table>
<tr>
<td>Max:</td><td>{content:fill:pre:temp_max_val}</td><td>{content:fill:pre:temp_max_date}</td>
</tr>
<tr>
<td>Min:</td><td>{content:fill:pre:temp_min_val}</td><td>{content:fill:pre:temp_min_date}</td>
</tr>
</table>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,12 @@
<?
class Module{
var parserInstance = NULL; /* Parser - Instanz */
var connectionInstance = NULL; /* Connection - Instanz */
function Module($modName, $sensId, $parser, $connection){
}
}
?>

View File

@ -0,0 +1,35 @@
<?
include_once("php_inc/module.inc.php");
include_once("php_inc/parser.inc.php");
/* Klasse, die die ModuleSets Verwaltet */
class ModuleSet{
var $connInstance = NULL; /* Instanz der Verbindungs-Klasse */
var $parserInstance = NULL; /* Instanz des Parsers */
/* Konstruktor */
function ModuleSet($setName){
$parser = $this->getParserInstance(); /* Parserinstanz holen */
$parser->parseContent($this->getSetFilename($setName), $this, NULL); /* Set Parsen */
}
/* Dateinamen eines Setz aus dessen Namen zusammenbauen */
function getSetFilename($setName){
return "content/module_sets/set_".$setName.".html";
}
/* Parser Instanzieren (wenn noch nicht ist) und zurückgeben */
function getParserInstance(){
if($this->parserInstance==NULL)
$parserInstance = new Parser();
return $parserInstance;
}
/* Ein Modul hinzufügen */
function addModule($modName){
$params = explode("_",$modName); /* Modulname und Sensorid trennen */
include("content/modules/mod_".$params[0].".html");
}
}
?>

View File

@ -0,0 +1,74 @@
<?
class Parser{
var $contentArray;
function Parser(){
$this->contentArray = array();
}
function getContentArray(){
return $this->contentArray;
}
/* Fügt Inhalt in das Inhalts-Array ein */
function appendContent($newContent){
if(is_array($newContent)){
for($i = 0; $i < count($newContent); $i++){
array_push($this->contentArray, $newContent[$i]);
}
} else {
array_push($this->contentArray, $newContent);
}
}
/* Zeigt den Geparsten Inhalt an */
function printContent(){
$array = &$this->getContentArray();
for ($i = 0; $i < count($array); $i++){
echo $array[$i];
}
}
function parseContent($fileName, $callingObject, $filePart=null){
$fileArray = file($fileName); /* File als Array einlesen */
if($filePart != null){
$fileArray = $this->_fetchFilePart(&$fileArray, $filePart); /* Wenn File aus mehreren Template-Teilen besteht, dann wird hir der relevante Zeil geholt */
}
for($i = 0; $i < count($fileArray); $i++){ /* Das Array durchlaufen ... */
if(0 != preg_match_all("/\{content:([a-z]+):([a-z0-9_]+)\}/i", $fileArray[$i], $results)){
print_r($results);
for($j = 0; $j < count($results[1]); $j++){
$callingObject->$results[1][$j]($results[2][$j]);
//$fileArray[$i] = preg_replace("/\{content:fill:".$results[1][$j]."\}/i", $fileContents[$results[1][$j]], $fileArray[$i]);
}
}
}
//$this->appendContent($fileArray);
}
/* Sucht innerhalb eines Template-Files nach dem richtigem Template-stück
* und pappt es in ein neues Array */
function _fetchFilePart($fileArray, $filePart){
$inPart = false; /* Flag ob innerhalb des gesuchten Templates Initialisieren */
$newArray = array(); /* Neues File-Array */
for($i = 0; $i < count($fileArray); $i++){ /* Altes Array dtrchlaufen */
if($inPart){
if(preg_match("/\{content:part:end\}/i", $fileArray[$i])){ /* Wenn im gesuchtem Template, dann nach {content:part:end\} suchen */
$inPart = false; /* ...wenn gefunden Flag wieder False setzen */
break; /* ...und Schleife abbrechen */
} else {
array_push($newArray, $fileArray[$i]); /* An sonsten Zeile zum neuem Array hinzufügen */
}
} else { /* Wenn nich im gesuchtem Template */
if(preg_match("/\{content:part:".$filePart."\}/i", $fileArray[$i])){ /* Nach dem Anfang des Templates suchen */
$inPart = true; /* und wenn gefunden, dann Flaf true setzen */
}
}
}
return $newArray; /* Neues Array zurueckgeben */
}
}
?>