Documentation is available at HandlerChain.inc
- <?php
- /**
- * Generic HandlerChain
- *
- * This file is part of CompInaBox.
- * @copyright CompInaBox Copyright 2001-2005. Eric D. Nielsen, All rights reserverd.
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- *
- * @author Eric D. Nielsen <nielsene@alum.mit.edu>
- * @package InputControllers
- */
- /**
- * The Generic HandlerChain
- *
- * @package InputControllers
- */
- require_once("conf/tools/defines.inc");
- class HandlerChain {
- var $_handlers;
- function HandlerChain($filename="") {
- $this->_handlers=array();
- if ($filename!="")
- $this->initHandlers(file(CIB_BASE."include/conf/handlers/$filename.setup"));
- }
- function addHandler(&$handler) {
- $this->_handlers[]=&$handler;
- }
- function invoke(&$con, $req) {
- $numHandlers=count($this->_handlers);
- $view="";
- for ($i=0;$i<$numHandlers;$i++) {
- $aHandler=&$this->_handlers[$i];
- if ($aHandler->canHandle($con,$req)) {
- $view=$aHandler->execute($con,$req);
- break;
- }
- }
- return $view;
- }
- function initHandlers($config) {
- foreach ($config as $aLine) {
- if ($aLine=="") continue;
- $components = explode(" ",$aLine);
- $type = $components[0];
- switch ($type) {
- case "AccessControl":
- $authRequired = in_array("AuthenticationRequired",$components);
- $levelIndex = array_search("Levels",$components);
- if ($levelIndex!==FALSE) {
- $permissions=& new Permissions($components[$levelIndex+1]);
- $handler = &new AccessDeniedHandler($authRequired,$permissions);
- } else {
- $handler =& new AccessDeniedHandler($authRequired);
- }
- $this->addHandler($handler); break;
- }
- }
- return;
- }
- }
- ?>
Documentation generated on Tue, 25 Apr 2006 13:01:48 -0400 by phpDocumentor 1.3.0RC3