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; }
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; }
public function action_delete($shortName = null) { if ($shortName == null) { return Response::forge('パラメータ異常'); } $this->template->content = ''; //ユーザーIDを取得 $userId = Auth::get('id'); //掲示板取得 $query = Model_Board::query()->where('shortName', $shortName); $query->and_where_open(); $query->where('userId', '=', $userId); $query->and_where_close(); $board = $query->get_one(); if ($board == null) { return Response::forge('パラメータ異常'); } $out = '掲示板タイトル:' . $board->title . '<BR>掲示板ショートネーム:' . $board->shortName . '<BR>'; $out .= 'を削除しました。'; //削除実行 $board->deleteAllContents(); $board->delete(); Session::set('errorMsg', $out); Response::redirect('bbsadmin/index'); }
echo '<a href = \'/bbs/index/' . $bd->shortName . '\'>' . $bd->title . '</a><BR>'; } echo '</div>'; } } ?> <?php if (isset($newestImages)) { if ($newestImages != null) { echo '<div id =\'newestImages\'>'; echo '<h3 class=\'title1\'>掲示板全体の最新画像</h3><BR>'; foreach ($newestImages as $at) { $query = Model_Board::query(); $query->select('id', 'shortName', 'title'); $query->where('id', '=', $at->bbsId); $bd = $query->get_one(); // Fuel\Core\Debug::dump($bd); echo '<div id = \'imageBox\'>'; echo '<div id = \'imageLink\'>'; echo '<a href=\'bbs/index' . DS . $bd->shortName . '\'>' . $bd->title . '</a>'; echo '</div>'; echo '<div id = \'thumbImage\'>'; echo '<img src =\'/imgLoader/thumbnail/' . $at->id . '\' width=100> '; echo '</div>'; echo '</div>'; } echo '</div>'; }
/** * ShortNameから掲示板(Model_Boardオブジェクト)を得る * @param type $shortName 掲示板shortName * @return type Model_Board */ public function getBoardFromShortName($shortName) { if ($shortName === null) { return null; } //Boardを取得 $query = Model_Board::query()->where('shortName', $shortName); $board = $query->get_one(); return $board; }
<?php if (isset($imgId) && isset($shortName)) { //掲示板を取得 $query = Model_Board::query()->where('shortName', $shortName); $board = $query->get_one(); if ($board == null) { echo 'パラメータ異常'; return; } //画像のbbsIDを確認 $img = Model_Attach::find($imgId); if ($img == null) { echo 'パラメータ異常'; return; } if ($img->bbsId != $board->id) { echo 'パラメータ異常'; return; } if (Auth::check()) { if ($board->userId == Auth::get('id')) { echo '<img src =\'/imgLoader/thumbnail/' . $imgId . '\' width=100/><BR>'; echo '<BR>'; echo '管理者権限で画像を削除しますか?<BR>'; echo '<div id=\'redBox\'> <a href = \'' . Uri::current() . '?mode=delete\'>削除</a></div>'; echo '<div id=\'shortBox\'> <a href = \'' . $backURL . '\'>キャンセル</a></div>'; echo '<BR>'; echo '<BR>'; return; }