Esempio n. 1
4
<?php

use Inphinit\App;
use Inphinit\View;
use Inphinit\Request;
use Inphinit\Routing\Route;
App::on('changestatus', function ($status, $msg) {
    if ($status === 503) {
        echo 'This site is currently down for maintenance and should be back soon!';
    } elseif (in_array($status, array(401, 403, 404, 500, 501))) {
        View::forceRender();
        View::render('httpview', array('title' => $msg ? $msg : 'Página inacessível', 'method' => $_SERVER['REQUEST_METHOD'], 'path' => Request::path(), 'route' => Request::path(true), 'status' => $status));
        exit;
    }
});
Route::set('ANY', '/', 'Home:index');
// Navitate to http://[server]/user/[YOUR NAME] like: http://[server]/user/mary
Route::set('ANY', 're:#^/user/([a-z0-9_]+)$#', 'Users.Profile:view');
// Navitate to http://[server]/info
Route::set('ANY', '/info', 'Examples:info');
// Navitate to http://[server]/closure
Route::set('ANY', '/closure', 'Examples:arrayClosure');
Esempio n. 2
2
 protected function checkPath()
 {
     if ($this->path) {
         $path = Request::path();
         if (strpos($path, $this->path) === 0) {
             $this->currentPrefixPath = $this->path;
             return array();
         } elseif (self::checkRegEx($this->path, $path, $matches)) {
             $this->currentPrefixPath = $matches[0];
             array_shift($matches);
             return $matches;
         }
     }
     return false;
 }
Esempio n. 3
1
 public static function renderError($type, $message, $file, $line)
 {
     if (empty(self::$views['error'])) {
         return null;
     }
     $data = self::details($message, $file, $line);
     if (!headers_sent() && Request::is('xhr')) {
         ob_start();
         self::unregister();
         Response::cache(0);
         Response::type('application/json');
         echo json_encode($data);
         App::abort(500);
     }
     View::render(self::$views['error'], $data);
 }