예제 #1
0
파일: api.php 프로젝트: uzura8/flockbird
 /**
  * Get image list
  * 
  * @access  public
  * @return  Response (html)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 public function get_list()
 {
     $this->api_accept_formats = array('html', 'json');
     $this->controller_common_api(function () {
         list($limit, $page) = $this->common_get_pager_list_params(\Config::get('admin.articles.images.limit'), \Config::get('admin.articles.images.limit_max'));
         $params = array('order_by' => array('id' => 'desc'));
         if ($limit) {
             $params['limit'] = $limit;
         }
         $data = \Model_SiteImage::get_pager_list($params, $page, $this->format == 'json');
         $this->set_response_body_api($data, $this->format == 'html' ? 'content/image/_parts/list' : null);
     });
 }
예제 #2
0
파일: image.php 프로젝트: uzura8/flockbird
 /**
  * Action image delete
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_delete($id = null)
 {
     \Util_security::check_csrf();
     $site_image = \Model_SiteImage::check_authority($id);
     try {
         \DB::start_transaction();
         $site_image->delete();
         \DB::commit_transaction();
         \Session::set_flash('message', term('site.image') . 'を削除しました。');
         \Response::redirect('admin/content/image');
     } catch (\Database_Exception $e) {
         $error_message = \Site_Controller::get_error_message($e, true);
     } catch (Exception $e) {
         $error_message = $e->getMessage();
     }
     if (\DB::in_transaction()) {
         \DB::rollback_transaction();
     }
     \Session::set_flash('error', $error_message);
     \Response::redirect('admin/content/image/' . $id);
 }