本文整理汇总了PHP中Region::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::update方法的具体用法?PHP Region::update怎么用?PHP Region::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region::update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
function doModel()
{
switch ($this->action) {
case 'comments':
//calling the comments settings view
$this->doView('settings/comments.php');
break;
case 'comments_post':
// updating comment
$iUpdated = 0;
$enabledComments = Params::getParam('enabled_comments');
$enabledComments = $enabledComments != '' ? true : false;
$moderateComments = Params::getParam('moderate_comments');
$moderateComments = $moderateComments != '' ? true : false;
$numModerateComments = Params::getParam('num_moderate_comments');
$commentsPerPage = Params::getParam('comments_per_page');
$notifyNewComment = Params::getParam('notify_new_comment');
$notifyNewComment = $notifyNewComment != '' ? true : false;
$notifyNewCommentUser = Params::getParam('notify_new_comment_user');
$notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
$regUserPostComments = Params::getParam('reg_user_post_comments');
$regUserPostComments = $regUserPostComments != '' ? true : false;
$msg = '';
if (!osc_validate_int(Params::getParam("num_moderate_comments"))) {
$msg .= _m("Number of moderate comments must only contain numeric characters") . "<br/>";
}
if (!osc_validate_int(Params::getParam("comments_per_page"))) {
$msg .= _m("Comments per page must only contain numeric characters") . "<br/>";
}
if ($msg != '') {
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
}
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
if ($moderateComments) {
$iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
} else {
$iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
}
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewCommentUser), array('s_name' => 'notify_new_comment_user'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
if ($iUpdated > 0) {
osc_add_flash_ok_message(_m("Comment settings have been updated"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
break;
case 'locations':
// calling the locations settings view
$location_action = Params::getParam('type');
$mCountries = new Country();
switch ($location_action) {
case 'add_country':
// add country
$countryCode = strtoupper(Params::getParam('c_country'));
$countryName = Params::getParam('country');
$exists = $mCountries->findByCode($countryCode);
if (isset($exists['s_name'])) {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
} else {
$countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
$countries = json_decode($countries_json);
$mCountries->insert(array('pk_c_code' => $countryCode, 's_name' => $countryName));
CountryStats::newInstance()->setNumItems($countryCode, 0);
if (isset($countries->error)) {
// Country is not in our GEO database
// We have no region for user-typed countries
} else {
// Country is in our GEO database, add regions and cities
$manager_region = new Region();
$regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
$regions = json_decode($regions_json);
if (!isset($regions->error)) {
if (count($regions) > 0) {
foreach ($regions as $r) {
$manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
$id = $manager_region->dao->insertedId();
RegionStats::newInstance()->setNumItems($id, 0);
}
}
unset($regions);
unset($regions_json);
$manager_city = new City();
if (count($countries) > 0) {
foreach ($countries as $c) {
$regions = $manager_region->findByCountry($c->id);
if (!isset($regions->error)) {
if (count($regions) > 0) {
foreach ($regions as $region) {
$cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '®ion=' . urlencode($region['s_name']) . '&term=all');
$cities = json_decode($cities_json);
if (!isset($cities->error)) {
if (count($cities) > 0) {
foreach ($cities as $ci) {
$manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
$id = $manager_city->dao->insertedId();
CityStats::newInstance()->setNumItems($id, 0);
}
}
//.........这里部分代码省略.........
示例2: array_push
array_push($errors, "The name field is required !");
}
if ($p_slug != '' && !preg_match('/^[a-zA-Z0-9_-]*$/', $p_slug)) {
$success = false;
array_push($errors, "Invalid slug!");
}
if ($p_slug == '') {
$success = false;
array_push($errors, "The slug field is required !");
}
if ($success) {
$update = array('name' => $p_name, 'slug' => $p_slug);
if ($region['parent'] > 0 && $p_parent > 0) {
$update['parent'] = $p_parent;
}
Region::update($g_id, $update);
$region = Region::get_one($g_id);
}
}
$regions = Region::get_all(array('parent' => 0));
include "page-header.php";
?>
<div id="wrapper">
<?php
include "page-left.php";
?>
<div id="content">
示例3: doModel
function doModel()
{
switch ($this->action) {
case 'comments':
//calling the comments settings view
$this->doView('settings/comments.php');
break;
case 'comments_post':
// updating comment
$iUpdated = 0;
$enabledComments = Params::getParam('enabled_comments');
$enabledComments = $enabledComments != '' ? true : false;
$moderateComments = Params::getParam('moderate_comments');
$moderateComments = $moderateComments != '' ? true : false;
$numModerateComments = Params::getParam('num_moderate_comments');
$commentsPerPage = Params::getParam('comments_per_page');
$notifyNewComment = Params::getParam('notify_new_comment');
$notifyNewComment = $notifyNewComment != '' ? true : false;
$regUserPostComments = Params::getParam('reg_user_post_comments');
$regUserPostComments = $regUserPostComments != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
if ($moderateComments) {
$iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
} else {
$iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
}
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
if ($iUpdated > 0) {
osc_add_flash_ok_message(_m('Comments\' settings have been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
break;
case 'locations':
// calling the locations settings view
$location_action = Params::getParam('type');
$mCountries = new Country();
switch ($location_action) {
case 'add_country':
// add country
$countryCode = strtoupper(Params::getParam('c_country'));
$request = Params::getParam('country');
foreach ($request as $k => $v) {
$countryName = $v;
break;
}
$exists = $mCountries->findByCode($countryCode);
if (isset($exists['s_name'])) {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
} else {
$countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
$countries = json_decode($countries_json);
foreach ($request as $k => $v) {
$data = array('pk_c_code' => $countryCode, 'fk_c_locale_code' => $k, 's_name' => $v);
$mCountries->insert($data);
}
if (isset($countries->error)) {
// Country is not in our GEO database
// We have no region for user-typed countries
} else {
// Country is in our GEO database, add regions and cities
$manager_region = new Region();
$regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
$regions = json_decode($regions_json);
if (!isset($regions->error)) {
if (count($regions) > 0) {
foreach ($regions as $r) {
$manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
}
}
unset($regions);
unset($regions_json);
$manager_city = new City();
if (count($countries) > 0) {
foreach ($countries as $c) {
$regions = $manager_region->listWhere('fk_c_country_code = \'' . $c->id . '\'');
if (!isset($regions->error)) {
if (count($regions) > 0) {
foreach ($regions as $region) {
$cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '®ion=' . urlencode($region['s_name']) . '&term=all');
$cities = json_decode($cities_json);
if (!isset($cities->error)) {
if (count($cities) > 0) {
foreach ($cities as $ci) {
$manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
}
}
}
unset($cities);
unset($cities_json);
}
}
}
}
}
}
}
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
}
//.........这里部分代码省略.........
示例4: doModel
function doModel()
{
// calling the locations settings view
$location_action = Params::getParam('type');
$mCountries = new Country();
switch ($location_action) {
case('add_country'): // add country
if( defined('DEMO') ) {
osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
}
osc_csrf_check();
$countryCode = strtoupper(Params::getParam('c_country'));
$countryName = Params::getParam('country');
$exists = $mCountries->findByCode($countryCode);
if(isset($exists['s_name'])) {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
} else {
if(Params::getParam('c_manual')==1) {
$mCountries->insert(array('pk_c_code' => $countryCode,
's_name' => $countryName));
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
} else {
if(!osc_validate_min($countryCode, 1) || !osc_validate_min($countryName, 1)) {
osc_add_flash_error_message(_m('Country code and name should have at least two characters'), 'admin');
} else {
$data_sql = osc_file_get_contents('http://geo.osclass.org/newgeo.download.php?action=country&term=' . urlencode($countryCode) );
if($data_sql!='') {
$conn = DBConnectionClass::newInstance();
$c_db = $conn->getOsclassDb();
$comm = new DBCommandClass($c_db);
$comm->query("SET FOREIGN_KEY_CHECKS = 0");
$comm->importSQL($data_sql);
$comm->query("SET FOREIGN_KEY_CHECKS = 1");
} else {
$mCountries->insert(array('pk_c_code' => $countryCode,
's_name' => $countryName));
}
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
}
}
}
osc_calculate_location_slug(osc_subdomain_type());
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case('edit_country'): // edit country
if( defined('DEMO') ) {
osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
}
osc_csrf_check();
if(!osc_validate_min(Params::getParam('e_country'), 1)) {
osc_add_flash_error_message(_m('Country name cannot be blank'), 'admin');
} else {
$name = Params::getParam('e_country');
$slug = Params::getParam('e_country_slug');
if($slug=='') {
$slug_tmp = $slug = osc_sanitizeString($name);
} else {
$exists = $mCountries->findBySlug($slug);
if(isset($exists['s_slug']) && $exists['pk_c_code']!=Params::getParam('country_code')) {
$slug_tmp = $slug = osc_sanitizeString($name);
} else {
$slug_tmp = $slug = osc_sanitizeString($slug);
}
}
$slug_unique = 1;
while(true) {
$location_slug = $mCountries->findBySlug($slug);
if(isset($location_slug['s_slug']) && $location_slug['pk_c_code']!=Params::getParam('country_code')) {
$slug = $slug_tmp . '-' . $slug_unique;
$slug_unique++;
} else {
break;
}
}
$ok = $mCountries->update(array('s_name'=> $name, 's_slug' => $slug), array('pk_c_code' => Params::getParam('country_code')));
if( $ok ) {
osc_add_flash_ok_message(_m('Country has been edited'), 'admin');
} else {
osc_add_flash_error_message(_m('There were some problems editing the country'), 'admin');
}
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case('delete_country'): // delete country
if( defined('DEMO') ) {
osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
}
osc_csrf_check();
$countryIds = Params::getParam('id');
if(is_array($countryIds)) {
$locations = 0;
$del_locations = 0;
//.........这里部分代码省略.........
示例5: doModel
function doModel()
{
switch ($this->action) {
case 'items':
// calling the items settings view
$this->doView('settings/items.php');
break;
case 'items_post':
// update item settings
$iUpdated = 0;
$enabledRecaptchaItems = Params::getParam('enabled_recaptcha_items');
$enabledRecaptchaItems = $enabledRecaptchaItems != '' ? true : false;
$enabledItemValidation = Params::getParam('enabled_item_validation');
$enabledItemValidation = $enabledItemValidation != '' ? true : false;
$loggedUserItemValidation = Params::getParam('logged_user_item_validation');
$loggedUserItemValidation = $loggedUserItemValidation != '' ? true : false;
$regUserPost = Params::getParam('reg_user_post');
$regUserPost = $regUserPost != '' ? true : false;
$notifyNewItem = Params::getParam('notify_new_item');
$notifyNewItem = $notifyNewItem != '' ? true : false;
$notifyContactItem = Params::getParam('notify_contact_item');
$notifyContactItem = $notifyContactItem != '' ? true : false;
$notifyContactFriends = Params::getParam('notify_contact_friends');
$notifyContactFriends = $notifyContactFriends != '' ? true : false;
$enabledFieldPriceItems = Params::getParam('enableField#f_price@items');
$enabledFieldPriceItems = $enabledFieldPriceItems != '' ? true : false;
$enabledFieldImagesItems = Params::getParam('enableField#images@items');
$enabledFieldImagesItems = $enabledFieldImagesItems != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledRecaptchaItems), array('s_name' => 'enabled_recaptcha_items'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledItemValidation), array('s_name' => 'enabled_item_validation'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $loggedUserItemValidation), array('s_name' => 'logged_user_item_validation'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPost), array('s_name' => 'reg_user_post'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewItem), array('s_name' => 'notify_new_item'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyContactItem), array('s_name' => 'notify_contact_item'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyContactFriends), array('s_name' => 'notify_contact_friends'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledFieldPriceItems), array('s_name' => 'enableField#f_price@items'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledFieldImagesItems), array('s_name' => 'enableField#images@items'));
if ($iUpdated > 0) {
osc_add_flash_message(_m('Items\' settings have been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=items');
break;
case 'comments':
//calling the comments settings view
$this->doView('settings/comments.php');
break;
case 'comments_post':
// updating comment
$iUpdated = 0;
$enabledComments = Params::getParam('enabled_comments');
$enabledComments = $enabledComments != '' ? true : false;
$moderateComments = Params::getParam('moderate_comments');
$moderateComments = $moderateComments != '' ? true : false;
$numModerateComments = Params::getParam('num_moderate_comments');
$notifyNewComment = Params::getParam('notify_new_comment');
$notifyNewComment = $notifyNewComment != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
if ($moderateComments) {
$iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
} else {
$iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
}
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
if ($iUpdated > 0) {
osc_add_flash_message(_m('Comments\' settings have been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
break;
case 'users':
// calling the users settings view
$this->doView('settings/users.php');
break;
case 'users_post':
// updating users
$iUpdated = 0;
$enabledUserValidation = Params::getParam('enabled_user_validation');
$enabledUserValidation = $enabledUserValidation != '' ? true : false;
$enabledUserRegistration = Params::getParam('enabled_user_registration');
$enabledUserRegistration = $enabledUserRegistration != '' ? true : false;
$enabledUsers = Params::getParam('enabled_users');
$enabledUsers = $enabledUsers != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserValidation), array('s_name' => 'enabled_user_validation'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserRegistration), array('s_name' => 'enabled_user_registration'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUsers), array('s_name' => 'enabled_users'));
if ($iUpdated > 0) {
osc_add_flash_message(_m('Users\' settings have been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=users');
break;
case 'locations':
// calling the locations settings view
$location_action = Params::getParam('type');
$mCountries = new Country();
switch ($location_action) {
case 'add_country':
// add country
if (!Params::getParam('c_manual')) {
$this->install_location_by_country();
} else {
$countryCode = Params::getParam('c_country');
//.........这里部分代码省略.........