コード例 #1
0
ファイル: system.php プロジェクト: katsuwo/bbs
 public static function getSystemRecord()
 {
     //システム設定レコードがなければ作成する。
     $sysRecords = Model_System::find('all');
     $found = false;
     $count = 0;
     $minId = 65535;
     $sys = null;
     foreach ($sysRecords as $sys) {
         if ($sys != null) {
             $found = true;
             $count++;
             if ($sys->id < $minId) {
                 $minId = $sys->id;
             }
         }
     }
     //レコードが複数ある場合(異常)
     if ($count >= 2) {
         $query = Model_System::query();
         $query->where('id', '!=', $minId);
         $invalidRecords = $query->get();
         //idが最も小さい物を除いて削除する
         foreach ($invalidRecords as $iv) {
             $iv->delete();
         }
     }
     if ($found == false) {
         $sys = Model_System::forge();
         $sys->mailAtLogin = 0;
         $sys->headTag = '';
         $sys->systemAd1 = '';
         $sys->systemAd2 = '';
         $sys->systemAd3 = '';
         $sys->systemAdMobile1 = '';
         $sys->systemAdMobile2 = '';
         $sys->systemAdMobile2 = '';
         $sys->save();
     }
     return $sys;
 }
コード例 #2
0
ファイル: admin.php プロジェクト: katsuwo/bbs
 function action_system()
 {
     $sys = Model_System::getSystemRecord();
     $postFormFieldSet = Fieldset::forge('postForm');
     $postFormFieldSet->add_model($sys);
     $postFormFieldSet->populate($sys);
     $postFormFieldSet->add('submit', '修正', array('type' => 'submit', 'width' => 80, 'value' => '送信'));
     $content = View::forge('admin/system');
     $content->set_safe('postForm', $postFormFieldSet->build('admin/index'), false);
     $this->template->boardDescription = 'システム設定';
     $this->template->content = $content;
 }
コード例 #3
0
ファイル: bbs.php プロジェクト: katsuwo/bbs
 /**
  * スレッドを表示するコントローラ
  * @param type $shortName 掲示板shortName
  * @param type $threadId スレッドId(書き込みId)
  */
 public function action_thread($shortName = null, $threadId = null)
 {
     if ($shortName == null || $threadId == null) {
         return Response::redirect(Uri::base());
     }
     //投稿失敗の時のPOSTとエラーメッセージをSessionから取得
     $oldPost = Session::get('oldPost');
     Session::delete('oldPost');
     $oldAr = $this->getOldPostedData($oldPost);
     Session::delete('POST');
     $msg = Session::get('errorMsg');
     Session::delete('errorMsg');
     //shortNameからBoardオブジェクトを得る
     $board = $this->getBoardFromShortName($shortName);
     if ($board == null) {
         return Response::redirect(Uri::base());
     }
     $data = array();
     $data['board'] = $board;
     //共通広告取得
     $sys = Model_System::getSystemRecord();
     $headTag = $sys->headTag;
     //掲示板タイトル等設定
     $this->setBoardTitle($board);
     $data['shortName'] = $board->shortName;
     //スレッドの元書き込みを得る
     $query = Model_Article::query()->where('bbsId', $board->id);
     $query->where('id', '=', $threadId);
     $query->order_by('id', 'desc');
     $masterArticle = $query->get_one();
     if ($masterArticle == null) {
         return Response::redirect('bbs/index/' . $shortName);
     }
     $masterArticle->reserve1 = 1;
     //擬似的に書き込み番号(レス番)を与える
     $data['article'] = $masterArticle;
     //ページネーションの為のコメント数を得る
     $count = $masterArticle->getCountOfComments();
     //ページネーション
     $pConfig = array('pagination_url' => 'bbs/thread/' . $shortName . DS . $threadId, 'uri_segment' => 5, 'num_links' => 10, 'per_page' => 10, 'total_items' => $count, 'show_first' => true, 'show_last' => true, 'name' => 'bootstrap3');
     $pagiNation = Pagination::forge('myPaginationIndex', $pConfig);
     //投稿用フォームを得る
     $postFormFieldSet = null;
     if ($board->allowRes == true) {
         $postFormFieldSet = $this->makePostFormFieldSet($board);
         $postFormFieldSet->populate($oldAr);
         //CommentOf_をHiddenでフォームに仕込む(CommentOfはModel_Articleに含まれるので_を付ける)
         $postFormFieldSet->add('commentOf_', '', array('type' => 'hidden', 'value' => $threadId));
         //コメントはタイトル無し
         $postFormFieldSet->field('title')->set_type('hidden');
     }
     //コメントを得る
     if ($board->type == 2) {
         $comments = $masterArticle->getComments($threadId, $pagiNation->offset, $pagiNation->per_page, 'id', 'asc');
     } else {
         $comments = $masterArticle->getComments($threadId, $pagiNation->offset, $pagiNation->per_page);
     }
     //擬似的に書き込み番号(レス番)を与える
     $count = $pagiNation->offset + 2;
     foreach ($comments as $cm) {
         $cm->reserve1 = $count++;
     }
     //XViodes YoutubeのURLからコードを作成
     if ($board->allowXvideos) {
         foreach ($comments as $cm) {
             $this->setVideoPlayerFromURL($cm, Agent::is_mobiledevice());
         }
     }
     $data['comments'] = $comments;
     //添付ファイルを得る
     $data['attaches'] = $this->getAttach($board, $threadId, $data['comments']);
     //デバイス・掲示板タイプに応じてテンプレートを選択
     $articleStyle = '';
     $resStyle = '';
     if (Agent::is_mobiledevice()) {
         //共通広告
         $data['systemAd1'] = $sys->systemAdMobile1;
         $data['systemAd2'] = $sys->systemAdMobile2;
         $data['systemAd3'] = $sys->systemAdMobile3;
         if ($board->type == 1) {
             $this->template->title = "記事一覧";
             $content = View::forge('bbs/thread', $data);
             //背景色設定
             $articleStyle = "background: -moz-linear-gradient(top, {$board->articleTopColor}, {$board->articleBottomColor});";
             $articleStyle .= "background: -webkit-gradient(linear,left top,left bottom, from({$board->articleTopColor}), to({$board->articleBottomColor}));";
             $resStyle = "background: -moz-linear-gradient(top, {$board->resTopColor}, {$board->resBottomColor});";
             $resStyle .= "background: -webkit-gradient(linear,left top,left bottom, from({$board->resTopColor}), to({$board->resBottomColor}));";
         } else {
             if ($board->type == 2) {
                 $content = View::forge('bbs/thread_2ch', $data);
                 $content->set_safe('modeDescription', "<h4>スレッド:{$masterArticle->title}</h4>", false);
                 //背景色設定
                 $articleStyle = "background-color:{$board->articleTopColor}";
                 $resStyle = "background-color:{$board->articleTopColor}";
             }
         }
     } else {
         //共通広告
         $data['systemAd1'] = $sys->systemAd1;
         $data['systemAd2'] = $sys->systemAd2;
         $data['systemAd3'] = $sys->systemAd3;
         if ($board->type == 1) {
             $this->template->title = "記事一覧";
             $content = View::forge('bbs/thread', $data);
             //背景色設定
             $articleStyle = "background: -moz-linear-gradient(top, {$board->articleTopColor}, {$board->articleBottomColor});";
             $articleStyle .= "background: -webkit-gradient(linear,left top,left bottom, from({$board->articleTopColor}), to({$board->articleBottomColor}));";
             $resStyle = "background: -moz-linear-gradient(top, {$board->resTopColor}, {$board->resBottomColor});";
             $resStyle .= "background: -webkit-gradient(linear,left top,left bottom, from({$board->resTopColor}), to({$board->resBottomColor}));";
         } else {
             if ($board->type == 2) {
                 $content = View::forge('bbs/thread_2ch', $data);
                 $content->set_safe('modeDescription', "<h4>スレッド:{$masterArticle->title}</h4>", false);
                 //背景色設定
                 $articleStyle = "background-color:{$board->articleTopColor}";
                 $resStyle = "background-color:{$board->articleTopColor}";
             }
         }
     }
     if ($board->allowRes == true) {
         $content->set('postForm', $postFormFieldSet->build('bbs/post'), false);
     }
     //管理者としてログイン中か?
     $content->set('isOwner', false);
     if (Auth::check()) {
         if ($board->userId == Auth::get('id')) {
             $content->set('isOwner', true);
         }
     }
     //エラーメッセージ設定
     if ($msg != null) {
         $content->set('msg', $msg, false);
     }
     //共通タグ(トラッキング用)
     $this->template->set_safe('headTag', $headTag, false);
     //背景色設定
     $backGroundColor = $board->backGroundColor;
     $content->set_safe('articleStyle', $articleStyle, false);
     $content->set_safe('resStyle', $resStyle, false);
     $this->template->set_safe('backGroundColor', $backGroundColor);
     //通常文字色
     $textColor = $board->textColor;
     $this->template->set_safe('textColor', $textColor);
     //リンクテキスト色設定
     $linkColor = $board->linkColor;
     $this->template->set_safe('linkColor', $linkColor);
     //モバイルフラグ
     $content->set('isMobile', Agent::is_mobiledevice());
     $content->set_safe('pagination', $pagiNation);
     $this->template->set_safe('keywords', $this->getKeyWordsList($board->keywords));
     $this->template->content = $content;
 }