当前位置: 首页>>代码示例>>PHP>>正文


PHP ake函数代码示例

本文整理汇总了PHP中ake函数的典型用法代码示例。如果您正苦于以下问题:PHP ake函数的具体用法?PHP ake怎么用?PHP ake使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ake函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkAccessModule

 public function checkAccessModule()
 {
     $user = Utils::get('ThinUser');
     if (null !== $user) {
         $aclRules = Utils::get('ThinConfigAcl');
         $module = Utils::get('ThinModuleName');
         $controller = Utils::get('ThinControllerName');
         $action = Utils::get('ThinActionName');
         $module = Utils::get('ThinModuleName');
         $userRoles = em($this->_datas['config']['usersroles']['entity'], $this->_datas['config']['usersroles']['table'])->fetch()->findByAccountId($user->getId());
         $aclRoles = $this->_datas['config']['acl']['roles'];
         /* on regarde s'il y a une restriction d acces au module, on prenant garde de pouvoir afficher les pages statiques no-right et is-404 */
         if (ake($module, $aclRules) && 'no-right' != $action && 'is-404' != $action) {
             if (ake('cannotByRole', $aclRules[$module])) {
                 $access = false;
                 foreach ($aclRoles as $aclRole) {
                     foreach ($userRoles as $userRole) {
                         $role = $this->_datas['roleModel']->find($userRole->getRoleId())->getRoleName();
                         if (!Arrays::in($role, $aclRules[$module]['cannotByRole']) && in_array($role, $aclRoles)) {
                             $access = true;
                         }
                     }
                 }
                 if (false === $access) {
                     Utils::go($this->_datas['noRight']);
                     exit;
                 }
             }
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:31,代码来源:Acl.php

示例2: adminPlural

 public static function adminPlural($type)
 {
     $settings = ake($type, Data::$_settings) ? Data::$_settings[$type] : array();
     if (ake('plural', $settings)) {
         return static::display($settings['plural']);
     }
     return static::display($type . 's');
 }
开发者ID:noikiy,项目名称:inovi,代码行数:8,代码来源:Helper.php

示例3: count

 /**
  * Count the messages in the message buffer
  *
  * @return int
  *
  *
  */
 public function count()
 {
     if (ake('ThinFlash', $_SESSION)) {
         return count($_SESSION['ThinFlash']);
     } else {
         return 0;
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:15,代码来源:Flash.php

示例4: render

 public static function render($type, $content)
 {
     if (ake($type, static::$_headers)) {
         if (!headers_sent()) {
             header(static::$_headers[$type]);
             die($content);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:9,代码来源:Render.php

示例5: add

 public function add($name, $method)
 {
     if (!ake($name, $this->_methods)) {
         $this->_methods[$name] = $method;
         return $this;
     } else {
         throw new \Thin\Exception("This method {$name} already exists in this service {$this->_name}.");
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:9,代码来源:Manager.php

示例6: newRow

 public function newRow($data = array())
 {
     $object = o(sha1(time() . $this->settings['entity'] . session_id() . Utils::token()));
     $object->thin_litedb = $this;
     $object->id = null;
     if (count($data) && Arrays::isAssoc($data)) {
         foreach ($this->settings['modelFields'] as $field => $infos) {
             $value = ake($field, $data) ? $data[$field] : null;
             $object->{$field} = $value;
         }
     }
     return $object;
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Litedb.php

示例7: _getEmFromKey

 public function _getEmFromKey($key)
 {
     $classModel = $this->_datas['classModel'];
     $obj = new $classModel();
     if (Arrays::in($key, $this->_datas['keys'])) {
         if (isset($this->_datas['configModel']['relationship']) && ake($key, $this->_datas['configModel']['relationship'])) {
             $m = $this->_datas['configModel']['relationship'][$key];
             if (ake($modelField, $this->_datas['configModel']['relationshipEntities'])) {
                 $entity = $this->_datas['configModel']['relationshipEntities'][$key];
             } else {
                 $entity = $obj->_entity;
             }
             if (null !== $m) {
                 return new self($entity, $m['foreignTable']);
             }
         }
     }
     return null;
 }
开发者ID:schpill,项目名称:thin,代码行数:19,代码来源:Orm.php

示例8: isRoute

 public function isRoute($routeName)
 {
     $routes = container()->getMapRoutes();
     if (Arrays::isArray($routes)) {
         if (ake($routeName, $routes)) {
             $route = $routes[$routeName];
             $actualRoute = $this->getRoute();
             return $actualRoute === $route;
         }
     }
     return false;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:12,代码来源:Container.php

示例9: language

 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));
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:41,代码来源:Router.php

示例10: update

 public static function update($type, $object, $newData)
 {
     $fields = static::getModel($type);
     $new = array();
     $new['id'] = $object->id;
     $new['date_create'] = $object->date_create;
     foreach ($fields as $field => $info) {
         if (ake($field, $newData)) {
             $new[$field] = $newData[$field];
         } else {
             $value = !empty($object->{$field}) ? $object->{$field} : null;
             $new[$field] = $value;
         }
     }
     foreach ($newData as $newField => $value) {
         if (!ake($newField, $fields)) {
             $new[$newField] = $value;
         }
     }
     static::delete($type, $object->id);
     static::store($type, $new, $object->id);
     return static::getById($type, $object->id);
 }
开发者ID:schpill,项目名称:thin,代码行数:23,代码来源:Datacloud.php

示例11: getNode

 public function getNode($name)
 {
     return ake($name, $this->nodes) ? $this->nodes[$name] : null;
 }
开发者ID:schpill,项目名称:thin,代码行数:4,代码来源:Tree.php

示例12: query

 public static function query($type, $conditions = '')
 {
     $settings = Arrays::exists($type, static::$_settings) ? static::$_settings[$type] : static::defaultConfig($type);
     $hook = Arrays::exists('query', $settings) ? $settings['query'] : null;
     static::_hook($hook, func_get_args(), 'before');
     if (!Arrays::exists($type, static::$_db)) {
         static::db($type);
     }
     static::_incQueries(static::_getTime());
     $dirName = static::checkDir($type);
     $indexDir = STORAGE_PATH . DS . 'data' . DS . $dirName . DS . 'indexes';
     $queryKey = sha1(serialize(func_get_args()));
     $cache = static::cache($type, $queryKey);
     if (!empty($cache)) {
         static::_hook($hook, func_get_args(), 'after');
         return $cache;
     }
     $results = array();
     $resultsAnd = array();
     $resultsOr = array();
     $resultsXor = array();
     $fields = ake($type, static::$_fields) ? static::$_fields[$type] : static::noConfigFields($type);
     $indexes = ake('indexes', $settings) ? $settings["indexes"] : array();
     $fields['id'] = array();
     $fields['date_create'] = array();
     $datas = static::getAll($type);
     if (!count($datas)) {
         static::_hook($hook, func_get_args(), 'after');
         return $results;
     }
     if (!strlen($conditions)) {
         $results = $datas;
     } else {
         $q = "SELECT * FROM {$type} WHERE id IS NOT NULL";
         $res = static::$_db[$type]->query($q);
         $next = true;
         while ($row = $res->fetchArray() && true === $next) {
             $next = false;
         }
         if (true === $next) {
             foreach ($datas as $tmpObject) {
                 $object = static::getObject($tmpObject, $type);
                 $q = "INSERT INTO {$type} (id, date_create) VALUES ('" . SQLite3::escapeString($object->id) . "', '" . SQLite3::escapeString($object->date_create) . "')";
                 static::$_db[$type]->exec($q);
                 foreach ($fields as $field => $info) {
                     $value = is_object($object->{$field}) ? 'object' : $object->{$field};
                     $q = "UPDATE {$type} SET {$field} = '" . SQLite3::escapeString($value) . "' WHERE id = '" . SQLite3::escapeString($object->id) . "'";
                     static::$_db[$type]->exec($q);
                 }
             }
         }
         list($field, $op, $value) = explode(' ', $conditions, 3);
         $where = "{$field} {$op} '" . SQLite3::escapeString($value) . "'";
         $q = "SELECT id FROM {$type} WHERE {$where} COLLATE NOCASE";
         $res = static::$_db[$type]->query($q);
         while ($row = $res->fetchArray()) {
             $object = static::getById($type, $row['id']);
             array_push($results, $object);
         }
         return $results;
         foreach ($datas as $tmpObject) {
             $object = static::getObject($tmpObject, $type);
             $conditions = repl('NOT LIKE', 'NOTLIKE', $conditions);
             $conditions = repl('NOT IN', 'NOTIN', $conditions);
             list($field, $op, $value) = explode(' ', $conditions, 3);
             if (Arrays::exists($field, $indexes)) {
                 $indexInfo = $indexes[$field];
                 $typeIndex = Arrays::exists('type', $indexInfo) ? $indexInfo['type'] : 'none';
                 if ('fulltext' == $typeIndex) {
                     $words = static::prepareFulltext($value);
                     if (count($words)) {
                         foreach ($words as $word) {
                             $indexWordDir = $indexDir . DS . $field . DS . md5($word);
                             $objects = glob($indexWordDir . DS . '*.data', GLOB_NOSORT);
                             if (!$objects) {
                                 $objects = array();
                             }
                             if (count($objects)) {
                                 foreach ($objects as $tmpObject) {
                                     $tab = explode(DS, $tmpObject);
                                     $idTmp = repl('.data', '', Arrays::last($tab));
                                     $object = static::getById($type, $idTmp);
                                     array_push($results, $object);
                                 }
                             }
                         }
                     }
                 } else {
                     $indexDir .= DS . $field . DS . md5($value);
                     $objects = glob($indexDir . DS . '*.data', GLOB_NOSORT);
                     if (!$objects) {
                         $objects = array();
                     }
                     if (count($objects)) {
                         foreach ($objects as $tmpObject) {
                             $tab = explode(DS, $tmpObject);
                             $idTmp = repl('.data', '', Arrays::last($tab));
                             $object = static::getById($type, $idTmp);
                             array_push($results, $object);
                         }
//.........这里部分代码省略.........
开发者ID:schpill,项目名称:thin,代码行数:101,代码来源:Data.php

示例13: row

 public function row(array $data, $recursive = true, $extends = array())
 {
     if (Arrays::isAssoc($data)) {
         $obj = o(sha1(serialize($data)));
         $obj->db_instance = $this;
         if (count($extends)) {
             foreach ($extends as $name => $instance) {
                 $closure = function ($object) use($name, $instance) {
                     $idx = $object->is_thin_object;
                     $objects = Utils::get('thinObjects');
                     return $instance->{$name}($objects[$idx]);
                 };
                 $obj->_closures[$name] = $closure;
             }
         }
         $fields = $this->fields();
         foreach ($fields as $field) {
             $hasFk = $this->hasFk($field);
             if (false === $hasFk) {
                 $obj->{$field} = $data[$field];
             } else {
                 extract($hasFk);
                 $ar = ar($foreignEntity, $foreignTable);
                 $one = contain('toone', Inflector::lower($type));
                 if ($one && $recursive) {
                     $foreignObj = $ar->findBy($foreignKey, $data[$field], $one);
                     $obj->{$relationKey} = $foreignObj;
                 }
             }
         }
         $hasFk = ake('relationships', $this->_settings);
         if (true === $hasFk && $recursive) {
             $rs = $this->_settings['relationships'];
             if (count($rs)) {
                 foreach ($rs as $field => $infos) {
                     extract($infos);
                     $ar = ar($foreignEntity, $foreignTable);
                     if (!Arrays::in($field, $fields)) {
                         $pk = $this->pk();
                         $obj->{$field} = $ar->findBy($foreignKey, $obj->{$pk}, false, false);
                     }
                 }
             }
         }
         return $obj;
     }
     return null;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:48,代码来源:Activerecord.php

示例14: select

 public static function select($name, $options = array(), $selected = null, $attributes = array(), $label = '')
 {
     $attributes['id'] = static::id($name, $attributes);
     $attributes['name'] = $name;
     $html = array();
     foreach ($options as $value => $display) {
         if (is_array($display)) {
             $html[] = static::optgroup($display, $value, $selected);
         } else {
             $html[] = static::option($value, $display, $selected);
         }
     }
     if (!ake('required', $attributes)) {
         $attributes['required'] = false;
     }
     $required = $attributes['required'];
     if (false === $required) {
         unset($attributes['required']);
     }
     $field = '<select class="span6"' . Html::attributes($attributes) . '>' . implode('', $html) . '</select>';
     return static::buildWrapper($field, $name, $label, false, $required);
 }
开发者ID:noikiy,项目名称:inovi,代码行数:22,代码来源:Form.php

示例15: makeSql

 private function makeSql()
 {
     $join = $distinct = $groupBy = $order = $limit = '';
     $where = empty($this->wheres) ? '1 = 1' : implode('', $this->wheres);
     if (ake('order', $this->query)) {
         $order = 'ORDER BY ';
         $i = 0;
         foreach ($this->query['order'] as $qo) {
             list($field, $direction) = $qo;
             if ($i > 0) {
                 $order .= ', ';
             }
             $order .= "{$this->db}.{$this->table}.{$field} {$direction}";
             $i++;
         }
     }
     if (ake('limit', $this->query)) {
         list($max, $offset) = $this->query['limit'];
         $limit = "LIMIT {$offset}, {$max}";
     }
     if (ake('join', $this->query)) {
         $join = implode(' ', $this->query['join']);
     }
     if (ake('groupBy', $this->query)) {
         $groupBy = 'GROUP BY ' . $this->query['groupBy'];
     }
     if (ake('distinct', $this->query)) {
         $distinct = true === $this->query['distinct'] ? 'DISTINCT' : '';
     }
     $sql = "SELECT {$distinct} " . $this->db . '.' . $this->table . '.' . implode(', ' . $this->db . '.' . $this->table . '.', $this->fields()) . "\n                FROM {$this->db}.{$this->table} {$join}\n                WHERE {$where} {$order} {$limit} {$groupBy}";
     return $sql;
 }
开发者ID:schpill,项目名称:standalone,代码行数:32,代码来源:Db.php


注:本文中的ake函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。