Merge branch 'master' of github.com:volkszaehler/volkszaehler.org
Conflicts: misc/tools/install
This commit is contained in:
commit
df3b88e77f
6 changed files with 70 additions and 42 deletions
|
@ -23,6 +23,8 @@
|
|||
|
||||
namespace Volkszaehler\Controller;
|
||||
|
||||
use Volkszaehler\View;
|
||||
|
||||
/**
|
||||
* Controller superclass for all controllers
|
||||
*
|
||||
|
@ -39,7 +41,7 @@ abstract class Controller {
|
|||
* @param View $view
|
||||
* @param EntityManager $em
|
||||
*/
|
||||
public function __construct(\Volkszaehler\View\View $view, \Doctrine\ORM\EntityManager $em) {
|
||||
public function __construct(View\View $view, \Doctrine\ORM\EntityManager $em) {
|
||||
$this->view = $view;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
@ -49,13 +51,19 @@ abstract class Controller {
|
|||
*
|
||||
* @param string $operation runs the operation if class method is available
|
||||
*/
|
||||
public function run($operation, array $identifiers = array()) {
|
||||
if (!is_callable(array($this, $operation))) {
|
||||
throw new \Exception('Invalid context operation: ' . $operation);
|
||||
public function run($op, array $arg = array()) {
|
||||
if (!method_exists($this, $op)) {
|
||||
throw new \Exception('Invalid context operation: ' . $op);
|
||||
}
|
||||
|
||||
switch(count($arg)) { // improved performence
|
||||
case 0: return $this->{$op}();
|
||||
case 1: return $this->{$op}($arg[0]);
|
||||
case 2: return $this->{$op}($arg[0], $arg[1]);
|
||||
case 3: return $this->{$op}($arg[0], $arg[1], $arg[2]);
|
||||
default: return call_user_func_array(array($this, $op), $arg);
|
||||
}
|
||||
|
||||
return call_user_func_array(array($this, $operation), $identifiers);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -116,8 +116,6 @@ class Router {
|
|||
$this->pathInfo = self::getPathInfo();
|
||||
$this->format = pathinfo($this->pathInfo, PATHINFO_EXTENSION);
|
||||
|
||||
Util\Debug::log('env vars', $_SERVER);
|
||||
|
||||
if (!array_key_exists($this->format, self::$viewMapping)) {
|
||||
$this->view = new View\JSON($request, $response); // fallback view
|
||||
|
||||
|
@ -143,8 +141,7 @@ class Router {
|
|||
*/
|
||||
public function run() {
|
||||
$operation = self::getOperation($this->view->request);
|
||||
$context = substr($this->pathInfo, 1, strrpos($this->pathInfo, '.') -1); // remove leading slash and format
|
||||
$context = explode('/', $context); // split into path segments
|
||||
$context = explode('/', substr($this->pathInfo, 1, strrpos($this->pathInfo, '.')-1)); // parse pathinfo
|
||||
|
||||
if (!array_key_exists($context[0], self::$controllerMapping)) {
|
||||
if (empty($context[0])) {
|
||||
|
@ -158,13 +155,7 @@ class Router {
|
|||
$class = self::$controllerMapping[$context[0]];
|
||||
$controller = new $class($this->view, $this->em);
|
||||
|
||||
if (isset($pathInfo[1])) {
|
||||
$result = $controller->run($operation, array_slice($context, 1));
|
||||
}
|
||||
else {
|
||||
$result = $controller->run($operation);
|
||||
}
|
||||
|
||||
$result = $controller->run($operation, array_slice($context, 1));
|
||||
$this->view->add($result);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,33 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2010 by Justin Otherguy <justin@justinotherguy.org>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# This is a simple bash script to read Dallas 1-Wire sensors
|
||||
# with digitemp and log their values to the volkszaehler project.
|
||||
#
|
||||
# call it with a cronjob similiar to this one:
|
||||
#
|
||||
# */5 * * * * ~/bin/log1wire.sh
|
||||
# */5 * * * * ~/bin/log1wire.sh
|
||||
#
|
||||
# @copyright Copyright (c) 2010, The volkszaehler.org project
|
||||
# @package controller
|
||||
# @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
|
||||
# @author Steffen Vogel <info@steffenvogel.de>
|
||||
#
|
||||
##
|
||||
# This file is part of volkzaehler.org
|
||||
#
|
||||
# volkzaehler.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# volkzaehler.org 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 volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# configuration
|
||||
#
|
|
@ -1,9 +1,35 @@
|
|||
#!/bin/bash
|
||||
# Jakob Hirsch, 2010-11-20
|
||||
#
|
||||
# Installer
|
||||
#
|
||||
# For creating/updating the configuration/database
|
||||
# and downloading of required libraries
|
||||
# and configuration of of the PHP interpreter/webserver
|
||||
#
|
||||
# @copyright Copyright (c) 2010, The volkszaehler.org project
|
||||
# @package tools
|
||||
# @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
|
||||
# @author Jakob Hirsch
|
||||
#
|
||||
##
|
||||
# This file is part of volkzaehler.org
|
||||
#
|
||||
# volkzaehler.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# volkzaehler.org 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 volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# cannot handle other hosts right now
|
||||
db_host=localhost
|
||||
db_host=localhost
|
||||
|
||||
set -e
|
||||
shopt -s nocasematch
|
||||
|
@ -108,9 +134,9 @@ if [ "$REPLY" == "y" ]; then
|
|||
echo creating database $db_name...
|
||||
mysql -h$db_host -u$db_admin_user -p$db_admin_pass -e 'CREATE DATABASE `'$db_name'`'
|
||||
pushd $vzdir
|
||||
php $dtdir orm:schema-tool:create
|
||||
php misc/tools/doctrine orm:schema-tool:create
|
||||
popd
|
||||
|
||||
|
||||
echo "creating db user $db_user with proper rights..."
|
||||
mysql -h$db_host -u$db_admin_user -p$db_admin_pass <<-EOF
|
||||
CREATE USER '$db_user'@'$db_host' IDENTIFIED BY '$db_pass';
|
||||
|
@ -124,7 +150,7 @@ ask "insert demo data in to database?" n
|
|||
if [ "$REPLY" == "y" ]; then
|
||||
get_admin
|
||||
get_db_name
|
||||
cat $vzdir/misc/sql/demo/entities.sql $vzdir/misc/sql/demo/properties.sql $vzdir/misc/sql/demo/data-demoset1.sql |
|
||||
cat $vzdir/misc/sql/demo/entities.sql $vzdir/misc/sql/demo/properties.sql $vzdir/share/sql/demo/data-demoset1.sql |
|
||||
mysql -h$db_host -u$db_admin_user -p$db_admin_pass $db_name
|
||||
fi
|
||||
|
Loading…
Add table
Reference in a new issue