示例#1
0
 /**
  *  Singletone static method
  */
 static function factory()
 {
     if (self::$_instance == NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 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);
 }
示例#3
0
文件: Route.php 项目: lev1976g/core
 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;
 }
 /**
  * @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;
 }
示例#6
0
 public static function addAlias(array $alias)
 {
     self::$alias = array_merge(self::$alias, $alias);
 }