本文整理汇总了PHP中Model_Location::rename_icon方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Location::rename_icon方法的具体用法?PHP Model_Location::rename_icon怎么用?PHP Model_Location::rename_icon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Location
的用法示例。
在下文中一共展示了Model_Location::rename_icon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_update
/**
* CRUD controller: UPDATE
*/
public function action_update()
{
$this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id');
$this->template->scripts['footer'][] = 'js/gmaps.min.js';
$this->template->scripts['footer'][] = 'js/oc-panel/locations-gmap.js';
$this->template->scripts['async_defer'][] = '//maps.google.com/maps/api/js?libraries=geometry&v=3&key=' . core::config("advertisement.gm_api_key") . '&callback=initLocationsGMap';
$form = new FormOrm($this->_orm_model, $this->request->param('id'));
$location = new Model_Location($this->request->param('id'));
if ($this->request->post()) {
if ($success = $form->submit()) {
if ($form->object->id_location == $form->object->id_location_parent) {
Alert::set(Alert::INFO, __('You can not set as parent the same location'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_location)));
}
//check if the parent is loaded/exists avoiding errors
$parent_loc = new Model_Location($form->object->id_location_parent);
if (!$parent_loc->loaded()) {
Alert::set(Alert::INFO, __('You are assigning a parent location that does not exist'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'create')));
}
$form->object->description = Kohana::$_POST_ORIG['formorm']['description'];
try {
$form->object->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
$form->object->parent_deep = $form->object->get_deep();
try {
$form->object->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
$this->action_deep();
//rename icon name
if ($location->has_image and $location->seoname != $form->object->seoname) {
$location->rename_icon($form->object->seoname);
}
Core::delete_cache();
Alert::set(Alert::SUCCESS, __('Item updated'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())));
} else {
Alert::set(Alert::ERROR, __('Check form for errors'));
}
}
return $this->render('oc-panel/pages/locations/update', array('form' => $form, 'location' => $location));
}