http://www.php.net/manual/es/function.error-reporting.php } try{ require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Config.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2AppConfig.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2ActionConfig.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2ConfigLoader.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2ConfigYaml.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Context.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Request.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Session.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Route.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2App.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Components.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2TemplateFilter.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2User.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2UserSecurity.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2UserSecurityManagement.class.php"); require_once(A2___P2A2FRAMEWORK."/lib/a2framework/A2Collection.class.php"); } catch(Exception $e){ A2Debug::error("No se ha cargado correctamente las clases base de /lib/a2framework/*! ".$e); } A2Config::add(array( "a2framework_app"=>A2___APP, "a2framework_debug"=>A2___DEBUG, "a2framework_p2fw"=>A2___P2A2FRAMEWORK, "a2framework_p2app"=>A2___P2A2FRAMEWORK.'/apps/'.A2___APP, "a2framework_p2root"=>A2___P2ROOT, "a2framework_p2fw_lib"=>A2___P2A2FRAMEWORK."/lib" )); // A2Debug::Info(A2Config::getAll(),"INICIALIZANDO APP"); if(is_readable(A2___P2A2FRAMEWORK."/config/settings.yml")){ try{ A2Config::add( A2ConfigYaml::load(A2Config::get("a2framework_p2fw")."/config/settings.yml") ); } catch(Exception $e){ A2Debug::error("No se ha cargado correctamente el fichero de configuracion principal! ".$e); } } else A2Debug::error("No existe el fichero de configuraciÛn principal!"); if(is_readable(A2___P2A2FRAMEWORK.'/apps/'.A2___APP."/config/settings.yml")) A2AppConfig::add( A2ConfigYaml::load(A2Config::get("a2framework_p2app")."/config/settings.yml") ); if(is_readable(A2___P2A2FRAMEWORK.'/apps/'.A2___APP."/config/routing.yml")) A2Route::add( A2ConfigYaml::load(A2Config::get("a2framework_p2app")."/config/routing.yml") ); if(A2Config::get("a2framework_bbdd")){ if(is_readable(A2Config::get("a2framework_p2fw")."/config/databases.yml")){ try{ A2Config::add( A2ConfigYaml::load(A2Config::get("a2framework_p2fw")."/config/databases.yml") ); require_once(A2___P2A2FRAMEWORK."/lib/a2dbal/A2Sql.class.php"); if(A2Config::get("a2framework_a2dorm")) require_once(A2___P2A2FRAMEWORK."/lib/a2dborm/A2Dborm.class.php"); } catch(Exception $e){ A2Debug::error("No se ha cargado correctamente el fichero de BBDD! ".$e); } } else A2Debug::error("No se puede habilitar la BBDD ya que no existe el fichero de configuracion databases.yml! ".$e); } if(is_readable(A2___P2A2FRAMEWORK.'/apps/'.A2___APP."/lib/".A2___APP.".class.php")){ require_once(A2___P2A2FRAMEWORK.'/apps/'.A2___APP."/lib/".A2___APP.".class.php"); A2Debug::Info("Se ha cargado correctamente la BaseClass de la App '".A2___APP."'"); } else A2Debug::error("No existe la BaseClass de la App en '".A2___P2A2FRAMEWORK.'/apps/'.A2___APP."/lib/".A2___APP.".class.php'!"); self::load(); } static public function Load() { $moduleAction=A2Route::GetModuleAction(); if($moduleAction!=NULL){ self::$App = self::LoadModuleAction( $moduleAction["module"], $moduleAction["action"] ); if(self::$App!=NULL){ // VALIDAMOS LAS CREDENCIALES DEL USUARIO self::$App->SecurityManagement->CheckModuleActionPermissions(); // self::$App->Request->add($moduleAction["param"]); // SOPORTE AUTOMÁTICO AJAX if(self::$App->isAjax()){ self::$App->disableTemplateSystem(); if( method_exists(self::$App,"globalAjaxStart") ){ A2Debug::Info("User method 'globalAjaxStart()' called in ".self::$App->Context->get("ModuleActionPath")."!"); self::$App->globalAjaxStart(); } // } else{ // NO AJAX if( method_exists(self::$App,"preExecute")){ A2Debug::Info("User method 'preExecute()' called in ".self::$App->Context->get("ModuleActionPath")."!"); self::$App->preExecute(); } self::$App->InitializeTemplateSystem(); self::$App->LoadFilters(); self::$App->LoadComponents(); if( method_exists(self::$App,"globalStart") ){ A2Debug::Info("User method 'globalStart()' called in ".self::$App->Context->get("ModuleActionPath")."!"); self::$App->globalStart(); } // } if( method_exists(self::$App,"globalExecute") ){ A2Debug::Info("User method 'globalExecute()' called in ".self::$App->Context->get("ModuleActionPath")."!"); self::$App->globalExecute(); } A2Debug::GroupEnd(); A2Debug::GroupUserCalls("Method/ActionCalls"); $timeStartUser = (float) array_sum(explode(' ',microtime())); call_user_func( array(self::$App,self::$App->Context->get("ActionMethodName")) ); A2Debug::GroupEnd(); A2Debug::GroupSystemCalls("SystemCalls (2)"); $timeStartDisplay = (float) array_sum(explode(' ',microtime())); self::$App->Display(); $timeEndDisplay = (float) array_sum(explode(' ',microtime())); if( method_exists(self::$App,"postExecute") ){ A2Debug::Info("User method 'postExecute()' called in ".self::$App->Context->get("ModuleActionPath")."!"); self::$App->postExecute(); } A2Debug::GroupEnd(); A2Debug::GroupTimeTrace("Estimated processing times"); $timeEnd = (float) array_sum(explode(' ',microtime())); $userActionTime=sprintf("%.4f", ($timeEnd-$timeStartUser)); $displayTemplateTime=sprintf("%.4f", ($timeEndDisplay-$timeStartDisplay)); $overAllTime=sprintf("%.4f", ($timeEnd-self::$timeStart)); A2Debug::Info("User Action: ".$userActionTime." seconds"); A2Debug::Info("Display Template: ".$displayTemplateTime." seconds"); A2Debug::Info("Over all time: ".$overAllTime." seconds"); A2Debug::GroupEnd(); } else{ A2Debug::Error('No se encuentra una pareja de Modulo/Accion valida. Se finaliza la ejecucion con un Error404!'); A2Debug::GroupEnd(); self::Forward404(); } } else{ A2Debug::Error("No hay un Modulo/Accion asociado a la URL!"); A2Debug::GroupEnd(); self::Forward404(); } } // usamos la misma nomenclatura que symphony, aunque no se debe esperar el mismo comportamiento... static private function LoadModuleAction($module,$action) { $fileName_ActionFile=DIRECTORY_SEPARATOR.$action."Action.class.php"; $fileName_GenericActionFile=DIRECTORY_SEPARATOR."actions.class.php"; $path_Module=A2Config::get("a2framework_p2fw").DIRECTORY_SEPARATOR."apps".DIRECTORY_SEPARATOR.A2Config::get("a2framework_app").DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR.$module; $path_ActionFile=$path_Module.DIRECTORY_SEPARATOR."actions".$fileName_ActionFile; $path_GenericActionFile=$path_Module.DIRECTORY_SEPARATOR."actions".$fileName_GenericActionFile; A2Config::add(array("a2framework_module_path"=>$path_Module)); //1. intentamos cargar la clase específica del modulo+accion if(is_readable($path_ActionFile)){ require_once($path_ActionFile); $actionClass=$action."Action"; if(class_exists($actionClass)) { $App=new $actionClass; $actionMethod="execute"; if( method_exists($App,$actionMethod) ){ $App->Context->add(array( "ModuleName" => $module, "ModulePath" => $path_Module, "ModuleActionPath" => $path_ActionFile, "ModuleActionClassName" => $actionClass, "ActionName" => $action, "ActionMethodName" => $actionMethod )); A2Debug::Info($App->Context->getAll(),"En '".$path_ActionFile."': Todo OK en '".$actionMethod."'"); return($App); } else A2Debug::Error("En '".$path_ActionFile."': No existe el metodo 'execute()'!"); } else A2Debug::Error("En '".$path_ActionFile."': No existe la clase '".$actionClass."'!"); } //2. como no ha funcionado lo primero, intentamos cargar la clase estándar actions else if(is_readable($path_GenericActionFile)){ require_once($path_GenericActionFile); $moduleClass=$module."Actions"; if(class_exists($moduleClass)) { $App=new $moduleClass; $actionMethod="execute".ucfirst($action); if( method_exists($App,$actionMethod) ){ $App->Context->add(array( "ModuleName" => $module, "ModulePath" => $path_Module, "ModuleActionPath" => $path_ActionFile, "ModuleActionClassName" => $moduleClass, "ActionName" => $action, "ActionMethodName" => $actionMethod )); A2Debug::Info($App->Context->getAll(),"En '".$path_GenericActionFile."': Todo OK en '".$actionMethod."'"); return($App); } else A2Debug::Error("En '".$path_GenericActionFile."': No existe el metodo '".$actionMethod."' en el modulo especificado!"); } else A2Debug::Error("En '".$path_GenericActionFile."': No existe la clase '".$moduleClass."' del modulo especificado!"); } else A2Debug::Error("No existe el fichero '".$path_ActionFile."' ni el fichero '".$path_GenericActionFile."'!"); return(NULL); } static public function Forward404() { header("HTTP/1.0 404 Not Found"); die(); } } ?>