public function db() { if ($this->db) { return Now::get($this->db); } return null; }
public function __get($k) { if ($k == 'link') { return Now::get("blizz.link.{$this->db}.{$this->table}"); } return isset($this->{$k}) ? $this->{$k} : null; }
/** * * @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); }
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; }
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; }
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; }
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; }
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); } }
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); } } }
public function collection() { return Now::get('remote.collection.' . $this->db . '.' . $this->table); }
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); } }
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; }
public function setVar($k, $v = null) { return Now::set($k, $v); }
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; } }
public function store() { return Now::get("bluzz.store.{$this->db}.{$this->table}"); }
public function forget($k) { $k = 'flash.' . $k; return Now::delrte($k); }
public function session_id() { return Now::get('session.id', session_id()); }