• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

magic framework の開発


Commit MetaInfo

Revision4edb4593b508a801b14a4053fbaeb069a13642d0 (tree)
Time2011-12-17 18:14:50
Authortaka451213 <taka451213@hotm...>
Commitertaka451213

Log Message

update

Signed-off-by: taka451213 <taka451213@hotmail.com>

Change Summary

Incremental Difference

--- a/koshien/app/action/pc/IndexAction.php
+++ b/koshien/app/action/pc/IndexAction.php
@@ -18,6 +18,7 @@ final class IndexAction extends Action {
1818 }
1919 public function index() {
2020 $this->dto->setTournaments($this->dao->selectTournament());
21+ $this->dto->setWinner($this->dao->selectWinner());
2122 $this->dto->setEntries($this->dao->selectEntries());
2223 return new Forward();
2324 }
--- /dev/null
+++ b/koshien/app/action/pc/StartAction.php
@@ -0,0 +1,59 @@
1+<?php
2+final class StartAction extends Action {
3+ /**
4+ * @var StartDao
5+ */
6+ protected $dao = NULL;
7+ /**
8+ * @var StartDto
9+ */
10+ protected $dto = NULL;
11+ public function __construct() {
12+ }
13+ /**
14+ * @return StartDto
15+ */
16+ public function getDto() {
17+ return $this->dto;
18+ }
19+ public function index() {
20+ $this->response->noCache();
21+ $key = 'uid_' . $this->dto->getUno() . '_' . $this->dto->getTno();
22+ if (!$uniqueId = $this->session->getCookieValue($key, 0)) {
23+ $uniqueId = md5(uniqid('', TRUE));
24+ $this->dao->replaceStart($uniqueId, $this->dto->getUno(), $this->dto->getTno());
25+ }
26+ $res = $this->dao->selectStart($uniqueId, $this->dto->getUno(), $this->dto->getTno());
27+ $this->dto->setUid($uniqueId);
28+ $this->session->setCookieValue($key, $uniqueId, time() + 7 * 24 * 3600);
29+ foreach ($res as $row) {
30+ $this->dto->setEntry($row['entry_no']);
31+ $this->dto->setImage($row['entry_image']);
32+ $this->dto->setComment($row['comment']);
33+ }
34+ return new Forward();
35+ }
36+ public function apply() {
37+ $this->response->noCache();
38+ $key = 'uid_' . $this->dto->getUno() . '_' . $this->dto->getTno();
39+ if (!$this->session->getCookieValue($key, 0)) {
40+ return new Redirect();
41+ }
42+ $this->dao->deleteStart($this->dto->getUid(), $this->dto->getWinner());
43+ $res = $this->dao->selectStart($this->dto->getUid(), $this->dto->getUno(), $this->dto->getTno());
44+ if (count($res) != 2) {
45+ $this->session
46+ ->setCookieValue('uid_' . $this->dto->getUno() . '_' . $this->dto->getTno(), '', time() - 3600);
47+ $this->dao->clearStart($this->dto->getUid());
48+ return new Redirect('winner',
49+ array('uno' => $this->dto->getUno(), 'tno' => $this->dto->getTno(), 'eno' => $res[0]['entry_no']));
50+ }
51+ foreach ($res as $row) {
52+ $this->dto->setEntry($row['entry_no']);
53+ $this->dto->setImage($row['entry_image']);
54+ $this->dto->setComment($row['comment']);
55+ }
56+ return new Forward();
57+ }
58+}
59+// EOF.
--- /dev/null
+++ b/koshien/app/action/pc/WinnerAction.php
@@ -0,0 +1,28 @@
1+<?php
2+final class WinnerAction extends Action {
3+ /**
4+ * @var WinnerDao
5+ */
6+ protected $dao = NULL;
7+ /**
8+ * @var WinnerDto
9+ */
10+ protected $dto = NULL;
11+ public function __construct() {
12+ }
13+ /**
14+ * @return WinnerDto
15+ */
16+ public function getDto() {
17+ return $this->dto;
18+ }
19+ public function index() {
20+ $row = $this->dao->selectEntry($this->dto->getUno(), $this->dto->getTno(), $this->dto->getEno());
21+ $this->dao->replaceWinner($row['entry_image'], $row['nickname']);
22+ $this->dto->setImage($row['entry_image']);
23+ $this->dto->setNickname($row['nickname']);
24+ $this->dto->setComment($row['comment']);
25+ return new Forward();
26+ }
27+}
28+// EOF.
--- a/koshien/app/dao/pc/IndexDao.php
+++ b/koshien/app/dao/pc/IndexDao.php
@@ -14,6 +14,16 @@ final class IndexDao extends Dao {
1414 $res->execute();
1515 return $res->fetchAll(PDO::FETCH_ASSOC);
1616 }
17+ public function selectWinner() {
18+ $stmt = " select entry_image,";
19+ $stmt .= " nickname,";
20+ $stmt .= " win_count";
21+ $stmt .= " from tr_winner";
22+ $stmt .= " order by win_count desc";
23+ $res = $this->pdo->prepare($stmt);
24+ $res->execute();
25+ return $res->fetchAll(PDO::FETCH_ASSOC);
26+ }
1727 public function selectEntries() {
1828 $stmt = " select ms.user_no,";
1929 $stmt .= " ms.tournament_no,";
--- a/koshien/app/dao/pc/KanriDao.php
+++ b/koshien/app/dao/pc/KanriDao.php
@@ -21,7 +21,21 @@ final class KanriDao extends AppDao {
2121 $stmt .= " and tournament_no = ?";
2222 $res = $this->pdo->prepare($stmt);
2323 $res->execute(array($userNo, $tournamentNo));
24- return $res->rowCount();
24+ if ($count = $res->rowCount()) {
25+ $res->closeCursor();
26+ $stmt = " delete from tr_entry";
27+ $stmt .= " where user_no = ?";
28+ $stmt .= " and tournament_no = ?";
29+ $res = $this->pdo->prepare($stmt);
30+ $res->execute(array($userNo, $tournamentNo));
31+ $res->closeCursor();
32+ $stmt = " delete from tr_start";
33+ $stmt .= " where user_no = ?";
34+ $stmt .= " and tournament_no = ?";
35+ $res = $this->pdo->prepare($stmt);
36+ $res->execute(array($userNo, $tournamentNo));
37+ }
38+ return $count;
2539 }
2640 public function updateTournament($userNo, $tournamentNo) {
2741 $stmt = " update ms_tournament";
--- a/koshien/app/dao/pc/MainDao.php
+++ b/koshien/app/dao/pc/MainDao.php
@@ -43,7 +43,21 @@ final class MainDao extends AppDao {
4343 $stmt .= " and tournament_no = ?";
4444 $res = $this->pdo->prepare($stmt);
4545 $res->execute(array($userNo, $tournamentNo));
46- return $res->rowCount();
46+ if ($count = $res->rowCount()) {
47+ $res->closeCursor();
48+ $stmt = " delete from tr_entry";
49+ $stmt .= " where user_no = ?";
50+ $stmt .= " and tournament_no = ?";
51+ $res = $this->pdo->prepare($stmt);
52+ $res->execute(array($userNo, $tournamentNo));
53+ $res->closeCursor();
54+ $stmt = " delete from tr_start";
55+ $stmt .= " where user_no = ?";
56+ $stmt .= " and tournament_no = ?";
57+ $res = $this->pdo->prepare($stmt);
58+ $res->execute(array($userNo, $tournamentNo));
59+ }
60+ return $count;
4761 }
4862 public function updateTournament($dest, $original, $userNo, $tournamentNo) {
4963 $stmt = " update ms_tournament";
--- /dev/null
+++ b/koshien/app/dao/pc/StartDao.php
@@ -0,0 +1,42 @@
1+<?php
2+final class StartDao extends Dao {
3+ public function __construct() {
4+ }
5+ public function replaceStart($uid, $uno, $tno) {
6+ $stmt = " replace into tr_start";
7+ $stmt .= " select ?, entry_no, user_no, tournament_no, now()";
8+ $stmt .= " from tr_entry";
9+ $stmt .= " where user_no = ?";
10+ $stmt .= " and tournament_no = ?";
11+ $res = $this->pdo->prepare($stmt);
12+ $res->execute(array($uid, $uno, $tno));
13+ }
14+ public function selectStart($uid, $uno, $tno) {
15+ $stmt = " select st.entry_no,";
16+ $stmt .= " en.entry_image,";
17+ $stmt .= " en.comment";
18+ $stmt .= " from tr_start st";
19+ $stmt .= " inner join tr_entry en";
20+ $stmt .= " on (en.user_no = ? and en.tournament_no = ? and en.entry_no = st.entry_no)";
21+ $stmt .= " where st.unique_id = ?";
22+ $stmt .= " order by rand()";
23+ $stmt .= " limit 2";
24+ $res = $this->pdo->prepare($stmt);
25+ $res->execute(array($uno, $tno, $uid));
26+ return $res->fetchAll(PDO::FETCH_ASSOC);
27+ }
28+ public function deleteStart($uid, $entryNo) {
29+ $stmt = " delete from tr_start";
30+ $stmt .= " where unique_id = ?";
31+ $stmt .= " and entry_no = ?";
32+ $res = $this->pdo->prepare($stmt);
33+ $res->execute(array($uid, $entryNo));
34+ }
35+ public function clearStart($uid) {
36+ $stmt = " delete from tr_start";
37+ $stmt .= " where unique_id = ?";
38+ $res = $this->pdo->prepare($stmt);
39+ $res->execute(array($uid));
40+ }
41+}
42+// EOF.
\ No newline at end of file
--- /dev/null
+++ b/koshien/app/dao/pc/WinnerDao.php
@@ -0,0 +1,30 @@
1+<?php
2+final class WinnerDao extends Dao {
3+ public function __construct() {
4+ }
5+ public function selectEntry($uno, $tno, $eno) {
6+ $stmt = " select entry_image, nickname, comment";
7+ $stmt .= " from tr_entry";
8+ $stmt .= " where user_no = ?";
9+ $stmt .= " and tournament_no = ?";
10+ $stmt .= " and entry_no = ?";
11+ $res = $this->pdo->prepare($stmt);
12+ $res->execute(array($uno, $tno, $eno));
13+ return $res->fetch(PDO::FETCH_ASSOC);
14+ }
15+ public function replaceWinner($image, $nickname) {
16+ $stmt = " select win_count";
17+ $stmt .= " from tr_winner";
18+ $stmt .= " where entry_image = ?";
19+ $res = $this->pdo->prepare($stmt);
20+ $res->execute(array($image));
21+ $count = $res->fetchColumn();
22+ $count = $count ? $count + 1 : 1;
23+ $res->closeCursor();
24+ $stmt = " replace into tr_winner";
25+ $stmt .= " values (?, ?, ?)";
26+ $res = $this->pdo->prepare($stmt);
27+ $res->execute(array($image, $nickname, $count));
28+ }
29+}
30+// EOF.
\ No newline at end of file
--- a/koshien/app/dto/pc/IndexDto.php
+++ b/koshien/app/dto/pc/IndexDto.php
@@ -1,6 +1,7 @@
11 <?php
22 final class IndexDto extends Dto {
33 private $_tournaments = array();
4+ private $_winner = array();
45 private $_entries = array();
56 public function __construct() {
67 }
@@ -10,6 +11,12 @@ final class IndexDto extends Dto {
1011 public function getTournaments() {
1112 return $this->_tournaments;
1213 }
14+ public function setWinner($winner) {
15+ $this->_winner = $winner;
16+ }
17+ public function getWinner() {
18+ return $this->_winner;
19+ }
1320 public function setEntries($entries) {
1421 $this->_entries = $entries;
1522 }
--- /dev/null
+++ b/koshien/app/dto/pc/StartDto.php
@@ -0,0 +1,55 @@
1+<?php
2+final class StartDto extends Dto {
3+ private $_uid = NULL;
4+ private $_uno = NULL;
5+ private $_tno = NULL;
6+ private $_image = array();
7+ private $_comment = array();
8+ private $_entry = array();
9+ private $_winner = NULL;
10+ public function __construct() {
11+ }
12+ public function setUid($uid) {
13+ $this->_uid = $uid;
14+ }
15+ public function getUid() {
16+ return $this->_uid;
17+ }
18+ public function setUno($uno) {
19+ $this->_uno = $uno;
20+ }
21+ public function getUno() {
22+ return $this->_uno;
23+ }
24+ public function setTno($tno) {
25+ $this->_tno = $tno;
26+ }
27+ public function getTno() {
28+ return $this->_tno;
29+ }
30+ public function setImage($image) {
31+ $this->_image[] = $image;
32+ }
33+ public function getImage() {
34+ return $this->_image;
35+ }
36+ public function setComment($comment) {
37+ $this->_comment[] = $comment;
38+ }
39+ public function getComment() {
40+ return $this->_comment;
41+ }
42+ public function setEntry($entry) {
43+ $this->_entry[] = $entry;
44+ }
45+ public function getEntry() {
46+ return $this->_entry;
47+ }
48+ public function setWinner($winner) {
49+ $this->_winner = $winner;
50+ }
51+ public function getWinner() {
52+ return $this->_winner;
53+ }
54+}
55+// EOF.
\ No newline at end of file
--- /dev/null
+++ b/koshien/app/dto/pc/WinnerDto.php
@@ -0,0 +1,48 @@
1+<?php
2+final class WinnerDto extends Dto {
3+ private $_uno = NULL;
4+ private $_tno = NULL;
5+ private $_eno = NULL;
6+ private $_image = NULL;
7+ private $_nickname = NULL;
8+ private $_comment = NULL;
9+ public function __construct() {
10+ }
11+ public function setUno($uno) {
12+ $this->_uno = $uno;
13+ }
14+ public function getUno() {
15+ return $this->_uno;
16+ }
17+ public function setTno($tno) {
18+ $this->_tno = $tno;
19+ }
20+ public function getTno() {
21+ return $this->_tno;
22+ }
23+ public function setEno($eno) {
24+ $this->_eno = $eno;
25+ }
26+ public function getEno() {
27+ return $this->_eno;
28+ }
29+ public function setImage($image) {
30+ $this->_image = $image;
31+ }
32+ public function getImage() {
33+ return $this->_image;
34+ }
35+ public function setNickname($nickname) {
36+ $this->_nickname = $nickname;
37+ }
38+ public function getNickname() {
39+ return $this->_nickname;
40+ }
41+ public function setComment($comment) {
42+ $this->_comment = $comment;
43+ }
44+ public function getComment() {
45+ return $this->_comment;
46+ }
47+}
48+// EOF.
\ No newline at end of file
--- a/koshien/app/view/pc/IndexView.php
+++ b/koshien/app/view/pc/IndexView.php
@@ -20,6 +20,17 @@ final class IndexView extends View {
2020 $tpl .= GenerateUtil::staticCreate($contents, array('part' => $buff));
2121 }
2222 $this->response->set('tournament_tpl', $tpl);
23+ $contents = file_get_contents(WEB . 'pc' . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . 'winner.tpl');
24+ $part = file_get_contents(WEB . 'pc' . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . 'winner_part.tpl');
25+ $tpl = '';
26+ foreach (array_chunk($this->response->get('winner'), 4) as $value) {
27+ $buff = '';
28+ foreach ($value as &$row) {
29+ $buff .= GenerateUtil::staticCreate($part, $row);
30+ }
31+ $tpl .= GenerateUtil::staticCreate($contents, array('part' => $buff));
32+ }
33+ $this->response->set('winner_tpl', $tpl);
2334 $contents = file_get_contents(WEB . 'pc' . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . 'entries.tpl');
2435 $part = file_get_contents(WEB . 'pc' . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . 'entries_part.tpl');
2536 $tpl = '';
--- /dev/null
+++ b/koshien/app/view/pc/StartView.php
@@ -0,0 +1,4 @@
1+<?php
2+final class StartView extends View {
3+}
4+// EOF.
\ No newline at end of file
--- /dev/null
+++ b/koshien/app/view/pc/WinnerView.php
@@ -0,0 +1,4 @@
1+<?php
2+final class WinnerView extends View {
3+}
4+// EOF.
\ No newline at end of file
--- a/koshien/web/pc/html/index.html
+++ b/koshien/web/pc/html/index.html
@@ -17,6 +17,7 @@
1717 </table>
1818 優勝回数ランキング
1919 <table>
20+ <?=$winner_tpl?>
2021 </table>
2122 エントリー受付中
2223 <table>
--- /dev/null
+++ b/koshien/web/pc/html/start.html
@@ -0,0 +1,46 @@
1+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+<html>
3+ <head>
4+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+ <link rel="stylesheet" href="/pc/css/common.css" type="text/css" />
6+ <title>Untitled Document</title>
7+ </head>
8+ <body>
9+ <div class="error">
10+ <?=$error?>
11+ </div>
12+ どちらがいいですか?
13+ <form name="login" action="/start/apply" method="post">
14+ <table>
15+ <tr>
16+ <td>
17+ <img src="/resource/<?=$image[0]?>" height="200" width="200">
18+ </td>
19+ <td>
20+ <img src="/resource/<?=$image[1]?>" height="200" width="200">
21+ </td>
22+ </tr>
23+ <tr>
24+ <td>
25+ <?=$comment[0]?>
26+ </td>
27+ <td>
28+ <?=$comment[1]?>
29+ </td>
30+ </tr>
31+ <tr>
32+ <td>
33+ <input type="radio" name="winner" value="<?=$entry[1]?>">
34+ </td>
35+ <td>
36+ <input type="radio" name="winner" value="<?=$entry[0]?>">
37+ </td>
38+ </tr>
39+ </table>
40+ <input type="submit" value="確定">
41+ <input type="hidden" name="uid" value="<?=$uid?>">
42+ <input type="hidden" name="uno" value="<?=$uno?>">
43+ <input type="hidden" name="tno" value="<?=$tno?>">
44+ </form>
45+ </body>
46+</html>
--- /dev/null
+++ b/koshien/web/pc/html/winner.html
@@ -0,0 +1,23 @@
1+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+<html>
3+ <head>
4+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+ <link rel="stylesheet" href="/pc/css/common.css" type="text/css" />
6+ <title>Untitled Document</title>
7+ </head>
8+ <body>
9+ <div class="error">
10+ <?=$error?>
11+ </div>
12+ 優勝です。
13+ <br>
14+ <?=$nickname?>
15+ さんのエントリー画像
16+ <br>
17+ <img src="/resource/<?=$image?>" height="200" width="200">
18+ <br>
19+ <?=$comment?>
20+ <br>
21+ <a href="/">TOP</a>
22+ </body>
23+</html>
--- a/koshien/web/pc/tpl/tournament_part.tpl
+++ b/koshien/web/pc/tpl/tournament_part.tpl
@@ -1,5 +1,5 @@
11 <td>
2- <a href="/start?u=${user_no}&t=${tournament_no}"><img src="/resource/${main_image}" height="200" width="200"></a>
2+ <a href="/start?uno=${user_no}&tno=${tournament_no}"><img src="/resource/${main_image}" height="200" width="200"></a>
33 <br>
4- <a href="/start?u=${user_no}&t=${tournament_no}">${tournament_name}</a>
4+ <a href="/start?uno=${user_no}&tno=${tournament_no}">${tournament_name}</a>
55 </td>
--- /dev/null
+++ b/koshien/web/pc/tpl/winner.tpl
@@ -0,0 +1,3 @@
1+<tr>
2+ ${part}
3+</tr>
--- /dev/null
+++ b/koshien/web/pc/tpl/winner_part.tpl
@@ -0,0 +1,7 @@
1+<td>
2+ ${win_count}勝
3+ <br>
4+ <img src="/resource/${entry_image}" height="200" width="200">
5+ <br>
6+ ${nickname}
7+</td>