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


PHP Arr::get方法代码示例

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


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

示例1: onUpdateDocument

 public function onUpdateDocument(DataSource_Hybrid_Document $old = NULL, DataSource_Hybrid_Document $new)
 {
     $files = Arr::get($_FILES, $this->name);
     $remove_files = $new->get($this->name . '_remove');
     if (!empty($remove_files)) {
         ORM::factory('media')->delete_by_ids($remove_files);
     }
     if (empty($files)) {
         return FALSE;
     }
     $old_files = $old->get($this->name);
     $old_files = empty($old_files) ? array() : explode(',', $old_files);
     $files = $this->_normalize_files($files);
     foreach ($files as $file) {
         if (!Upload::not_empty($file)) {
             continue;
         }
         try {
             $uploaded_file = ORM::factory('media')->set('module', $this->module_id())->upload($file, array('jpg', 'jpeg', 'gif', 'png'), $this->max_size);
             if ($uploaded_file->loaded()) {
                 $old_files[] = $uploaded_file->id;
             }
         } catch (Exception $ex) {
             continue;
         }
     }
     $new->set($this->name, implode(',', $old_files));
     return TRUE;
 }
开发者ID:ortodesign,项目名称:cms,代码行数:29,代码来源:images.php

示例2: get_available_langs

 public function get_available_langs()
 {
     $langs = I18n::available_langs();
     $system_default = Arr::get($langs, Config::get('site', 'default_locale'));
     $langs[Model_User::DEFAULT_LOCALE] = __('System default (:locale)', array(':locale' => $system_default));
     return $langs;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:profile.php

示例3: set_cache

 /**
  * Override of the set_cache method, works in exactly the same way except
  * the check for the max-age header in the response has been removed so that
  * Codebase API responses will always be cached, this breaks HTTP Cache
  * rules but is the cleanest way of enabling caching for all responses
  * within Kohana.
  *
  * @param	Response	$response
  * @return	boolean
  */
 public function set_cache(Response $response)
 {
     $headers = $response->headers()->getArrayCopy();
     if ($cache_control = Arr::get($headers, 'cache-control')) {
         // Parse the cache control
         $cache_control = HTTP_Header::parse_cache_control($cache_control);
         // If the no-cache or no-store directive is set, return
         if (array_intersect($cache_control, array('no-cache', 'no-store'))) {
             return FALSE;
         }
         // Check for private cache and get out of here if invalid
         if (!$this->_allow_private_cache and in_array('private', $cache_control)) {
             if (!isset($cache_control['s-maxage'])) {
                 return FALSE;
             }
             // If there is a s-maxage directive we can use that
             $cache_control['max-age'] = $cache_control['s-maxage'];
         }
     }
     /**
      * if the max-age cache control header is set to 0 in the response, set
      * it to 1 hour so the reponse will be cacheable
      */
     $cache_control_header = $response->headers('Cache-Control');
     $response->headers('Cache-Control', str_replace('max-age=0', 'max-age=3600', $cache_control_header));
     if ($expires = Arr::get($headers, 'expires') and !isset($cache_control['max-age'])) {
         // Can't cache things that have expired already
         if (strtotime($expires) <= time()) {
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:rpa-design,项目名称:codebase,代码行数:43,代码来源:cache.php

示例4: verify

 /**
  * Verify the login result and do whatever is needed to access the user data from this provider.
  * @return bool
  */
 public function verify()
 {
     // create token
     $request_token = OAuth_Token::factory('request', array('token' => Session::instance()->get('oauth_token'), 'secret' => Session::instance()->get('oauth_token_secret')));
     // Store the verifier in the token
     $verifier = Arr::get($_REQUEST, 'oauth_verifier');
     if (empty($verifier)) {
         return false;
     }
     $request_token->verifier($verifier);
     // Exchange the request token for an access token
     $access_token = $this->provider->access_token($this->consumer, $request_token);
     if ($access_token and $access_token->name === 'access') {
         $request = OAuth_Request::factory('resource', 'GET', 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,email-address)?format=json', array('oauth_consumer_key' => $this->consumer->key, 'oauth_signature_method' => "HMAC-SHA1", 'oauth_token' => $access_token->token));
         // Sign the request using only the consumer, no token is available yet
         $request->sign(new OAuth_Signature_HMAC_SHA1(), $this->consumer, $access_token);
         // decode and store data
         $data = json_decode($request->execute(), true);
         $this->uid = $data['id'];
         $this->data = $data;
         return true;
     } else {
         return false;
     }
 }
开发者ID:rafsoaken,项目名称:useradmin,代码行数:29,代码来源:linkedin.php

示例5: action_add

 public function action_add()
 {
     if (!$this->user->id) {
         $this->redirect('/');
     }
     $comment = new Model_Comment();
     $comment->article_id = Arr::get($_POST, 'article_id');
     $comment->text = Arr::get($_POST, 'text');
     $comment->parent_id = Arr::get($_POST, 'parent_id', '0');
     $comment->user_id = $this->user->id;
     if (preg_match('(^[0-9]{1,})', $comment->article_id) != true) {
         $this->redirect('/');
     }
     if ($comment->text == '') {
         $this->redirect('/article/' . $comment->article_id);
     }
     if ($comment->parent_id != 0) {
         $parent_comment = Model_Comment::get($comment->parent_id);
         if ($parent_comment->parent_id != 0) {
             $comment->root_id = $parent_comment->root_id;
         } else {
             $comment->root_id = $parent_comment->id;
         }
     } else {
         $comment->root_id = 0;
     }
     $comment->insert();
     $this->redirect('/article/' . $comment->article_id);
 }
开发者ID:Kapitonova,项目名称:codex,代码行数:29,代码来源:Comments.php

示例6: submit

 protected function submit($task, $id, $type)
 {
     $item = Jelly::select($type, $id);
     $redirect = HTML::uri(array('action' => Inflector::plural($type)));
     switch ($task) {
         case 'apply':
             $item->set($_POST)->save();
             $redirect = HTML::uri(array('action' => $type, 'task' => 'edit', 'id' => $item->id));
             $this->request->redirect($redirect);
             break;
         case 'save':
             $item->set($_POST)->save();
             $this->request->redirect($redirect);
             break;
         case 'cancel':
             $this->request->redirect($redirect);
             break;
         case 'delete':
             if ($ids = Arr::get($_POST, 'cid', NULL)) {
                 $items = Jelly::delete($item)->where(':primary_key', 'IN', $ids)->execute();
             }
             $this->request->redirect($redirect);
             break;
         case 'default':
             if (!$item->loaded()) {
                 $this->request->redirect($redirect);
             }
             break;
     }
     return $item;
 }
开发者ID:raeldc,项目名称:kojo-klibrary,代码行数:31,代码来源:library.php

示例7: load

 protected function load($menu = null)
 {
     $menu = $menu ?: $this->menu;
     $data = \Config::load('menu/' . $menu, true, true, true);
     $this->meta = array('name' => \Arr::get($data, 'name'), 'identifier' => \Arr::get($data, 'slug'), 'num_items' => $this->count($data['children']));
     return $data;
 }
开发者ID:indigophp,项目名称:fuel-menu,代码行数:7,代码来源:static.php

示例8: action_edit

 /**
  * Редактирование акции
  * @return void
  */
 public function action_edit()
 {
     $stock = ORM::factory('stock', $this->request->param('id', NULL));
     if (!$stock->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'stock_not_found'));
         $this->request->redirect('admin/service/stock');
     }
     if ($_POST) {
         try {
             $stock->values($_POST, array('text'));
             $stock->active = Arr::get($_POST, 'active', 0);
             $stock->update();
             Message::set(Message::SUCCESS, 'Акция отредактиована');
             $this->request->redirect('admin/service/stock');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     } else {
         $this->values = $stock->as_array();
     }
     $this->view = View::factory('backend/stock/form')->set('url', 'admin/service/stock/edit/' . $stock->id)->set('errors', $this->errors)->set('values', $this->values);
     $this->template->title = 'Редактирования акции';
     $this->template->bc['#'] = 'Редактирования акции ' . $stock->service->name;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:30,代码来源:stock.php

示例9: action_show

 public function action_show()
 {
     $id = Arr::get($_GET, 'id');
     $state = intval(Arr::get($_GET, 'state'));
     DB::update('job_columns')->set(array('show_reports' => $state))->where('id', '=', $id)->execute();
     die(json_encode(array('success' => true)));
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:7,代码来源:Columns.php

示例10: init

 protected function init()
 {
     $module_config = Helper_Module::load_config('blog');
     $helper_acl = new Helper_ACL($this->acl);
     $helper_acl->inject(Arr::get($module_config, 'a2'));
     $this->blog_group = Arr::get($this->params, 'group');
 }
开发者ID:greor,项目名称:kohana-blog,代码行数:7,代码来源:blog.php

示例11: read

	/**
	 * Retrieve posts.
	 *
	 *		Blogger::factory('posts')->read($consumer, $token, $blog_id, NULL, array('orderby' => 'updated'));
	 *
	 * IMPORTANT: define categories in parameters like this: array('categories' => '/Fritz/Laurie')
	 *
	 * @param   OAuth_Consumer	consumer
	 * @param   OAuth_Token		token
	 * @param   string			blog ID
	 * @param   string			post ID for a single post, if set to NULL all posts are retrieved
	 * @param   array			optional query parameters for search: http://code.google.com/apis/blogger/docs/2.0/developers_guide_protocol.html#RetrievingWithQuery
	 * @return  mixed
	 */
	public function read(OAuth_Consumer $consumer, OAuth_Token $token, $blog_id, $post_id = NULL, array $params = NULL)
	{
		// Look for categories in params
		if ($categories = Arr::get($params, 'categories'))
		{
			// Set post_id to '-' if categories are found
			$post_id = '-';
		}

		// Categories must not in query parameters
		unset($params['categories']);

		// Create a new GET request with the required parameters
		$request = OAuth_Request::factory('resource', 'GET', $this->url($blog_id, "posts/default/{$post_id}{$categories}"), array(
				'oauth_consumer_key' => $consumer->key,
				'oauth_token' => $token->token,
			));

		if ($params)
		{
			// Load user parameters
			$request->params($params);
		}

		// Sign the request using the consumer and token
		$request->sign($this->signature, $consumer, $token);

		// Create a response from the request
		$response = $request->execute();

		return $this->parse($response);
	}
开发者ID:nnc,项目名称:apis,代码行数:46,代码来源:posts.php

示例12: add_tags

 public function add_tags($data, $photo)
 {
     $tag = ORM::factory('tag');
     $tags = Arr::get($data, 'tags');
     $tags = explode(',', $tags);
     foreach ($tags as $tag) {
         $tag = strtolower($tag);
         $tag = trim($tag);
         //removes extra whitespace
         $tag = strip_tags($tag);
         $tag = htmlentities($tag);
         if ($tag != '' and !empty($tag)) {
             $check = ORM::factory('tag')->where('name', '=', $tag)->find();
             if ($check->loaded()) {
                 if (!$check->has('photos', $photo)) {
                     $check->add('photos', $photo);
                 }
             } else {
                 $check->name = $tag;
                 $check->save();
                 $check->add('photos', $photo);
                 $this->action_build(false);
             }
         }
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:26,代码来源:tags.php

示例13: index

 public function index()
 {
     $group = $this->config->item('admin_group', 'ion_auth');
     $ia = new Ion_auth_model();
     $limit = $this->config->config['users_on_page'];
     $page = !empty($_GET['page']) ? $_GET['page'] : 1;
     if ($page == 1) {
         $offset = '';
     } else {
         $offset = $limit * ($page - 1);
     }
     $searchText = Arr::get($_GET, 'search', '');
     $filter = Arr::get($_GET, 'filter', '');
     $admins = $ia->getUsersByGroup($group);
     if ($searchText || $filter !== '') {
         $admins->search($searchText, $filter, null, $limit, $offset);
         JsSettings::instance()->add(array('search' => $searchText, 'filter' => $filter, 'group' => $group));
     } else {
         if ($admins) {
             $admins->get($limit, $offset);
         }
     }
     $this->template->set('users', $admins);
     $this->template->set('group', $group);
     $this->template->set('limit', $limit);
     $this->template->set('page', $page);
     $this->template->set('c_user', $this->c_user);
     $this->template->render();
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:29,代码来源:manage_admins.php

示例14: action_index

 public function action_index()
 {
     $code = $this->request->param('code');
     if ($code === NULL) {
         Model_Page_Front::not_found();
     }
     $reflink_model = ORM::factory('user_reflink', $code);
     if (!$reflink_model->loaded()) {
         Messages::errors(__('Reflink not found'));
         $this->go_home();
     }
     $next_url = Arr::get($reflink_model->data, 'next_url');
     try {
         Database::instance()->begin();
         Reflink::factory($reflink_model)->confirm();
         $reflink_model->delete();
         Database::instance()->commit();
     } catch (Kohana_Exception $e) {
         Database::instance()->rollback();
         Messages::errors($e->getMessage());
     }
     if (Valid::url($next_url)) {
         $this->go($next_url);
     }
     $this->go_home();
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:26,代码来源:reflink.php

示例15: input

 public static function input($name, $value = NULL, array $attributes = NULL)
 {
     if (static::$model) {
         if (isset(static::$model->table_columns()[$name])) {
             if ($value === NULL) {
                 switch (Arr::get($attributes, 'type')) {
                     case 'checkbox':
                     case 'radio':
                         $attributes['checked'] = static::$model->{$name} == $value;
                         break;
                     case '':
                     case 'text':
                     case 'hidden':
                     case 'email':
                     case 'url':
                     case 'search':
                     case 'date':
                     case 'datetime':
                     case 'time':
                     case 'month':
                     case 'week':
                     case 'color':
                     case 'number':
                     case 'range':
                         $value = static::$model->{$name};
                         break;
                 }
             }
             $attributes['id'] = static::$model_name . '_' . URL::title($name);
             $name = static::$model_name . '[' . $name . ']';
         }
     }
     return parent::input($name, $value, $attributes);
 }
开发者ID:alshabalin,项目名称:kohana-advanced-view,代码行数:34,代码来源:Form.php


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