Пример #1
0
	/**
	 * Find and include specific controller based on controller name
	 *
	 * @access public
	 * @param string $controller_name
	 * @return boolean
	 * @throws FileDnxError if controller file does not exists
	 * 
	 */
	static function useController($controller_name) {
		$controller_class = Env::getControllerClass($controller_name);
		
		// Search For Plugin. Execute it if found
		$plugins = Plugins::instance()->getActive() ;
		$pluginName = null ; 
		foreach ($plugins as $plugin) {
			/* @var $plugin Plugin  */
			$systemName = $plugin->getSystemName() ;
			//$controller_file = ROOT."/plugins/$pluginName/application/controllers/$controller_class.class.php";
			$controller_file = $plugin->getControllerPath()."$controller_class.class.php";
			//echo $controller_file ."<br/>";
			if (is_file($controller_file)){
				$pluginName = $plugin ;
				Plugins::instance()->setCurrent($plugin) ;
				include_once $controller_file;
				return true ;
			}
		}
		
		
		// Plugin not found - Search for core controller
		
		
		if(class_exists($controller_class, false)) return true;

		$controller_file = APPLICATION_PATH . "/controllers/$controller_class.class.php";
		if(is_file($controller_file)) {
			include_once $controller_file;
			return true;
		} else {
			throw new FileDnxError($controller_file, "Controller '$controller_name' does not exists (expected location '$controller_file')");
		} // if
	} // useController
Пример #2
0
 /**
  * Find and include specific controller based on controller name
  *
  * @access public
  * @param string $controller_name
  * @return boolean
  * @throws FileDnxError if controller file does not exists
  */
 static function useController($controller_name)
 {
     $controller_class = Env::getControllerClass($controller_name);
     if (class_exists($controller_class, false)) {
         return true;
     }
     $controller_file = APPLICATION_PATH . "/controllers/{$controller_class}.class.php";
     if (is_file($controller_file)) {
         include_once $controller_file;
         return true;
     } else {
         throw new FileDnxError($controller_file, "Controller '{$controller_name}' does not exists (expected location '{$controller_file}')");
     }
     // if
 }
Пример #3
0
 /**
  * Get Controller File Path, looks for controller file and returns the path 
  *
  * @access public
  * @param string $controller_name
  * @return boolean
  * @throws FileDnxError if controller file does not exists
  */
 static function getControllerPath($controller_name)
 {
     trace(__FILE__, "getControllerPath({$controller_name})");
     $controller_class = Env::getControllerClass($controller_name);
     $controller_file = APPLICATION_PATH . "/controllers/{$controller_class}.class.php";
     trace(__FILE__, "getControllerPath({$controller_name}) - core: {$controller_file}");
     $controller_file_plugin = APPLICATION_PATH . "/plugins/{$controller_name}/controllers/{$controller_class}.class.php";
     trace(__FILE__, "getControllerPath({$controller_name}) - plugin: {$controller_file_plugin}");
     if (is_file($controller_file)) {
         return $controller_file;
     } else {
         if (is_file($controller_file_plugin)) {
             return $controller_file_plugin;
         } else {
             throw new FileDnxError($controller_file, "Controller '{$controller_name}' does not exists (expected location '{$controller_file}' or '{$controller_file_plugin}')");
         }
     }
 }
Пример #4
0
 /**
 * Get Controller File Path, looks for controller file and returns the path 
 *
 * @access public
 * @param string $controller_name
 * @return boolean
 * @throws FileDnxError if controller file does not exists
 */
 static function getControllerPath($controller_name) {
   trace(__FILE__,"getControllerPath($controller_name)");
   $controller_class = Env::getControllerClass($controller_name);
   $controller_file = APPLICATION_PATH . "/controllers/$controller_class.class.php";
   trace(__FILE__,"getControllerPath($controller_name) - core: $controller_file");
   $controller_file_plugin = APPLICATION_PATH . "/plugins/$controller_name/controllers/$controller_class.class.php";
   trace(__FILE__,"getControllerPath($controller_name) - plugin: $controller_file_plugin");
   if (is_file($controller_file)) return $controller_file;
   else if (is_file($controller_file_plugin)) return $controller_file_plugin;
   else throw new FileDnxError($controller_file, "Controller '$controller_name' does not exists (expected location '$controller_file' or '$controller_file_plugin')");
 } // getControllerFilePath