当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Category::rename_icon方法代码示例

本文整理汇总了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'));
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:60,代码来源:category.php


注:本文中的Model_Category::rename_icon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。