本文整理汇总了PHP中Model_Category::rename_icon方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Category::rename_icon方法的具体用法?PHP Model_Category::rename_icon怎么用?PHP Model_Category::rename_icon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Category
的用法示例。
在下文中一共展示了Model_Category::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->styles = array('css/sortable.css' => 'screen');
$this->template->scripts['footer'][] = 'js/oc-panel/category_edit.js';
$form = new FormOrm($this->_orm_model, $this->request->param('id'));
$category = new Model_Category($this->request->param('id'));
$fields = Model_Field::get_all();
$category_fields = array();
$selectable_fields = array();
// get selectable fields
foreach ($fields as $field => $values) {
if (!(is_array($values['categories']) and in_array($category->id_category, $values['categories']))) {
$selectable_fields[$field] = $values;
} else {
$category_fields[$field] = $values;
}
}
if ($this->request->post()) {
if ($success = $form->submit()) {
//category is different than himself, cant be his own father!!!
if ($form->object->id_category == $form->object->id_category_parent) {
Alert::set(Alert::INFO, __('You can not set as parent the same category'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_category)));
}
//check if the parent is loaded/exists avoiding errors
$parent_cat = new Model_Category($form->object->id_category_parent);
if (!$parent_cat->loaded()) {
Alert::set(Alert::INFO, __('You are assigning a parent category that does not exist'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_category)));
}
$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 ($category->has_image and $category->seoname != $form->object->seoname) {
$category->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/categories/update', compact('form', 'category', 'category_fields', 'selectable_fields'));
}