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


PHP arr::get方法代码示例

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


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

示例1: action_login

 public function action_login()
 {
     if ((bool) arr::get($_GET, 'return', false)) {
         site::set_last_url($this->request->referrer());
     }
     $error = false;
     if ($_POST) {
         $email = arr::get($_POST, 'email', '');
         $password = arr::get($_POST, 'password', '');
         $remember = arr::get($_POST, 'remember', '') == 'yes';
         if (user::login($email, $password, $remember)) {
             $user = user::get();
             notes::success('You have been logged in. Welcome back!');
             $lasturl = site::get_last_url();
             if ($lasturl) {
                 site::redirect($lasturl);
             }
             site::redirect('write');
         } else {
             //notes::error('Wrong username or password. Please try again.');
             $error = true;
         }
     }
     $this->bind('error', $error);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:25,代码来源:User.php

示例2: action_index

 public function action_index()
 {
     $code = $this->request->param('code');
     $message = arr::get(Response::$messages, $code);
     $this->template->title = sprintf('Error %s: %s', $code, $message);
     $this->response->status($code);
 }
开发者ID:ariol,项目名称:adminshop,代码行数:7,代码来源:Error.php

示例3: dropdown

 public static function dropdown($data, $selected = NULL, $extra = '')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $defaults = array('null_option' => FALSE, 'default_first' => TRUE, 'unauth_before_auth' => FALSE);
     $data = arr::merge($defaults, $data);
     $options = array();
     $sipinterfaces = Doctrine::getTable('SipInterface')->findAll();
     foreach ($sipinterfaces as $sipinterface) {
         if (!($id = arr::get($sipinterface, 'sipinterface_id')) or !($name = arr::get($sipinterface, 'name'))) {
             continue;
         }
         if ($data['unauth_before_auth'] and !$sipinterface['auth'] or !$data['unauth_before_auth'] and $sipinterface['auth']) {
             arr::unshift_assoc($options, $id, $name);
             continue;
         }
         $options[$id] = $name;
     }
     if ($data['default_first'] and $default_sipinterface = SipInterface::get_default()) {
         unset($options[$default_sipinterface['sipinterface_id']]);
         arr::unshift_assoc($options, $default_sipinterface['sipinterface_id'], $default_sipinterface['name']);
     }
     if ($data['null_option']) {
         arr::unshift_assoc($options, 0, $data['null_option']);
     }
     $data = array_diff($data, $defaults);
     // use kohana helper to generate the markup
     return form::dropdown($data, $options, $selected, $extra);
 }
开发者ID:swk,项目名称:bluebox,代码行数:32,代码来源:sipinterfaces.php

示例4: action_result

 public function action_result()
 {
     $data = array();
     if ($_POST) {
         $id_brand = arr::get($_POST, 'id_brand');
         $id_model = arr::get($_POST, 'id_model');
         $id_series = arr::get($_POST, 'series');
         $year = arr::get($_POST, 'year');
         $to_number = arr::get($_POST, 'to_number');
         $millage_val = arr::get($_POST, 'millage_val');
         //$brands = ORM::factory('labor')->find_all();
         $brand = ORM::factory('brand', $id_brand)->name;
         $model = ORM::factory('model', $id_model)->name;
         $series = ORM::factory('series', $id_series)->as_array();
         $price = ORM::factory('price');
         $modification = new Model_Modification();
         $result = $modification->getModification($year, $id_series, $to_number);
         $labors = new Model_Labor();
         foreach ($result as $mod) {
             $labors_val[$mod['id']] = $labors->getLabors($mod['id'], $to_number)->as_array();
         }
         $calc_view = View::factory('forms/form.calculator')->set('id_brand', $id_brand)->set('id_model', $id_model)->set('id_series', $id_series)->set('year', $year)->set('millage_val', $millage_val)->set('modification', $result)->set('test', $modification)->set('to_number', $to_number);
         $this->template->content = View::factory('calculator.result')->set('brand', $brand)->set('model', $model)->set('year', $year)->set('series', $series)->set('millage_val', $millage_val)->set('modification', $result)->set('to_number', $to_number)->set('labors', $labors_val)->set('price', $price)->set('calculator_form', $calc_view->render());
     } else {
         HTTP::redirect('calculator');
     }
 }
开发者ID:redeggplant,项目名称:avtok,代码行数:27,代码来源:calculator.php

示例5: do_login

 protected function do_login()
 {
     if ($this->request->is_ajax() && $_POST) {
         $this->do_auth();
     }
     $this->template->set_layout('layout/admin/login');
     $this->template->email = '';
     $this->template->remember = false;
     $this->template->error = '';
     $this->template->return = arr::get($_GET, 'return', arr::get($_POST, 'return', FALSE));
     if (isset($_POST['login'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $remember = $_POST['remember'];
         $this->template->email = $email;
         $this->template->remember = $remember;
         if (Auth::instance()->login($email, $password, (bool) $remember)) {
             if ($this->template->return) {
                 HTTP::redirect($this->template->return);
             } else {
                 return TRUE;
             }
         }
         if (Auth::instance()->is_banned()) {
             $banned_to = Auth::instance()->get_banned_to();
             $this->template->error = 'Аккаунт заблокирован до ' . date('Y-m-d H:i', $banned_to) . ' (до разблокировки ' . ceil(($banned_to - time()) / 3600) . ' ч ' . date('i мин', $banned_to - time()) . ')';
         } else {
             $this->template->error = 'Неверные e-mail или пароль';
         }
         return FALSE;
     }
 }
开发者ID:ariol,项目名称:adminshop,代码行数:32,代码来源:Base.php

示例6: remote

 /**
  * Returns the output of a remote URL. Any [curl option](http://php.net/curl_setopt)
  * may be used.
  *
  *     // Do a simple GET request
  *     $data = Remote::get($url);
  *
  *     // Do a POST request
  *     $data = Remote::get($url, array(
  *         CURLOPT_POST       => TRUE,
  *         CURLOPT_POSTFIELDS => http_build_query($array),
  *     ));
  *
  * @param   string   remote URL
  * @param   array    curl options
  * @return  string
  * @throws  Kohana_Exception
  */
 public static function remote($url, array $options = NULL)
 {
     // The transfer must always be returned
     $options[CURLOPT_RETURNTRANSFER] = TRUE;
     // Open a new remote connection
     $remote = curl_init($url);
     // Set connection options
     if (!curl_setopt_array($remote, $options)) {
         throw new Kohana_Exception('Failed to set CURL options, check CURL documentation: :url', array(':url' => 'http://php.net/curl_setopt_array'));
     }
     // Get the response
     $response = curl_exec($remote);
     // @TODO: Find a better way to do this
     if (curl_errno($remote) == 60) {
         curl_setopt($remote, CURLOPT_CAINFO, arr::get(Kohana::find_file('config', 'ca-bundle', 'crt'), 0, ''));
         $response = curl_exec($remote);
     }
     // Get the response information
     $code = curl_getinfo($remote, CURLINFO_HTTP_CODE);
     if ($code and $code < 200 or $code > 299) {
         $error = $response;
     } elseif ($response === FALSE) {
         $error = curl_error($remote);
     }
     // Close the connection
     curl_close($remote);
     if (isset($error)) {
         throw new Kohana_OAuth_Exception('Error fetching remote :url [ status :code ] :error', array(':url' => $url, ':code' => $code, ':error' => $error));
     }
     return $response;
 }
开发者ID:rafi,项目名称:oauth,代码行数:49,代码来源:oauth.php

示例7: tiers_POST

 protected static function tiers_POST($id, $envelope)
 {
     if (is_null($id)) {
         self::throwErrorAndDie('Invalid request', array($id), 410);
     }
     $data = self::requireData($envelope);
     $tier_agents = array();
     if ($agents = arr::get($data, 'agents')) {
         foreach ($agents as $agent) {
             if ($tier_agent_id = arr::get($agent, 'tier_agent_id')) {
                 $tier_agent = Doctrine::getTable('TierAgent')->findOneBy('tier_agent_id', $tier_agent_id);
             } else {
                 $tier_agent = new TierAgent();
             }
             try {
                 $tier_agent->synchronizeWithArray($agent);
                 $tier_agent->save();
                 $tier_agents[] = $tier_agent->toArray();
             } catch (Exception $e) {
                 self::throwErrorAndDie('Invalid data', Bluebox_Controller::$validation->errors(), 400);
             }
         }
         arr::remove('agents', $data);
         arr::merge($envelope['data'], $data);
     }
     $response = self::generalAPI_POST($id, 'tier_id', 'Tier', $envelope);
     $response['agents'] = $tier_agents;
     return $response;
 }
开发者ID:swk,项目名称:bluebox,代码行数:29,代码来源:CallCenter.php

示例8: action_index

 /**
  * Processes incoming text
  */
 public function action_index()
 {
     $this->request->headers['Content-type'] = 'image/png';
     // Grab text and styles
     $text = arr::get($_GET, 'text');
     $styles = $_GET;
     $hover = FALSE;
     try {
         // Create image
         $img = new PNGText($text, $styles);
         foreach ($styles as $key => $value) {
             if (substr($key, 0, 6) == 'hover-') {
                 // Grab hover associated styles and override existing styles
                 $hover = TRUE;
                 $styles[substr($key, 6)] = $value;
             }
         }
         if ($hover) {
             // Create new hover image and stack it
             $hover = new PNGText($text, $styles);
             $img->stack($hover);
         }
         echo $img->draw();
     } catch (Exception $e) {
         if (Kohana::config('pngtext.debug')) {
             // Dump error message in an image form
             $img = imagecreatetruecolor(strlen($e->getMessage()) * 6, 16);
             imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
             imagestring($img, 2, 0, 0, $e->getMessage(), imagecolorallocate($img, 0, 0, 0));
             echo imagepng($img);
         }
     }
 }
开发者ID:andygoo,项目名称:kohana-pngtext,代码行数:36,代码来源:pngtext.php

示例9: echo_test

 public static function echo_test()
 {
     $featureCode = new FeatureCode();
     $featureCode['name'] = 'Echo Test';
     $featureCode['registry'] = array('feature' => 'echo');
     $featureCode->save();
     try {
         $location = Doctrine::getTable('Location')->findAll();
         if (!$location->count()) {
             throw Exception('Could not find location id');
         }
         $location_id = arr::get($location, 0, 'location_id');
         $number = new Number();
         $number['user_id'] = users::getAttr('user_id');
         $number['number'] = '9999';
         $number['location_id'] = $location_id;
         $number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
         $dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
         $number['dialplan'] = $dialplan;
         $number['class_type'] = 'FeatureCodeNumber';
         $number['foreign_id'] = $featureCode['feature_code_id'];
         $context = Doctrine::getTable('Context')->findOneByName('Outbound Routes');
         $number['NumberContext']->fromArray(array(0 => array('context_id' => $context['context_id'])));
         $numberType = Doctrine::getTable('NumberType')->findOneByClass('FeatureCodeNumber');
         if (empty($numberType['number_type_id'])) {
             return FALSE;
         }
         $number['NumberPool']->fromArray(array(0 => array('number_type_id' => $numberType['number_type_id'])));
         $number->save();
         return $number['number_id'];
     } catch (Exception $e) {
         kohana::log('error', 'Unable to initialize device number: ' . $e->getMessage());
         throw $e;
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:35,代码来源:FeatureCodeManager.php

示例10: validate

 public function validate(CM_Form_Abstract $form)
 {
     if ($this->_extra_validation) {
         $values = array();
         foreach ($form->get_values() as $name => $value) {
             $values[$name] = $value->get_raw();
             $this->_extra_validation->label($name, $form->get_field($name)->get_label());
         }
         // Validation только read-only, поэтому создаем новый объект
         $this->_extra_validation = $this->_extra_validation->copy($values);
     }
     try {
         $this->get_model()->check($this->_extra_validation);
     } catch (ORM_Validation_Exception $e) {
         $errors = $e->errors('validation');
         if ($external = arr::get($errors, '_external')) {
             $errors = arr::merge($errors, $external);
             unset($errors['_external']);
         }
         foreach ($errors as $name => $error) {
             $form->get_field($name)->set_error($error);
         }
         return FALSE;
     }
     return TRUE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:26,代码来源:ORM.php

示例11: action_ajax_add_feedback

 public function action_ajax_add_feedback()
 {
     if ($_POST) {
         $errors = array('name' => 'false', 'text' => 'false', 'email' => 'false', 'check' => 'false', 'phone' => 'false');
         if (Validation::factory($_POST)->rule('email', 'email')->rule('email', 'not_empty')->check()) {
             $errors['email'] = 'true';
         }
         if (Validation::factory($_POST)->rule('phone', 'not_empty')->check()) {
             $errors['phone'] = 'true';
         }
         if (Validation::factory($_POST)->rule('name', 'not_empty')->check()) {
             $errors['name'] = 'true';
         }
         if (Validation::factory($_POST)->rule('text', 'not_empty')->check()) {
             $errors['text'] = 'true';
         }
         $check = arr::get($_POST, 'check');
         if (!$check) {
             $errors['check'] = 'true';
         }
         if ($errors['name'] == 'true' && $errors['email'] == 'true' && $errors['phone'] == 'true' && $errors['text'] == 'true' && $errors['check'] == 'true') {
             $feedback = ORM::factory('Feedback');
             $feedback->name = arr::get($_POST, 'name');
             $feedback->phone = arr::get($_POST, 'phone');
             $feedback->email = arr::get($_POST, 'email');
             $feedback->text = arr::get($_POST, 'text');
             $feedback->save();
             Email::send('info@trip-shop.by', array('info@trip-shop.by', 'Trip-Shop'), 'Новый отзыв', 'Имя - ' . arr::get($_POST, 'name') . '<br/>' . 'Email - ' . arr::get($_POST, 'email') . '<br/>' . 'Телефон - ' . arr::get($_POST, 'phone') . '<br/>' . arr::get($_POST, 'text'), true);
         }
         echo json_encode($errors);
     } else {
         $this->forward_404();
     }
 }
开发者ID:ariol,项目名称:adminshop,代码行数:34,代码来源:Ajax.php

示例12: get_submitted_value

 public function get_submitted_value()
 {
     $source = $this->get_value_source();
     $values = array();
     foreach ($source as $field_name => $field_value) {
         if (strpos($field_name, $this->get_name() . '_') === 0) {
             $num = str_replace($this->get_name() . '_', '', $field_name);
             // Нашли поле, отвечающее за имя
             if (preg_match('#^[0-9]+$#', $num)) {
                 $namefield = new CM_Field_String();
                 $namefield->set_name($field_name);
                 $namefield->set_value_source($this->get_value_source());
                 $name = $namefield->get_submitted_value()->get_raw();
                 $valuefield = clone $this->get_value_field();
                 $value = arr::get(array_values($this->get_value()->get_values()), $num);
                 if ($value) {
                     $value = $value->get_raw();
                 }
                 $valuefield->set_raw_value($value);
                 $valuefield->set_name($field_name . '_value');
                 $valuefield->set_value_source($this->get_value_source());
                 $values[$name] = $valuefield->get_submitted_value()->get_raw();
             }
         }
     }
     return $this->create_raw_value(serialize($values));
 }
开发者ID:ariol,项目名称:adminshop,代码行数:27,代码来源:Hash.php

示例13: action_files

 public function action_files()
 {
     $files = array();
     $limit = arr::get($_GET, 'limit', 10);
     $offset = arr::get($_GET, 'offset', 0);
     $query = ORM::factory('File');
     if (arr::get($_GET, 'tags', false)) {
         $tags = arr::get($_GET, 'tags');
         if (arr::get($_GET, 'matchAll', false) == "true") {
             $tagsquery = DB::select('files_tags.file_id')->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->group_by('files_tags.file_id')->having(DB::expr('COUNT(files_tags.file_id)'), '=', count($tags))->execute();
             //die(var_dump($tagsquery));
         } else {
             $tagsquery = DB::select('files_tags.file_id')->distinct(true)->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->execute();
             //die(var_dump($tagsquery));
         }
         if ((bool) $tagsquery->count()) {
             $ids = array();
             foreach ($tagsquery as $q) {
                 $ids[] = arr::get($q, 'file_id');
                 //$files[] = ORM::factory('File', arr::get($q, 'file_id'))->info();
             }
             $query = $query->where('id', 'IN', $ids);
         } else {
             // Empty resultset
             ajax::success('ok', array('files' => array()));
         }
     }
     $query = $query->order_by('created', 'DESC')->limit($limit)->offset($offset)->find_all();
     if ((bool) $query->count()) {
         foreach ($query as $file) {
             $files[] = $file->info();
         }
     }
     ajax::success('ok', array('files' => $files));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:35,代码来源:Filebrowser.php

示例14: action_edit

 public function action_edit()
 {
     $file = ORM::factory('file', $this->request->param('id'));
     if (!$file->loaded()) {
         notes::add('error', 'Filen blev ikke fundet!');
         cms::redirect('files');
     }
     if ($_POST) {
         $filename = arr::get($_POST, 'filename', '');
         if (empty($filename)) {
             $filename = $file->filename;
         }
         if ($filename != $file->filename) {
             $filename = files::fixname($filename);
             $filename = files::get_available_filename('files/', $filename, $file->ext);
             rename('files/' . $file->filename(), 'files/' . $filename . '.' . $file->ext);
             $versions = $file->versions->find_all();
             if ((bool) $versions->count()) {
                 foreach ($versions as $version) {
                     $version->delete();
                 }
             }
         }
         $file->filename = $filename;
         $file->alt = arr::get($_POST, 'alt', '');
         $file->description = arr::get($_POST, 'description', '');
         try {
             $file->save();
             cms::redirect('files/edit/' . $file->id);
         } catch (exception $e) {
             notes::add('error', 'Filen kunne ikke gemmes! Siden sagde: ' . $e->getMessage());
         }
     }
     $this->bind('file', $file);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:35,代码来源:Files.php

示例15: human_readable_created

 public function human_readable_created($segments = 2)
 {
     $when = Date::span($this->created);
     $years = arr::get($when, 'years', 0);
     $months = arr::get($when, 'months', 0);
     $weeks = arr::get($when, 'weeks', 0);
     $days = arr::get($when, 'days', 0);
     $hours = arr::get($when, 'hours', 0);
     $minutes = arr::get($when, 'minutes', 0);
     $seconds = arr::get($when, 'seconds', 0);
     $str = array();
     if ($years > 0) {
         $str[] = $years . ' ' . ($years == 1 ? __('year') : __('years'));
     }
     if ($months > 0) {
         $str[] = $months . ' ' . ($months == 1 ? __('month') : __('months'));
     }
     if ($weeks > 0) {
         $str[] = $weeks . ' ' . ($weeks == 1 ? __('week') : __('weeks'));
     }
     if ($days > 0) {
         $str[] = $days . ' ' . ($days == 1 ? __('day') : __('days'));
     }
     if ($hours > 0) {
         $str[] = $hours . ' ' . ($hours == 1 ? __('hour') : __('hours'));
     }
     if ($minutes > 0) {
         $str[] = $minutes . ' ' . ($minutes == 1 ? __('minute') : __('minutes'));
     }
     if ($seconds > 0) {
         $str[] = $seconds . ' ' . ($seconds == 1 ? __('second') : __('secondss'));
     }
     $str = array_slice($str, 0, $segments);
     return implode(', ', $str);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:35,代码来源:Content.php


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