예제 #1
0
파일: admin.php 프로젝트: katsuwo/bbs
 public function action_imagelist()
 {
     $query = Model_Board::query()->select("id");
     $bbsCount = $query->count();
     //ページネーション
     $pConfig = array('pagination_url' => 'admin/imagelist/', 'uri_segment' => 3, 'num_links' => 2, 'per_page' => 3, 'total_items' => $bbsCount, 'show_first' => true, 'show_last' => true, 'name' => 'bootstrap3');
     $pagiNation = Pagination::forge('adminPagination', $pConfig);
     $query2 = Model_Board::query();
     $query2->rows_offset($pagiNation->offset);
     $query2->rows_limit($pagiNation->per_page);
     $query2->order_by('id', 'desc');
     $data['bbss'] = $query2->get();
     $query3 = Model_Attach::query();
     $query3->select('id', 'bbsId', 'mime');
     foreach ($data['bbss'] as $bbs) {
         $query3->or_where_open();
         $query3->where('bbsId', '=', $bbs->id);
         $query3->or_where_close();
     }
     $query3->order_by('id', 'desc');
     $data['attaches'] = $query3->get();
     $this->template->boardDescription = '画像一覧';
     $content = View::forge('admin/imglist', $data);
     $content->set_safe('pagination', $pagiNation);
     $this->template->content = $content;
 }
예제 #2
0
파일: index.php 프로젝트: katsuwo/bbs
 public function action_index($pr1 = null, $pr2 = null)
 {
     //パラメータが付いていた場合はリダイレクト
     if ($pr1 != null || $pr2 != null) {
         return Response::forge(Uri::base());
     }
     $msg = Session::get('errorMsg');
     Session::delete('errorMsg');
     /*		
     		//ログインフォーム作成
     		$loginFieldSet = Fieldset::forge('loginForm');
     		$loginFieldSet->add('username','',array('type'=>'text','size'=>20));
     		$loginFieldSet->add('password','',array('type'=>'password','size'=>20));
     		$loginFieldSet->repopulate();
     		//送信ボタン追加
     		$loginFieldSet->add('submit','',array('type'=>'submit','width'=>80,'value'=>' ログイン '));
     */
     $content = '';
     if (Agent::is_mobiledevice()) {
         $content = View::forge('index/index_mobile');
     } else {
         $content = View::forge('index/index_pc');
     }
     //掲示板全体の最新画像
     $query = Model_Attach::query();
     $query->select('id', 'bbsId');
     $query->limit(12);
     $query->order_by('created_at', 'desc');
     $images = $query->get();
     //最新の書き込み掲示板(10個)
     $query2 = Model_Board::query();
     $query2->select('id', 'shortName', 'title', 'updated_at');
     $query2->limit(10);
     $query2->order_by('updated_at', 'desc');
     $update = $query2->get();
     //投稿数順
     Model_Board::clear_cache();
     $query3 = Model_Board::query();
     $query3->select('id', 'shortName', 'title', 'postCount');
     $query3->limit(10);
     $query3->order_by('postCount', 'desc');
     $postCount = $query3->get();
     $this->setBoardTitle();
     //		$content->set('loginForm',$loginFieldSet->build('index/login'),false);
     $content->set('newestImages', $images);
     $content->set('updateBoards', $update);
     $content->set('postCount', $postCount);
     //エラーメッセージ設定
     if ($msg != null) {
         $content->set('msg', $msg, false);
     }
     $this->template->content = $content;
 }
예제 #3
0
파일: board.php 프로젝트: katsuwo/bbs
 public function deleteAttach()
 {
     $query = Model_Attach::query()->where('bbsId', $this->id);
     $ats = $query->get();
     foreach ($ats as $at) {
         $at->delete();
     }
 }
예제 #4
0
파일: bbs.php 프로젝트: katsuwo/bbs
 /**
  * スレッド元書き込み($threadId)とコメント(Model_Articleの配列)の添付ファイルを得る
  * (mimeとId,添付元IDのみを返す)
  * @param type $board Model_Board
  * @param type $threadId Model_Articleの配列のId(スレッド元)
  * @param type $comments Model_Articleの配列(コメント)
  * @return type Model_Attachの配列
  */
 public function getAttach($board = null, $threadId = null, $comments = null, $limit = null)
 {
     if ($board == null || $threadId == null) {
         return null;
     }
     $query = Model_Attach::query()->select('mime', 'id', 'attachOf')->where('bbsId', $board->id);
     $query->and_where_open();
     $query->where('attachOf', '=', $threadId);
     if ($comments != null) {
         foreach ($comments as $comment) {
             $query->or_where_open();
             $query->where('attachOf', '=', $comment->id);
             $query->or_where_close();
         }
     }
     $query->and_where_close();
     if ($limit != null) {
         $query->rows_limit($limit);
     }
     $query->order_by('id', 'desc');
     return $query->get();
 }