本文整理汇总了PHP中city::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP city::getByName方法的具体用法?PHP city::getByName怎么用?PHP city::getByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类city
的用法示例。
在下文中一共展示了city::getByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseAddress
/**
* Пытаемся разобрать адресс, если не получиться то вернем то что передали
* Например: 127287, Россия, г. Москва, ул. 2-я Хуторская д 38А стр.9
*/
function parseAddress($address)
{
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
$index = null;
$country_name = null;
$country_id = null;
$city_id = null;
$city_name = null;
$parts = explode(',', $address);
if ($parts) {
$countryObject = new country();
$cityObject = new city();
$parts = array_map('trim', $parts);
//Индекс
$country_pos = 0;
if (intval($parts[0]) > 0) {
$index = intval($parts[0]);
$country_pos = 1;
}
//Страна
$city_pos = $country_pos;
$_country_name = ucfirst($parts[$country_pos]);
if ($country_id = $countryObject->getCountryId($_country_name)) {
$country_name = $_country_name;
$city_pos++;
}
//Город
$street_pos = $city_pos;
$_city_name = ucfirst(trim(str_replace('г.', '', $parts[$city_pos])));
if ($city_data = $cityObject->getByName($_city_name)) {
$city_id = $city_data['id'];
$city_name = $_city_name;
$street_pos++;
//Если нет страны то пробуем ее определить из города
$country_id = !$country_id ? $city_data['country_id'] : $country_id;
}
//Неудалось разобрать адресс
if (!$street_pos) {
return false;
}
$parts = array_slice($parts, $street_pos);
$address = implode(', ', $parts);
return array('index' => $index, 'country' => $country_name, 'country_id' => $country_id, 'city' => $city_name, 'city_id' => $city_id, 'address' => $address);
}
return false;
}
示例2: addArchiveToLetters
/**
* Создать письма в разделе /siteadmin/letters/ для БС архива
*
* @param type $ids
* @param CFile $cfile
*/
public function addArchiveToLetters($ids, CFile $cfile)
{
require_once ABS_PATH . '/classes/reserves/ReservesTServiceOrderModel.php';
require_once ABS_PATH . '/classes/letters.php';
//require_once(ABS_PATH . '/classes/country.php');
require_once ABS_PATH . '/classes/city.php';
$users_reqv = ReservesTServiceOrderModel::model()->getReservesBankReqvByIds($ids);
if (!$users_reqv) {
return false;
}
$letters = new letters();
$letter_ids_exist = $this->getLetterIds($ids);
$letter_ids_new = array();
//$countryObject = new country();
$cityObject = new city();
foreach ($users_reqv as $user_reqv) {
$uid = $user_reqv['uid'];
$src_id = $user_reqv['src_id'];
$address = $user_reqv['address'];
$country_id = null;
$city_id = null;
if ($res = parseAddress($address)) {
$address = $res['address'];
$country_id = $res['country_id'];
$city_id = $res['city_id'];
}
if (!$city_id) {
$city_name = trim(str_replace('г.', '', $user_reqv['city']));
$city_data = $cityObject->getByName($city_name);
if ($city_data) {
$country_id = $city_data['country_id'];
$city_id = $city_data['id'];
}
}
if (!$city_id) {
$city_id = $user_reqv['city_id'];
}
if (!$country_id) {
$country_id = $user_reqv['country_id'];
}
$name = htmlspecialchars_decode($user_reqv['name'], ENT_QUOTES);
$letter_company_id = $letters->findCompanyId(array('fio' => $user_reqv['fio'], 'name' => $name, 'address' => $address, 'index' => $user_reqv['index']));
if (!$letter_company_id) {
$letter_company_id = $letters->addCompany(array('frm_company_name' => $name, 'country_columns' => array($country_id, $city_id), 'frm_company_index' => $user_reqv['index'], 'frm_company_address' => $address, 'frm_company_fio' => $user_reqv['fio'], 'frm_company_type' => sbr_meta::$types_short[$user_reqv['type']]));
}
$frm = array('letters_doc_frm_title' => sprintf(ReservesTServiceOrderModel::NUM_FORMAT, $user_reqv['src_id']), 'letters_doc_frm_user_1_db_id' => 4, 'letters_doc_frm_user_2_db_id' => $letter_company_id, 'letters_doc_frm_delivery_db_id' => 1, 'letters_doc_frm_user2_status_data' => 11, 'letters_doc_frm_user_1_section' => true, 'letters_doc_frm_user_2_section' => true, 'letters_doc_frm_group' => sprintf(self::LETTER_GROUP_TXT, $cfile->getOriginalName()), 'letters_doc_frm_comment' => sprintf(self::LETTER_COMMENT, $cfile->getUrl()));
if (isset($letter_ids_exist[$src_id])) {
$letters->updateDocument($letter_ids_exist[$src_id], $frm);
} else {
$letter_ids_new[] = array('letter_id' => $letters->addDocument($frm), 'order_id' => $src_id);
}
}
if (!empty($letter_ids_new)) {
$this->addLetterIds($letter_ids_new);
}
return true;
}