예제 #1
0
 /**
  * Shows a 404.  Checks to see if a 404_override route is set, if not show
  * a default 404.
  *
  * Usage:
  *
  *     Request::show_404();
  *
  * @param   bool         Whether to return the 404 output or just output and exit
  * @return  void|string  Void if $return is false, the output if $return is true
  */
 public static function show_404($return = false)
 {
     logger(Fuel::L_INFO, 'Called', __METHOD__);
     // This ensures that show_404 doesn't recurse indefinately
     static $call_count = 0;
     $call_count++;
     if ($call_count == 1) {
         // first call, route the 404 route
         $route_request = true;
     } elseif ($call_count == 2) {
         // second call, try the 404 route without routing
         $route_request = false;
     } else {
         // third call, there's something seriously wrong now
         exit('It appears your _404_ route is incorrect.  Multiple Recursion has happened.');
     }
     if (\Config::get('routes._404_') === null) {
         $response = new \Response(\View::factory('404'), 404);
         if ($return) {
             return $response;
         }
         \Event::shutdown();
         $response->send(true);
     } else {
         $request = \Request::factory(\Config::get('routes._404_'), $route_request)->execute();
         if ($return) {
             return $request->response;
         }
         \Event::shutdown();
         $request->response->send(true);
     }
     \Fuel::finish();
     exit;
 }
예제 #2
0
파일: index.php 프로젝트: hymns/fuel
// Use an anonymous function to keep the global namespace clean
call_user_func(function () {
    /**
     * Set all the paths here
     */
    $app_path = '../fuel/app/';
    $package_path = '../fuel/packages/';
    $core_path = '../fuel/core/';
    /**
     * Website docroot
     */
    define('DOCROOT', __DIR__ . DIRECTORY_SEPARATOR);
    !is_dir($app_path) and is_dir(DOCROOT . $app_path) and $app_path = DOCROOT . $app_path;
    !is_dir($core_path) and is_dir(DOCROOT . $core_path) and $core_path = DOCROOT . $core_path;
    !is_dir($package_path) and is_dir(DOCROOT . $package_path) and $package_path = DOCROOT . $package_path;
    define('APPPATH', realpath($app_path) . DIRECTORY_SEPARATOR);
    define('PKGPATH', realpath($package_path) . DIRECTORY_SEPARATOR);
    define('COREPATH', realpath($core_path) . DIRECTORY_SEPARATOR);
});
// Get the start time and memory for use later
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true));
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage());
// Boot the app
require_once APPPATH . 'bootstrap.php';
// Generate the request, execute it and send the output.
echo Request::factory()->execute()->send_headers()->output();
// Fire off the shutdown event
Event::shutdown();
// Do some final cleanup
Fuel::finish();
/* End of file index.php */
예제 #3
0
 /**
  * Build
  * 
  * Builds the grid and renders
  * it as a View object
  * 
  * @access	public
  * @return	View
  */
 public function build()
 {
     // Make sure we have columns
     if (!$this->get_columns()->count()) {
         throw new Exception('You must add a column to the grid before building it');
     }
     $this->_prepare_grid();
     // Build the grid
     $grid = \View::forge(\Config::get('grid.view.grid', 'grid'))->set('grid', $this, false);
     // If we can't display a container just return
     // the grid
     if (!$this->can_display_container()) {
         // If we're dealing with an
         // AJAX request, we want to
         // stream a new response
         if (\Input::is_ajax() and $this->should_override_response()) {
             // Create and send a response
             // with the grid as the contents
             $response = new \Response($grid);
             $response->send(true);
             // Close down fuel
             \Event::shutdown();
             \Fuel::finish();
             exit;
         }
         // Return the grid
         return $grid;
     }
     // If we can display a container, add it
     // and return both of them
     return $this->get_container()->build()->set('grid', $grid, false);
 }