示例#1
0
 public function db()
 {
     if ($this->db) {
         return Now::get($this->db);
     }
     return null;
 }
示例#2
0
 public function __get($k)
 {
     if ($k == 'link') {
         return Now::get("blizz.link.{$this->db}.{$this->table}");
     }
     return isset($this->{$k}) ? $this->{$k} : null;
 }
示例#3
0
 /**
  *
  * @method __get
  *
  * @param  [type]
  *
  * @return [type]
  */
 public function __get($k)
 {
     if ($k == 'db') {
         $nowKey = 'cachemelite.link.' . $this->ns;
         return Now::get($nowKey);
     }
     return $this->get($k);
 }
示例#4
0
 public function getValue($username, $field, $default = null)
 {
     $row = coll(Now::get('acl.users.' . $this->ns, []))->firstBy('username', $username);
     if ($row) {
         return isAke($row, $field, $default);
     }
     return $default;
 }
示例#5
0
 public function fire($hook, $parameters = [])
 {
     $hooks = Now::get('core.hooks', []);
     $closure = isAke($hooks, $hook, null);
     if ($closure) {
         return call_user_func_array($closure, $parameters);
     }
     return null;
 }
示例#6
0
 public function fire($event, $parameters = [])
 {
     $events = Now::get('core.events', []);
     $closure = isAke($events, $event, null);
     if ($closure) {
         return call_user_func_array($closure, $parameters);
     }
     return null;
 }
示例#7
0
 public function reset()
 {
     $this->results = null;
     $this->totalResults = 0;
     $this->transactions = 0;
     $this->selects = [];
     $this->joinTables = [];
     $this->wheres = [];
     $this->groupBys = [];
     $this->orders = [];
     $store = lib('arstore', [$this->collection]);
     Now::set('ardb.store.' . $this->collection, $store);
     return $this;
 }
示例#8
0
 public function boot()
 {
     $uri = $this->getUri();
     list($controllerName, $action, $render) = $this->routes($uri);
     Now::set('controller', $controllerName);
     Now::set('action', $action);
     Now::set('session', session(SITE_NAME));
     $controllerFile = Config::get('mvc.dir', APPLICATION_PATH) . DS . 'controllers' . DS . $controllerName . '.php';
     if (!is_file($controllerFile)) {
         $controllerFile = Config::get('mvc.dir', APPLICATION_PATH) . DS . 'controllers' . DS . 'static.php';
         $action = 404;
     }
     require_once $controllerFile;
     $class = '\\Thin\\' . ucfirst(strtolower(SITE_NAME)) . ucfirst(Inflector::lower($controllerName)) . 'Controller';
     Now::set('request', (new Object())->populate($_REQUEST));
     $controller = new $class($action);
     if (true === $render) {
         $this->render($controller);
     }
 }
示例#9
0
 public function __call($m, $a)
 {
     $c = Now::get(str_replace(DS, '.', $this->_db->dir) . '.' . $m);
     if ($c && is_callable($c)) {
         $a[] = $this;
         return call_user_func_array($c, $a);
     } else {
         if (fnmatch('set*', $m)) {
             $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('set'))));
             $field = Inflector::lower($uncamelizeMethod);
             if (!empty($a)) {
                 $val = current($a);
             } else {
                 $val = null;
             }
             $this->{$field} = $val;
             return $this;
         } elseif (fnmatch('get*', $m)) {
             $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('set'))));
             $field = Inflector::lower($uncamelizeMethod);
             $default = count($a) == 1 ? current($a) : null;
             return isset($this->{$field}) ? $this->{$field} : $default;
         } else {
             return call_user_func_array([$this->_db], $a);
         }
     }
 }
示例#10
0
 public function collection()
 {
     return Now::get('remote.collection.' . $this->db . '.' . $this->table);
 }
示例#11
0
function path($k, $v = null, $d = null)
{
    $k = 'helpers.paths.' . $k;
    if (is_null($v)) {
        return Now::get($k, $d);
    } else {
        return Now::set($k, $v);
    }
}
示例#12
0
 public function check($id, $html)
 {
     require_once __DIR__ . DS . 'dom.php';
     $str = str_get_html($html);
     $segLangs = $str->find('lang');
     foreach ($segLangs as $segLang) {
         $default = $segLang->innertext;
         $args = $segLang->args;
         if (!empty($args)) {
             $controller = Now::get('instance.controller');
             $replace = "<lang args=\"{$args}\">{$default}</lang>";
             $file = path('cache') . DS . sha1(serialize($args)) . '.display';
             File::put($file, '<?php namespace Thin; ?>' . $args);
             ob_start();
             include $file;
             $args = ob_get_contents();
             ob_end_clean();
             File::delete($file);
         } else {
             $args = '[]';
             $replace = "<lang>{$default}</lang>";
         }
         $by = '<?php __(\'' . $default . '\', \'' . $id . '.' . Inflector::urlize($default, '-') . '\', ' . $args . '); ?>';
         $html = str_replace($replace, $by, $html);
     }
     return $html;
 }
示例#13
0
 public function setVar($k, $v = null)
 {
     return Now::set($k, $v);
 }
示例#14
0
 public function exec()
 {
     $method = $this->getMethod();
     $routes = [];
     $found = 0;
     $routes = isAke($this->routes, $method, []);
     if (!empty($routes)) {
         $found = $this->analyze($routes);
     }
     if ($found < 1) {
         if (isset($this->cb404) && is_callable($this->cb404)) {
             Now::set('page404', true);
             return call_user_func($this->cb404);
         } else {
             header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
             die;
         }
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'HEAD') {
             ob_end_clean();
         }
         return $this->route;
     }
 }
示例#15
0
 public function store()
 {
     return Now::get("bluzz.store.{$this->db}.{$this->table}");
 }
示例#16
0
 public function forget($k)
 {
     $k = 'flash.' . $k;
     return Now::delrte($k);
 }
示例#17
0
 public function session_id()
 {
     return Now::get('session.id', session_id());
 }