Frontend module vor Rain added

git-svn-id: file:///home/jan/tmp/wetterstation/trunk@27 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
losinshi 2006-08-18 19:43:54 +00:00
parent 1b6938fa41
commit 7d9466a0d2
5 changed files with 42 additions and 19 deletions

View File

@ -1 +1 @@
{content:addModule:temp_1}{content:addModule:temp_4} {content:addModule:rain_3}{content:addModule:temp_1}{content:addModule:temp_4}

View File

@ -1,4 +1,4 @@
<h3 class="mod_headline">Temparatur - {content:fill:sens_location}</h3> <h3 class="mod_headline">Temperatur - {content:fill:sens_location}</h3>
<p class="mod_description">{content:fill:sens_description}</p> <p class="mod_description">{content:fill:sens_description}</p>
<h4 class="mod_subhead">Momentane Werte</h4> <h4 class="mod_subhead">Momentane Werte</h4>
<table class="mod_temp_now_data"> <table class="mod_temp_now_data">

View File

@ -1,12 +1,15 @@
<? <?
/* Connection-Klasse..ist für die Datenbankverbindung zuständig */
class Connection{ class Connection{
var $conn = NULL; var $conn = NULL; /* Verbindung */
/* Konstruktor */
function Connection(){ function Connection(){
$this->conn = NULL; $this->conn = NULL;
} }
/* Verbindung herstellen (wenn noch net besteht)*/
function _createConn(){ function _createConn(){
if($this->conn == NULL){ if($this->conn == NULL){
$this->conn = pg_connect("host=141.30.228.39 dbname=wetter user=losinshi") $this->conn = pg_connect("host=141.30.228.39 dbname=wetter user=losinshi")
@ -14,6 +17,7 @@ class Connection{
} }
} }
/* Verbindung schließen */
function closeConn(){ function closeConn(){
if($this->conn != NULL){ if($this->conn != NULL){
pg_close($this->conn); pg_close($this->conn);
@ -21,6 +25,7 @@ class Connection{
} }
} }
/* Eine Zeile holen */
function fetchQueryResultLine($query){ function fetchQueryResultLine($query){
$this->_createConn(); $this->_createConn();
$result = pg_query($this->conn, $query) $result = pg_query($this->conn, $query)
@ -30,6 +35,7 @@ class Connection{
return $array; return $array;
} }
/* mehrere Zeilen holen */
function fetchQueryResultSet($query){ function fetchQueryResultSet($query){
$returnArray = array(); $returnArray = array();
$this->_createConn(); $this->_createConn();

View File

@ -1,8 +1,10 @@
<? <?
include_once("php_inc/parser.inc.php"); include_once("php_inc/parser.inc.php"); /* Parser */
include_once("php_inc/sensor.inc.php"); include_once("php_inc/sensor.inc.php"); /* Sensor-Klasse */
include_once("php_inc/temp.inc.php"); include_once("php_inc/temp.inc.php"); /* Temp-Klasse */
include_once("php_inc/rain.inc.php"); /* Rain-Klasse */
/* Representiert ein Modul */
class Module{ class Module{
var $sensId; /* Sensor-Id */ var $sensId; /* Sensor-Id */
@ -11,43 +13,54 @@ class Module{
var $connectionInstance = NULL; /* Connection - Instanz */ var $connectionInstance = NULL; /* Connection - Instanz */
var $sensInstance = NULL; /* Sensor-Instanz */ var $sensInstance = NULL; /* Sensor-Instanz */
var $tempInstance = NULL; /* Temp-Instanz */ var $tempInstance = NULL; /* Temp-Instanz */
var $rainInstance = NULL; /* Rain-Instanz */
/* Konstruktor */
function Module($modName, $sensId, &$parser, &$connection){ function Module($modName, $sensId, &$parser, &$connection){
/* Klassenvariablen zuordnen */
$this->sensId = $sensId; $this->sensId = $sensId;
$this->connection = &$connection; $this->connection = &$connection;
$this->parserInstance = &$parser; $this->parserInstance = &$parser;
$parser->parseContent($this->_getModuleFilename("frame"), & $this, "top"); /* Oberen Modulrahmen parsen */
$parser->parseContent($this->_getModuleFilename("frame"), & $this, "top"); $parser->parseContent($this->_getModuleFilename($modName), & $this, NULL); /* Modul Parsen */
$parser->parseContent($this->_getModuleFilename($modName), & $this, NULL); $parser->parseContent($this->_getModuleFilename("frame"), & $this, "bottom"); /* unteren Modulrahmen Parsen */
$parser->parseContent($this->_getModuleFilename("frame"), & $this, "bottom");
} }
/* Dateinamen des Modul-Files zusammenbauen */
function _getModuleFilename($modName){ function _getModuleFilename($modName){
return "content/modules/mod_".$modName.".html"; return "content/modules/mod_".$modName.".html";
} }
/* Instanz der Sensorklasse holen */
function &_get_sens(){ function &_get_sens(){
if($this->sensInstance == NULL) if($this->sensInstance == NULL)
$this->sensInstance = new Sensor($this->sensId, $this->connection); $this->sensInstance = new Sensor($this->sensId, $this->connection);
return $this->sensInstance; return $this->sensInstance;
} }
/* Instanz der Temp-Klasse holen */
function &_get_temp(){ function &_get_temp(){
if($this->tempInstance == NULL) if($this->tempInstance == NULL)
$this->tempInstance = new Temp($this->sensId, $this->connection); $this->tempInstance = new Temp($this->sensId, $this->connection);
return $this->tempInstance; return $this->tempInstance;
} }
function fill($contentId){ /* Instanz der Rain-Klasse holen */
$content_split = explode("_", $contentId); function &_get_rain(){
$callObject = & call_user_method("_get_".$content_split[0], $this); if($this->rainInstance == NULL)
$funcName = "get".substr($contentId, strlen($content_split[0]), strlen($contentId)-strlen($content_split[0])); $this->rainInstance = new Rain($this->sensId, $this->connection);
return $this->rainInstance;
}
return $callObject->$funcName($content_split[1]); /* Callback-Funktion, wird ausgeführt wenn {content:fill:xyz} gefunden wird */
function fill($contentId){
$content_split = explode("_", $contentId); /* Modultyp bekommen */
$callObject = & call_user_method("_get_".$content_split[0], $this); /* Instanz der zum Modul gehörenden Klasse */
$funcName = "get".substr($contentId, strlen($content_split[0]), strlen($contentId)-strlen($content_split[0])); /* Namen der In der Instanz aufzurufenden Methode zusammenbauen */
return $callObject->$funcName($content_split[1]); /* Methode ausführen (Wert holen) und zurückgeben */
} }
} }

View File

@ -15,6 +15,10 @@ class ModuleSet{
$parser->parseContent($this->_getSetFilename($setName), &$this, NULL); /* Set Parsen */ $parser->parseContent($this->_getSetFilename($setName), &$this, NULL); /* Set Parsen */
$parser->printContent(); $parser->printContent();
if ($this->connInstance != NULL){
$this->connInstance->closeConn();
}
} }
/* Dateinamen eines Setz aus dessen Namen zusammenbauen */ /* Dateinamen eines Setz aus dessen Namen zusammenbauen */