1
0
mirror of https://github.com/agdsn/ancient-weatherstation.git synced 2026-06-19 23:07:59 +00:00

charts added to webfrontend

git-svn-id: file:///home/jan/tmp/wetterstation/trunk@114 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
losinshi
2006-09-18 17:58:25 +00:00
parent cac1a73c77
commit 504ee3b339
8 changed files with 211 additions and 2 deletions
+68
View File
@@ -0,0 +1,68 @@
<?
include_once("php_inc/config.inc.php");
class Chart{
function Chart($template, &$parser){
$parser->parseContent($this->_getTemplateFileName("frame"), & $this, "top"); /* Oberen Modulrahmen parsen */
$parser->parseContent($this->_getTemplateFileName($template), & $this, NULL); /* Modul Parsen */
$parser->parseContent($this->_getTemplateFileName("frame"), & $this, "bottom"); /* unteren Modulrahmen Parsen */
}
function _getTemplateFileName($template_name){
return "content/charts/chart_".$template_name.".html";
}
function generateChartLink($chartName){
$chartArray = Config::getChartArray($chartName);
$buff = '<div class="chart_link_div">';
$buff .= '<a href="';
$buff .= $_SERVER['PHP_SELF'].'?setType='.$chartArray[4]."&chartName=".$chartName;
$buff .= '" class="chart_link">';
$buff .= $chartArray[1];
$buff .= '<p class="chart_link_desc">';
$buff .= $chartArray[2];
if ($chartArray[3] == null){
$buff .= '<img class="chart_link_prev" width="250" height="100" src="';
$buff .= Chart::_getChartImgLink($chartArray[0]);
$buff .= '">';
} else {
$buff .= '<img class="chart_link_prev" width="250" height="100" src="';
$buff .= Chart::_getChartImgLink($chartArray[3]);
$buff .= '">';
}
$buff .= '</p>';
$buff .= '</a>';
$buff .= '</div>';
return $buff;
}
function _getChartImgLink($img_filename){
return Config::getDefaultChartDir().$img_filename;
}
function _getChartImgTag($chartName){
$chartArray = Config::getChartArray($chartName);
$buff = '<img class="chart_img" src="';
$buff .= Chart::_getChartImgLink($chartArray[0]);
$buff .= '">';
return $buff;
}
function insertChart($chartName){
if($chartName == "auto"){
$chartName = $_REQUEST['chartName'];
}
return Chart::_getChartImgTag($chartName);
}
}
?>
+27 -1
View File
@@ -6,7 +6,24 @@
$pg_pass = "";
/* Default-Werte */
$default_set = "test";
$default_set = "test";
$default_chart_dir = "images/chart/";
/* Graphen - Bilder */
$cImg = array(
/* Bild - Id Dateiname Link - Name Link - Beschreibung Vorschaubild Set */
'temp_test_1' => array( "temp_ex.png", "Beispiel - Temp", "Zeigt den Temparaturverlauf der letzten 10 Tage", null, "chart"),
'hum_test_1' => array( "hum_ex.png", "Beispiel - Hum", "Zeigt den Luftfeuchte - verlauf der letzten 10 Tage", null, "chart"),
'press_test_1' => array( "press_ex.png", "Beispiel - Press", "Zeigt den Luftdruck - verlauf der letzten 10 Tage", null, "chart"),
'' => array( "", "", "", null, "chart")
);
/* Config-Klasse, Bitte nicht ändern! */
class Config{
@@ -21,5 +38,14 @@ class Config{
return $default_set;
}
function getChartArray($chartId){
global $cImg;
return $cImg[$chartId];
}
function getDefaultChartDir(){
global $default_chart_dir;
return $default_chart_dir;
}
}
?>
+9
View File
@@ -1,5 +1,6 @@
<?
include_once("php_inc/parser.inc.php"); /* Parser */
include_once("php_inc/chart.inc.php"); /* Chart */
include_once("php_inc/modules/sensor.inc.php"); /* Sensor-Klasse */
include_once("php_inc/modules/temp.inc.php"); /* Temp-Klasse */
include_once("php_inc/modules/rain.inc.php"); /* Rain-Klasse */
@@ -92,10 +93,18 @@ class Module{
return $callObject->$funcName($content_split[1]); /* Methode ausführen (Wert holen) und zurückgeben */
}
function addChartLink($chartName){
return Chart::generateChartLink($chartName.'_'.$this->sensId);
}
function getModId($type){
if($type == "css")
return $this->modName."_".$this->sensId;
}
function addChart($chartName){
Chart::insertChart($chartName);
}
}
?>
@@ -3,6 +3,7 @@ include_once("php_inc/module.inc.php");
include_once("php_inc/parser.inc.php");
include_once("php_inc/connection.inc.php");
include_once("php_inc/config.inc.php");
include_once("php_inc/chart.inc.php");
/* Klasse, die die ModuleSets Verwaltet */
@@ -15,6 +16,10 @@ class ModuleSet{
$parser = & $this->_getParserInstance(); /* Parserinstanz holen */
$parser->parseContent($this->_getSetFilename($setName), &$this, NULL); /* Set Parsen */
if($_REQUEST['chartName'] != ""){
$parser->appendContent($this->getBackLink());
}
$parser->printContent();
if ($this->connInstance != NULL){
@@ -48,5 +53,21 @@ class ModuleSet{
$params = explode("_",$modName); /* Modulname und Sensorid trennen */
new Module($params[0], $params[1], $this->_getParserInstance(), $this->_getConnInstance());
}
function addChart($template){
new Chart($template, $this->_getParserInstance());
}
function getBackLink(){
$buff = '<div class="back_link_div">';
$buff .= '<a class="back_link" href="';
$buff .= $_SERVER['HTTP_REFERER'];
$buff .= '">';
$buff .= 'zur&uuml;ck';
$buff .= "</a>";
$buff .= "</div>";
return $buff;
}
}
?>