예제 #1
0
파일: api.php 프로젝트: uzura8/flockbird
 protected function update_sort_order()
 {
     if (!($ids = \Util_Array::cast_values(explode(',', \Input::post('ids')), 'int', true))) {
         throw new \HttpInvalidInputException('Invalid input data.');
     }
     return \Site_Model::update_sort_order($ids, \News\Model_NewsCategory::forge());
 }
예제 #2
0
 /**
  * The edit_all action.
  * 
  * @access  public
  * @return  void
  */
 public function action_edit_all()
 {
     $news_categories = \News\Model_NewsCategory::get_all();
     $posted_vals = array();
     if (\Input::method() == 'POST') {
         try {
             \Util_security::check_csrf();
             $posted_vals = \Input::post('labels');
             if (count($posted_vals) != count($news_categories)) {
                 throw new \httpinvalidinputexception();
             }
             \DB::start_transaction();
             foreach ($news_categories as $news_category) {
                 $value = $posted_vals[$news_category->id];
                 if (!strlen($value)) {
                     throw new \httpinvalidinputexception('未入力の項目があります。');
                 }
                 if ($value !== $news_category->label) {
                     $news_category->label = $value;
                     $news_category->save();
                 }
             }
             \DB::commit_transaction();
             \Session::set_flash('message', term('news.category.view') . 'を編集しました。');
             \Response::redirect('admin/news/category');
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $vals = array();
     foreach ($news_categories as $news_category) {
         $vals[$news_category->id] = isset($posted_vals[$news_category->id]) ? $posted_vals[$news_category->id] : $news_category->label;
     }
     $this->set_title_and_breadcrumbs(term('news.view', 'news.category.label', 'form.edit_all'), array('admin/news' => term('news.view', 'site.management'), 'admin/news/category' => term('news.category.view', 'site.management')));
     $this->template->content = \View::forge('news/category/edit_all', array('vals' => $vals, 'news_categories' => $news_categories));
 }