Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
LikeWidget Class Reference
Inheritance diagram for LikeWidget:
BaseJuiWidget

Public Member Functions

 init ()
 run ()
- Public Member Functions inherited from BaseJuiWidget
 getViewFile ($viewName)

Public Attributes

 $model
 $contentId
 $lastLikesQty
 $topLikesQty
 $likesQty
 $likes
 $hasLiked = false
 $isPreview = false

Detailed Description

Gentics Portal.Node PHP Author & Copyright (c) by Gentics Software GmbH sales.nosp@m.@gen.nosp@m.tics..nosp@m.com http://www.gentics.com Licenses can be found in the LICENSE.txt file in the root-folder of this installation You must not use this software without a valid license agreement.

Widget for view comments for current model

Definition at line 13 of file LikeWidget.php.

Member Function Documentation

LikeWidget::init ( )

Initializes the widget.

Returns
void

Definition at line 70 of file LikeWidget.php.

{
}
LikeWidget::run ( )

Selects model and renders view

Returns
void

Definition at line 79 of file LikeWidget.php.

References $likes.

{
$this->model = $this->_loadModel();
/* show widget only if we have $this->model->content_id */
if ($this->model->content_id > 0) {
/* get total likes quantity for current content*/
$this->likesQty = $this->model->likesQty;
/* get top and last likes depending on config set above */
$this->likes = $this->model->likes;
//if not guest set current user like at first position
if (!Yii::app()->user->isGuest) {
if (!empty($this->model->likes)) {
$likes = $this->model->likes;
for ($i = 0; $i < count($likes); $i++) {
if ($likes[$i]->user_id == Yii::app()->user->id) {
$this->hasLiked = true;
$tmp = $likes[0];
$likes[0] = $likes[$i];
$likes[$i] = $tmp;
break;
}
}
$this->model->likes = $likes;
}
}
$this->render('LikeWidget', array('model' => $this->model, 'hasLiked' => $this->hasLiked));
}
}

Member Data Documentation

LikeWidget::$hasLiked = false

flag if user has likes this content before

Definition at line 56 of file LikeWidget.php.

LikeWidget::$isPreview = false

flag if JavaScript should be available

Definition at line 63 of file LikeWidget.php.

LikeWidget::$likes

containing info about likes of given content

Definition at line 50 of file LikeWidget.php.

Referenced by run().


The documentation for this class was generated from the following file: