• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Address类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getLatLon

 /**
  * Get lat lon by address
  * @author Oleg D.
  */
 function getLatLon($address, $updateAddress = 0)
 {
     $addressString = $city = $state = $country = '';
     if (!empty($address['address'])) {
         $addressString = $address['address'] . ' ' . $address['address2'] . ' ' . $address['address3'];
         if (!empty($address['city'])) {
             $city = $address['city'];
         }
         if (!empty($address['Country']['name'])) {
             $country = $address['Country']['name'];
         } elseif (!empty($address['country_name'])) {
             $country = $address['country_name'];
         }
         if (!empty($address['Provincestate']['name'])) {
             $state = $address['Provincestate']['name'];
         } elseif (!empty($address['state_name'])) {
             $state = $address['state_name'];
         }
         App::import('Vendor', 'GoogleMapAPI', array('file' => 'class.GoogleMapAPI.php'));
         $map = new GoogleMapAPI();
         $map->setAPIKey(GOOGLE_MAP_KEY);
         $latLon = $map->getCoordsByAddress(trim($addressString), $city, $state, $country);
         if ($updateAddress && !empty($address['id']) && !empty($latLon['lat']) && !empty($latLon['lon'])) {
             $Address = new Address();
             $Address->save(array('id' => $address['id'], 'latitude' => $latLon['lat'], 'longitude' => $latLon['lon']));
         }
         return $latLon;
     } else {
         return false;
     }
 }
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:35,代码来源:AddressHelper.php


示例2: getPeople

 public function getPeople($ids, $profileDetails)
 {
     $ret = array();
     $query = "select * from user_profile where user_id in (" . implode(',', $ids) . ")";
     $res = mysql_query($query);
     if ($res) {
         while ($row = @mysql_fetch_assoc($res)) {
             $person_id = $row['user_id'];
             $name = new Name($row['first_name'] . ' ' . $row['last_name']);
             $name->setGivenName($row['first_name']);
             $name->setFamilyName($row['last_name']);
             $person = new Person($row['user_id'], $name);
             $person->setProfileUrl($row['profile_url']);
             $date = date($row['date_of_birth']);
             $person->setDateOfBirth($date);
             $address = new Address($row['city']);
             $address->setLocality($row['city']);
             $person->setAddresses($address);
             $interests = $row['interests'];
             $interests = explode(',', $interests);
             $person->setInterests($interests);
             $person->setThumbnailUrl(!empty($row['user_image']) ? $this->url_prefix . $row['user_image'] : '');
             if (!empty($row['Gender'])) {
                 if ($row['Gender'] == 'f') {
                     $person->setGender('FEMALE');
                 } else {
                     $person->setGender('MALE');
                 }
             }
             $ret[$person_id] = $person;
         }
     }
     return $ret;
 }
开发者ID:nicklvsa,项目名称:esprit,代码行数:34,代码来源:espritDBFetcher.php


示例3: createAddressFromCoordinates

 public function createAddressFromCoordinates($lat, $lng)
 {
     $addressResult = $this->geocoder->reverseGeocode($lat, $lng);
     $address = new Address();
     $address->updateFromAddressResult($addressResult);
     return $address;
 }
开发者ID:aplysie,项目名称:hitema-exos-m1,代码行数:7,代码来源:exemple1.php


示例4: test

 /**
  * Runs the test.
  */
 public function test()
 {
     $email = '[email protected]';
     $name = 'Jyxo';
     // Email and name given
     $address = new Address($email, $name);
     $this->assertEquals($email, $address->getEmail());
     $this->assertEquals($name, $address->getName());
     // Only email given
     $address = new Address($email);
     $this->assertEquals($email, $address->getEmail());
     $this->assertEquals('', $address->getName());
     // It is necessary to trim whitespace
     $address = new Address(' ' . $email, $name . ' ');
     $this->assertEquals($email, $address->getEmail());
     $this->assertEquals($name, $address->getName());
     // Invalid email
     try {
         $address = new Address('žlutý kůň@jyxo.com', $name);
         $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 }
开发者ID:jyxo,项目名称:php,代码行数:30,代码来源:AddressTest.php


示例5: up

 public function up()
 {
     $this->addColumn($this->tableName, $this->columnName, 'int');
     /** @var $data Office[] */
     $data = Office::model()->findAll();
     $migratedAddresses = [];
     foreach ($data as $office) {
         $fullAddress = implode(' ', [$office->address1, $office->address2, $office->address3, $office->address4]);
         if (isset($migratedAddresses[$fullAddress])) {
             $office->addressId = $migratedAddresses[$fullAddress]->id;
             $office->save(false);
             continue;
         }
         $parts = explode(' ', $office->address1);
         $buildingNumber = array_shift($parts);
         $line2 = implode(' ', $parts);
         $address = new Address();
         $address->line1 = $buildingNumber;
         $address->line2 = $line2;
         $address->line5 = $office->address3;
         $address->postcode = $office->postcode;
         $address->save();
         $migratedAddresses[$fullAddress] = $address;
         $office->addressId = $migratedAddresses[$fullAddress]->id;
         $office->save(false);
         continue;
     }
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:28,代码来源:m120923_123505_alter_table_office_add_addressID_and_migrate_data.php


示例6: actionCreate

 public function actionCreate()
 {
     if ($model = Shop::getCustomer()) {
         $address = $model->address;
     } else {
         $model = new Customer();
     }
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         if (isset($_POST['Address'])) {
             $address = new Address();
             $address->attributes = $_POST['Address'];
             if ($address->save()) {
                 $model->address_id = $address->id;
             }
         }
         if (!Yii::app()->user->isGuest) {
             $model->user_id = Yii::app()->user->id;
         }
         if ($model->save()) {
             Yii::app()->user->setState('customer_id', $model->customer_id);
             $this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
         }
     }
     $this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
 }
开发者ID:huynhchanhuy,项目名称:yii_shopping,代码行数:26,代码来源:CustomerController.php


示例7: save

 function save($id = FALSE)
 {
     if ($_POST) {
         $about = new Address($id);
         // if($_FILES['image']['name'])
         // {
         // if($about->id){
         // $about->delete_file($about->id,'uploads/about_us/','image');
         // }
         // $_POST['image'] = $about->upload($_FILES['image'],'uploads/about_us/',260,195);
         // }
         // if($_FILES['imagemap']['name'])
         // {
         // if($about->id){
         // $about->delete_file($about->id,'uploads/about_us/','imagemap');
         // }
         // $_POST['imagemap'] = $about->upload($_FILES['imagemap'],'uploads/about_us/');
         // }
         $_POST['name'] = lang_encode($_POST['name']);
         $_POST['address'] = lang_encode($_POST['address']);
         $_POST['tel'] = lang_encode($_POST['tel']);
         $_POST['facebook'] = lang_encode($_POST['facebook']);
         $_POST['twitter'] = lang_encode($_POST['twitter']);
         $_POST['googleplus'] = lang_encode($_POST['googleplus']);
         $_POST['open'] = lang_encode($_POST['open']);
         $_POST['open2'] = lang_encode($_POST['open2']);
         //$_POST['service_time'] = lang_encode($_POST['service_time']);
         $_POST['detail'] = lang_encode($_POST['detail']);
         // $_POST['user_id'] = $this->session->userdata('id');
         $about->from_array($_POST);
         $about->save();
         set_notify('success', lang('save_data_complete'));
     }
     redirect('addresses/admin/addresses');
 }
开发者ID:unisexx,项目名称:drtooth,代码行数:35,代码来源:addresses.php


示例8: setAddress

 public function setAddress(Address $address)
 {
     if ($this->address !== $address) {
         $this->address = $address;
         $address->setUser($this);
     }
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:7,代码来源:User.php


示例9: compare

 public static function compare(Address $a, Address $b)
 {
     if ($a->toArray() == $b->toArray()) {
         return true;
     }
     return false;
 }
开发者ID:expressly,项目名称:php-common,代码行数:7,代码来源:Address.php


示例10: isEqualTo

 /**
  * @param Address $address
  * @return bool
  */
 public function isEqualTo(Address $address)
 {
     if ($this->getArray() === $address->getArray()) {
         return true;
     }
     return false;
 }
开发者ID:alistairshaw,项目名称:vendirun-plugin,代码行数:11,代码来源:Address.php


示例11: renderForm

 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $image = _PS_STORE_IMG_DIR_ . $obj->id . '.jpg';
     $image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true);
     $image_size = file_exists($image) ? filesize($image) / 1000 : false;
     $tmp_addr = new Address();
     $res = $tmp_addr->getFieldsRequiredDatabase();
     $required_fields = array();
     foreach ($res as $row) {
         $required_fields[(int) $row['id_required_field']] = $row['field_name'];
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Stores'), 'icon' => 'icon-home'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => false, 'hint' => array($this->l('Store name (e.g. City Center Mall Store).'), $this->l('Allowed characters: letters, spaces and %s'))), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'required' => true), array('type' => 'text', 'label' => $this->l('Address (2)'), 'name' => 'address2'), array('type' => 'text', 'label' => $this->l('Zip/postal Code'), 'name' => 'postcode', 'required' => in_array('postcode', $required_fields)), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('id' => 'id_state', 'name' => 'name', 'query' => null)), array('type' => 'latitude', 'label' => $this->l('Latitude / Longitude'), 'name' => 'latitude', 'required' => true, 'maxlength' => 12, 'hint' => $this->l('Store coordinates (e.g. 45.265469/-47.226478).')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone'), array('type' => 'text', 'label' => $this->l('Fax'), 'name' => 'fax'), array('type' => 'text', 'label' => $this->l('Email address'), 'name' => 'email'), array('type' => 'textarea', 'label' => $this->l('Note'), 'name' => 'note', 'cols' => 42, 'rows' => 4), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Whether or not to display this store.')), array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Storefront picture.'))), 'hours' => array(), 'submit' => array('title' => $this->l('Save')));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
     }
     $days = array();
     $days[1] = $this->l('Monday');
     $days[2] = $this->l('Tuesday');
     $days[3] = $this->l('Wednesday');
     $days[4] = $this->l('Thursday');
     $days[5] = $this->l('Friday');
     $days[6] = $this->l('Saturday');
     $days[7] = $this->l('Sunday');
     $hours = $this->getFieldValue($obj, 'hours');
     if (!empty($hours)) {
         $hours_unserialized = Tools::unSerialize($hours);
     }
     $this->fields_value = array('latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'), 'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'), 'days' => $days, 'hours' => isset($hours_unserialized) ? $hours_unserialized : false);
     return parent::renderForm();
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:33,代码来源:AdminStoresController.php


示例12: testForm

 public function testForm()
 {
     $address = new Address(array('Country' => 'NZ', 'State' => 'Wellington', 'City' => 'TeAro', 'PostalCode' => '1333', 'Address' => '23 Blah Street', 'AddressLine2' => 'Fitzgerald Building, Foor 3', 'Company' => 'Ink inc', 'FirstName' => 'Jerald', 'Surname' => 'Smith', 'Phone' => '12346678'));
     $fields = $address->getFrontEndFields();
     $requiremetns = $address->getRequiredFields();
     $this->assertEquals("23 Blah Street|Fitzgerald Building, Foor 3|TeAro|Wellington|1333|NZ", $address->toString("|"));
 }
开发者ID:renskorswagen,项目名称:silverstripe-shop,代码行数:7,代码来源:AddressTest.php


示例13: displayMain

 public function displayMain()
 {
     global $smarty, $link, $cookie;
     $errors = false;
     if (!$cookie->logged || !User::checkPassword($cookie->id_user, $cookie->passwd)) {
         Tools::redirect($link->getPage('userView'));
     }
     $referer = Tools::Q('referer') ? $link->getPage(Tools::Q('referer')) : $link->getPage('MyAddressesView');
     if ($id_address = Tools::Q('id')) {
         $address = new Address((int) $id_address);
         if (Tools::isSubmit('saveAddress')) {
             $address->copyFromPost();
             if ($address->update()) {
                 Tools::redirect($referer);
             } else {
                 $errors = $address->_errors;
             }
         }
         $smarty->assign('address', $address);
     } elseif (Tools::isSubmit('saveAddress')) {
         $address = new Address();
         $address->copyFromPost();
         $address->id_user = $cookie->id_user;
         if ($address->add()) {
             Tools::redirect($referer);
         } else {
             $errors = $address->_errors;
         }
     }
     $countrys = Country::loadData(1, 1000, 'position', 'asc', array('active' => true));
     $smarty->assign(array('referer' => Tools::Q('referer'), 'countrys' => $countrys, 'errors' => $errors));
     return $smarty->fetch('address.tpl');
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:33,代码来源:AddressView.php


示例14: add

 public function add()
 {
     if (!isset($_POST['card_number'])) {
         $this->redirect_to();
     }
     $paymentMethod = new Payment_Method();
     $paymentMethod->assignProperties($_POST);
     $paymentMethod->runValidations();
     if ($_POST['include_new_address'] == "1") {
         require_once '../app/models/Address.php';
         $address = new Address();
         $address->assignProperties($_POST);
         $address->runValidations();
         // A valid payment method will still have one error - fk_payment_method_address  will be missing.
         if (count($paymentMethod->errorsList) == 1 && isset($paymentMethod->errorsList['fk_payment_method_address'])) {
             $addressId = $address->savePreparedStatementToDb('address', $address->properties);
         }
     } else {
         $addressId = $_POST['addressId'];
     }
     $paymentMethod->properties['fk_payment_method_address'] = $addressId;
     $paymentMethodId = $paymentMethod->savePreparedStatementToDb('payment_method', $paymentMethod->properties);
     $_SESSION['paymentMethodId'] = $paymentMethodId;
     $_SESSION['payment_method'] = $paymentMethod;
     if (isset($_SESSION['address'])) {
         $_SESSION['address'] = $address;
     }
     $this->redirect_to($_POST['redirect']);
 }
开发者ID:matthewleighton,项目名称:online_shop,代码行数:29,代码来源:payment_methods_controller.php


示例15: __construct

 public function __construct(FirstName $firstName, LastName $lastName, Email $email, Address $address)
 {
     $this->firstName = $firstName;
     $this->lastName = $lastName;
     $this->email = $email;
     $this->address = $address;
     $this->shoppingCart = new ShoppingCart($this->address->country());
 }
开发者ID:mihaeu,项目名称:PW-SimpleShop,代码行数:8,代码来源:Customer.php


示例16: _loadAddress

 private function _loadAddress($type)
 {
     $address = new Address();
     $address->practiceId = (int) $this->id;
     $address->type = (int) $type;
     $address->populateWithPracticeIdType();
     return $address;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:8,代码来源:Practice.php


示例17: testAddressLatitudeAndLongitude

 public function testAddressLatitudeAndLongitude()
 {
     $address = new Address();
     $address->latitude = 123.145638;
     $this->assertEquals('123.145638', $address->getLatitude());
     $address->longitude = 121.176129;
     $this->assertEquals('121.176129', $address->getLongitude());
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:8,代码来源:AddressTest.php


示例18: save

 /**
  * Méthode permettant d'enregistrer une adresse
  * @param $address L'adresse à enregistrer
  * @return void
  */
 public function save(Address $address)
 {
     if ($address->isValid()) {
         $address->isNew() ? $this->add($address) : $this->modify($address);
     } else {
         throw new RuntimeException('L\'adresse doit être valide pour être enregistrée');
     }
 }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:13,代码来源:AddressesManager.class.php


示例19: addCoords

 static function addCoords(Address $address)
 {
     if ($coords = self::coords($address->getOneLiner())) {
         $address->latitude = $coords['latitude'];
         $address->longitude = $coords['longitude'];
     }
     return $address;
 }
开发者ID:silky,项目名称:littlesis,代码行数:8,代码来源:AddressTable.class.php


示例20: hookFooter

 /**
  * Returns module content for header
  *
  * @param array $params Parameters
  * @return string Content
  */
 function hookFooter($params)
 {
     global $smarty, $cookie, $cart;
     if (isset($smarty->_tpl_vars['HOOK_EXTRACARRIER']) and $smarty->_tpl_vars['page_name'] == 'order') {
         $smarty->assign('TNTCarrierId', $this->_id_carrier);
         //			if ($smarty->_tpl_vars['page_name'] == 'order')
         //				$smarty->assign('TNT_js', 'relaisColis');
         if ($smarty->_tpl_vars['page_name'] == 'history') {
             $smarty->assign('TNT_js', 'suiviColis');
         }
         return $this->display(__FILE__, 'relaistnt_footer.tpl');
     } elseif ($smarty->_tpl_vars['page_name'] == 'order' and (Tools::isSubmit('processCarrier') or Tools::getValue('step') === '3') and Validate::isLoadedObject($cart)) {
         if ($cart->id_carrier != intval($this->_id_carrier)) {
             return;
         }
         if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcmp(Tools::getToken(false), Tools::getValue('token')) && $cookie->isLogged() === true) {
             $error = $this->l('invalid token');
         }
         $tntRCSelectedCode = pSQL(Tools::getValue('tntRCSelectedCode'));
         if (empty($tntRCSelectedCode) or is_null($tntRCSelectedCode)) {
             $error = $this->l('Avec la livraison TNT, vous devez choisir le relais dans lequel votre colis sera livré.');
         }
         if (!isset($error)) {
             $address_TNT = new Address();
             $address_TNT->id_country = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
             $address_TNT->id_customer = intval($cart->id_customer);
             $address_TNT->alias = $this->l('TNT-') . $cart->id . '-' . $tntRCSelectedCode;
             $address_TNT->lastname = $this->l('TNT');
             $address_TNT->firstname = $this->l('Relais Colis');
             if (Validate::isName(Tools::getValue('tntRCSelectedNom'))) {
                 $address_TNT->company = pSQL(Tools::getValue('tntRCSelectedNom'));
                 $address_TNT->firstname .= ' - ' . pSQL(Tools::getValue('tntRCSelectedNom'));
             }
             if (Validate::isAddress(Tools::getValue('tntRCSelectedAdresse'))) {
                 $address_TNT->address1 = pSQL(Tools::getValue('tntRCSelectedAdresse'));
             }
             if (Validate::isPostCode(Tools::getValue('tntRCSelectedCodePostal'))) {
             }
             $address_TNT->postcode = pSQL(Tools::getValue('tntRCSelectedCodePostal'));
             if (Validate::isCityName(preg_replace('[\\d]', '', pSQL(Tools::getValue('tntRCSelectedCommune'))))) {
                 $address_TNT->city = preg_replace('[\\d]', '', pSQL(Tools::getValue('tntRCSelectedCommune')));
             }
             $address_TNT->deleted = 1;
             $errors = $address_TNT->validateControler();
             if (is_array($errors) and isset($errors[0])) {
                 Tools::redirect('order.php?step=2&error;=' . urlencode($errors[0]));
             }
             if ($address_TNT->save()) {
                 $cart->id_address_delivery = intval($address_TNT->id);
                 $cart->save();
             } else {
                 Tools::redirect('order.php?step=2&error;=' . urlencode($this->l('could not save TNT address')));
             }
         } else {
             Tools::redirect('order.php?step=2&error;=' . urlencode($error));
         }
     }
 }
开发者ID:bastnic,项目名称:presta-relaistnt,代码行数:64,代码来源:relaistnt.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP AddressFormat类代码示例发布时间:2022-05-23
下一篇:
PHP Addons类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap