本文整理汇总了PHP中Address类的典型用法代码示例。如果您正苦于以下问题:PHP Address类的具体用法?PHP Address怎么用?PHP Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
示例3: createAddressFromCoordinates
public function createAddressFromCoordinates($lat, $lng)
{
$addressResult = $this->geocoder->reverseGeocode($lat, $lng);
$address = new Address();
$address->updateFromAddressResult($addressResult);
return $address;
}
示例4: test
/**
* Runs the test.
*/
public function test()
{
$email = 'jyxo@jyxo.com';
$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);
}
}
示例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()));
}
示例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');
}
示例8: setAddress
public function setAddress(Address $address)
{
if ($this->address !== $address) {
$this->address = $address;
$address->setUser($this);
}
}
示例9: compare
public static function compare(Address $a, Address $b)
{
if ($a->toArray() == $b->toArray()) {
return true;
}
return false;
}
示例10: isEqualTo
/**
* @param Address $address
* @return bool
*/
public function isEqualTo(Address $address)
{
if ($this->getArray() === $address->getArray()) {
return true;
}
return false;
}
示例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();
}
示例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("|"));
}
示例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');
}
示例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']);
}
示例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());
}