From 096a2daaad41ba1538a04bc2dcdb9f247a608e77 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 20 Jul 2010 19:10:45 +0200 Subject: [PATCH] replaced registry by dedicated static class rearanged view and controller factories in dispatcher optimized views --- backend/bin/doctrine.php | 6 +- backend/index.php | 7 +- backend/lib/Controller/Controller.php | 13 --- backend/lib/Dispatcher.php | 63 ++++++++----- backend/lib/Interpreter/Interpreter.php | 4 + backend/lib/Util/Configuration.php | 112 ++++++++++++++++++++++++ backend/lib/Util/Registry.php | 103 ---------------------- backend/lib/View/Csv/Csv.php | 10 ++- backend/lib/View/JpGraph.php | 78 +++++++++++------ backend/lib/View/Json/Json.php | 25 ++++-- backend/lib/View/View.php | 42 ++------- backend/lib/View/Xml/Xml.php | 6 +- backend/volkszaehler.conf.default.php | 9 -- share/tests/configuration.php | 33 +++++++ share/tests/test.php | 25 ++++++ share/tools/install.php | 47 ++++++++++ 16 files changed, 352 insertions(+), 231 deletions(-) create mode 100644 backend/lib/Util/Configuration.php delete mode 100644 backend/lib/Util/Registry.php create mode 100644 share/tests/configuration.php create mode 100644 share/tests/test.php create mode 100644 share/tools/install.php diff --git a/backend/bin/doctrine.php b/backend/bin/doctrine.php index 57b844d..981e1f6 100644 --- a/backend/bin/doctrine.php +++ b/backend/bin/doctrine.php @@ -15,11 +15,13 @@ foreach ($classLoaders as $loader) { $loader->register(); // register on SPL autoload stack } -// load configuration into registry +// load configuration if (!file_exists(BACKEND_DIR . '/volkszaehler.conf.php')) { throw new Exception('No configuration available! Use volkszaehler.conf.default.php as an template'); } -include BACKEND_DIR . '/volkszaehler.conf.php'; +else { + Util\Configuration::load(BACKEND_DIR . '/volkszaehler.conf.php'); +} $em = Volkszaehler\Dispatcher::createEntityManager(); diff --git a/backend/index.php b/backend/index.php index 6f8b4af..0573cb0 100644 --- a/backend/index.php +++ b/backend/index.php @@ -44,12 +44,7 @@ foreach ($classLoaders as $loader) { // enable strict error reporting error_reporting(E_ALL); -// load configuration into registry -if (!file_exists(BACKEND_DIR . '/volkszaehler.conf.php')) { - throw new Exception('No configuration available! Use volkszaehler.conf.default.php as an template'); -} - -include BACKEND_DIR . '/volkszaehler.conf.php'; +Util\Configuration::load(BACKEND_DIR . '/volkszaehler.conf'); $fc = new Dispatcher; // spawn frontcontroller / dispatcher $fc->run(); // execute controller and sends output diff --git a/backend/lib/Controller/Controller.php b/backend/lib/Controller/Controller.php index ca159e0..450e336 100644 --- a/backend/lib/Controller/Controller.php +++ b/backend/lib/Controller/Controller.php @@ -33,19 +33,6 @@ abstract class Controller { $this->em = $em; } - /* - * creates new view instance depending on the requested format - */ - public static function factory(\Volkszaehler\View\View $view, \Doctrine\ORM\EntityManager $em) { - $controller = ucfirst(strtolower($view->request->getParameter('controller'))); - - $controllerClassName = 'Volkszaehler\Controller\\' . $controller; - if (!(\Volkszaehler\Util\ClassLoader::classExists($controllerClassName)) || !is_subclass_of($controllerClassName, '\Volkszaehler\Controller\Controller')) { - throw new \InvalidArgumentException('\'' . $controllerClassName . '\' is not a valid controller'); - } - return new $controllerClassName($view, $em); - } - /** * run controller actions * diff --git a/backend/lib/Dispatcher.php b/backend/lib/Dispatcher.php index 8badede..e556b52 100644 --- a/backend/lib/Dispatcher.php +++ b/backend/lib/Dispatcher.php @@ -30,30 +30,54 @@ use Volkszaehler\Util; */ final class Dispatcher { // MVC - private $em = NULL; // Model (Doctrine EntityManager) - private $view = NULL; // View - private $controller = NULL; // Controller + protected $em; // Model (Doctrine EntityManager) + protected $view; // View + protected $controller; // Controller /* * constructor */ public function __construct() { + // create HTTP request & response (needed to initialize view & controller) $request = new View\Http\Request(); $response = new View\Http\Response(); - $format = $request->getParameter('format'); + $format = ($request->getParameter('format')) ? $request->getParameter('format') : 'json'; // default action $controller = $request->getParameter('controller'); + // initialize entity manager $this->em = Dispatcher::createEntityManager(); - $this->view = View\View::factory($request, $response); - $this->controller = Controller\Controller::factory($this->view, $this->em); + + // initialize view + if (in_array($format, array('png', 'jpeg', 'gif'))) { + $this->view = new View\JpGraph($request, $response, $format); + } + else { + if ($controller == 'data' && ($format == 'json' || $format == 'xml')) { + $controller = 'channel'; + } + + $viewClassName = 'Volkszaehler\View\\' . ucfirst($format) . '\\' . ucfirst($controller); + if (!(\Volkszaehler\Util\ClassLoader::classExists($viewClassName)) || !is_subclass_of($viewClassName, '\Volkszaehler\View\View')) { + throw new \InvalidArgumentException('\'' . $viewClassName . '\' is not a valid View'); + } + + $this->view = new $viewClassName($request, $response); + } + + // initialize controller + $controllerClassName = 'Volkszaehler\Controller\\' . ucfirst(strtolower($request->getParameter('controller'))); + if (!(\Volkszaehler\Util\ClassLoader::classExists($controllerClassName)) || !is_subclass_of($controllerClassName, '\Volkszaehler\Controller\Controller')) { + throw new \InvalidArgumentException('\'' . $controllerClassName . '\' is not a valid controller'); + } + $this->controller = new $controllerClassName($this->view, $this->em); } /** * execute application */ public function run() { - $action = (is_null($this->view->request->getParameter('action'))) ? 'get' : $this->view->request->getParameter('action'); // default action + $action = ($this->view->request->getParameter('action')) ? 'get' : $this->view->request->getParameter('action'); // default action $this->controller->run($action); // run controllers actions (usually CRUD: http://de.wikipedia.org/wiki/CRUD) $this->view->render(); // render view & send http response @@ -62,30 +86,27 @@ final class Dispatcher { /** * factory for doctrines entitymanager * - * @todo create extra singleton class or registry? + * @todo create extra singleton class? */ public static function createEntityManager() { - $vzConfig = Util\Registry::get('config'); - - // Doctrine - $dcConfig = new \Doctrine\ORM\Configuration; + $config = new \Doctrine\ORM\Configuration; if (extension_loaded('apc')) { $cache = new \Doctrine\Common\Cache\ApcCache; - $dcConfig->setMetadataCacheImpl($cache); - $dcConfig->setQueryCacheImpl($cache); + $config->setMetadataCacheImpl($cache); + $config->setQueryCacheImpl($cache); } - $driverImpl = $dcConfig->newDefaultAnnotationDriver(BACKEND_DIR . '/lib/Model'); - $dcConfig->setMetadataDriverImpl($driverImpl); + $driverImpl = $config->newDefaultAnnotationDriver(BACKEND_DIR . '/lib/Model'); + $config->setMetadataDriverImpl($driverImpl); - $dcConfig->setProxyDir(BACKEND_DIR . '/lib/Model/Proxies'); - $dcConfig->setProxyNamespace('Volkszaehler\Model\Proxies'); - $dcConfig->setAutoGenerateProxyClasses(DEV_ENV == true); + $config->setProxyDir(BACKEND_DIR . '/lib/Model/Proxies'); + $config->setProxyNamespace('Volkszaehler\Model\Proxies'); + $config->setAutoGenerateProxyClasses(DEV_ENV == true); - $dcConfig->setSQLLogger(Util\Debug::getSQLLogger()); + $config->setSQLLogger(Util\Debug::getSQLLogger()); - $em = \Doctrine\ORM\EntityManager::create($vzConfig['db'], $dcConfig); + $em = \Doctrine\ORM\EntityManager::create(Util\Configuration::read('db'), $config); return $em; } diff --git a/backend/lib/Interpreter/Interpreter.php b/backend/lib/Interpreter/Interpreter.php index a332956..e173774 100644 --- a/backend/lib/Interpreter/Interpreter.php +++ b/backend/lib/Interpreter/Interpreter.php @@ -66,6 +66,10 @@ abstract class Interpreter implements InterpreterInterface { case 'minute': $sqlGroupBy = 'YEAR(' . $ts . '), DAYOFYEAR(' . $ts . '), HOUR(' . $ts . '), MINUTE(' . $ts . ')'; break; + + case 'second': + $sqlGroupBy = 'YEAR(' . $ts . '), DAYOFYEAR(' . $ts . '), HOUR(' . $ts . '), MINUTE(' . $ts . '), SECOND(' . $ts . ')'; + break; default: if (is_numeric($groupBy)) { // lets agrregate it with php diff --git a/backend/lib/Util/Configuration.php b/backend/lib/Util/Configuration.php new file mode 100644 index 0000000..94fb492 --- /dev/null +++ b/backend/lib/Util/Configuration.php @@ -0,0 +1,112 @@ + + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License (either version 2 or + * version 3) as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * For more information on the GPL, please go to: + * http://www.gnu.org/copyleft/gpl.html + */ + +namespace Volkszaehler\Util; + +class Configuration { + static public $values = array(); // TODO protected + + static public function write($var, $value) { + if (!is_scalar($value) && !is_array($value)) { + throw new \Exception('sry we can\'t store this datatype in the configuration'); + } + + $values =& self::$values; + $tree = explode('.', $var); + foreach ($tree as $part) { + $values =& $values[$part]; + } + + $values = $value; + } + + static public function read($var = NULL) { + $tree = explode('.', $var); + + if (is_null($var)) { + return self::$values; + } + + $values = self::$values; + foreach ($tree as $part) { + $values = $values[$part]; + } + + return $values; + } + + static public function delete($var) { + + } + + /* + * configuration file handling + */ + static public function load($filename) { + $filename .= '.php'; + + if (!file_exists($filename)) { + throw new \Exception('configuration file not found: ' . $filename); + } + + include $filename; + + if (!isset($config)) { + throw new \Exception('no variable $config found in ' . $filename); + } + + self::$values = $config; + } + + static public function store($filename) { + $filename .= '.php'; + + $delcaration = ''; + foreach (self::$values as $key => $value) { + $export = var_export($value, true); + $export = preg_replace('/=>\s+array/', '=> array', $export); + $export = str_replace(" ", "\t", $export); + + $declaration .= '$config[\'' . $key . '\'] = ' . $export . ';' . PHP_EOL . PHP_EOL; + } + + $content = << +EOT; + return file_put_contents($filename, $content); + } +} + +?> \ No newline at end of file diff --git a/backend/lib/Util/Registry.php b/backend/lib/Util/Registry.php deleted file mode 100644 index 644db1c..0000000 --- a/backend/lib/Util/Registry.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License (either version 2 or - * version 3) as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * For more information on the GPL, please go to: - * http://www.gnu.org/copyleft/gpl.html - */ - -namespace Volkszaehler\Util; - -/** - * Registry class to pass global variables between classes. - */ -abstract class Registry { - /** - * Object registry provides storage for shared objects - * - * @var array - */ - protected static $registry = array(); - - /** - * Adds a new variable to the Registry. - * - * @param string $key Name of the variable - * @param mixed $value Value of the variable - * @throws Exception - * @return bool - */ - public static function set($key, $value) { - if (!isset(self::$registry[$key])) { - self::$registry[$key] = $value; - return true; - } else { - throw new \Exception('Unable to set variable `' . $key . '`. It was already set.'); - } - } - - /** - * Returns the value of the specified $key in the Registry. - * - * @param string $key Name of the variable - * @return mixed Value of the specified $key - */ - public static function get($key) - { - if (isset(self::$registry[$key])) { - return self::$registry[$key]; - } - return null; - } - - /** - * Returns the whole Registry as an array. - * - * @return array Whole Registry - */ - public static function getAll() - { - return self::$registry; - } - - /** - * Removes a variable from the Registry. - * - * @param string $key Name of the variable - * @return bool - */ - public static function remove($key) - { - if (isset(self::$registry[$key])) { - unset(self::$registry[$key]); - return true; - } - return false; - } - - /** - * Removes all variables from the Registry. - * - * @return void - */ - public static function removeAll() - { - self::$registry = array(); - return; - } -} - -?> \ No newline at end of file diff --git a/backend/lib/View/Csv/Csv.php b/backend/lib/View/Csv/Csv.php index d10b7e3..c713469 100644 --- a/backend/lib/View/Csv/Csv.php +++ b/backend/lib/View/Csv/Csv.php @@ -21,6 +21,8 @@ namespace Volkszaehler\View\Csv; +use Volkszaehler\Util; + abstract class Csv extends \Volkszaehler\View\View { protected $csv = array(); protected $header = array(); @@ -35,8 +37,8 @@ abstract class Csv extends \Volkszaehler\View\View { $this->header[] = 'source: volkszaehler.org'; $this->header[] = 'version: ' . \Volkszaehler\VERSION; - $this->response->setHeader('Content-type', 'text/csv'); - $this->response->setHeader('Content-Disposition', 'attachment; filename="data.csv"'); + $this->response->setHeader('Content-type', 'text/plain'); + //$this->response->setHeader('Content-Disposition', 'attachment; filename="data.csv"'); } public function render() { @@ -60,13 +62,13 @@ abstract class Csv extends \Volkszaehler\View\View { } public function addDebug() { - $config = \Volkszaehler\Util\Registry::get('config'); $this->footer[] = 'time: ' . $this->getTime(); - $this->footer[] = 'database: ' . $config['db']['driver']; + $this->footer[] = 'database: ' . Util\Configuration::read('db.driver'); foreach (\Volkszaehler\Util\Debug::getSQLLogger()->queries as $query) { $this->footer[] = 'query: ' . $query['sql']; + $this->footer[] = ' parameters: ' . implode(', ', $query['parameters']); } } diff --git a/backend/lib/View/JpGraph.php b/backend/lib/View/JpGraph.php index 37db0bf..88f0515 100644 --- a/backend/lib/View/JpGraph.php +++ b/backend/lib/View/JpGraph.php @@ -32,34 +32,44 @@ require_once \Volkszaehler\BACKEND_DIR . '/lib/vendor/JpGraph/jpgraph_date.php'; * @todo unifiy axes of same unit */ class JpGraph extends View { - protected $width = 800; - protected $height = 600; + /* + * indicator => ynaxis[n] mapping + */ + protected $axes = array(); protected $channels = array(); + protected $width = 800; + protected $height = 400; + protected static $colors = array('chartreuse', 'chocolate1', 'cyan', 'blue', 'lightcyan4', 'gold'); protected $graph; + /* + * constructor + */ public function __construct(Http\Request $request, Http\Response $response, $format) { parent::__construct($request, $response); $this->graph = new \Graph($this->width,$this->height); + + $this->graph->img->SetImgFormat($format); // Specify what scale we want to use, $this->graph->SetScale('datlin'); - $this->graph->legend->setPos(0.15,0.025, 'left', 'top'); + $this->graph->legend->SetPos(0.1,0.02, 'left', 'top'); + $this->graph->legend->SetShadow(false); $this->graph->SetMarginColor('white'); - $this->graph->SetMargin(90,65,10,90); $this->graph->SetYDeltaDist(65); $this->graph->yaxis->SetTitlemargin(36); $this->graph->SetTickDensity(TICKD_DENSE, TICKD_SPARSE); $this->graph->xaxis->SetFont(FF_ARIAL); - $this->graph->xaxis->SetLabelAngle(60); + $this->graph->xaxis->SetLabelAngle(45); $this->graph->xaxis->SetLabelFormatCallback(function($label) { return date('j.n.y G:i', $label); }); //$this->graph->img->SetAntiAliasing(); @@ -73,51 +83,63 @@ class JpGraph extends View { $yData[] = $reading['value']; } - // Create the linear plot + // Create the scatter plot $plot = new \ScatterPlot($yData, $xData); - $plot->setLegend($obj->getName() . ': ' . $obj->getDescription() . ' [' . $obj->getUuid() . ']'); + $plot->setLegend($obj->getName() . ': ' . $obj->getDescription() . ' [' . $obj->getUnit() . ']'); + $plot->SetLinkPoints(true, self::$colors[$count]); $plot->mark->SetColor(self::$colors[$count]); $plot->mark->SetFillColor(self::$colors[$count]); - $plot->mark->SetType(MARK_DIAMOND); $plot->mark->SetWidth(1); - $plot->SetLinkPoints(true, self::$colors[$count]); - if ($count == 0) { - $yaxis = $this->graph->yaxis; - $this->graph->Add($plot); + $axis = $this->getAxisIndex($obj); + if ($axis >= 0) { + $this->graph->AddY($axis, $plot); } else { - $this->graph->SetYScale($count-1,'lin'); - $yaxis = $this->graph->ynaxis[$count-1]; - $this->graph->SetMargin(60,($count) * 65,10,90); - $this->graph->AddY($count-1, $plot); + $this->graph->Add($plot); } - $yaxis->title->Set($obj->getUnit()); - $yaxis->title->SetFont(FF_ARIAL); - $yaxis->SetColor(self::$colors[$count]); - $yaxis->SetTitleMargin('50'); - $this->channels[] = $obj; } - public function addException(\Exception $e) { echo $e; } - public function addDebug() {} - - public static function factory(Http\Request $request, Http\Response $response) { - + protected function getAxisIndex(\Volkszaehler\Model\Channel $obj) { + if (!in_array($obj->getIndicator(), array_keys($this->axes))) { + $count =count($this->axes); + if ($count == 0) { + $this->axes[$obj->getIndicator()] = -1; + + $yaxis = $this->graph->yaxis; + } + else { + $this->axes[$obj->getIndicator()] = $count - 1; + + $this->graph->SetYScale($this->axes[$obj->getIndicator()],'lin'); + + $yaxis = $this->graph->ynaxis[$this->axes[$obj->getIndicator()]]; + } + + $yaxis->title->Set($obj->getUnit()); + + $yaxis->SetFont(FF_ARIAL); + $yaxis->title->SetFont(FF_ARIAL); + + $yaxis->SetTitleMargin('50'); + } + + return $this->axes[$obj->getIndicator()]; } - + public function render() { + $this->graph->SetMargin(75, (count($this->axes) - 1) * 65 + 10, 20, 90); + // Display the graph $this->graph->Stroke(); parent::render(); } - } ?> \ No newline at end of file diff --git a/backend/lib/View/Json/Json.php b/backend/lib/View/Json/Json.php index 25e1163..43a1254 100644 --- a/backend/lib/View/Json/Json.php +++ b/backend/lib/View/Json/Json.php @@ -39,13 +39,22 @@ abstract class Json extends \Volkszaehler\View\View { } public function render() { - echo self::format(json_encode($this->json)); - parent::render(); + // TODO solve rendering order problem + + $json = json_encode($this->json); + + if ($this->request->getParameter('debug')) { + echo self::format($json); + } + else { + echo $json; + } + + } protected static function format($json) { - $tab = "\t"; $formatted = ''; $indentLevel = 0; $inString = false; @@ -59,21 +68,21 @@ abstract class Json extends \Volkszaehler\View\View { $formatted .= $char; if (!$inString && (ord($json[$c+1]) != ord($char)+2)) { $indentLevel++; - $formatted .= "\n" . str_repeat($tab, $indentLevel); + $formatted .= "\n" . str_repeat("\t", $indentLevel); } break; case '}': case ']': if (!$inString && (ord($json[$c-1]) != ord($char)-2)) { $indentLevel--; - $formatted .= "\n" . str_repeat($tab, $indentLevel); + $formatted .= "\n" . str_repeat("\t", $indentLevel); } $formatted .= $char; break; case ',': $formatted .= $char; if (!$inString) { - $formatted .= "\n" . str_repeat($tab, $indentLevel); + $formatted .= "\n" . str_repeat("\t", $indentLevel); } break; case ':': @@ -96,10 +105,8 @@ abstract class Json extends \Volkszaehler\View\View { } public function addDebug() { - $config = Util\Registry::get('config'); - $this->json['debug'] = array('time' => $this->getTime(), - 'database' => array('driver' => $config['db']['driver'], + 'database' => array('driver' => Util\Configuration::read('db.driver'), 'queries' => Util\Debug::getSQLLogger()->queries) ); diff --git a/backend/lib/View/View.php b/backend/lib/View/View.php index ee0f685..6177766 100644 --- a/backend/lib/View/View.php +++ b/backend/lib/View/View.php @@ -21,12 +21,7 @@ namespace Volkszaehler\View; -interface ViewInterface { - public function addException(\Exception $e); - public function addDebug(); -} - -abstract class View implements ViewInterface { +abstract class View { public $request; protected $response; @@ -44,33 +39,6 @@ abstract class View implements ViewInterface { set_error_handler(array($this, 'errorHandler')); } - /* - * creates new view instance depending on the requested format - * @todo improve mapping - */ - public static function factory(Http\Request $request, Http\Response $response) { - $format = strtolower($request->getParameter('format')); - $controller = strtolower($request->getParameter('controller')); - - if (in_array($format, array('png', 'jpg'))) { - $view = new JpGraph($request, $response, $format); - } - else { - if ($controller == 'data' && ($format == 'json' || $format == 'xml')) { - $controller = 'channel'; - } - $viewClassName = 'Volkszaehler\View\\' . ucfirst($format) . '\\' . ucfirst($controller); - - if (!(\Volkszaehler\Util\ClassLoader::classExists($viewClassName)) || !is_subclass_of($viewClassName, '\Volkszaehler\View\View')) { - throw new \InvalidArgumentException('\'' . $viewClassName . '\' is not a valid View'); - } - - $view = new $viewClassName($request, $response); - } - - return $view; - } - /* * error & exception handling */ @@ -102,4 +70,12 @@ abstract class View implements ViewInterface { $this->response->send(); } + + public function addException(\Exception $e) { + echo $e; + } + + public function addDebug() { + + } } \ No newline at end of file diff --git a/backend/lib/View/Xml/Xml.php b/backend/lib/View/Xml/Xml.php index d403c28..0aeff02 100644 --- a/backend/lib/View/Xml/Xml.php +++ b/backend/lib/View/Xml/Xml.php @@ -22,6 +22,8 @@ namespace Volkszaehler\View\Xml; // TODO outdated +use Volkszaehler\Util; + abstract class Xml extends \Volkszaehler\View\View { protected $xmlDoc; @@ -57,12 +59,10 @@ abstract class Xml extends \Volkszaehler\View\View { } public function addDebug() { - $config = \Volkszaehler\Util\Registry::get('config'); - $xmlDebug = $this->xmlDoc->createElement('debug'); $xmlDebug->appendChild($this->xmlDoc->createElement('time', $this->getTime())); - $xmlDebug->appendChild($this->xmlDoc->createElement('database', $config['db']['driver'])); + $xmlDebug->appendChild($this->xmlDoc->createElement('database', Util\Configuration::read('db.driver'))); // TODO add queries diff --git a/backend/volkszaehler.conf.default.php b/backend/volkszaehler.conf.default.php index 1a8dcd5..91d4737 100644 --- a/backend/volkszaehler.conf.default.php +++ b/backend/volkszaehler.conf.default.php @@ -25,15 +25,6 @@ $config['db']['user'] = 'volkszaehler'; $config['db']['password'] = ''; $config['db']['dbname'] = 'volkszaehler'; -$config['passthru']['enabled'] = false; -$config['passthru']['url'] = 'http://volkszaehler.org/httplog/httplog.php?&passthru=yes'; - $config['debug'] = false; -// insert configuration into registry -Registry::set('config', $config); - -// unset registry from page context -unset($config); - ?> diff --git a/share/tests/configuration.php b/share/tests/configuration.php new file mode 100644 index 0000000..d1b82ba --- /dev/null +++ b/share/tests/configuration.php @@ -0,0 +1,33 @@ + + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License (either version 2 or + * version 3) as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * For more information on the GPL, please go to: + * http://www.gnu.org/copyleft/gpl.html + */ + +use Volkszaehler\Util; +include '../../backend/lib/Util/Configuration.php'; +echo '
';
+
+Util\Configuration::load('config_test');
+
+var_dump(Util\Configuration::read());
+
+Util\Configuration::store('config_test');
+
+echo '
'; +?> \ No newline at end of file diff --git a/share/tests/test.php b/share/tests/test.php new file mode 100644 index 0000000..f88fc80 --- /dev/null +++ b/share/tests/test.php @@ -0,0 +1,25 @@ + 'pdo_mysql', + 'host' => 'localhost', + 'user' => 'volkszaehler', + 'password' => '', + 'dbname' => 'volkszaehler', +); + +$config['debug'] = false; + +?> \ No newline at end of file diff --git a/share/tools/install.php b/share/tools/install.php new file mode 100644 index 0000000..4ab39b7 --- /dev/null +++ b/share/tools/install.php @@ -0,0 +1,47 @@ + + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License (either version 2 or + * version 3) as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * For more information on the GPL, please go to: + * http://www.gnu.org/copyleft/gpl.html + */ +?> + + + + + + volkszaehler.org installer + + + +welcome to the installation of your volkszaehler backend!

+

lets proceed with the next step

'; +} + +?> + + + \ No newline at end of file