Select Git revision
mysql.lib.php
Action.php 2.93 KiB
<?php
/**
* Action.php Defines the standard NMC Action class
*
* LICENSE: Some license information
*
* @copyright 2006 New Media Center - University of Nebraska-Lincoln
* @license http://www.gnu.org/licenses/gpl.txt GPL
* @version 0.0.1
* @link http://nmc.unl.edu/
* @since File available since Release 0.0.1
*/
Zend::loadClass('Nmc_Controller_Action_Plugin_Broker');
/**
* Nmc_Controller_Action: Extends the Zend action to include a default noRouteAction
*
* @copyright 2006 New Media Center - University of Nebraska Lincoln
* @license http://www.gnu.org/gpl.txt GPL
* @version Release: 0.0.1
* @link http://nmc.unl.edu/
* @since Class available since Release 0.0.1
*/
abstract class Nmc_Controller_Action extends Zend_Controller_Action {
/**
* Plugin broker for current action
*
* @var Nmc_Controller_Action_Plugin_Broker
*/
protected $_pluginBroker;
public function __construct()
{
parent::__construct();
}
public function run(Zend_Controller_Dispatcher_Interface $dispatcher,
Zend_Controller_Dispatcher_Token $action)
{
$this->_action = $action;
$this->_params = $action->getParams();
$this->_preAction();
$returnValue = parent::run($dispatcher, $action);
$this->_postAction();
return $returnValue;
}
protected function _registerPlugin(Nmc_Controller_Action_Plugin_Interface $plugin)
{
if(! $this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) {
$this->_pluginBroker = new Nmc_Controller_Action_Plugin_Broker();
}
$this->_pluginBroker->registerPlugin($plugin);
}
protected function _unregisterPlugin(Nmc_Controller_Action_Plugin_Interface $plugin)
{
if($this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) {
$this->_pluginBroker->unregisterPlugin($plugin);
}
}
protected function _preAction()
{
if($this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) {
$this->_pluginBroker->preAction($this, $this->_action);
}
}
protected function _postAction()
{
if($this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) {
$this->_pluginBroker->postAction($this, $this->_action);
}
}
function noRouteAction()
{
header('HTTP/1.0 404 Not Found');
$out = new Nmc_View();
$out->page = '404';
$out->title = '404 Not Found';
echo $out->render();
}
function __call($method, $args)
{
if($this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) {
if($this->_pluginBroker->pluginMethodExists($method)) {
return $this->_pluginBroker->callPluginMethod($method, $args);
}
}
if(substr($method, -6) == 'Action') {
return $this->noRouteAction();
}
}
}
?>