예제 #1
0
 public static function boot()
 {
     //echo '<pre>';
     //$url = 'http://*****:*****@hostname:9090/path?arg=value#anchor';
     //echo $url;
     //var_dump(parse_url($url));
     //var_dump(parse_url($url, PHP_URL_SCHEME));
     //var_dump(parse_url($url, PHP_URL_USER));
     //var_dump(parse_url($url, PHP_URL_PASS));
     //var_dump(parse_url($url, PHP_URL_HOST));
     //var_dump(parse_url($url, PHP_URL_PORT));
     //        echo '----';
     //var_dump(parse_url($url, PHP_URL_PATH));
     //var_dump(parse_url($url, PHP_URL_QUERY));
     //var_dump(parse_url($url, PHP_URL_FRAGMENT));
     //die();
     $uri = parse_url(self::getCurrentPageUrl(), PHP_URL_PATH);
     //$uri = $_SERVER['PATH_INFO'];
     $method = $_SERVER['REQUEST_METHOD'];
     try {
         $content = self::$route->run($uri, $method);
         if (is_object($content)) {
             $content->show();
         } else {
             echo $content;
         }
     } catch (Exception $e) {
         $view = new View();
         $view->load('error', ['message' => $e->getMessage(), 'system' => $e->getTraceAsString()]);
         $view->show();
         //redirect();
     }
 }
예제 #2
0
 /**
  * Main app screen with tasks if there are any
  * @param array $params parameters sent via http
  */
 public function index($params)
 {
     $ret = [];
     $view = new View('DONE! ToDo tasks app, MongoDB, Redis, localstorage');
     $ret['translations'] = json_encode($this->config->translations);
     $ret['categories'] = json_encode($this->config->categories);
     $mongoService = new MongoService($this->config);
     $ret['tasks'] = $mongoService->getAll($params);
     $view->render($ret);
 }
예제 #3
0
 /**
  * Render the output view when you finish the game
  *
  * @param Game $game
  */
 protected function renderGameFinished(Game $game)
 {
     $viewFlashMessage = new ViewFlashMessage();
     $view = new MainView();
     $flashMessage = $game->getFlashMessage();
     $message = "Well done! You complete the game in {$game->getShots()} shots";
     $flashMessage->customNotification($message);
     $viewFlashMessage->prepare($flashMessage);
     $view->addViewObject($viewFlashMessage);
     $view->render();
 }
예제 #4
0
 /**
  * Construtor
  * 
  * @param string $tipo
  * 
  * @throws \Exception
  */
 public function __construct($tipo)
 {
     // se existir $_GET['modulo']
     if (isset($_GET['modulo'])) {
         // concatenando o Namespace das Models ao valor $_GET
         $modulo = "\\Model\\{$_GET['modulo']}";
         // verificar se a classe existe
         if (class_exists($modulo)) {
             $model_obj = new $modulo();
             // se existir $_GET['acao']
             if (isset($_GET['acao'])) {
                 if ($tipo == Perfis::ADMINISTRATIVO && $_GET['acao'] != 'logar') {
                     if (!isset($_SESSION['funcionarios'])) {
                         header('Location: admin.php');
                     }
                 }
                 $acao = $_GET['acao'];
                 $dados = $model_obj->{$acao}();
                 $template = "{$_GET['modulo']}/{$acao}";
             } else {
                 throw new \Exception("Acao deve ser informada!");
             }
         } else {
             throw new \Exception("Model '{$_GET['modulo']}' nao encontrada!");
         }
         return View::carregar($tipo, strtolower($template), $dados);
     } else {
         // exibicao padrao
         return View::carregar($tipo, 'index');
     }
 }
예제 #5
0
 public static function dispatch($controller)
 {
     $url = array();
     $urlPath = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
     $urlParts = explode("/", $urlPath);
     $action = $urlParts[1];
     if (empty($action)) {
         $action = "index";
     }
     if (method_exists($controller, $action)) {
         self::$view = View::getInstance();
         $enableView = call_user_func_array(array($controller, $action), array());
         if ($enableView) {
             self::$view->loadTemplates($action);
         }
     } else {
         header("HTTP/1.1 404 Not Found");
         die("Wrong action");
     }
 }
예제 #6
0
파일: Helpers.php 프로젝트: itnactcp/htdocs
function view($file, $variable = array())
{
    $view = new View();
    $view->load($file, $variable);
    return $view;
}
예제 #7
0
파일: Load.php 프로젝트: ignaszak/cms
 /**
  * Load theme index file
  */
 public function loadTheme()
 {
     $this->view->loadFile('index.html');
 }