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


PHP Arr类代码示例

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


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

示例1: __call

 function __call($name, $arguments)
 {
     $iconvArguments = array();
     foreach ($arguments as $eachArgument) {
         $iconvArguments[] = iconv("utf-8", $this->_dataCharset, $eachArgument);
     }
     $result = call_user_func_array(array($this->_data, $name), $iconvArguments);
     if (is_string($result)) {
         return iconv($this->_dataCharset, "utf-8", $result);
     } else {
         if ($result instanceof \Doctrine\Common\Collections\Collection) {
             $result2 = new Arr();
             foreach ($result as $eachResultItem) {
                 $result2->add(new IconvWrapper($eachResultItem));
             }
             return $result2;
         } else {
             if ($result instanceof \Doctrine\ORM\Proxy\Proxy) {
                 return new IconvWrapper($result);
             } else {
                 return $result;
             }
         }
     }
 }
开发者ID:alexey-baranov,项目名称:billing,代码行数:25,代码来源:IconvWrapper.php

示例2: testCreate

 /**
  *  @since  11-7-11
  */
 public function testCreate()
 {
     $arr = new Arr('one', 'two', 'three');
     $narr = $arr->getArrayCopy();
     $this->assertEquals(array('one', 'two', 'three'), $narr);
     $arr = new Arr(array('one', 'two', 'three'));
     $narr = $arr->getArrayCopy();
     $this->assertEquals(array('one', 'two', 'three'), $narr);
     $arr[] = 'four';
     \out::e($arr->getArrayCopy());
 }
开发者ID:Jaymon,项目名称:Montage,代码行数:14,代码来源:ArrTest.php

示例3: action_execute

 /**
  * Handles the request to execute a task.
  *
  * Responsible for parsing the tasks to execute & also any config items that
  * should be passed to the tasks
  */
 public function action_execute()
 {
     if (empty($this->_task)) {
         return $this->action_help();
     }
     $task = $this->_retrieve_task();
     $defaults = $task->get_config_options();
     if (!empty($defaults)) {
         if (Arr::is_assoc($defaults)) {
             $options = array_keys($defaults);
             $options = call_user_func_array(array('CLI', 'options'), $options);
             $config = Arr::merge($defaults, $options);
         } else {
             // Old behavior
             $config = call_user_func_array(array('CLI', 'options'), $defaults);
         }
     } else {
         $config = array();
     }
     // Validate $config
     $validation = Validation::factory($config);
     $validation = $task->build_validation($validation);
     if (!$validation->check()) {
         echo View::factory('minion/error/validation')->set('errors', $validation->errors($task->get_errors_file()));
     } else {
         // Finally, run the task
         echo $task->execute($config);
     }
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:35,代码来源:minion.php

示例4: before

 public function before()
 {
     if (!User::current()) {
         $this->redirect('/login');
     }
     $url = str_replace('.', '_', URL::base() . $this->request->uri());
     if (isset($_GET[$url])) {
         unset($_GET[$url]);
     }
     if (isset($_GET[$url . '/'])) {
         unset($_GET[$url . '/']);
     }
     if (Group::current('is_admin') || Group::current('show_all_jobs') && Group::current('allow_finance')) {
         Pager::$counts[] = 2500;
     }
     if (Arr::get($_GET, 'limit') && in_array($_GET['limit'], Pager::$counts)) {
         DB::update('users')->set(array('list_items' => intval($_GET['limit'])))->where('id', '=', User::current('id'))->execute();
         die(json_encode(array('success' => 'true')));
     }
     if (Arr::get($_GET, 'dismiss')) {
         DB::delete('notifications')->where('user_id', '=', User::current('id'))->and_where('id', '=', intval($_GET['dismiss']))->execute();
         die(json_encode(array('success' => 'true')));
     }
     if (!Group::current('allow_assign')) {
         Enums::$statuses[Enums::STATUS_UNALLOC] = 'Not active';
     }
     View::set_global('notifications', DB::select()->from('notifications')->where('user_id', '=', User::current('id'))->order_by('id', 'desc')->execute());
 }
开发者ID:nikulinsanya,项目名称:exeltek,代码行数:28,代码来源:Controller.php

示例5: 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

示例6: 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

示例7: setup_configs_template_body

 public static function setup_configs_template_body($configs)
 {
     foreach ($configs as $type => $types) {
         foreach ($types as $module => $modules) {
             foreach ($modules as $item_key => $items) {
                 if (!isset($items['body'])) {
                     continue;
                 }
                 if (!is_array($items['body'])) {
                     continue;
                 }
                 if (!empty($items['body']['default']['file'])) {
                     $ext = !empty($items['format']) ? $items['format'] : 'php';
                     $body = file_get_contents(sprintf('%sviews/%s.%s', APPPATH, $items['body']['default']['file'], $ext));
                 } elseif (!empty($items['body']['default']['value'])) {
                     $body = $items['body']['default']['value'];
                 } else {
                     continue;
                 }
                 $key = implode('.', array($type, $module, $item_key, 'body'));
                 Arr::set($configs, $key, $body);
             }
         }
     }
     return $configs;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:26,代码来源:config.php

示例8: action_save

 /**
  * 保存账号
  */
 public function action_save()
 {
     $this->_autoRender = FALSE;
     $givenName = Arr::get($_POST, 'given_name', '');
     $name = Arr::get($_POST, 'name', '');
     $password = Arr::get($_POST, 'password', '');
     $email = Arr::get($_POST, 'email', '');
     $mobile = Arr::get($_POST, 'mobile', '');
     $phone = Arr::get($_POST, 'phone', '');
     if ($givenName == '') {
         return Prompt::jsonWarning('姓名不能为空');
     }
     if ($name == '') {
         return Prompt::jsonWarning('用户名不能为空');
     }
     if ($password == '') {
         return Prompt::jsonWarning('密码不能为空');
     }
     if ($email == '') {
         return Prompt::jsonWarning('邮箱不能为空');
     }
     $values = array('given_name' => $givenName, 'name' => $name, 'password' => md5($password), 'email' => $email, 'mobile' => $mobile, 'phone' => $phone);
     try {
         $result = Model::factory('Account')->create($values)->getArray();
         if (!$result[0]) {
             //TODO 日志
             return Prompt::jsonError('添加账号失败');
         }
     } catch (Exception $e) {
         //TODO 日志
         return Prompt::jsonError('添加账号失败');
     }
     //TODO 日志
     return Prompt::jsonSuccess('添加账号成功', URL::site('account/add'));
 }
开发者ID:panchao1,项目名称:cronsystem,代码行数:38,代码来源:Account.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: action_delete

 public function action_delete()
 {
     $dispute = ORM::factory('admin_dispute', $this->request->param('id', NULL));
     if (!$dispute->loaded()) {
         Message::set(Message::ERROR, 'Такое дополнение не найдено');
         $this->request->redirect('admin/development');
     }
     $task_url = 'admin/development/task/view/' . $dispute->task->id;
     if ($_POST) {
         $actions = Arr::extract($_POST, array('submit', 'cancel'), FALSE);
         /*
         if ($actions['cancel'])
             $this->request->redirect('admin/development/task/view/'.$dispute->task->id);
         */
         if ($actions['submit']) {
             $dispute->delete();
             Message::set(Message::SUCCESS, 'Дополнение к задаче удалено');
         }
         $this->request->redirect($task_url);
     }
     $this->view = View::factory('backend/delete')->set('url', $this->request->uri())->set('from_url', $task_url)->set('title', 'Удаление дополнения к задаче')->set('text', 'Вы действительно хотите удалить дополнение к задаче "' . $dispute->task->title . '"');
     $this->template->title = 'Удаление дополнения к задаче';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:25,代码来源:dispute.php

示例11: get_fieid_attribute

 public static function get_fieid_attribute(Validation $val, $name, $default_value = null, $is_textarea = false, $optional_attr = array())
 {
     $field = $val->fieldset()->field($name);
     $label = '';
     $input_attr = array();
     $is_required = false;
     if (is_callable(array($field, 'get_attribute'))) {
         $input_attr = $field->get_attribute();
         $input_attr = Arr::filter_keys($input_attr, array('validation', 'label'), true);
         if ((is_null($default_value) || empty($default_value) && !strlen($default_value)) && !is_null($field->get_attribute('value'))) {
             $default_value = $field->get_attribute('value');
         }
         $is_required = $field->get_attribute('required') == 'required';
         $label = $field->get_attribute('label');
     }
     if (!is_array($optional_attr)) {
         $optional_attr = (array) $optional_attr;
     }
     if ($optional_attr) {
         $input_attr += $optional_attr;
     }
     if (empty($input_attr['id'])) {
         $input_attr['id'] = Site_Form::get_field_id($name);
     }
     if (empty($input_attr['class'])) {
         $input_attr['class'] = 'form-control';
     }
     return array($default_value, $label, $is_required, $input_attr);
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:29,代码来源:form.php

示例12: get_options

 public function get_options()
 {
     $uid = $this->param('uid', NULL, TRUE);
     $options = ORM::factory('email_type', (int) $uid)->data();
     $options = Arr::merge($options, Config::get('email', 'default_template_data', array()));
     $this->response($options);
 }
开发者ID:ortodesign,项目名称:cms,代码行数:7,代码来源:types.php

示例13: 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

示例14: action_save

 public function action_save()
 {
     $data = Arr::extract($_POST, array('sitename', 'description', 'session', 'keywords', 'robots', 'email', 'author', 'copyright', 'page404', 'status', 'debug', 'cache'));
     foreach ($data as $key => $value) {
         Kohana::$config->_write_config('site', $key, $value);
     }
 }
开发者ID:raku,项目名称:front-cms,代码行数:7,代码来源:options.php

示例15: 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


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