Example #1
0
 public function before_filter()
 {
     $this->limit_params = false;
     // Si es AJAX enviar solo el view
     if (Input::isAjax()) {
         View::response('view');
     }
 }
Example #2
0
File: rest.php Project: Jamp/sgas
 /**
  * Define el inicio de un servicio REST
  *
  * @param Controller $controller controlador que se convertira en un servicio REST
  */
 public static function init(Controller $controller)
 {
     $content = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : 'text/html';
     /**
      * Verifico el formato de entrada
      */
     self::$_iFormat = str_replace(array('text/', 'application/'), '', $content);
     /* Compruebo el método de petición */
     self::$_method = strtolower($_SERVER['REQUEST_METHOD']);
     $format = explode(',', $_SERVER['HTTP_ACCEPT']);
     while (self::$_oFormat = array_shift($format)) {
         self::$_oFormat = str_replace(array('text/', 'application/'), '', self::$_oFormat);
         if (in_array(self::$_oFormat, self::$_outputFormat)) {
             break;
         }
     }
     /**
      * Si no lo encuentro, revuelvo un error
      */
     if (self::$_oFormat == null) {
         return 'error';
     } else {
         View::response(self::$_oFormat);
         View::select('response');
     }
     /**
      * Si la acción del controlador es un numero lo pasamos a los parametros
      */
     if (is_numeric($controller->action_name)) {
         $controller->parameters = array($controller->action_name) + Rest::param();
     } else {
         $controller->parameters = Rest::param();
     }
     /**
      * reescribimos la acción a ejecutar, ahora tendra será el metodo de
      * la peticion: get , put, post, delete, etc.
      */
     $controller->action_name = self::$_method;
     $controller->limit_params = FALSE;
     //no hay verificación en el numero de parametros.
     $controller->data = array();
     //variable por defecto para las vistas.
 }
 /**
  * Indica el tipo de Respuesta dada por el controlador
  *
  * @param string $type
  *
  * @deprecated Ahora se usa <code>View::response()</code>
  */
 protected function set_response($type, $template = FALSE)
 {
     View::response($type, $template);
 }
 public function checkLogin()
 {
     $salida['status'] = "ERROR";
     if (Input::hasPost('login')) {
         $login = Input::post('login');
         Load::model('usuario');
         $usuario = new Usuario();
         if (!$usuario->buscarLogin($login)) {
             $salida['status'] = "OK";
         }
     }
     View::template(null);
     View::response('json');
     print json_encode($salida);
 }
 /**
  * Genera RSS
  *
  */
 public function rss()
 {
     View::response('view');
     $articulo = new Articulo();
     $this->lastPost = $articulo->getLast();
 }
Example #6
0
 /**
  * Corriendo filtro
  *
  */
 public function before_filter()
 {
     if (Input::isAjax()) {
         View::response('view');
     }
 }
Example #7
0
 public function js()
 {
     $url = $_GET['src'];
     return parent::response("{$url}", "text/javascript");
 }
Example #8
0
<?php

$start = microtime(true);
// Подключение всех файлов php c контроллерами, моделями и библиотеками
foreach (glob("lib/*.php") as $file) {
    include $file;
}
foreach (glob("controller/*.php") as $file) {
    include $file;
}
foreach (glob("model/*.php") as $file) {
    include $file;
}
DB::connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// TODO --- http://php.net/manual/ru/language.exceptions.php
// Если переданны данные
try {
    list($controller_name, $method_name, $params) = Core::parse_url();
    $controller = new $controller_name();
    // Вызывается метод, с передачей массива параметров
    $result = $controller->run($method_name, $params);
} catch (Exception $e) {
    $controller = new View();
    $result = View::error404($e->getMessage());
}
$controller->response($result);
mysql_close();
$time = microtime(true) - $start;
echo '<!--Скрипт выполнялся ' . round($time, 6) . ' сек.-->';
 public function getParroquiaMunicipio()
 {
     View::response('view');
     $this->municipio_id = Input::post('municipio_id');
 }