當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。