Exemplo n.º 1
0
 /**
  * FlexiNSP
  *
  * @access public
  * @param string classname
  * @loading class from namespace of framework
  */
 public static function load($className)
 {
     // all registered namespaces
     self::$ListOfNameSpaces = NameSpaces::getNSPList();
     // if object registerd ?
     if (count(self::$ListOfNameSpaces) > 0) {
         // searching in namespace ...
         foreach (self::$ListOfNameSpaces as $Key => $Value) {
             #print_r(NameSpaces::${$Value});
             if (array_key_exists($className, NameSpaces::${$Value})) {
                 #if(isset(NameSpaces::${$Value}[$className])){
                 $pathToClass = NameSpaces::${$Value}[$className];
                 if (isset($pathToClass)) {
                     if (file_exists($pathToClass)) {
                         // ... so wird sie eingebunden
                         require_once $pathToClass;
                     }
                     break;
                 }
             }
             // ${$Value} = name of class
             // {$classname} = name of property (Path) ~ name of class
             // Korrespondiert mit der STATIC Klasse "NameSpaces"
             /*
                      		if(isset(NameSpaces::${$Value}->{$className})){       
             
             					// Name des Pfades und der Klasse
             					$ExternalPathAndNameOfClass = NameSpaces::${$Value}->{$className};
             
                         		// Existiert die Klasse, ...
                         		if(file_exists($ExternalPathAndNameOfClass)){ 
             			  
             		      			// ... so wird sie eingebunden
             				  		require_once($ExternalPathAndNameOfClass); 
             					} 
             	        		break;        
                      		} #if
             */
         }
         #foreach
     }
     #count
 }
Exemplo n.º 2
0
 /**
  * @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);
     }
 }
Exemplo n.º 3
0
 /**
  * init ORM
  * DBScan
  *
  * @return void
  */
 private function initializeORM()
 {
     NameSpaces::setNamespaceToObject('NSP_ORM', ResourcesNameSpaces::getNamespaces(FL_PATH_ORM, true));
 }
Exemplo n.º 4
0
 /**
  * @access public static
  * @param classname
  * 
  * all classes of specification name
  */
 public static function getNamespaceOfClassSpecification($ClassName, $subset = false)
 {
     self::$ReturnNameSpaces = null;
     // Alle registrierten Objekte betrachten
     foreach (self::$ListOfNameSpaces as $key => $value) {
         // Die Eigenschaften aller registrierten Objekt durchsuchen
         foreach (self::${$value} as $obj => $property) {
             // Suchefunktion
             if (self::searchClassInNamespaceObject($ClassName, $obj) !== false) {
                 // Teilklasse gefunden => Aufnahme der gefundenen Klassen
                 if ($subset === true) {
                     if ($ClassName === $obj) {
                         self::$ReturnNameSpaces[] = $obj;
                     }
                 } else {
                     self::$ReturnNameSpaces[] = $obj;
                 }
             }
         }
     }
     if (is_array(self::$ReturnNameSpaces)) {
         sort(self::$ReturnNameSpaces);
     }
     return self::$ReturnNameSpaces;
 }
Exemplo n.º 5
0
 /**
  * @access private 
  * initPostControllers
  * 
  * @var instance
  */
 private function initPostControllers($controllers)
 {
     if (is_array($controllers)) {
         foreach ($controllers as $ControllerName) {
             // if POSTControllers in Application Namespaces
             if (NameSpaces::classExistsInApplication($ControllerName) || NameSpaces::classExistsInApplicationOnly($ControllerName)) {
                 // Whitelist ?
                 if (ArrayHelper::hasEntries($this->ControllerRules)) {
                     $PostControllerStart = $this->foundControllerActionInWhitelist($ControllerName);
                 } else {
                     $PostControllerStart = true;
                 }
                 // PreController Init
                 if ($PostControllerStart) {
                     $this->debug->trace('+++ Post Controller INIT: ' . $ControllerName, 'PreController (Excecute)');
                     $this->addPostController($this->objectManager->getObject($ControllerName));
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 /**
  * @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;
 }