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

Public Member Functions

 init ()
 run ()
 getCommentsAmount ()
 forContent ($contentId)
- Public Member Functions inherited from BaseWidget
 getViewFile ($viewName)

Public Attributes

 $contentId

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.

Definition at line 11 of file CommentsAmountWidget.php.

Member Function Documentation

CommentsAmountWidget::forContent (   $contentId)

Declares the validation rules.

Parameters
string$contentIddefines contentId
Returns
void

Definition at line 72 of file CommentsAmountWidget.php.

{
$amount = isset($this->commentsAmount[$contentId]) ? $this->commentsAmount[$contentId] : 0;
$this->render('CommentsAmountWidget', array('amount' => $amount));
}
CommentsAmountWidget::getCommentsAmount ( )

Calculates comment amount

Returns
array

Definition at line 43 of file CommentsAmountWidget.php.

References Comment\model().

{
if ($this->_commentsAmount === null) {
$dependency = new CExpressionDependency(
'Yii::app()->db->createCommand()->select("id, status")->from(Comment::model()->tableName())->where(array("in", "content_id", ' . var_export($this->contentId, true) . '))->queryAll()'
);
$result = Yii::app()->db->cache(Yii::app()->getModule('comments')->cacheTime, $dependency)
->createCommand()
->select('content_id, count(*) as count')
->from(Comment::model()->tableName())
->where(array('and', 'status=' . Comment::APPROVED, array('in', 'content_id', $this->contentId)))
->group('content_id')
->queryAll();
$this->_commentsAmount = array();
foreach ($result as $r) {
$this->_commentsAmount[$r['content_id']] = $r['count'];
}
}
return $this->_commentsAmount;
}
CommentsAmountWidget::init ( )

widget initial function

Returns
array

Definition at line 21 of file CommentsAmountWidget.php.

{
if (!is_array($this->contentId)) {
$this->contentId = array($this->contentId);
}
}
CommentsAmountWidget::run ( )

called when widget runs

Returns
void

Definition at line 34 of file CommentsAmountWidget.php.

{
}

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