本文整理汇总了PHP中CommentForm::defineShowRating方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentForm::defineShowRating方法的具体用法?PHP CommentForm::defineShowRating怎么用?PHP CommentForm::defineShowRating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommentForm
的用法示例。
在下文中一共展示了CommentForm::defineShowRating方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$newComment = $this->createComment();
$comments = $newComment->getCommentsThree();
$form = new CommentForm();
$form->url = $this->url;
$form->modelName = $this->getModelName();
$form->modelId = $this->getModelId();
$form->defineShowRating();
$this->render('commentsListWidget', array('comments' => $comments, 'newComment' => $newComment, 'form' => $form));
}
示例2: actionWriteComment
public function actionWriteComment()
{
$model = new CommentForm();
if (isset($_POST['CommentForm']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
$model->attributes = $_POST['CommentForm'];
$model->defineShowRating();
if ($model->validate() && Comment::checkExist(null, $model->modelName, $model->modelId)) {
if ($model->modelName == 'News' && !param('enableCommentsForNews', 1) || $model->modelName == 'Apartment' && !param('enableCommentsForApartments', 1) || $model->modelName == 'Menu' && !param('enableCommentsForPages', 0) || $model->modelName == 'Article' && !param('enableCommentsForFaq', 1) || $model->modelName == 'InfoPages' && !param('enableCommentsForPages', 0)) {
throw404();
}
$comment = new Comment();
$comment->body = $model->body;
$comment->parent_id = $model->rel;
$comment->user_ip = Yii::app()->controller->currentUserIp;
$comment->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
if ($model->rel == 0) {
$comment->rating = $model->rating;
} else {
$comment->rating = -1;
}
$comment->model_name = $model->modelName;
$comment->model_id = $model->modelId;
if (Yii::app()->user->isGuest) {
$comment->user_name = $model->user_name;
$comment->user_email = $model->user_email;
} else {
$comment->owner_id = Yii::app()->user->id;
}
if (param('commentNeedApproval', 1) && !Yii::app()->user->checkAccess('backend_access')) {
$comment->status = Comment::STATUS_PENDING;
Yii::app()->user->setFlash('success', Yii::t('module_comments', 'Thank you for your comment. Your comment will be posted once it is approved.'));
} else {
$comment->status = Comment::STATUS_APPROVED;
Yii::app()->user->setFlash('success', Yii::t('module_comments', 'Thank you for your comment.'));
}
$comment->save(false);
$this->redirect($model->url);
}
}
$this->render('commentForm', array('model' => $model));
}
示例3: _calcRating
public function _calcRating()
{
$form = new CommentForm();
$form->modelName = $this->model_name;
$form->defineShowRating();
if ($form->enableRating && $this->rating != -1) {
$rating = self::calcRating($this->model_name, $this->model_id);
$tmp = new $this->model_name();
$tmp->writeRating($this->model_id, $rating);
}
}