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


PHP Arr::getVal方法代码示例

本文整理汇总了PHP中Arr::getVal方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::getVal方法的具体用法?PHP Arr::getVal怎么用?PHP Arr::getVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arr的用法示例。


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

示例1: replacer

 public static function replacer($content = '', $data = array(), $other = array())
 {
     $other = (array) $other;
     $exploder = isset($other['exploder']) ? $other['exploder'] : '.';
     $replace_null = isset($other['replace_null']) ? $other['replace_null'] : false;
     $brackets = isset($other['brackets']) ? $other['brackets'] : array("{", "}");
     $op = $brackets[0];
     $cl = $brackets[1];
     preg_match_all('/' . preg_quote($op) . '([^(' . $cl . '|' . $op . '| )]*?)' . preg_quote($cl) . '/i', $content, $curly_matches);
     if (isset($curly_matches[1]) && !empty($curly_matches[1])) {
         foreach ($curly_matches[1] as $match) {
             $value = Arr::getVal($data, explode($exploder, $match));
             if (is_string($value) and !empty($other['nl2br'])) {
                 $value = nl2br($value);
             }
             if (!is_null($value)) {
                 if (is_array($value)) {
                     $content = str_replace($op . $match . $cl, var_export($value, true), $content);
                 } else {
                     if (!empty($other['escape'])) {
                         $content = str_replace($op . $match . $cl, htmlspecialchars($value), $content);
                     } else {
                         $content = str_replace($op . $match . $cl, $value, $content);
                     }
                 }
             } else {
                 if ($replace_null === true) {
                     $content = str_replace($op . $match . $cl, '', $content);
                 }
             }
         }
     }
     return $content;
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:34,代码来源:str.php

示例2: get

 function get($k, $v = null)
 {
     $return = Arr::getVal($this->params, explode('.', $k), '___NOT_SET___');
     if (!is_string($return) or $return != '___NOT_SET___') {
         return $return;
     } else {
         return $v;
     }
 }
开发者ID:joecacti,项目名称:diversebuild,代码行数:9,代码来源:parameter.php

示例3: replacer

 public static function replacer($content = '', $data = array(), $other = array())
 {
     $other = (array) $other;
     $exploder = isset($other['exploder']) ? $other['exploder'] : '.';
     $replace_null = isset($other['replace_null']) ? $other['replace_null'] : false;
     $repeater = isset($other['repeater']) ? $other['repeater'] : false;
     $brackets = isset($other['brackets']) ? $other['brackets'] : array("{", "}");
     $op = $brackets[0];
     $cl = $brackets[1];
     if (!empty($repeater)) {
         preg_match_all('/' . preg_quote($op) . $repeater . '([^' . preg_quote($cl) . ']*)' . preg_quote($cl) . '(.*?)' . preg_quote($op) . '\\/' . $repeater . preg_quote($cl) . '/is', $content, $repeater_matches);
         if (!empty($repeater_matches[0])) {
             foreach ($repeater_matches[0] as $k => $match) {
                 $path = '';
                 if (!empty($repeater_matches[1][$k])) {
                     $path = str_replace(':', '', $repeater_matches[1][$k]);
                 }
                 $sub_data = Arr::getVal($data, explode('.', $path), array());
                 if (!Arr::is_assoc($sub_data)) {
                     $sub_content = '';
                     foreach ($sub_data as $i => $sub_data_array) {
                         $sub_content .= self::replacer($repeater_matches[2][$k], $sub_data_array);
                     }
                     $content = str_replace($repeater_matches[0][$k], $sub_content, $content);
                 }
             }
         }
     }
     preg_match_all('/' . preg_quote($op) . '([^(' . $cl . '|' . $op . '| )]*?)' . preg_quote($cl) . '/i', $content, $curly_matches);
     if (isset($curly_matches[1]) && !empty($curly_matches[1])) {
         foreach ($curly_matches[1] as $match) {
             $value = Arr::getVal($data, explode($exploder, $match));
             if (is_string($value) and !empty($other['nl2br'])) {
                 $value = nl2br($value);
             }
             if (!is_null($value)) {
                 if (is_array($value)) {
                     $content = str_replace($op . $match . $cl, var_export($value, true), $content);
                 } else {
                     if (!empty($other['escape'])) {
                         $content = str_replace($op . $match . $cl, htmlspecialchars($value), $content);
                     } else {
                         $content = str_replace($op . $match . $cl, $value, $content);
                     }
                 }
             } else {
                 if ($replace_null === true) {
                     $content = str_replace($op . $match . $cl, '', $content);
                 }
             }
         }
     }
     return $content;
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:54,代码来源:str.php

示例4: data

 public static function data($key, $default = null)
 {
     //check POST
     $value = Arr::getVal(self::$data, explode('.', $key), null);
     if (!is_null($value)) {
         return $value;
     }
     //check POST
     $post = Arr::getVal($_POST, explode('.', $key), null);
     if (!is_null($post)) {
         return $post;
     }
     //check GET
     $get = Arr::getVal($_GET, explode('.', $key), null);
     if (!is_null($get)) {
         return $get;
     }
     //return default
     return $default;
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:20,代码来源:request.php

示例5: login

 public static function login($credentials)
 {
     $session = Base::getSession();
     $username_field = Base::getConfig('username_field', 'username');
     if (isset($credentials[$username_field]) and isset($credentials['password'])) {
         $user_model = new \GCore\Admin\Models\User();
         $user = $user_model->find('first', array('conditions' => array($username_field => $credentials[$username_field])));
         if (!empty($user)) {
             $user_groups = Arr::getVal($user, array('GroupUser', '[n]', 'group_id'), self::get_public_groups());
             $user_groups_paths = Arr::getVal($user, array('Group', '[n]', 'path'), array());
             $user_inheritance = array();
             foreach ($user_groups_paths as $user_groups_path) {
                 $user_inheritance = array_merge($user_inheritance, array_filter(explode('.', $user_groups_path)));
             }
             $user_inheritance = array_unique($user_inheritance);
             $user = $user['User'];
             $password_correct = self::check_password($credentials['password'], $user['password']);
             if (!$password_correct) {
                 $session->setFlash('error', l_('AUTHENTICATE_INCORRECT_LOGIN_CREDENTIALS'));
                 return false;
             }
             if (!empty($user['activation'])) {
                 $session->setFlash('error', l_('AUTHENTICATE_ACCOUNT_NOT_ACTIVATED'));
                 return false;
             }
             if ($user['blocked'] == 1) {
                 $session->setFlash('error', l_('AUTHENTICATE_ACCOUNT_BLOCKED'));
                 return false;
             }
             //account is found and can login, insert session data
             $user_session = array();
             $user_session['id'] = $user['id'];
             $user_session['name'] = $user['name'];
             $user_session['username'] = $user['username'];
             $user_session['email'] = $user['email'];
             $user_session['last_login'] = $user['last_visit'];
             $user_session['logged_in'] = 1;
             $user_session['groups'] = $user_groups;
             $user_session['inheritance'] = $user_inheritance;
             //get referer
             $referer = $session->get('_referer');
             $session->restart();
             $session->set('_referer', $referer);
             $session->set('user', array_merge($session->get('user', array()), $user_session));
             if (Base::getConfig('session_handler', 'php') == 'database') {
                 $session_model = new \GCore\Admin\Models\Session();
                 //$update = $session_model->updateAll(array('user_id' => $user['id'], 'site' => GCORE_SITE), array('session_id' => $session->get_id()));
                 $insert_status = $session_model->save(array('session_id' => $session->get_id(), 'user_id' => $user['id'], 'site' => GCORE_SITE, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'last_activity' => time()), array('new' => true));
             }
             //update last visit
             $user_model->updateAll(array('last_visit' => date('Y-m-d H:i:s', time())), array('id' => $user['id']), array('modified' => false));
             //after login hook
             $hook_results = Event::trigger('on_after_user_login');
             return true;
         } else {
             $session->setFlash('error', l_('AUTHENTICATE_INCORRECT_LOGIN_CREDENTIALS'));
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:62,代码来源:authenticate.php

示例6: setFlash

 function setFlash($type, $msg = '', $group = '')
 {
     $flashes = $this->get('__FLASH__', array());
     $path = array($type);
     if (!empty($group)) {
         $path = array($type, $group);
     }
     $type_msgs = Arr::getVal($flashes, $path, array());
     $type_msgs = array_merge($type_msgs, (array) $msg);
     return $this->set('__FLASH__', Arr::setVal($flashes, $path, $type_msgs));
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:11,代码来源:session.php

示例7: _save_hasMany

 private function _save_hasMany($data)
 {
     if (!empty($this->hasMany)) {
         foreach ($this->hasMany as $alias => $model_info) {
             if (!empty($model_info['save_on_save']) and (bool) $model_info['save_on_save'] === true and isset($this->{$alias})) {
                 //if the model class is loaded, inject new join
                 $className =& $this->{$alias};
                 $foreignKey = $model_info['foreignKey'];
                 //check if this is a new record or an existing one
                 if ($this->created === true) {
                     //new record, update and save associated data
                     if (!empty($data) and !empty($data[$alias])) {
                         foreach ($data[$alias] as $k => $_d) {
                             $data[$alias][$k][$foreignKey] = $this->id;
                         }
                         $className->saveAll($data[$alias]);
                     }
                 } else {
                     //update existing associated record
                     if (!empty($data) and isset($data[$alias])) {
                         //delete non existent records based on p key values
                         if (!empty($model_info['delete_non_existent']) and (bool) $model_info['delete_non_existent'] === true) {
                             $existing_keys = Arr::getVal($data, array($alias, '[n]', $className->pkey));
                             $existing_keys = array_unique($existing_keys);
                             $existing_keys = array_filter($existing_keys);
                             $delete_conditions = empty($model_info['conditions']) ? array($foreignKey => $this->id, 'NOT' => array($className->pkey => $existing_keys)) : array_merge(array($foreignKey => $this->id, 'NOT' => array($className->pkey => $existing_keys)), $model_info['conditions']);
                             $className->deleteAll($delete_conditions);
                         }
                         if (!empty($data[$alias])) {
                             //fix any foreign key issues and save
                             foreach ($data[$alias] as $k => $_d) {
                                 $data[$alias][$k][$foreignKey] = $this->id;
                             }
                             $className->saveAll($data[$alias]);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:41,代码来源:model.php

示例8: addJsFile

 function addJsFile($path, $type = 'text/javascript')
 {
     if (substr($path, 0, 4) != 'http') {
         if (strpos($path, '/') === false) {
             $path = \GCore\Helpers\Assets::js($path);
         } else {
             //relative file path provided
             $path = $this->url . $path;
         }
     }
     if (!in_array($path, (array) Arr::getVal($this->jsfiles, array('[n]', 'src')))) {
         $this->jsfiles[] = array('src' => $path, 'type' => $type);
     }
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:14,代码来源:document.php

示例9: _filter

 function _filter($columns = array())
 {
     $model_class = !empty($this->filter_model) ? $this->filter_model : null;
     if (empty($model_class)) {
         $alias = $this->get_main_model();
         if (!empty($alias)) {
             $model_class = $this->{$alias};
         } else {
             return;
         }
     }
     $prefix = '';
     if (!empty($this->filter_prefix)) {
         $prefix = '.' . $this->filter_prefix;
     }
     $session = Base::getSession();
     $filters = Request::data('fltr', $session->get(get_class($this) . $prefix . '.' . $model_class->alias . '.filters', array()));
     $conditions = array();
     if (!empty($filters)) {
         foreach ($columns as $k => $column) {
             $fv = Arr::getVal($filters, explode('.', $column), null);
             if (strlen($fv) > 0) {
                 $conditions[$column] = $fv;
             }
         }
     }
     Request::set('fltr', $filters);
     //set model conditions based on filters
     $model_class->conditions = array_merge($conditions, $model_class->conditions);
     $session->set(get_class($this) . $prefix . '.' . $model_class->alias . '.filters', $filters);
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:31,代码来源:gcontroller.php

示例10: afterFind

 function afterFind($type, &$data)
 {
     if (!empty($data) and is_array($data)) {
         $fresh_models = false;
         $_items = array_values($data);
         if ($data === $_items and !empty($_items[0][$this->alias])) {
             //this is a modeled data array
             $fresh_models = true;
             $this->_get_params_fields();
         }
         $models_list = array_merge(array($this->alias), array_keys($this->hasOne), array_keys($this->belongsTo));
         foreach ($data as $k => $record) {
             if ($fresh_models) {
                 $models_list = array_keys($record);
             }
             foreach ($models_list as $model) {
                 if (!empty($data[$k][$model])) {
                     if (isset($data[$k][$model]['extras'])) {
                         $extras = new Base64($data[$k][$model]['extras']);
                         $data[$k][$model]['extras'] = $extras->decode();
                     }
                     foreach ($this->params_fields as $params_field) {
                         if (isset($data[$k][$model][$params_field])) {
                             $params = new Parameter($data[$k][$model][$params_field]);
                             $data[$k][$model][$params_field] = $params->toArray();
                         }
                     }
                     if (!in_array($model, array('TagItem', 'Tag')) and !empty($this->hasMany['TagItem']) and isset($data[$k]['Tag'])) {
                         $tags = !is_null(Arr::getVal($data[$k]['Tag'], array('[n]', 'title'))) ? Arr::getVal($data[$k]['Tag'], array('[n]', 'title')) : array();
                         $data[$k][$model]['tags'] = implode(',', $tags);
                     }
                 }
             }
         }
     }
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:36,代码来源:gmodel.php


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