diff --git a/webstuff/frontend/content/modules/mod_temp.html b/webstuff/frontend/content/modules/mod_temp.html new file mode 100644 index 0000000..9988222 --- /dev/null +++ b/webstuff/frontend/content/modules/mod_temp.html @@ -0,0 +1,23 @@ +

Temparatur - {content:fill:pre:location}

+

{content:fill:pre:description}

+

Momentane Werte

+ + + + + + + + + + +
Momentan:{content:fill:pre:temp_now_val}{content:fill:pre:temp_now_date}
Durchschnitt (halbe std.):{content:fill:pre:temp_av_value} 
Tendenz (2 std.):{content:fill:pre:temp_changing} 
+

Extrema

+ + + + + + + +
Max:{content:fill:pre:temp_max_val}{content:fill:pre:temp_max_date}
Min:{content:fill:pre:temp_min_val}{content:fill:pre:temp_min_date}
diff --git a/webstuff/frontend/php_inc/config.inc.php b/webstuff/frontend/php_inc/config.inc.php new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/webstuff/frontend/php_inc/config.inc.php @@ -0,0 +1 @@ + diff --git a/webstuff/frontend/php_inc/connection.inc.php b/webstuff/frontend/php_inc/connection.inc.php new file mode 100644 index 0000000..e69de29 diff --git a/webstuff/frontend/php_inc/module.inc.php b/webstuff/frontend/php_inc/module.inc.php new file mode 100644 index 0000000..65ee12d --- /dev/null +++ b/webstuff/frontend/php_inc/module.inc.php @@ -0,0 +1,12 @@ + diff --git a/webstuff/frontend/php_inc/module_set.inc.php b/webstuff/frontend/php_inc/module_set.inc.php new file mode 100644 index 0000000..9b620e5 --- /dev/null +++ b/webstuff/frontend/php_inc/module_set.inc.php @@ -0,0 +1,35 @@ +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"); + } +} +?> diff --git a/webstuff/frontend/php_inc/parser.inc.php b/webstuff/frontend/php_inc/parser.inc.php new file mode 100644 index 0000000..49d0bd3 --- /dev/null +++ b/webstuff/frontend/php_inc/parser.inc.php @@ -0,0 +1,74 @@ +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 */ + } + +} +?>