/** * Adds one vote to the subject votes count, a like or dislike. * @param integer $vote_id the ID of the subject * @param string $vote the vote: either like or dislike */ public function actionVote($subject_id, $vote = "") { global $arr_response; if (!Yii::app()->user->isGuest) { $subject_count = Subject::add_vote($subject_id, $vote, Yii::app()->user->id); if ($subject_count['success'] == true) { $arr_response['subject_vote'] = SiteHelper::subject_vote($subject_count['subject_id'], $subject_count['likes'], $subject_count['dislikes'], true); $arr_response['response_message'] = Yii::t('subject', 'Vote sent.'); } else { $arr_response['response_code'] = 409; $arr_response['response_message'] = $subject_count['message']; } } else { $arr_response['response_code'] = 401; $arr_response['response_message'] = Yii::t('subject', 'Sorry, you must log in to be able to vote.'); } }
function display_elements(obj_json){ time_submitted = fromUnixTime(obj_json.time_submitted); current_title = obj_json.title;//title submit_info = '<?php echo Yii::t('site', 'by {username} at {time} UTC', array('{username}' => '<a href="' . Yii::app()->getRequest()->getBaseUrl(true) . '/mysub/\'+obj_json.username+\'">\' + obj_json.username + \'</a>', '{time}' => "'+time_submitted.getHours()+':'+time_submitted.getMinutes()+'")); ?> '; share_links = '<?php echo SiteHelper::share_links("'+obj_json.urn+'", "'+obj_json.title+'"); ?> '; $('#subject_voting').html( '<?php echo SiteHelper::subject_vote("'+obj_json.subject_id+'", "'+obj_json.likes+'", "'+obj_json.dislikes+'"); ?> ');; $('#share_links').html(share_links); $('#submit_info').html(submit_info); $('#perma_link').html('<a id="urn_link" title="' +obj_json.title +'" href="'+obj_json.permalink+'">[permalink]</a>'); $('#content_div_1').empty();//some times iframes or object elements stay inside, so clean it just in those rare cases $('#content_div_1').html('<?php echo SiteHelper::content_html("'+obj_json.content_html+'", "'+obj_json.user_comment+'"); ?> '); current_info = '<b>'+obj_json.country_name+'</b> | '; //$("#comments_board").html("Waiting for comments");
<div class="row"> <?php echo SiteHelper::formatted($model->user_comment); ?> </div> <div style="float:left;"> <?php echo SiteHelper::share_links($model->urn, $model->title); ?> </div> <div style="float:right;margin-left:10px"> <?php echo SiteHelper::subject_vote($model->id, $model->likes, $model->dislikes); ?> </div> <div class="clear_both"></div> <br> <h3 class="detail_header"><?php echo Yii::t('subject', 'Comments'); ?> </h3> <?php $comments = Comment::model()->with('user', 'country')->findAll("subject_id = {$model->id}"); $total_comments = count($comments); if ($total_comments == 0) { echo "<h4>" . Yii::t('subject', 'NO COMMENTS') . "</h4>"; }