Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public function before()
 {
     if (Agent::is_mobiledevice()) {
         \Response::redirect('mobile/index.html');
     }
     parent::before();
     foreach (\Auth::verified() as $driver) {
         if (($id = $driver->get_user_id()) !== false) {
             $this->current_user = Model\Auth_User::find($id[1]);
         }
         break;
     }
     // Set a global variable so views can use it
     View::set_global('current_user', $this->current_user);
 }
Esempio n. 3
0
 public function before()
 {
     parent::before();
     if ($this->getNotOpenidAllowed()) {
         return;
     }
     if (!\Agent::is_mobiledevice()) {
         $this->theme = 'mobile';
         $this->template->set_filename('mobile/template');
     }
     if (!\Auth::check()) {
         \Response::redirect('/admin/login');
     }
     // 检测是否后台帐户
     if (!\Session::get('employee', false) && \Auth::get_user()->username != 'admin') {
         \Auth::logout();
         \Response::redirect('/admin/login');
     }
 }
Esempio n. 4
0
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title><?php 
if (isset($title)) {
    echo $title;
}
?>
</title>
		<?php 
if (Agent::is_mobiledevice()) {
    echo '<meta name="viewport" content="width=device-width">';
    echo Asset::css('bootstrap.css');
    echo Asset::css('mobile.css');
} else {
    echo Asset::css('bootstrap.css');
    echo Asset::css('pc.css');
}
?>
		<?php 
if (isset($keywords)) {
    if (count($keywords) != 0) {
        echo '<meta name ="keywords" contents="' . $keywords . '">';
    }
}
?>

		<style>
			body {
				   color : <?php 
Esempio n. 5
0
 public function action_deleteConfirm($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('パラメータ異常');
     }
     $data['board'] = $board;
     if (Agent::is_mobiledevice()) {
     } else {
         $content = View::forge('bbsadmin/deleteconfirm', $data);
     }
     $this->setBoardTitle();
     $this->template->boardDescription = '掲示板削除';
     $content->set('msg', $board->title . '(' . $board->shortName . ')を削除しますか?', false);
     $this->template->content = $content;
 }
Esempio n. 6
0
 /**
  * Tests Agent::is_mobiledevice()
  *
  * @test
  */
 public function test_is_mobiledevice()
 {
     $output = Agent::is_mobiledevice();
     $this->assertFalse($output);
 }
Esempio n. 7
0
File: bbs.php Progetto: 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;
 }