Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed voting

  • Loading branch information...
commit 21adaa55764184a5697d3c72813061cb45df10ec 1 parent d70817f
@joni authored
View
2  yii-app/css/main.css
@@ -3,7 +3,7 @@ body
margin: 0;
padding: 0;
color: #555;
- font: normal 14pt Arial,Helvetica,sans-serif;
+ font: normal 12pt Arial,Helvetica,sans-serif;
background: #EFEFEF;
}
View
7 yii-app/protected/controllers/BookController.php
@@ -20,7 +20,12 @@ public function actionIndex()
public function actionVote($id, $vote) {
$book = new Book($id);
- $book->vote($vote);
+ if ($vote == -1) {
+ $book->nvote();
+ } else {
+ $book->vote();
+ }
+
$this->redirect(Yii::app()->request->urlReferrer);
}
View
8 yii-app/protected/views/book/view.php
@@ -7,11 +7,13 @@
<div style="float: left; margin: 10px 10px 0 0">
<?= CHtml::image($book->image) ?>
</div>
-<h1><?= $book->title ?>
-<?= CHtml::link('+1',array('vote','id'=>$book->google_id,'vote'=>+1)) ?> /
-<?= CHtml::link('-1',array('vote','id'=>$book->google_id,'vote'=>-1)) ?>
+<h1><?= $book->title ?> (<span style="color:green">+<?=$book->vote?></span> / <span style="color:red">-<?=$book->n_vote?></span>)
</h1>
<h2>By <?=$book->author ?></h2>
<p><?= nl2br($book->description) ?></p>
+<span style="color: green"><?= CHtml::link('+1',array('vote','id'=>$book->google_id,'vote'=>+1)) ?> </span> /
+<span style="color: red">
+<?= CHtml::link('-1',array('vote','id'=>$book->google_id,'vote'=>-1)) ?></a>
+</span>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.