Exemplo n.º 1
0
 /**
  * Application startup method
  * 
  * @return void
  */
 public static function runApp()
 {
     try {
         $application = new Uni_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/system.xml');
         $bs = $application->bootstrap();
         $bs->run();
         if (!Uni_Core_Installer::isInstalled()) {
             throw new Exception('Application is not installed.', 9999);
         }
     } catch (Exception $e) {
         $systemConfigPath = CONFIG_DIR . DIRECTORY_SEPARATOR . 'system.xml';
         if ($e->getCode() == 9999 || !(file_exists($systemConfigPath) && is_readable($systemConfigPath))) {
             $urlParts = explode('/', $_SERVER['REQUEST_URI']);
             $urlPattern = '';
             if (count($urlParts) > 2) {
                 for ($i = 0; $i < count($urlParts); $i++) {
                     if ($urlParts[$i] == 'installer') {
                         $urlPattern = $urlParts[$i];
                         break;
                     }
                 }
             }
             if (!(strtolower($urlPattern) == 'installer')) {
                 self::runInstaller();
             } else {
                 self::$modeRun = FALSE;
                 Fox::setMode('installer');
                 $application = new Uni_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/system_default.xml');
                 try {
                     $application->bootstrap()->run();
                 } catch (Exception $e) {
                     if (Uni_Core_Installer::isInstalled()) {
                         echo $e->getMessage() . '<br/>';
                         echo $e->getTraceAsString();
                     }
                 }
             }
         } else {
             echo $e->getMessage();
         }
     }
 }