Esempio n. 1
0
 /**
  * Singleton
  *
  * @static
  * @return null
  */
 public static function singleton()
 {
     $returnValue = null;
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     $returnValue = self::$instance;
     return $returnValue;
 }
 /**
  * Executes a query on the storage engine. Should be only used for INSERT,
  * DELETE statements.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  string statement
  * @param  array params
  * @return int
  */
 public function exec($statement, $params = array())
 {
     $this->debug($statement);
     common_Profiler::queryStart();
     $returnValue = $this->persistence->exec($statement, $params);
     common_Profiler::queryStop($statement, $params);
     $this->incrementNrOfQueries();
     return (int) $returnValue;
 }
 /**
  * Dispatch the current http request into the control loop:
  *  1. Load the ressources
  *  2. Start the MVC Loop from the ClearFW
  *  manage Exception:
  */
 public function dispatch()
 {
     common_Profiler::start('dispatch');
     if (!self::$isDispatched) {
         $isAjax = tao_helpers_Request::isAjax();
         if (tao_helpers_Context::check('APP_MODE')) {
             if (!$isAjax) {
                 $this->scripts();
             }
         }
         //Catch all exceptions
         try {
             //the app is ready
             if ($this->isReady()) {
                 $this->mvc();
             } else {
                 //the request is not an ajax request, redirect the user to the maintenance page
                 if (!$isAjax) {
                     require_once Template::getTemplate('error/maintenance.tpl', 'tao');
                     //else throw an exception, this exception will be send to the client properly
                 } else {
                     throw new common_exception_SystemUnderMaintenance();
                 }
             }
         } catch (Exception $e) {
             $this->catchError($e);
         }
         self::$isDispatched = true;
     }
     common_Profiler::stop('dispatch');
 }