public function row($tab = array()) { $fields = array_keys($this->map['fields']); $pk = $this->pk(); $id = isAke($tab, $pk, false); if (count($tab)) { foreach ($tab as $key => $value) { if (!Arrays::in($key, $fields)) { unset($tab[$key]); } } foreach ($fields as $field) { $val = isAke($tab, $field, false); if (false === $val && false === $id) { $tab[$field] = null; } } } else { foreach ($fields as $field) { if (false === $id) { $tab[$field] = null; } } } $o = new Container(); $o->populate($tab); return $this->closures($o); }
public function toObject($tab = array()) { $o = new Container(); $o->populate($tab); return $this->closures($o); }
public static function language() { $isCMS = null !== container()->getPage(); $session = session('web'); if (true === $isCMS) { if (count($_POST)) { if (ake('cms_lng', $_POST)) { $session->setLanguage($_POST['cms_lng']); } else { $language = $session->getLanguage(); $language = null === $language ? Cms::getOption('default_language') : $language; $session->setLanguage($language); } } else { $language = $session->getLanguage(); $language = null === $language ? Cms::getOption('default_language') : $language; $session->setLanguage($language); } } else { $route = Utils::get('appDispatch'); $language = $session->getLanguage(); if (null === $language || $language != $route->getLanguage()) { $language = null === $route->getLanguage() ? options()->getDefaultLanguage() : $route->getLanguage(); $session->setLanguage($language); } $module = $route->getModule(); $controller = $route->getController(); $action = $route->getAction(); $module = is_string($action) ? Inflector::lower($module) : $module; $controller = is_string($action) ? Inflector::lower($controller) : $controller; $action = is_string($action) ? Inflector::lower($action) : $action; $config = array(); $config['language'] = $language; $config['module'] = $module; $config['controller'] = $controller; $config['action'] = $action; $configLanguage = new Container(); $configLanguage->populate($config); container()->setLanguage(new Language($configLanguage)); } }
function request() { $tab = explode('?', $_SERVER['REQUEST_URI']); if (count($tab) > 1) { list($start, $query) = explode('?', $_SERVER['REQUEST_URI']); if (strlen($query)) { $str = parse_str($query, $output); if (count($output)) { foreach ($output as $k => $v) { $_REQUEST[$k] = $v; } } } } $object = new Container(); $object->populate($_REQUEST); $uri = substr($_SERVER['REQUEST_URI'], 1, strlen($_SERVER['REQUEST_URI'])); $object->setThinUri(explode('/', $uri)); return $object; }
public function row(array $values) { $class = $this; $obj = new Container(); $key = $this->key; $record = function () use($class, $obj, $key) { $tab = $obj->assoc(); return $class->push($key, $tab); }; $purge = function () use($class, $obj, $key) { $tab = $obj->assoc(); return $class->pop($key, $tab['id']); }; $date = function ($f) use($obj) { return date('Y-m-d H:i:s', $obj->{$f}); }; $hydrate = function ($data) use($obj) { if (Arrays::isAssoc($data)) { foreach ($data as $k => $v) { $obj->{$k} = $v; } } return $obj; }; $display = function ($field) use($obj) { return \Thin\Html\Helper::display($obj->{$field}); }; $tab = function () use($obj) { return $obj->assoc(); }; $asset = function ($field) use($obj) { return '/storage/img/' . $obj->{$field}; }; $obj->event('record', $record)->event('purge', $purge)->event('date', $date)->event('hydrate', $hydrate)->event('tab', $tab)->event('asset', $asset)->event('display', $display); return $obj->populate($values); }
public function row($tab = []) { $id = isAke($tab, 'id', false); if (false !== $id) { if (!is_numeric($id)) { throw new Exception("the id must be numeric."); } else { $tab['id'] = (int) $id; } } $o = new Container(); $o->populate($tab); return $this->closures($o); }
public function row($tab = []) { $o = new Container(); $o->populate($tab); return $this->closures($o); }