本文整理汇总了PHP中Model_Location::gen_seoname方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Location::gen_seoname方法的具体用法?PHP Model_Location::gen_seoname怎么用?PHP Model_Location::gen_seoname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Location
的用法示例。
在下文中一共展示了Model_Location::gen_seoname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_geonames
/**
* Import multiple locations from geonames
* @return void
*/
public function action_geonames()
{
$this->template->title = __('Geonames');
$this->template->scripts['footer'][] = URL::base('http') . 'themes/default/js/oc-panel/locations-geonames.js';
$location = NULL;
if (intval(Core::get('id_location')) > 0) {
$location = new Model_Location(Core::get('id_location'));
if ($location->loaded()) {
Breadcrumbs::add(Breadcrumb::factory()->set_title($location->name)->set_url(Route::url('oc-panel', array('controller' => 'location', 'action' => 'geonames')) . '?id_location=' . $location->id_location));
} else {
Alert::set(Alert::ERROR, __('You are selecting a location that does not exist'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())));
}
}
//update the elements related to that ad
if (core::post('geonames_locations') !== "") {
$geonames_locations = json_decode(core::post('geonames_locations'));
if (count($geonames_locations) > 0) {
$obj_location = new Model_Location();
$locations_array = array();
$insert = DB::insert('locations', array('name', 'seoname', 'id_location_parent', 'latitude', 'longitude', 'id_geoname', 'fcodename_geoname', 'order'));
$i = 1;
$execute = FALSE;
foreach ($geonames_locations as $location) {
if (!empty($location->name) and !in_array($location->seoname = $obj_location->gen_seoname($location->name), $locations_array)) {
$execute = TRUE;
$insert = $insert->values(array($location->name, $location->seoname, Core::get('id_location', 1), isset($location->lat) ? $location->lat : NULL, isset($location->long) ? $location->long : NULL, isset($location->id_geoname) ? $location->id_geoname : NULL, isset($location->fcodename_geoname) ? $location->fcodename_geoname : NULL, $i));
$locations_array[] = $location->seoname;
$i++;
}
}
// Insert everything with one query.
if ($execute == TRUE) {
$insert->execute();
Core::delete_cache();
}
HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')) . '?id_location=' . Core::get('id_location', 1));
}
} else {
Alert::set(Alert::INFO, __('Select some locations first.'));
}
$this->template->content = View::factory('oc-panel/pages/locations/geonames', array('location' => $location));
}
示例2: action_geonames_locations
/**
* Import multiple locations from geonames
* @return void
*/
public function action_geonames_locations()
{
$this->auto_render = FALSE;
//update the elements related to that ad
if (core::post('geonames_locations') !== "") {
$geonames_locations = json_decode(core::post('geonames_locations'));
if (count($geonames_locations) > 0) {
$obj_location = new Model_Location();
$locations_array = array();
$insert = DB::insert('locations', array('name', 'seoname', 'id_location_parent', 'latitude', 'longitude', 'order'));
$i = 1;
foreach ($geonames_locations as $location) {
if (!in_array($location->seoname = $obj_location->gen_seoname($location->name), $locations_array)) {
$insert = $insert->values(array($location->name, $location->seoname, Core::get('id_location', 1), isset($location->lat) ? $location->lat : NULL, isset($location->long) ? $location->long : NULL, $i));
$locations_array[] = $location->seoname;
$i++;
}
}
// Insert everything with one query.
$insert->execute();
Core::delete_cache();
}
} else {
Alert::set(Alert::INFO, __('Select some locations first.'));
}
HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')) . '?id_location=' . Core::get('id_location', 1));
}