cleaned project, repaired router
This commit is contained in:
parent
2156d3f5c6
commit
bffe0f1660
16 changed files with 1172 additions and 1440 deletions
|
|
@ -1,105 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract Controller
|
||||
* All controllers must extend this class.
|
||||
*
|
||||
* @author Karl Pannek <info@katharsis.in>
|
||||
* @version 0.5.2
|
||||
* @package Katharsis
|
||||
*/
|
||||
abstract class Katharsis_Controller_Abstract
|
||||
{
|
||||
/**
|
||||
* @var Katharsis_Db5
|
||||
*/
|
||||
protected $_con;
|
||||
|
||||
/**
|
||||
* @var Katharsis_View
|
||||
*/
|
||||
protected $_view;
|
||||
|
||||
/**
|
||||
* Instances class attributes, calles init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public final function __construct()
|
||||
{
|
||||
$this->_con = Katharsis_DatabaseConnector::getConnection();
|
||||
$this->_view = Katharsis_View::getInstance();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this method instead of using a constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* If subclass hasn't got a __call method, this exception will be thrown
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __call($action, $params)
|
||||
{
|
||||
throw new Katharsis_Exception('Action "' . $action . '" doesn\'t exist.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific request parameter
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _getParam($key)
|
||||
{
|
||||
$params = Katharsis_Request::getParams();
|
||||
if(array_key_exists($key,$params))
|
||||
{
|
||||
return $params[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all request parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getAllParams()
|
||||
{
|
||||
return Katharsis_Request::getParams();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward to an other action
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $controller
|
||||
* @param array $getParams
|
||||
* @return void
|
||||
*/
|
||||
protected function _location($action, $controller = null, $getParams = null)
|
||||
{
|
||||
if($controller === null)
|
||||
{
|
||||
$controller = Katharsis_Request::getControllerName();
|
||||
}
|
||||
|
||||
$paramstring = "";
|
||||
if($getParams !== null)
|
||||
{
|
||||
foreach($getParams as $key => $value)
|
||||
{
|
||||
$paramstring .= "/" . (string) $key . "/" . (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
header("location: " . $this->_view->base . "/" . $controller . "/" . $action . $paramstring);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
abstract class Katharsis_Controller_Abstract
|
||||
{
|
||||
protected $_con;
|
||||
protected $_view;
|
||||
|
||||
public final function __construct()
|
||||
{
|
||||
$this->_con = Katharsis_DatabaseConnector::getConnection();
|
||||
$this->_view = Katharsis_View::getInstance();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
||||
public function __call($action, $params)
|
||||
{
|
||||
throw new Katharsis_Exception('Die von Ihnen angeforderte Seite (Action) "' . substr($action, 0, -6) . '" konnte nicht gefunden werden.');
|
||||
}
|
||||
|
||||
protected function _getParam($key)
|
||||
{
|
||||
$params = Katharsis_Request::getParams();
|
||||
if(array_key_exists($key,$params))
|
||||
{
|
||||
return $params[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function _getAllParams()
|
||||
{
|
||||
return Katharsis_Request::getParams();
|
||||
}
|
||||
|
||||
protected function _location($action, $controller = null, $getParams = null)
|
||||
{
|
||||
if($controller === null)
|
||||
{
|
||||
$controller = Katharsis_Request::getControllerName();
|
||||
}
|
||||
|
||||
$paramstring = "";
|
||||
if($getParams !== null)
|
||||
{
|
||||
foreach($getParams as $key => $value)
|
||||
{
|
||||
$paramstring .= "/" . (string) $key . "/" . (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
header("location: " . $this->_view->base . "/" . $controller . "/" . $action . $paramstring);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,53 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Central Plugin Class
|
||||
*
|
||||
* @author Karl Pannek <info@katharsis.in>
|
||||
* @version 0.5.2
|
||||
* @package Katharsis
|
||||
*/
|
||||
class Katharsis_Controller_Plugin
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $_plugins;
|
||||
|
||||
/**
|
||||
* Register all plugins with this method
|
||||
* Plugins will be called in the same order as they have been registered
|
||||
*
|
||||
* @param object $object - an instance of your plugin
|
||||
* @return void
|
||||
*/
|
||||
public static function registerPlugin($object)
|
||||
{
|
||||
self::$_plugins[] = $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes preController methods of all plugins
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function preControllerHook()
|
||||
{
|
||||
foreach(self::$_plugins as $plugin)
|
||||
{
|
||||
$plugin->preController();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes postController methods of all plugins
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function postControllerHook()
|
||||
{
|
||||
foreach(self::$_plugins as $plugin)
|
||||
{
|
||||
$plugin->postController();
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
class Katharsis_Controller_Plugin
|
||||
{
|
||||
protected static $_plugins;
|
||||
|
||||
public static function registerPlugin($object)
|
||||
{
|
||||
self::$_plugins[] = $object;
|
||||
}
|
||||
|
||||
public static function preControllerHook()
|
||||
{
|
||||
foreach(self::$_plugins as $plugin)
|
||||
{
|
||||
$plugin->preController();
|
||||
}
|
||||
}
|
||||
|
||||
public static function postControllerHook()
|
||||
{
|
||||
foreach(self::$_plugins as $plugin)
|
||||
{
|
||||
$plugin->postController();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,36 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract Controller Plugin
|
||||
* All controller plugins must extend this class.
|
||||
*
|
||||
* @author Karl Pannek <info@katharsis.in>
|
||||
* @version 0.5.2
|
||||
* @package Katharsis
|
||||
*/
|
||||
abstract class Katharsis_Controller_Plugin_Abstract
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->_con = Katharsis_DatabaseConnector::getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this method, if you want something to be processed
|
||||
* _before_ the controller is called
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preController()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this method, if you want something to be processed
|
||||
* _after_ the controller was called
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postController()
|
||||
{
|
||||
}
|
||||
}
|
||||
<?php
|
||||
abstract class Katharsis_Controller_Plugin_Abstract
|
||||
{
|
||||
protected $_con;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_con = Katharsis_DatabaseConnector::getConnection();
|
||||
}
|
||||
|
||||
public function preController()
|
||||
{
|
||||
}
|
||||
|
||||
public function postController()
|
||||
{
|
||||
}
|
||||
}
|
||||
?>
|
||||
21
library/Katharsis/Controller/Plugin/AutoScriptControl.php
Normal file
21
library/Katharsis/Controller/Plugin/AutoScriptControl.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
class Katharsis_Controller_Plugin_AutoScriptControl extends Katharsis_Controller_Plugin_Abstract
|
||||
{
|
||||
public function preController()
|
||||
{
|
||||
$view = Katharsis_View::getInstance();
|
||||
|
||||
$view->autoScriptFile = false;
|
||||
|
||||
|
||||
|
||||
$scriptName = ucfirst(Katharsis_Request::getControllerName()) . '/' . strtolower(Katharsis_Request::getActionName());
|
||||
$autoScriptFile = 'scripts/DidgeridooArtwork/' . $scriptName . '.js';
|
||||
$sl = DIRECTORY_SEPARATOR;
|
||||
|
||||
if(file_exists(getcwd() . $sl . str_replace('/', $sl, $autoScriptFile)))
|
||||
{
|
||||
$view->autoScriptFile = $view->base . '/' . $autoScriptFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Autorender Controller Plugin
|
||||
*
|
||||
* @author Karl Pannek <info@katharsis.in>
|
||||
* @version 0.5.2
|
||||
* @package Katharsis
|
||||
*/
|
||||
class Katharsis_Controller_Plugin_Autorender extends Katharsis_Controller_Plugin_Abstract
|
||||
{
|
||||
/**
|
||||
* Renders a controller/action.phtml template automaticly after processing controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postController()
|
||||
{
|
||||
|
||||
$view = Katharsis_View::getInstance();
|
||||
|
||||
$view->controllerAction = false;
|
||||
|
||||
$templateName = strtolower(Katharsis_Request::getControllerName()) . DIRECTORY_SEPARATOR . strtolower(Katharsis_Request::getActionName());
|
||||
|
||||
if(file_exists('application/view' . DIRECTORY_SEPARATOR . $templateName . '.phtml'))
|
||||
{
|
||||
$view->controllerAction = $templateName;
|
||||
}
|
||||
|
||||
$view = Katharsis_View::getInstance();
|
||||
echo $view->render('main');
|
||||
}
|
||||
}
|
||||
<?php
|
||||
class Katharsis_Controller_Plugin_Autorender extends Katharsis_Controller_Plugin_Abstract
|
||||
{
|
||||
public function postController()
|
||||
{
|
||||
$view = Katharsis_View::getInstance();
|
||||
|
||||
$view->stageContent = false;
|
||||
|
||||
$templateName = ucfirst(Katharsis_Request::getControllerName()) . DIRECTORY_SEPARATOR . strtolower(Katharsis_Request::getActionName());
|
||||
|
||||
if(file_exists(getcwd() . '/application/view' . DIRECTORY_SEPARATOR . $templateName . '.phtml'))
|
||||
{
|
||||
$view->stageContent = $view->render($templateName);
|
||||
}
|
||||
|
||||
echo $view->render('main');
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue