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

Public Member Functions

 init ()
 run ()
 getCurrentPage ()
 canReply ()
 createPaginationUrl ($page)
 getSafeCommentAttributes ($comments)
 getAvatar ($comment)

Public Attributes

 $oneLevelReply = false
 $hash
 $formWidget
 $commentsPerPage = 5
 $paginationPagesCount = 5
- Public Attributes inherited from CommentsBaseWidget
 $contentId
 $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 12 of file CommentsListWidget.php.

Member Function Documentation

CommentsListWidget::canReply ( )

Check if reply possibility allowed for current comments list

Returns
bool flag that shows if user allowed reply for comment or not

Definition at line 187 of file CommentsListWidget.php.

{
return $this->oneLevelReply && $this->formWidget && ($this->formWidget->allowAnonymous || !Yii::app()->user->isGuest);
}
CommentsListWidget::createPaginationUrl (   $page)

Returns current page

Parameters
integer$pagepage number
Returns
string

Definition at line 199 of file CommentsListWidget.php.

{
$url = Yii::app()->request->getUrl();
$name = "clw{$this->contentId}";
$newParam = "clw{$this->contentId}=$page";
if (($oldValue = Yii::app()->request->getParam($name)) !== null) {
$url = str_replace("$name=$oldValue", $newParam, $url);
} else {
if (strpos($url, '?') !== false) {
$url .= '&' . $newParam;
} else {
$url .= '?' . $newParam;
}
}
$url .= '#list_' . $this->contentId;
return $url;
}
CommentsListWidget::getAvatar (   $comment)

Get comment author avatar image

Parameters
array$commenta comment
Returns
String

Definition at line 251 of file CommentsListWidget.php.

References Gravatar\getImage().

{
return Gravatar::getImage($comment->email, Yii::app()->request->isSecureConnection ? 'https' : 'http');
}
CommentsListWidget::getCurrentPage ( )

Returns current page

Returns
integer

Definition at line 177 of file CommentsListWidget.php.

{
return Yii::app()->request->getParam("clw{$this->contentId}", 0);
}
CommentsListWidget::getSafeCommentAttributes (   $comments)

Returns comment attributes

Parameters
array$commentsarray of comments
Returns
array

Definition at line 225 of file CommentsListWidget.php.

{
$commentsAttributes = array();
foreach ($comments as $parent) {
$parentData = array(
'id' => $parent->id,
'subject' => $parent->subject
);
foreach ($parent->childs as $child) {
$parentData['childs'][] = array(
'id' => $child->id,
'subject' => $child->subject
);
}
$commentsAttributes[] = $parentData;
}
return $commentsAttributes;
}
CommentsListWidget::init ( )

Make widgets options hash key and store options in session

Returns
void

Reimplemented from CommentsBaseWidget.

Definition at line 44 of file CommentsListWidget.php.

{
$assetsUrl = Yii::app()->getModule('comments')->getAssetsUrl();
Yii::app()->clientScript->registerCssFile($assetsUrl . '/css/pagination.css');
Yii::app()->clientScript->registerScriptFile($assetsUrl . '/js/initCommentsReply.js');
$options = array(
'contentId' => $this->contentId
);
$this->hash = md5(serialize($options) . Yii::app()->getModule('comments')->hashSalt);
if (Yii::app()->cache->get($this->hash) != $options) {
Yii::app()->cache->set($this->hash, $options);
}
}
CommentsListWidget::run ( )

Find all comments by contentId. Preload child comments.

Returns
void

Definition at line 65 of file CommentsListWidget.php.

{
$comments = $this->_loadComments();
$this->render(
'CommentsListWidget',
array(
'comments' => $comments['comments'],
'commentsTotal' => $comments['total'],
'commentsCountWithChildren' => $comments['countWithChildren'],
'pages' => $comments['pages']
)
);
}

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