Example #1
0
 public function __toString()
 {
     try {
         return $this->getHtml();
     } catch (Exception $e) {
         Oops_Debug::Dump($e, 'exception', true);
         return '';
     }
 }
Example #2
0
 function Out()
 {
     ob_start();
     Oops_Debug::Dump($this->_in);
     return ob_get_clean();
 }
Example #3
0
 /**
  * @ignore
  */
 public static function print_r_dhtml($value, $first = true)
 {
     static $style = '';
     static $i = 0;
     $i++;
     static $j = 0;
     if ($first) {
         $j = 0;
         $style = "display: block;";
         //			$value = unserialize(serialize($value));
     }
     if (++$j > 10) {
         $style = "display: none;";
     }
     $type = gettype($value);
     switch ($type) {
         case "object":
             $type .= " <i>" . get_class($value) . "</i>";
             $value = array('__dump__' => print_r($value, true));
         case "array":
             echo "<a onclick=\"document.getElementById('_ate_{$i}').style.display = ";
             echo "document.getElementById('_ate_{$i}";
             echo "').style.display == 'block' ?";
             echo "'none' : 'block';return false;\" href=\"#\">" . ucfirst($type) . " (" . sizeof($value) . ")</a>\n";
             echo "<ul id=\"_ate_{$i}\" style=\"{$style}\">";
             foreach ($value as $k => $v) {
                 echo "<li>[" . htmlspecialchars($k) . "] => ";
                 Oops_Debug::print_r_dhtml($v, false);
                 echo "</li>\n";
             }
             echo "</ul>";
             break;
         case "double":
         case "float":
         case "integer":
             echo '<span style="color:blue;">' . htmlspecialchars($value) . '</span>';
             break;
         case "boolean":
             echo '<span style="color:#335577;">' . ($value ? "true" : "false") . '</span>';
             break;
         case "string":
             echo '<span style="color:#337733;"><pre><code>' . htmlspecialchars($value) . "</code></pre></span>";
             break;
         default:
             echo $type;
             break;
     }
 }
Example #4
0
 /**
  * Run the application and output the response
  *
  * @param Oops_Server_Request $request
  *        	Request to dispatch
  * @return void
  */
 public function Run($request = null)
 {
     // @todo skip hander and use error log, or use static handler that will
     // log errors?
     $this->_errorHandler = new Oops_Error_Handler();
     try {
         if (!is_object($request)) {
             $this->_request = new Oops_Server_Request_Http();
             $this->_response = new Oops_Server_Response_Http();
         } else {
             $this->_request = $request;
             $this->_response = new Oops_Server_Response();
         }
         $this->_parseRequest();
         $this->_initView();
         $this->_routeRequest();
         // @todo try to find controller action, then do everything else
         $this->_initController();
         $data = $this->_controller_instance->Run();
         // @todo Let the view handler use getRequest and getResponse as it
         // need it
         $this->_view->In($data);
         $this->_view->Set('controller', $this->_router->controller);
         $this->_view->Set('uri', $this->_request->getUri());
         $this->_view->Set('ext', $this->_extension);
         $this->_view->Set('action', $this->_action);
         $this->_view->Set('uri_parts', $this->_uri_parts);
         $this->_response->setHeader("Content-type", $this->_view->getContentType());
         $this->_response->setBody($this->_view->Out());
     } catch (Oops_Server_Exception $e) {
         // Here we catch cases where response code was set by router or
         // controller (302, 301, 404 еtс)
         switch ($e->getCode()) {
             case OOPS_SERVER_EXCEPTION_RESPONSE_READY:
                 //
                 // init response code handler here
                 $responseCodeHandler = $this->loadResponseCodeHandler();
                 $responseCodeHandler->handle($this->_response);
                 break;
             default:
                 // @todo refactor unknown exceptions catching to log and 500
                 throw $e;
         }
     } catch (Exception $e) {
         trigger_error($e->getMessage(), E_USER_ERROR);
     }
     // @todo refactor error logging etc
     if ((string) $this->_config->oops->errors2Headers && Oops_Debug::allow()) {
         $this->_response->reportErrors($this->_errorHandler);
     }
     if ((string) $this->_config->oops->errorlog->enabled) {
         Oops_Log_Error::report($this->_errorHandler, $this->_config->oops->errorlog->path);
     }
     restore_error_handler();
     return $this->_response;
 }