/** * @private * * flow */ private function flow() { #Benchmark::start('CON'); #Benchmark::start('SYS'); $this->debug = $this->objectManager->getObject('Debug'); // --------------------------------------------------------------------------------- // Filter-/Controller chains instances // --------------------------------------------------------------------------------- $this->initChains(); // --------------------------------------------------------------------------------- // Controller Rules // --------------------------------------------------------------------------------- #print_r(NameSpaces::$NSP_Application); $this->ControllerRulesClass = NameSpaces::getNamespaceOfClassSpecification('ControllerRules', true); if (is_array($this->ControllerRulesClass)) { $this->ControllerRules = $this->objectManager->getObject('ControllerRules')->rules(); } // --------------------------------------------------------------------------------- // Request // GET,POST,FILES,SERVER,HEADER,COOKIE // --------------------------------------------------------------------------------- // Request auslösen $request = $this->objectManager->getObject('Request'); // --------------------------------------------------------------------------------- // ActionController // Names from Dispatcher and Router // // $dispatcher->getControllerName(); // $dispatcher->getActionName(); // --------------------------------------------------------------------------------- // Dispatcher $dispatcher = $this->objectManager->getObject('Dispatcher'); // flrp (FLOWLite Router Protocol) $this->flrp = $this->objectManager->getObject('flrp'); // Dispatch Controller and Action over Routing $dispatcher->dispatchControllerAction($request); // get Controller over Protocol FLRP $this->controller = $this->flrp->getController(); // get Action over Protocol FLRP $this->action = $this->flrp->getAction(); // --------------------------------------------------------------------------------- // RequestFilters // --------------------------------------------------------------------------------- // Filter ermitteln (RequestFilter) FilterChain $requestFilters = NameSpaces::getNamespaceOfClassSpecification('RequestFilter'); if (is_array($requestFilters) && count($requestFilters) > 0) { // Filter instanzieren $this->initRequestFilter($requestFilters); // Alle Filter ausführen (Request übergeben) $this->requestFilters->execute($request); } // --------------------------------------------------------------------------------- // RequestValidator // --------------------------------------------------------------------------------- // Validator ermitteln (RequestValidator) ValidatorChain $requestValidators = NameSpaces::getNamespaceOfClassSpecification('RequestValidator'); if (is_array($requestValidators) && count($requestValidators) > 0) { // Validator instanzieren $this->initRequestValidators($requestValidators); // Alle Validatoren ausführen (Request übergeben) $this->requestValidators->execute($request); } // --------------------------------------------------------------------------------- // PreController // Before Action Controller // --------------------------------------------------------------------------------- // PreController ermitteln $PreControllers = NameSpaces::getNamespaceOfClassSpecification('PreController'); if (is_array($PreControllers) && count($PreControllers) > 0) { // Controller instanzieren $this->initPreControllers($PreControllers); // Controller ausführen (Request übergeben) $this->PreControllers->execute($request); } // --------------------------------------------------------------------------------- // PostController // After Action Controller // --------------------------------------------------------------------------------- // PreController ermitteln $PostControllers = NameSpaces::getNamespaceOfClassSpecification('PostController'); if (is_array($PostControllers) && count($PostControllers) > 0) { // Controller instanzieren $this->initPostControllers($PostControllers); } // --------------------------------------------------------------------------------- // @@@ ActionController // @@@ action with praefix "Action" // @@@ run // --------------------------------------------------------------------------------- // Init Object $this->debug->trace('Action Controller: ' . $this->controller, 'FrontController'); $this->debug->trace('Action : ' . $this->action, 'FrontController'); // Existiert eine Controller Whitelist $ControllerExceptions = $this->objectManager->getObject('ControllerExceptions')->getExceptions(); // @@@ Check Controller // @@@ // @@@ Ist der Controller innerhalb der Whitelist zu finden (Kann, muss nicht) // @@@ Der Controller muss im Namespacebereich der Application gefunden werden. // @@@ #echo $this->controller; echo "<br>"; #echo $this->action; echo "<br>"; #Benchmark::stop('CON'); #echo "CON "; #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('CON'),array(BaseHelperEscapeChars::getEscapeChar('BR'))); #print_r(NameSpaces::$NSP_Application); #Benchmark::stop('SYS'); #echo "SYS "; #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('SYS'),array(BaseHelperEscapeChars::getEscapeChar('BR'))); if (in_array($this->controller, $ControllerExceptions) || NameSpaces::classExistsInApplication($this->controller)) { // Inizialization controller $controller = $this->initActionController($this->controller); // Action $action = trim($this->action) . 'Action'; #echo $this->controller; #echo "<br>"; #echo $this->action; #exit; // Call controller and action // Check of object // Check of callable if ($this->isValid($controller) && is_callable(array($controller, $action))) { $controller->{$action}(); } else { // Controller nicht gefunden, kein Object oder nicht aufrufbar throw new Exception('Controller not callable (' . $this->controller . '->' . $action . ') !', 273562354); } } else { // Controller nicht gefunden throw new Exception('Controller or Action not found (' . $this->controller . ') ! ', 273562352); } // --------------------------------------------------------------------------------- // PostController // After Action Controller // --------------------------------------------------------------------------------- if ($this->registry->SystemFrontControllerRepeater === false) { if (is_array($PostControllers) && count($PostControllers) > 0) { $this->PostControllers->execute($request); } } else { # $this->deletePostControllers($PostControllers); } }
/** * @access private * route Rewrite * */ private function route_REWRITE() { /* * init empty flag controller & action */ $FLAG_EMPTY_CONTROLLER = false; $FLAG_EMPTY_ACTION = false; /* * init name of controller & action */ $this->appController = ''; $this->appAction = ''; /* * find urlRules class */ $this->urlRulesClass = NameSpaces::getNamespaceOfClassSpecification('urlRules', true); /* * reading url rules, if find urlRules class */ if (is_array($this->urlRulesClass)) { $this->urlRules = $this->objectManager->getObject('urlRules')->rules(); } /* * route * * The URI which was given in order to access this page; for instance, '/index.html'. * * @param REQUEST_URI */ $route = $_SERVER['REQUEST_URI']; /* * script * * Contains the current script's path. This is useful for pages * which need to point to themselves. The __FILE__ constant * contains the full path and filename of the current file. * * @param SCRIPT_NAME */ $script = $_SERVER['SCRIPT_NAME']; /* * delete left and right slash in route */ $route = $this->teminateSlashes($route); /* * pathname of script * * Returns parent directory's path of PHP_SELF * * @param dirname(PHP_SELF) */ $dirPathOfPHP_SELF = dirname($_SERVER['PHP_SELF']); /* * delete left and right slash in dirPathOfPHP_SELF */ $dirPathOfPHP_SELF = $this->teminateSlashes($dirPathOfPHP_SELF); /* * delete dirPathOfPHP_SELF in route */ $route = $this->teminateDirnameOfPHP_SELF($route, $dirPathOfPHP_SELF); /* * delete left and right slash in route */ $route = $this->teminateSlashes($route); /* * add slash to route */ $routeParam = explode('/', $route); /* * set arguments in registry of route */ $this->setArgumentsOfRoute($routeParam); /* * set default, if zero arguments */ if ($this->registry->countArguments == 0) { $this->NameOfController = $this->registry->standardController; $this->NameOfAction = $this->registry->standardAction; return false; } /* * controller position (first/last) */ $this->controllerPosition = 'first'; // default /* * first or last from urlRules (urlControllerInPath) */ if (is_array($this->urlRules) || isset($this->urlRules[0]['urlControllerInPath'])) { $this->controllerPosition = $this->urlRules[0]['urlControllerInPath']; } /* * Who is my Controller without "unity screen design" */ if ($this->registry->countArguments >= 1 && $this->registry->routerUnity === false) { switch ($this->controllerPosition) { case 'first': $this->appController = $this->getRoutingParam($routeParam, 0); break; case 'last': $this->appController = $this->getRoutingParam($routeParam, $this->registry->countArguments - 1); break; default: $this->appController = $this->registry->standardController; break; } } /* * Who is my Controller with "unity screen design" */ if ($this->registry->countArguments >= 1 && $this->registry->routerUnity === true) { switch ($this->controllerPosition) { case 'first': $this->NameOfUnity = $this->getRoutingParam($routeParam, 0); $this->NameOfScreen = $this->getRoutingParam($routeParam, 1); break; case 'last': $this->NameOfUnity = $this->getRoutingParam($routeParam, $this->registry->countArguments - 1); $this->NameOfScreen = $this->getRoutingParam($routeParam, $this->registry->countArguments - 2); break; default: $this->appController = $this->registry->standardController; break; } /* * Controller = Unity + ... (see you later ) */ $this->appController = $this->NameOfUnity; } /* * Controller is empty default set */ if (empty($this->appController)) { $this->appController = $this->registry->standardController; } /* * Filter of Extensions * SEO Component (htm|html) * * 1.) Es existieren Extension in den urlRules (url Regeln) * Die Extension müssen grundsätzlich als Array angegeben werden * * a.) Extension ist 'all' oder 'ALL' * Eine in der URL gefundene Extension wird immer abgeschnitten * * b.) Extension besteht aus einer Auflistung (z.B. 'htm'|'html') * Eine in der URL gefundene Extension muss auch im * vorgegbenen Array gefunden werden, so wird sie abgeschnitten, * ansonsten bleibt sie Bestandteil des Controllers */ if (is_array($this->urlRules) || isset($this->urlRules[0]['extensions'])) { // Returns information about a file path $pathInfoOfController = pathinfo($this->appController); // find extension in pathinfo if (array_key_exists('extension', $pathInfoOfController)) { /* * a.) all extension are allowed */ if (in_array('all', $this->urlRules[0]['extensions']) || in_array('ALL', $this->urlRules[0]['extensions'])) { $this->appController = $pathInfoOfController['filename']; } else { /* * b.) Filter of Extension ... only certain extension are permitted */ if (!in_array('all', $this->urlRules[0]['extensions']) || !in_array('ALL', $this->urlRules[0]['extensions'])) { // if customer extension in urlRules ? if (in_array($pathInfoOfController['extension'], $this->urlRules[0]['extensions'])) { $this->appController = $pathInfoOfController['filename']; } } } } } /* * USD (Unity Screen Design ? ) */ if ($this->registry->routerUnity === true) { $this->appController .= $this->NameOfScreen; } /* * Who is my Action ? */ if ($this->registry->countArguments >= 2 && $this->registry->routerUnity === false) { switch ($this->controllerPosition) { case 'first': $this->appAction = $this->getRoutingParam($routeParam, 1); break; case 'last': $this->appAction = $this->getRoutingParam($routeParam, $this->registry->countArguments - 2); break; default: $this->appAction = $this->registry->standardAction; break; } } /* * Who is my Action with "unity screen design" */ if ($this->registry->countArguments >= 2 && $this->registry->routerUnity === true) { switch ($this->controllerPosition) { case 'first': $this->appAction = $this->getRoutingParam($routeParam, 2); break; case 'last': $this->appAction = $this->getRoutingParam($routeParam, $this->registry->countArguments - 3); break; default: $this->appAction = $this->registry->standardAction; break; } } /* * Action is empty default set */ if (empty($this->appAction)) { $this->appAction = $this->registry->standardAction; } /* * Interface to FLRP (FLOWLite Router Protocol) */ $this->NameOfController = $this->appController; $this->NameOfAction = $this->appAction; }