示例#1
0
 /**
  * Executes the widget.
  */
 public function run()
 {
     $currentUserLiked = false;
     $likes = Like::GetLikes(get_class($this->object), $this->object->id);
     foreach ($likes as $like) {
         if ($like->getUser()->id == Yii::app()->user->id) {
             $currentUserLiked = true;
         }
     }
     $this->render('likeLink', array('likes' => $likes, 'currentUserLiked' => $currentUserLiked, 'id' => $this->object->getUniqueId()));
 }
示例#2
0
 /**
  * Returns an JSON with current like informations about a target
  */
 public function actionShowLikes()
 {
     // Some Meta Infos
     $currentUserLiked = false;
     $likes = Like::GetLikes($this->contentModel, $this->contentId);
     foreach ($likes as $like) {
         if ($like->getUser()->id == Yii::app()->user->id) {
             $currentUserLiked = true;
         }
     }
     $json = array();
     $json['currentUserLiked'] = $currentUserLiked;
     $json['likeCounter'] = count($likes);
     echo CJSON::encode($json);
     Yii::app()->end();
 }