本文整理汇总了PHP中Country::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::Load方法的具体用法?PHP Country::Load怎么用?PHP Country::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* The run() function is called from Web Store to actually do the calculation. It returns an array of the service
* levels and prices available to the customer (as keys and values in the array, respectively).
* @return array
*/
public function run()
{
if (!isset($this->config['offerservices'])) {
return false;
}
$weight = $this->objCart->Weight;
if (_xls_get_conf('WEIGHT_UNIT', 'lb') != 'lb') {
// one KG is 2.2 pounds
$weight = $weight * 2.2;
}
//USPS wants a full country name
$objCountry = Country::Load($this->CheckoutForm->shippingCountry);
if ($objCountry instanceof Country) {
$country = $objCountry->country;
} else {
$country = "US";
}
if (empty($this->config['username']) || empty($this->config['originpostcode'])) {
return false;
}
$this->init_vars($this->config['username'], $this->config['originpostcode'], $this->CheckoutForm->shippingPostal, $country, $this->config['markup']);
$this->addItem(intval($weight), round(($weight - intval($weight)) * 16, 0), $this->objCart->total);
$rates = $this->getRate();
if ($rates === FALSE || count($rates) == 0) {
Yii::log("USPS: Could not get rates. " . print_r($this, true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
return false;
}
return $this->convertRetToDisplay($rates);
}
示例2: validateAttribute
/**
* Validates that the state that the customer enters either
* in the shipping form or billing form respects the format
* for the countries we want to validate it upon.
*
* @param CModel $model
* @param string $attribute
* @return void
*/
public function validateAttribute($model, $attribute)
{
switch ($attribute) {
case 'shippingState':
$objCountry = Country::Load($model->shippingCountry);
break;
case 'billingState':
$objCountry = Country::Load($model->billingCountry);
break;
default:
// Cannot validate any other attributes.
return;
}
if ($objCountry === null) {
// Country isn't valid, can't validate the state!
return;
}
$countriesToValidateState = array(self::USA, self::CANADA, self::AUSTRALIA);
if (in_array($objCountry->id, $countriesToValidateState) === false) {
// Do not attempt to validate the state.
return;
}
if (empty($model->{$attribute}) === true) {
$this->addError($model, $attribute, Yii::t('yii', '{attributeName} cannot be blank.', array('{attributeName}' => $model->getattributeLabel($attribute))));
} else {
$objState = State::Load($model->{$attribute});
if ($objState === null) {
$this->addError($model, $attribute, Yii::t('yii', '{attributeName} is invalid.', array('{attributeName}' => $model->getattributeLabel($attribute))));
}
}
}
示例3: SetupCountry
protected function SetupCountry()
{
// Lookup Object PK information from Query String (if applicable)
// Set mode to Edit or New depending on what's found
$intCountryId = QApplication::QueryString('intCountryId');
if ($intCountryId) {
$this->objCountry = Country::Load($intCountryId);
if (!$this->objCountry) {
throw new Exception('Could not find a Country object with PK arguments: ' . $intCountryId);
}
$this->strTitleVerb = QApplication::Translate('Edit');
$this->blnEditMode = true;
} else {
$this->objCountry = new Country();
$this->strTitleVerb = QApplication::Translate('Create');
$this->blnEditMode = false;
}
}
示例4: holidayToEvent
public function holidayToEvent($holiday)
{
$event = array();
$event['id'] = "hd_" . $holiday->id;
if ($holiday->status == "Full Day") {
$event['title'] = $holiday->name;
} else {
$event['title'] = $holiday->name . " (" . $holiday->status . ")";
}
if (!empty($holiday->country)) {
$country = new Country();
$country->Load("id = ?", array($holiday->country));
$event['title'] .= " / " . $country->name . " only";
}
$event['start'] = $holiday->dateh;
$event['end'] = $holiday->dateh;
$eventBackgroundColor = "#3c8dbc";
$event['color'] = $eventBackgroundColor;
$event['backgroundColor'] = $eventBackgroundColor;
$event['textColor'] = "#FFF";
return $event;
}
示例5: getLeaveDays
public function getLeaveDays($req)
{
//Find Current leave period
$leaveCounts = array();
$currentLeavePeriodResp = $this->getCurrentLeavePeriod($req->start_date, $req->end_date);
if ($currentLeavePeriodResp->getStatus() != IceResponse::SUCCESS) {
return new IceResponse(IceResponse::ERROR, $currentLeavePeriodResp->getData());
} else {
$currentLeavePeriod = $currentLeavePeriodResp->getData();
}
$employee = $this->baseService->getElement('Employee', $this->getCurrentProfileId(), null, true);
$rule = $this->getLeaveRule($employee, $req->leave_type, $currentLeavePeriod);
if ($this->user->user_level == 'Admin' && $this->getCurrentProfileId() != $this->user->employee) {
//Admin is updating information for an employee
if ($rule->supervisor_leave_assign == "No") {
return new IceResponse(IceResponse::ERROR, "You are not allowed to assign this type of leaves as admin");
}
} else {
if ($rule->employee_can_apply == "No") {
return new IceResponse(IceResponse::ERROR, "You are not allowed to apply for this type of leaves");
}
}
$leaveMatrix = $this->getAvailableLeaveMatrixForEmployeeLeaveType($employee, $currentLeavePeriod, $req->leave_type);
$leaves = array();
$leaves['totalLeaves'] = floatval($leaveMatrix[0]);
$leaves['pendingLeaves'] = floatval($leaveMatrix[1]);
$leaves['approvedLeaves'] = floatval($leaveMatrix[2]);
$leaves['rejectedLeaves'] = floatval($leaveMatrix[3]);
$leaves['cancelRequestedLeaves'] = floatval($leaveMatrix[5]);
$leaves['availableLeaves'] = $leaves['totalLeaves'] - $leaves['pendingLeaves'] - $leaves['approvedLeaves'] - $leaves['cancelRequestedLeaves'];
//=== Resolve Employee Country
$employeeCountry = NULL;
if (!empty($employee->country)) {
$country = new Country();
$country->Load("code = ?", array($employee->country));
$employeeCountry = $country->id;
}
//============================
$startDate = $req->start_date;
$endDate = $req->end_date;
$days = array();
$days = $this->getDays($startDate, $endDate);
$dayMap = array();
foreach ($days as $day) {
$dayMap[$day] = $this->getDayWorkTime($day, $employeeCountry);
}
return new IceResponse(IceResponse::SUCCESS, array($dayMap, $leaves, $rule));
}
示例6: Create
/**
* Static Helper Method to Create using PK arguments
* You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
* If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
* static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
* edit, or if we are also allowed to create a new one, etc.
*
* @param mixed $objParentObject QForm or QPanel which will be using this CountryMetaControl
* @param integer $intCountryId primary key value
* @param QMetaControlCreateType $intCreateType rules governing Country object creation - defaults to CreateOrEdit
* @return CountryMetaControl
*/
public static function Create($objParentObject, $intCountryId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
{
// Attempt to Load from PK Arguments
if (strlen($intCountryId)) {
$objCountry = Country::Load($intCountryId);
// Country was found -- return it!
if ($objCountry) {
return new CountryMetaControl($objParentObject, $objCountry);
} else {
if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
throw new QCallerException('Could not find a Country object with PK arguments: ' . $intCountryId);
}
}
// If EditOnly is specified, throw an exception
} else {
if ($intCreateType == QMetaControlCreateType::EditOnly) {
throw new QCallerException('No PK arguments specified');
}
}
// If we are here, then we need to create a new record
return new CountryMetaControl($objParentObject, new Country());
}
示例7: __get
//.........这里部分代码省略.........
*/
return $this->intCreatedBy;
case 'CreationDate':
/**
* Gets the value for dttCreationDate
* @return QDateTime
*/
return $this->dttCreationDate;
case 'ModifiedBy':
/**
* Gets the value for intModifiedBy
* @return integer
*/
return $this->intModifiedBy;
case 'ModifiedDate':
/**
* Gets the value for strModifiedDate (Read-Only Timestamp)
* @return string
*/
return $this->strModifiedDate;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Company':
/**
* Gets the value for the Company object referenced by intCompanyId (Not Null)
* @return Company
*/
try {
if (!$this->objCompany && !is_null($this->intCompanyId)) {
$this->objCompany = Company::Load($this->intCompanyId);
}
return $this->objCompany;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'Country':
/**
* Gets the value for the Country object referenced by intCountryId (Not Null)
* @return Country
*/
try {
if (!$this->objCountry && !is_null($this->intCountryId)) {
$this->objCountry = Country::Load($this->intCountryId);
}
return $this->objCountry;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'StateProvince':
/**
* Gets the value for the StateProvince object referenced by intStateProvinceId
* @return StateProvince
*/
try {
if (!$this->objStateProvince && !is_null($this->intStateProvinceId)) {
$this->objStateProvince = StateProvince::Load($this->intStateProvinceId);
}
return $this->objStateProvince;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
示例8: Reload
/**
* Reload this Country from the database.
* @return void
*/
public function Reload()
{
// Make sure we are actually Restored from the database
if (!$this->__blnRestored) {
throw new QCallerException('Cannot call Reload() on a new, unsaved Country object.');
}
// Reload the Object
$objReloaded = Country::Load($this->intId);
// Update $this's local variables to match
$this->strName = $objReloaded->strName;
$this->strAbbreviation = $objReloaded->strAbbreviation;
}
示例9: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'Id':
// Gets the value for intId (Read-Only PK)
// @return integer
return $this->intId;
case 'PersonTypeId':
// Gets the value for intPersonTypeId (Not Null)
// @return integer
return $this->intPersonTypeId;
case 'Username':
// Gets the value for strUsername (Unique)
// @return string
return $this->strUsername;
case 'Password':
// Gets the value for strPassword
// @return string
return $this->strPassword;
case 'FirstName':
// Gets the value for strFirstName (Not Null)
// @return string
return $this->strFirstName;
case 'LastName':
// Gets the value for strLastName (Not Null)
// @return string
return $this->strLastName;
case 'Email':
// Gets the value for strEmail (Unique)
// @return string
return $this->strEmail;
case 'DisplayName':
// Gets the value for strDisplayName
// @return string
return $this->strDisplayName;
case 'PasswordResetFlag':
// Gets the value for blnPasswordResetFlag
// @return boolean
return $this->blnPasswordResetFlag;
case 'DisplayRealNameFlag':
// Gets the value for blnDisplayRealNameFlag
// @return boolean
return $this->blnDisplayRealNameFlag;
case 'DisplayEmailFlag':
// Gets the value for blnDisplayEmailFlag
// @return boolean
return $this->blnDisplayEmailFlag;
case 'OptInFlag':
// Gets the value for blnOptInFlag
// @return boolean
return $this->blnOptInFlag;
case 'DonatedFlag':
// Gets the value for blnDonatedFlag
// @return boolean
return $this->blnDonatedFlag;
case 'Location':
// Gets the value for strLocation
// @return string
return $this->strLocation;
case 'CountryId':
// Gets the value for intCountryId
// @return integer
return $this->intCountryId;
case 'Url':
// Gets the value for strUrl
// @return string
return $this->strUrl;
case 'TimezoneId':
// Gets the value for intTimezoneId
// @return integer
return $this->intTimezoneId;
case 'RegistrationDate':
// Gets the value for dttRegistrationDate (Not Null)
// @return QDateTime
return $this->dttRegistrationDate;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Country':
// Gets the value for the Country object referenced by intCountryId
// @return Country
try {
if (!$this->objCountry && !is_null($this->intCountryId)) {
$this->objCountry = Country::Load($this->intCountryId);
}
return $this->objCountry;
} catch (QCallerException $objExc) {
//.........这里部分代码省略.........
示例10: btnEdit_Click
public function btnEdit_Click($strFormId, $strControlId, $strParameter)
{
$strParameterArray = explode(',', $strParameter);
$objCountry = Country::Load($strParameterArray[0]);
$objEditPanel = new CountryEditPanel($this, $this->strCloseEditPanelMethod, $objCountry);
$strMethodName = $this->strSetEditPanelMethod;
$this->objForm->{$strMethodName}($objEditPanel);
}
示例11: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'StateProvinceId':
// Gets the value for intStateProvinceId (Read-Only PK)
// @return integer
return $this->intStateProvinceId;
case 'CountryId':
// Gets the value for intCountryId
// @return integer
return $this->intCountryId;
case 'ShortDescription':
// Gets the value for strShortDescription
// @return string
return $this->strShortDescription;
case 'Abbreviation':
// Gets the value for strAbbreviation
// @return string
return $this->strAbbreviation;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Country':
// Gets the value for the Country object referenced by intCountryId
// @return Country
try {
if (!$this->objCountry && !is_null($this->intCountryId)) {
$this->objCountry = Country::Load($this->intCountryId);
}
return $this->objCountry;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
////////////////////////////
// Virtual Object References (Many to Many and Reverse References)
// (If restored via a "Many-to" expansion)
////////////////////////////
////////////////////////////
// Virtual Object References (Many to Many and Reverse References)
// (If restored via a "Many-to" expansion)
////////////////////////////
case '_Address':
// Gets the value for the private _objAddress (Read-Only)
// if set due to an expansion on the address.state_province_id reverse relationship
// @return Address
return $this->_objAddress;
case '_AddressArray':
// Gets the value for the private _objAddressArray (Read-Only)
// if set due to an ExpandAsArray on the address.state_province_id reverse relationship
// @return Address[]
return (array) $this->_objAddressArray;
case '__Restored':
return $this->__blnRestored;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例12: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'StateProvinceId':
/**
* Gets the value for intStateProvinceId (Read-Only PK)
* @return integer
*/
return $this->intStateProvinceId;
case 'CountryId':
/**
* Gets the value for intCountryId
* @return integer
*/
return $this->intCountryId;
case 'ShortDescription':
/**
* Gets the value for strShortDescription
* @return string
*/
return $this->strShortDescription;
case 'Abbreviation':
/**
* Gets the value for strAbbreviation
* @return string
*/
return $this->strAbbreviation;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Country':
/**
* Gets the value for the Country object referenced by intCountryId
* @return Country
*/
try {
if (!$this->objCountry && !is_null($this->intCountryId)) {
$this->objCountry = Country::Load($this->intCountryId);
}
return $this->objCountry;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
////////////////////////////
// Virtual Object References (Many to Many and Reverse References)
// (If restored via a "Many-to" expansion)
////////////////////////////
////////////////////////////
// Virtual Object References (Many to Many and Reverse References)
// (If restored via a "Many-to" expansion)
////////////////////////////
case '_Address':
/**
* Gets the value for the private _objAddress (Read-Only)
* if set due to an expansion on the address.state_province_id reverse relationship
* @return Address
*/
return $this->_objAddress;
case '_AddressArray':
/**
* Gets the value for the private _objAddressArray (Read-Only)
* if set due to an ExpandAsArray on the address.state_province_id reverse relationship
* @return Address[]
*/
return (array) $this->_objAddressArray;
case '_FedexShipmentAsHoldAtLocationState':
/**
* Gets the value for the private _objFedexShipmentAsHoldAtLocationState (Read-Only)
* if set due to an expansion on the fedex_shipment.hold_at_location_state reverse relationship
* @return FedexShipment
*/
return $this->_objFedexShipmentAsHoldAtLocationState;
case '_FedexShipmentAsHoldAtLocationStateArray':
/**
* Gets the value for the private _objFedexShipmentAsHoldAtLocationStateArray (Read-Only)
* if set due to an ExpandAsArray on the fedex_shipment.hold_at_location_state reverse relationship
* @return FedexShipment[]
*/
return (array) $this->_objFedexShipmentAsHoldAtLocationStateArray;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
//.........这里部分代码省略.........
示例13: __get
/**
* Override method to perform a property "Get"
* This will get the value of $strName
*
* @param string $strName Name of the property to get
* @return mixed
*/
public function __get($strName)
{
switch ($strName) {
///////////////////
// Member Variables
///////////////////
case 'AddressId':
// Gets the value for intAddressId (Read-Only PK)
// @return integer
return $this->intAddressId;
case 'CompanyId':
// Gets the value for intCompanyId (Not Null)
// @return integer
return $this->intCompanyId;
case 'ShortDescription':
// Gets the value for strShortDescription (Not Null)
// @return string
return $this->strShortDescription;
case 'CountryId':
// Gets the value for intCountryId (Not Null)
// @return integer
return $this->intCountryId;
case 'Address1':
// Gets the value for strAddress1 (Not Null)
// @return string
return $this->strAddress1;
case 'Address2':
// Gets the value for strAddress2
// @return string
return $this->strAddress2;
case 'City':
// Gets the value for strCity (Not Null)
// @return string
return $this->strCity;
case 'StateProvinceId':
// Gets the value for intStateProvinceId
// @return integer
return $this->intStateProvinceId;
case 'PostalCode':
// Gets the value for strPostalCode (Not Null)
// @return string
return $this->strPostalCode;
case 'CreatedBy':
// Gets the value for intCreatedBy
// @return integer
return $this->intCreatedBy;
case 'CreationDate':
// Gets the value for dttCreationDate
// @return QDateTime
return $this->dttCreationDate;
case 'ModifiedBy':
// Gets the value for intModifiedBy
// @return integer
return $this->intModifiedBy;
case 'ModifiedDate':
// Gets the value for strModifiedDate (Read-Only Timestamp)
// @return string
return $this->strModifiedDate;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Company':
// Gets the value for the Company object referenced by intCompanyId (Not Null)
// @return Company
try {
if (!$this->objCompany && !is_null($this->intCompanyId)) {
$this->objCompany = Company::Load($this->intCompanyId);
}
return $this->objCompany;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'Country':
// Gets the value for the Country object referenced by intCountryId (Not Null)
// @return Country
try {
if (!$this->objCountry && !is_null($this->intCountryId)) {
$this->objCountry = Country::Load($this->intCountryId);
}
return $this->objCountry;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'StateProvince':
// Gets the value for the StateProvince object referenced by intStateProvinceId
// @return StateProvince
try {
if (!$this->objStateProvince && !is_null($this->intStateProvinceId)) {
//.........这里部分代码省略.........
示例14: _xls_country
function _xls_country()
{
$objCountry = Country::Load(_xls_get_conf('DEFAULT_COUNTRY', 39));
return $objCountry->code;
}
示例15: postValidatePostal
/**
* Perform validation on the zip/postal code and populate model
* with error if necessary
*
* @param $attribute
* @return void
*/
protected function postValidatePostal($attribute, $country)
{
if (is_numeric($country) === true) {
$objCountry = Country::Load($country);
} else {
$objCountry = Country::LoadByCode($country);
}
if ($objCountry instanceof Country === false) {
Yii::log(sprintf('Shipping Country: %s is not a valid country', $this->shippingCountry), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
$this->addError($attribute, Yii::t('yii', '{attribute} is invalid.', array('{attribute}' => $this->getAttributeLabel('shippingCountry'))));
} else {
if ($this->{$attribute} == '') {
$this->addError($attribute, Yii::t('yii', '{attribute} cannot be blank.', array('{attribute}' => $this->getAttributeLabel($attribute))));
} elseif (is_null($objCountry->zip_validate_preg) === false && _xls_validate_zip($this->{$attribute}, $objCountry->zip_validate_preg) === false) {
$this->addError($attribute, Yii::t('yii', '{attribute} format is incorrect for this country.', array('{attribute}' => $this->getAttributeLabel($attribute))));
}
}
}