Ejemplo n.º 1
0
 /**
  *  Singletone static method
  */
 static function factory()
 {
     if (self::$_instance == NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 public function findAll($opciones = array(), $pagina = 1, $items_by_page = 20)
 {
     $db = CoreDb::getInstance();
     $where = "";
     // select all active users
     if (sizeof($opciones) > 0) {
         $w = CoreRoute::getWhere($opciones);
         if (sizeof($w) > 0) {
             $where = " WHERE " . implode(" AND ", $w);
         }
     }
     $result = $db->query("SELECT count(id) as total FROM " . $this->dbTable . $where, 1);
     $total = $result[0]["total"];
     $result = $db->query("SELECT * FROM " . $this->dbTable . $where . " LIMIT " . ($pagina - 1) * $items_by_page . "," . $items_by_page);
     return array("records" => $result, "total" => $total);
 }
Ejemplo n.º 3
0
 public function __construct($route, \Closure $callback = null)
 {
     if (!self::$_buildApi) {
         self::$_buildApi = true;
         $routes = (require PHPFOX_DIR_SETTING . 'routes.sett.php');
         foreach ($routes as $key => $value) {
             self::$routes[trim($key, '/')] = $value;
         }
     }
     if (is_array($route)) {
         foreach ($route as $key => $value) {
             if (is_string($value)) {
                 $value = ['call' => $value];
             }
             $key = trim($key, '/');
             $value['path'] = \Core\Route\Controller::$active;
             self::$routes[$key] = $value;
         }
     } else {
         if (self::$group) {
             $route = self::$group . $route;
         }
         $route = trim($route, '/');
         self::$routes[$route] = ['path' => \Core\Route\Controller::$active, 'id' => \Core\Route\Controller::$activeId];
         if ($callback instanceof \Closure) {
             self::$routes[$route]['run'] = $callback;
         }
         self::$_active = $route;
     }
     /*
     $apps = \Core\App::$routes;
     if ($apps) {
     	$_routes = [];
     	foreach ($apps as $key => $value) {
     		$_routes[trim($key, '/')] = $value;
     	}
     	// d(self::$routes); exit;
     	self::$routes = array_merge(self::$routes, (array) $_routes);
     }
     */
     // d(self::$routes); exit;
 }
Ejemplo n.º 4
0
 /**
  * @return mixed
  */
 public function getUser()
 {
     return CoreRoute::getUserLogged();
 }
 private function breadcrumb($breadcrumb)
 {
     $lista = array();
     foreach ($breadcrumb as $value) {
         switch ($value) {
             case "listado":
                 $lista[] = array("url" => CoreRoute::getUrl(self::$urlBase), "text" => _("Usuarios"));
                 break;
             case "add":
                 $lista[] = array("url" => CoreRoute::getUrl(self::$urlBase . "&a=Add"), "text" => _("Agregar usuario"));
                 break;
             case "edit":
                 $id = $_GET["id"];
                 $lista[] = array("url" => CoreRoute::getUrl(self::$urlBase . "&a=Edit&id=" . $id), "text" => _("Editar usuario"));
                 break;
         }
     }
     return $lista;
 }
Ejemplo n.º 6
0
 public static function addAlias(array $alias)
 {
     self::$alias = array_merge(self::$alias, $alias);
 }