Ejemplo n.º 1
0
 public function db()
 {
     if ($this->db) {
         return Now::get($this->db);
     }
     return null;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
 public function boot($cb404 = null)
 {
     if (is_null($cb404)) {
         $this->cb404 = function () {
             return ['static', 'is404', true];
         };
     } else {
         $this->cb404 = $cb404;
     }
     list($controllerName, $action, $render) = $this->init();
     Now::set('request.controller', $controllerName);
     Now::set('request.action', $action);
     $controllerFile = path('module') . DS . 'controllers' . DS . $controllerName . '.php';
     if (!is_file($controllerFile)) {
         $controllerFile = path('module') . DS . 'controllers' . DS . 'static.php';
         $action = 'is404';
     }
     if (!is_file($controllerFile)) {
         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;
         }
     }
     require_once $controllerFile;
     $class = '\\Thin\\' . ucfirst(Inflector::lower($controllerName)) . 'Controller';
     $actions = get_class_methods($class);
     $father = get_parent_class($class);
     if ($father == 'Thin\\FrontController') {
         $a = $action;
         $method = $this->getMethod();
         $action = Inflector::lower($method) . ucfirst(Inflector::camelize(strtolower($action)));
         $controller = new $class();
         $controller->_name = $controllerName;
         $controller->action = $a;
         if (in_array('boot', $actions)) {
             $controller->boot();
         }
         if (in_array($action, $actions)) {
             $controller->{$action}();
         } else {
             Clipp::is404();
         }
         if (in_array('unboot', $actions)) {
             $controller->unboot();
         }
     } else {
         $controller = new $class($action);
     }
     if (true === $render) {
         $this->render($controller, Now::get('page404', false));
     }
 }
Ejemplo n.º 8
0
 public function get($k, $d = null)
 {
     $k = 'flash.' . $k;
     return Now::get($k, $d);
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 10
0
 public function collection()
 {
     return Now::get('remote.collection.' . $this->db . '.' . $this->table);
 }
Ejemplo n.º 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);
    }
}
Ejemplo n.º 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;
 }
Ejemplo n.º 13
0
 public function store()
 {
     return Now::get("bluzz.store.{$this->db}.{$this->table}");
 }
Ejemplo n.º 14
0
 public function getVar($k, $d = null)
 {
     return Now::get($k, $d);
 }
Ejemplo n.º 15
0
 public function session_id()
 {
     return Now::get('session.id', session_id());
 }