本文整理汇总了PHP中arr类的典型用法代码示例。如果您正苦于以下问题:PHP arr类的具体用法?PHP arr怎么用?PHP arr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了arr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __get
function __get($key)
{
if (arr::has($this->_properties, $key)) {
return $this->_properties[$key];
}
return null;
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:product.php
示例2: index
public function index()
{
// Create new session
$this->session->create();
$this->template->header->this_page = 'alerts';
$this->template->content = new View('alerts');
// Display news feeds?
$this->template->content->allow_feed = Kohana::config('settings.allow_feed');
// Retrieve default country, latitude, longitude
$default_country = Kohana::config('settings.default_country');
// Retrieve Country Cities
$this->template->content->cities = $this->_get_cities($default_country);
// Setup and initialize form field names
$form = array('alert_mobile' => '', 'alert_mobile_yes' => '', 'alert_email' => '', 'alert_email_yes' => '', 'alert_lat' => '', 'alert_lon' => '', 'alert_radius' => '');
// Copy the form as errors, so the errors will be stored with keys
// corresponding to the form field names
$errors = $form;
$form_error = FALSE;
$form_saved = FALSE;
// If there is a post and $_POST is not empty
if ($post = $this->input->post()) {
// Create a new alert
$alert = ORM::factory('alert');
// Test to see if things passed the rule checks
if ($alert->validate($post)) {
// Yes! everything is valid
// Save alert and send out confirmation code
if (!empty($post->alert_mobile)) {
$this->_send_mobile_alert($post->alert_mobile, $post->alert_lon, $post->alert_lat, $post->alert_radius);
}
if (!empty($post->alert_email)) {
$this->_send_email_alert($post->alert_email, $post->alert_lon, $post->alert_lat, $post->alert_radius);
}
$this->session->set('alert_mobile', $post->alert_mobile);
$this->session->set('alert_email', $post->alert_email);
url::redirect('alerts/confirm');
} else {
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('alerts'));
$form_error = TRUE;
}
} else {
$form['alert_lat'] = Kohana::config('settings.default_lat');
$form['alert_lon'] = Kohana::config('settings.default_lon');
$form['alert_radius'] = 20;
}
$this->template->content->form = $form;
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->form_saved = $form_saved;
// Javascript Header
$this->template->header->map_enabled = TRUE;
$this->template->header->js = new View('alerts_js');
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = $form['alert_lat'];
$this->template->header->js->longitude = $form['alert_lon'];
}
开发者ID:phpdiva,项目名称:Ushahidi_Haiti,代码行数:60,代码来源:alerts.php
示例3: index
/**
* Show latest PER_PAGE news on page
* @return void
*/
public function index($module = NULL, $page = 1)
{
$this->set_title(Kohana::lang('search.search'));
if ($page == 1) {
$this->add_breadcrumb(Kohana::lang('search.the_best_results'), url::current());
} else {
$this->add_breadcrumb(Kohana::lang('search.page_no') . ' ' . $page, url::current());
}
// Default values
$form = array('value' => '');
$errors = array();
if ($_POST) {
$post = new Validation($_POST);
// Some filters
$post->pre_filter('trim', TRUE);
// Rules
$post->add_rules('value', 'required');
if ($post->validate()) {
$form = arr::overwrite($form, $post->as_array());
} else {
// Repopulate form with error and original values
$form = arr::overwrite($form, $post->as_array());
$errors = $post->errors('search_errors');
}
}
$this->template->content = new View('search');
$data = $this->products->search($post['value']);
$data2 = $this->page->search($post['value']);
$data3 = $this->news->search($post['value']);
$this->template->content->data = $data;
$this->template->content->data2 = $data2;
$this->template->content->data3 = $data3;
$this->template->content->form = $form;
$this->template->content->errors = $errors;
}
开发者ID:repli2dev,项目名称:re-eshop,代码行数:39,代码来源:search.php
示例4: __construct
public function __construct($options = array())
{
$default = array("width" => "100", "height" => "100", "images" => array(), "class" => "square_thumb", "view" => null, "thickbox" => true);
$config = Kohana::config_load('zest');
$config = arr::overwrite($default, $config['gallery']);
$this->config = arr::overwrite($config, $options);
}
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:7,代码来源:Gallery.php
示例5: set_fields
/**
* Sets fields to the current object
*
* @param Array $fields
*/
public function set_fields($fields)
{
$this->title = arr::get($fields, 'title');
$this->description = arr::get($fields, 'description');
$this->budget = arr::get($fields, 'budget');
$this->category_id = arr::get($fields, 'category_id');
$this->jobtype_id = arr::get($fields, 'jobtype_id');
$this->contact = arr::get($fields, 'contact');
$this->telecommute = arr::get($fields, 'telecommute', 0);
$this->location = arr::get($fields, 'location', 'Anywhere');
$this->highlight = arr::get($fields, 'highlight', 0);
$this->company_logo = arr::get($fields, 'company_logo');
$this->email = arr::get($fields, 'email');
$this->discount_code = arr::get($fields, 'discount_code');
$this->created_at = arr::get($fields, 'created_at');
$this->jobboard_id = arr::get($fields, 'jobboard_id', 1);
$this->active = 0;
if (arr::get($fields, 'private_company') == 1) {
$this->company_name = '';
$this->company_url = '';
$this->company_address = '';
} else {
$this->company_name = arr::get($fields, 'company_name');
$this->company_url = arr::get($fields, 'company_url');
$this->company_address = arr::get($fields, 'company_address');
}
}
开发者ID:hbarroso,项目名称:Goworkat,代码行数:32,代码来源:ad.php
示例6: _get_valid_accinfo
private function _get_valid_accinfo($old_pass)
{
$form = array('txt_old_pass' => '', 'txt_new_pass' => '', 'txt_cf_new_pass' => '', 'txt_email' => '');
$errors = $form;
if ($_POST) {
$post = new Validation($_POST);
$post->pre_filter('trim', TRUE);
if (!empty($old_pass)) {
$post->add_rules('txt_new_pass', 'required', 'length[6,50]');
$post->add_rules('txt_cf_new_pass', 'matches[txt_new_pass]');
$post->add_callbacks('txt_old_pass', array($this, '_check_old_pass'));
}
$post->add_rules('txt_email', 'required', 'email');
$post->add_callbacks('txt_email', array($this, '_check_email'));
if ($post->validate()) {
$form = arr::overwrite($form, $post->as_array());
return $form;
} else {
$form = arr::overwrite($form, $post->as_array());
$this->session->set_flash('input_data', $form);
$errors = arr::overwrite($errors, $post->errors('account_validation'));
$str_error = '';
foreach ($errors as $id => $name) {
if ($name) {
$str_error .= $name . '<br>';
}
}
$this->session->set_flash('error_msg', $str_error);
url::redirect($this->uri->segment(1));
die;
}
}
}
开发者ID:vobinh,项目名称:PHP,代码行数:33,代码来源:admin_myaccount.php
示例7: add
public function add()
{
$form = array('building_id' => '', 'name' => '', 'index' => '', 'img_uri' => '', 'active' => '');
$errors = $form;
if ($_POST) {
$post = new Validation($_POST);
$post->pre_filter('trim', true);
$post->add_rules('buildings_id', 'required', 'digit');
$post->add_rules('name', 'required');
$post->add_rules('index', 'required');
$post->add_rules('img_uri', 'required');
$post->add_rules('active', 'required');
if ($post->validate()) {
// check for invilid
$form = arr::overwrite($form, $post->as_array());
$people = new Person_Model();
$result = $people->save($this->input->get('person'), $person_id);
} else {
$form = arr::overwrite($form, $post->as_array());
client::validation_results(arr::overwrite($errors, $post->errors('hiring_employee_form_validations')));
client::messageSend("There were errors in some fields", E_USER_WARNING);
}
}
$building = new Building_Model();
$buildings_list = $building->select_list();
$this->template->title = 'Seating::Spaces::Add';
$this->template->content = new View('pages/spaces_add');
$this->template->content->form = $form;
$this->template->content->buildings_list = $buildings_list;
}
开发者ID:samkeen,项目名称:Confab-Server,代码行数:30,代码来源:spaces.php
示例8: login
public function login()
{
$form = $errors = array("user" => "", "password" => "");
$post = new Validation($_POST);
$post->add_rules("user", "required");
$post->add_rules("password", "required");
if ($valid = $post->validate()) {
try {
$token = G3Remote::instance()->get_access_token($post["user"], $post["password"]);
Session::instance()->set("g3_client_access_token", $token);
$response = G3Remote::instance()->get_resource("gallery");
$valid = true;
$content = $this->_get_main_view($response->resource);
} catch (Exception $e) {
Kohana_Log::add("error", Kohana_Exception::text($e));
$valid = false;
}
}
if (!$valid) {
$content = new View('login.html');
$content->form = arr::overwrite($form, $post->as_array());
$content->errors = arr::overwrite($errors, $post->errors());
}
$this->auto_render = false;
print json_encode(array("status" => $valid ? "ok" : "error", "content" => (string) $content));
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:26,代码来源:g3_client.php
示例9: get_file_info
private function get_file_info($file)
{
$filesize = 0;
$fileParts = parse_url($file);
$path = arr::get($fileParts, 'path');
$path = substr_replace($path, '', 0, 1);
$path = urldecode($path);
$pathParts = explode('/', $path);
$name = end($pathParts);
if (is_file(PUBLIC_ROOT . $path)) {
$filesize = filesize(PUBLIC_ROOT . $path) / 1000;
}
$mbSize = $filesize / 1000;
$type = 'KB';
if ($mbSize > 1) {
$filesize = $mbSize;
$type = 'MB';
}
$fileType = 'file';
try {
$exifImageType = @exif_imagetype(PUBLIC_ROOT . $path);
if ($exifImageType > 0 && $exifImageType < 18) {
$fileType = 'image';
}
} catch (Exception $e) {
}
return array('type' => $type, 'size' => round($filesize, 2, PHP_ROUND_HALF_UP), 'name' => $name, 'file_type' => $fileType);
}
开发者ID:ariol,项目名称:adminshop,代码行数:28,代码来源:Abstract.php
示例10: ignoreLogLevels
public static function ignoreLogLevels($ignore)
{
if (!is_array($ignore)) {
$ignore = array($ignore);
}
self::$ignore = arr::merge(self::$ignore, $ignore);
}
开发者ID:swk,项目名称:bluebox,代码行数:7,代码来源:Message.php
示例11: __construct
public function __construct($config = array())
{
// Set the config
$this->config = $config;
// Set a filename, if we don't have one
if (str::e($this->config['filename'])) {
$this->config['filename'] = date("Y-m-d_g-ia");
}
// Build driver class
$driver = "Export_Driver_" . trim(strtoupper($config['driver']));
// Load the driver
if (!Eight::auto_load($driver)) {
throw new Export_Exception('export.driver_not_supported', $config['driver']);
}
// Initialize the driver
$this->driver = new $driver($this->config);
// Validate the driver
if (!$this->driver instanceof Export_Driver) {
throw new Export_Exception('export.driver_not_supported', 'Export drivers must use the Export_Driver interface.');
}
// Set the columns
if (!arr::e($this->config['columns'])) {
$this->driver->set_columns($this->config['columns']);
}
}
开发者ID:enormego,项目名称:EightPHP,代码行数:25,代码来源:export.php
示例12: 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
$data += array('nullOption' => 'Account Default');
$data = arr::update($data, 'class', ' callid_dropdown');
// see if the module wants to allow null selections
if (!empty($data['nullOption'])) {
$options = array('0' => $data['nullOption']);
} else {
$options = array();
}
unset($data['nullOption']);
// build an array of netlists sutable for the dropdown helper
$numbers = Doctrine_Query::create()->from('Number n')->Where('LENGTH(n.number) >= 10 ')->execute(array(), Doctrine::HYDRATE_ARRAY);
foreach ($numbers as $number) {
$matches = array();
preg_match('/^\\+?1?([2-9][0-8][0-9])([2-9][0-9][0-9])([0-9]{4})$/', $number['number'], $matches);
if (count($matches) == 4) {
$options[$number['number_id']] = '( ' . $matches[1] . ' ) ' . $matches[2] . ' - ' . $matches[3];
} else {
$options[$number['number_id']] = $number['number'];
}
}
return form::dropdown($data, $options, $selected, $extra);
}
开发者ID:swk,项目名称:bluebox,代码行数:29,代码来源:callid.php
示例13: 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
示例14: dropdownUserType
public static function dropdownUserType($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
$data += array('nullOption' => FALSE);
// append or insert the class
$data = arr::update($data, 'class', 'user_type_dropdown');
// render a null option if its been set in data
if (!empty($data['nullOption'])) {
$options = array(0 => $data['nullOption']);
} else {
$options = array();
}
unset($data['nullOption']);
$userTypes = self::getUserTypes();
foreach ($userTypes as $userType => $displayName) {
if ($userType <= users::getAttr('user_type')) {
$options[$userType] = $displayName;
}
}
// use kohana helper to generate the markup
return form::dropdown($data, $options, $selected, $extra);
}
开发者ID:swk,项目名称:bluebox,代码行数:26,代码来源:usermanager.php
示例15: __construct
/**
* @brief Constructor
*
* @param String $algo The algorithm
*/
public function __construct($algo)
{
$algo = strtolower($algo);
// Check for support
if (extension_loaded('hash')) {
// We got the hashing support, so let's check if the algorithm is
// supported.
if (arr::hasValue(hash_algos(), $algo)) {
$this->module = self::MOD_HASH;
$this->algo = $algo;
return;
}
}
if (extension_loaded('mhash')) {
// No hash support but mhash support, can it handle the algorithm?
$num = mhash_count();
for ($i = 0; $i <= $num; $i++) {
if (mhash_get_hash_name($i) == $algo) {
$this->module = self::MOD_MHASH;
$this->algo = $algo;
return;
}
}
}
// Fall back on legacy spport here, is the algorithm one of the
// by php supported ones?
if (arr::hasValue(array('md5', 'sha1', 'crc32'), $algo)) {
$this->module = self::MOD_PHP;
$this->algo = $algo;
return;
}
// No support, throw exception
throw new SecurityException("Request for unsupported hash algorithm");
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:39,代码来源:hash.php
示例16: pop_dir
/**
* Pops back to previous directory
*/
public static function pop_dir()
{
if (!arr::e(self::$dir_stack)) {
$dir = array_pop(self::$dir_stack);
chdir($dir);
}
}
开发者ID:enormego,项目名称:EightPHP,代码行数:10,代码来源:file.php
示例17: _get_frm_valid
private function _get_frm_valid()
{
$rdo_type = 'image';
$file_ext = 'jpg,jpeg,gif,png';
$form = array('hd_id' => '', 'attach_image' => '', 'txt_width' => '', 'txt_height' => '', 'sel_status' => '');
$errors = $form;
if ($_POST) {
$post = new Validation(array_merge($_FILES, $_POST));
$post->add_rules('attach_' . $rdo_type, 'upload::type[' . $file_ext . ']', 'upload::size[10M]');
$post->add_rules('txt_width', 'digit');
$post->add_rules('txt_height', 'digit');
if ($post->validate()) {
$form = arr::overwrite($form, $post->as_array());
return $form;
} else {
$errors = $post->errors('banner_validation');
$str_error = '';
foreach ($errors as $id => $name) {
if ($name) {
$str_error .= $name . '<br>';
}
}
$this->session->set_flash('error_msg', $str_error);
url::redirect($this->site['history']['current']);
die;
}
}
}
开发者ID:vobinh,项目名称:PHP,代码行数:28,代码来源:admin_banner.php
示例18: action_index
public function action_index()
{
$view = View::factory('kadldap/index');
$this->template->content = $view;
$this->template->title = 'Kadldap';
$this->template->menu = NULL;
$this->template->breadcrumb = array(Route::get('docs/guide')->uri() => __('User Guide'), Route::get('docs/guide')->uri() . '/kadldap.about' => $this->template->title, 'Configuration Test');
$view->message = FALSE;
if (isset($_POST['login'])) {
$post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('username', 'not_empty')->rule('username', 'min_length', array(1))->rule('password', 'not_empty');
if ($post->check()) {
$username = $post['username'];
$password = arr::get($post, 'password', '');
try {
if (Auth::instance()->login($username, $password)) {
$view->message = 'Successful login.';
} else {
$view->message = 'Login failed.';
}
} catch (adLDAPException $e) {
$view->message = $e->getMessage();
}
} else {
$view->message = 'You must enter both your username and password.';
}
}
if (Auth::instance()->logged_in()) {
$username = Auth::instance()->get_user();
$password = Auth::instance()->password($username);
$view->kadldap = Kadldap::instance();
$view->kadldap->authenticate($username, $password);
}
}
开发者ID:phpclub,项目名称:kohana_kadldap,代码行数:33,代码来源:kadldap.php
示例19: _get_frm_valid
private function _get_frm_valid()
{
$hd_id = $this->input->post('hd_id');
$form = $this->data_template_model->get_frm();
$errors = $form;
if ($_POST) {
$post = new Validation($_POST);
$post->pre_filter('trim', TRUE);
$post->add_rules('txt_name', 'required', 'length[1,200]');
$post->add_rules('txt_content', 'required');
if ($post->validate()) {
$form = arr::overwrite($form, $post->as_array());
return $form;
} else {
$form = arr::overwrite($form, $post->as_array());
$errors = arr::overwrite($errors, $post->errors('account_validation'));
$str_error = '';
foreach ($errors as $id => $name) {
if ($name) {
$str_error .= $name . '<br>';
}
}
$this->session->set_flash('error_msg', $str_error);
if ($hd_id) {
url::redirect('admin_emailtemplate/edit/' . $hd_id);
}
die;
}
}
}
开发者ID:vobinh,项目名称:PHP,代码行数:30,代码来源:admin_emailtemplate.php
示例20: actionSelect
public function actionSelect($field = '', $dir = '')
{
$dir = empty($dir) ? zotop::get('dir') : $dir;
$dir = trim(url::decode($dir), '/');
$path = site::template();
$path = $path . DS . str_replace('/', DS, $dir);
$path = path::clean($path);
$folders = folder::folders($path);
$files = folder::files($path);
$position = '<a href="' . zotop::url('system/template/select') . '">' . zotop::t('根目录') . '</a><em> : //</em> ';
if (!empty($dir)) {
$dirs = arr::dirpath($dir, '/');
foreach ($dirs as $d) {
$position .= '<a href="' . zotop::url('system/template/select', array('dir' => rawurlencode($d[1]))) . '">' . $d[0] . '</a> <em>/</em>';
}
}
$page = new dialog();
$page->title = zotop::t('模板管理');
$page->set('field', $field);
$page->set('dir', $dir);
$page->set('position', $position);
$page->set('folders', $folders);
$page->set('files', $files);
$page->display();
}
开发者ID:dalinhuang,项目名称:zotop,代码行数:25,代码来源:template.php
注:本文中的arr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论