Working on Frontend
git-svn-id: file:///home/jan/tmp/wetterstation/trunk@24 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
parent
162879454a
commit
4249404692
|
|
@ -1,23 +1,23 @@
|
|||
<h3 class="mod_headline">Temparatur - {content:fill:pre:location}</h3>
|
||||
<p class="mod_description">{content:fill:pre:description}</p>
|
||||
<h3 class="mod_headline">Temparatur - {content:fill:sens_location}</h3>
|
||||
<p class="mod_description">{content:fill:sens_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>
|
||||
<td>Momentan:</td><td>{content:fill:temp_now_val}</td><td>{content:fill:temp_now_date}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Durchschnitt (halbe std.):</td><td>{content:fill:pre:temp_av_value}</td><td> </td>
|
||||
<td>Durchschnitt (halbe std.):</td><td>{content:fill:temp_av_value}</td><td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tendenz (2 std.):</td><td>{content:fill:pre:temp_changing}</td><td> </td>
|
||||
<td>Tendenz (2 std.):</td><td>{content:fill:temp_changing}</td><td> </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>
|
||||
<td>Max:</td><td>{content:fill:temp_max_val}</td><td>{content:fill: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>
|
||||
<td>Min:</td><td>{content:fill:temp_min_val}</td><td>{content:fill:temp_min_date}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1,22 +1,50 @@
|
|||
<?
|
||||
include_once("php_inc/parser.inc.php");
|
||||
include_once("php_inc/sensor.inc.php");
|
||||
include_once("php_inc/temp.inc.php");
|
||||
|
||||
class Module{
|
||||
|
||||
var $sensId; /* Sensor-Id */
|
||||
var $connection; /* Connection - Instanz */
|
||||
var $parserInstance = NULL; /* Parser - Instanz */
|
||||
var $connectionInstance = NULL; /* Connection - Instanz */
|
||||
var $sensInstance = NULL; /* Sensor-Instanz */
|
||||
var $tempInstance = NULL; /* Temp-Instanz */
|
||||
|
||||
|
||||
function Module($modName, $sensId, $parser, $connection){
|
||||
$parser->parseContent($this->_getModuleFilename($modName));
|
||||
$this->$sensId = $sensId;
|
||||
$this->$connection = $connection;
|
||||
|
||||
$parser->parseContent($this->_getModuleFilename("frame"), $this, "top");
|
||||
$parser->parseContent($this->_getModuleFilename($modName), $this, NULL);
|
||||
$parser->parseContent($this->_getModuleFilename("frame"), $this, "bottom");
|
||||
}
|
||||
|
||||
function _getModuleFilename($modName){
|
||||
return "/content/modules/mod_".$modName.".html";
|
||||
return "content/modules/mod_".$modName.".html";
|
||||
}
|
||||
|
||||
function _get_sens(){
|
||||
if($sensInstance == NULL)
|
||||
$this->$sensInstance = new Sensor($this->$sensId, $this->$connection);
|
||||
return $this->$sensInstance;
|
||||
}
|
||||
|
||||
function _get_temp(){
|
||||
if($tempInstance == NULL)
|
||||
$this->$tempInstance = new Temp($this->$sensId, $this->$connection);
|
||||
return $this->$tempInstance;
|
||||
}
|
||||
|
||||
function fill($contentId){
|
||||
$content_split = explode("_", $contentId);
|
||||
return $this->"get".$content_split[0]($content_split[1])
|
||||
$callObject = call_user_method("_get_".$content_split[0], $this);
|
||||
$funcName = "get".substr($contentId, strlen($content_split[0]), strlen($contentId)-strlen($content_split[0]));
|
||||
|
||||
echo "\n\naufruf: ".$funcName."()\n\n";
|
||||
return $callObject->$funcName($content_split[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ class ModuleSet{
|
|||
function ModuleSet($setName){
|
||||
$parser = $this->_getParserInstance(); /* Parserinstanz holen */
|
||||
$parser->parseContent($this->_getSetFilename($setName), $this, NULL); /* Set Parsen */
|
||||
|
||||
echo "\n\n";
|
||||
$parser->printContent();
|
||||
}
|
||||
|
||||
/* Dateinamen eines Setz aus dessen Namen zusammenbauen */
|
||||
|
|
@ -21,15 +24,20 @@ class ModuleSet{
|
|||
|
||||
/* Parser Instanzieren (wenn noch nicht ist) und zurückgeben */
|
||||
function _getParserInstance(){
|
||||
if($this->parserInstance==NULL)
|
||||
$parserInstance = new Parser();
|
||||
return $parserInstance;
|
||||
if($this->$parserInstance==NULL)
|
||||
$this->$parserInstance = new Parser();
|
||||
return $this->$parserInstance;
|
||||
}
|
||||
|
||||
function _getConnInstance(){
|
||||
// TODO: Muss noch Implementiert werden!!
|
||||
return $connInstance;
|
||||
}
|
||||
|
||||
/* Ein Modul hinzufügen */
|
||||
function _addModule($modName){
|
||||
function addModule($modName){
|
||||
$params = explode("_",$modName); /* Modulname und Sensorid trennen */
|
||||
include("content/modules/mod_".$params[0].".html");
|
||||
new Module($params[0], $params[1], $this->_getParserInstance(), $this->_getConnInstance());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ class Parser{
|
|||
function appendContent($newContent){
|
||||
if(is_array($newContent)){
|
||||
for($i = 0; $i < count($newContent); $i++){
|
||||
echo "adding: ".$newContent[$i]."\n";
|
||||
array_push($this->contentArray, $newContent[$i]);
|
||||
echo "added: ".$this->contentArray[count($this->contentArray)-1]."\n";
|
||||
}
|
||||
} else {
|
||||
array_push($this->contentArray, $newContent);
|
||||
|
|
@ -23,6 +25,8 @@ class Parser{
|
|||
|
||||
/* Zeigt den Geparsten Inhalt an */
|
||||
function printContent(){
|
||||
echo "\n ---- Printing ----\n";
|
||||
echo "";
|
||||
$array = &$this->getContentArray();
|
||||
for ($i = 0; $i < count($array); $i++){
|
||||
echo $array[$i];
|
||||
|
|
@ -31,20 +35,22 @@ class Parser{
|
|||
|
||||
|
||||
function parseContent($fileName, $callingObject, $filePart=null){
|
||||
echo "\n\nparse: ".$fileName."\n\n";
|
||||
$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 ... */
|
||||
echo "Zeile: ".$i." = ".$fileArray[$i]."\n";
|
||||
if(0 != preg_match_all("/\{content:([a-z]+):([a-z0-9_]+)\}/i", $fileArray[$i], $results)){
|
||||
print_r($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);
|
||||
$this->appendContent($fileArray);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue