本文整理汇总了PHP中Country::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::model方法的具体用法?PHP Country::model怎么用?PHP Country::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$country = Country::model()->findAll(['order' => 'country_order']);
$region = Regions::model()->findAllByAttributes(['id_country' => $this->model['countries']]);
$city = City::model()->findAllByAttributes(['id_region' => $this->model['region']]);
$this->render('main', ['model' => $this->model, 'title' => $this->title, 'prefix_name' => $this->prefixName, 'country' => $country, 'region' => $region, 'city' => $city]);
}
示例2: getAdminForm
public function getAdminForm()
{
if (empty($this->origincountry)) {
$this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
}
return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'mode' => array('type' => 'dropdownlist', 'items' => array('UPS' => 'Domestic US UPS Mode', 'IUPS' => 'IUPS International UPS Mode')), 'username' => array('type' => 'text', 'maxlength' => 64), 'password' => array('type' => 'text', 'maxlength' => 64), 'accesskey' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => ups::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'package' => array('type' => 'dropdownlist', 'items' => ups::$package_types), 'ratecode' => array('type' => 'dropdownlist', 'items' => ups::$rate_types), 'customerclassification' => array('type' => 'dropdownlist', 'items' => array('04' => 'Retail', '03' => 'Occasional', '01' => 'Wholesale')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
}
示例3: beforeSave
/**
*
*/
public function beforeSave()
{
if ($this->getIsNewRecord()) {
// Assign the user_id 1 if is a guest
///TODO:add userid. Issue, cant make use of user component while other request is open(subject/fetch) $this->user_id=(Yii::app()->user->getId()) ? Yii::app()->user->getId() : 1;
$this->user_id = 0;
//$this->time = SiteLibrary::utc_time();
$this->user_ip = $_SERVER['REMOTE_ADDR'];
$country_id = 1;
$country_code = 'WW';
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
Yii::import('ext.EGeoIP');
$geoIp = new EGeoIP();
$geoIp->locate($_SERVER['REMOTE_ADDR']);
//http://www.iso.org/iso/english_country_names_and_code_elements
$country = Country::model()->find('code=:code', array(':code' => $geoIp->countryCode));
if ($country) {
$country_id = $country->id;
$country_code = $country->code;
}
}
$this->country_id = $country_id;
$this->time = SiteLibrary::utc_time();
$this->user_id = Yii::app()->user->id;
}
return true;
}
示例4: actionAdd
public function actionAdd()
{
global $arr_response;
$model = new Subject();
$model->scenario = 'add';
$_REQUEST['content_type_id'] = ContentType::model()->find('name=:name', array(':name' => $_REQUEST['content_type']))->id;
$_REQUEST['country_id'] = Country::model()->find('code=:code', array(':code' => $_REQUEST['country_code']))->id;
$_REQUEST['priority_id'] = Priority::model()->find('name=:name', array(':name' => $_REQUEST['priority']))->id;
if ($_REQUEST['time']) {
if (date("l", $_REQUEST['time'])) {
//if its a valid timestamp
$_REQUEST['user_position_ymd'] = date("Y", $_REQUEST['time']) . "/" . date("m", $_REQUEST['time']) . "/" . date("d", $_REQUEST['time']);
$_REQUEST['user_position_hour'] = date("H", $_REQUEST['time']);
$_REQUEST['user_position_minute'] = date("i", $_REQUEST['time']);
}
} else {
$_REQUEST['user_position_anydatetime'] = 1;
}
$model->attributes = $_REQUEST;
//NOTICE that we are creating a new record, so model its not loaded, ($model->content_type its juest the received $_REQUEST parameter)
//print_r($model);
//$model->content_type_id = $content_type->id;
if ($model->save()) {
$arr_response['response_message'] = Yii::t('subject', 'Subject successfully saved.');
} else {
$arr_response['response_code'] = 409;
$arr_response['response_message'] = Yii::t('subject', 'Subject could not be saved.');
$arr_response['response_details'] = $model->getErrors();
}
}
示例5: getAdminForm
public function getAdminForm()
{
if (empty($this->origincountry)) {
$this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
}
return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'accnumber' => array('type' => 'text', 'maxlength' => 64), 'meternumber' => array('type' => 'text', 'maxlength' => 64), 'securitycode' => array('type' => 'text', 'maxlength' => 64), 'authkey' => array('type' => 'text', 'maxlength' => 64), 'originadde' => array('type' => 'text', 'maxlength' => 64), 'origincity' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => fedex::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'packaging' => array('type' => 'dropdownlist', 'items' => array('YOUR_PACKAGING' => 'Your packaging', 'FEDEX_BOX' => 'FedEx Box', 'FEDEX_PAK' => 'FedEx Pak', 'FEDEX_TUBE' => 'FedEx Tube')), 'ratetype' => array('type' => 'dropdownlist', 'items' => array('RATED_LIST' => 'List Rates', 'RATED_ACCOUNT' => 'Negotiated rates')), 'customs' => array('type' => 'dropdownlist', 'items' => array('CLEARANCEFEE' => 'FedEx Handles Customs Clearance', 'NOCHARGE' => 'My store handles Customs Clearance')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
}
示例6: actionUpdate
public function actionUpdate($id)
{
$model = new SettingsForm();
if (isset($_POST['SettingsForm'])) {
$model->attributes = $_POST['SettingsForm'];
if ($model->validate() && $model->save()) {
$this->redirect(array('index'));
}
} else {
$model->loadDataFromStore($id);
}
$directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
$themes = array();
foreach ($directories as $directory) {
$themes[] = basename($directory);
}
$layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
$countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
$zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
$languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
$currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
$yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
$lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
$weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
$taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
$customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
$informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
// TODO: localisation
$orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
// TODO: localisation
$returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
$mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
$this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
}
示例7: DropDown
public static function DropDown()
{
$res = array();
foreach (Country::model()->findAll("visible = :visible", array(":visible" => 1)) as $record) {
$res[$record->idCountry] = $record->CountryName;
}
return $res;
}
示例8: mapCountry
private function mapCountry(\Address $address)
{
$country = null;
if ($code = $this->getAssignedProperty('Country')) {
if (!($country = \Country::model()->findByAttributes(array('code' => $code)))) {
$this->addWarning('Unrecognised country code ' . $code);
}
}
$address->country_id = $country ? $country->id : null;
}
示例9: actionDelete
public function actionDelete($ids)
{
$ids = explode(',', $ids);
if (count($ids) > 0) {
foreach ($ids as $id) {
$country = Country::model()->findByPk($id);
$country->delete();
}
}
$this->redirect(array('index'));
}
示例10: actionGetcountries
/**
* Get the list of countries
*/
public function actionGetcountries()
{
global $arr_response;
$countries = Country::model()->findAll();
foreach ($countries as $country) {
$i++;
$arr_countries[$i]['code'] = $country['code'];
$arr_countries[$i]['name'] = $country['name'];
}
$arr_response['countries'] = $arr_countries;
}
示例11: getNameById
public static function getNameById($id)
{
if (!$id) {
return '';
}
if (empty(self::$nameById[$id])) {
$c = Country::model()->findByPk($id);
if ($c) {
self::$nameById[$id] = $c->name;
}
}
return self::$nameById[$id];
}
示例12: check
public static function check($_cpt, $_shrt)
{
$country = Country::model()->find('short=:shrt', array(':shrt' => $_shrt));
if ($country !== null) {
return $country->getPrimaryKey();
}
$country = new Country();
$country->attributes = array('caption' => $_cpt, 'short' => $_shrt);
if ($country->save()) {
return $country->getPrimaryKey();
}
return 1;
//false;
}
示例13: actionGetCityInfoByZip
/**
* Get city info by zip
*
*/
public function actionGetCityInfoByZip($zipCode)
{
$city = USCity::model()->find('city_zip=:zipcode', array(':zipcode' => $zipCode));
if (!$city) {
echoJson(array('error' => at('Sorry, That zip code does not exists.')));
}
// Get state id
$state = USState::model()->find('short=LOWER(:short)', array(':short' => strtolower($city->city_state)));
// Get us country
$country = Country::model()->find('short=LOWER(:short)', array(':short' => 'us'));
$info = array('city_name' => $city->city_name, 'city_zip' => $city->city_zip, 'city_state' => $state ? $state->id : 0, 'country' => $country ? $country->id : 0);
$text = at("Zip Code Exists.\nCity Name: {cityname}, State: {state}", array('{cityname}' => $city->city_name, '{state}' => $city->city_state));
echoJson(array('info' => $info, 'text' => $text));
}
示例14: toModel
public function toModel(\Address $address)
{
$address->address1 = $this->line1;
$address->address2 = $this->line2;
$address->city = $this->city;
$address->county = $this->state;
$address->postcode = $this->zip;
$crit = new \CDbCriteria();
$crit->addColumnCondition(array('code' => $this->country, 'name' => $this->country), 'OR');
$country = \Country::model()->find($crit);
if (!$country) {
$country = \Country::model()->findByAttributes(array('code' => 'GB'));
}
$address->country_id = $country->id;
}
示例15: toModel
public function toModel(\Address $address)
{
$address->address1 = $this->line1;
$address->address2 = $this->line2;
$address->city = $this->city;
$address->county = $this->state;
$address->postcode = $this->zip;
$crit = new \CDbCriteria();
$crit->addColumnCondition(array('code' => $this->country, 'name' => $this->country), 'OR');
$country = \Country::model()->find($crit);
if (!$country) {
throw new InvalidValue("Unrecognised country: '{$this->country}'");
}
$address->country_id = $country->id;
}