当前位置: 首页>>代码示例>>PHP>>正文


PHP CommentForm类代码示例

本文整理汇总了PHP中CommentForm的典型用法代码示例。如果您正苦于以下问题:PHP CommentForm类的具体用法?PHP CommentForm怎么用?PHP CommentForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommentForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeDoAdd

 /**
  * executeDo_add_new_comment 
  * 
  * @access public
  * @return void
  */
 public function executeDoAdd(sfWebRequest $request)
 {
     // Pull associated model
     $record_id = $request->getParameter('record_id');
     $model = $request->getParameter('model');
     $this->record = Doctrine::getTable($model)->find($record_id);
     $commentForm = new CommentForm();
     $commentForm->bind($request->getParameter('comment'));
     // return bound form with errors if form is invalid
     if (!$commentForm->isValid()) {
         return $this->renderPartial('csComments/add_comment', array('commentForm' => $commentForm));
     }
     // save the object
     /* SHOULD USE IMBEDDED FORMS
            Used this hack instead.  Need to fix
            -B.Shaffer
        */
     $commentVals = $commentForm->getValues();
     $commenter = new Commenter();
     $commenter->fromArray($commentVals['Commenter']);
     $commenter->save();
     $comment = new Comment();
     $comment['body'] = $commentVals['body'];
     $comment['Commenter'] = $commenter;
     $comment->save();
     $this->comment = $comment;
     // Pass parent comment id if comment is nested
     $parent_id = $this->getRequestParameter('comment_id');
     $this->record->addComment($this->comment, $parent_id);
     $this->record->save();
 }
开发者ID:bshaffer,项目名称:Symplist,代码行数:37,代码来源:BasecsCommentsActions.class.php

示例2: actionComment

 public function actionComment($callback, $id = 0)
 {
     $id = (int) $id;
     $callback = strip_tags(trim($callback));
     if (!request()->getIsAjaxRequest() || !request()->getIsPostRequest() || empty($callback)) {
         throw new CHttpException(500);
     }
     $data = array();
     $model = new CommentForm();
     $model->attributes = $_POST['CommentForm'];
     $model->content = h($model->content);
     if ($id > 0 && ($quote = Comment::model()->findByPk($id))) {
         $quoteTitle = sprintf(t('comment_quote_title'), $quote->authorName);
         $html = '<fieldset class="beta-comment-quote"><legend>' . $quoteTitle . '</legend>' . $quote->content . '</fieldset>';
         $model->content = $html . $model->content;
     }
     if ($model->validate() && ($comment = $model->save())) {
         $data['errno'] = 0;
         $data['text'] = t('ajax_comment_done');
         $data['html'] = $this->renderPartial('/comment/_one', array('comment' => $comment), true);
         // @todo 反回此条评论的html代码
     } else {
         $data['errno'] = 1;
         $attributes = array_keys($model->getErrors());
         foreach ($attributes as $attribute) {
             $labels[] = $model->getAttributeLabel($attribute);
         }
         $errstr = join(' ', $labels);
         $data['text'] = sprintf(t('ajax_comment_error'), $errstr);
     }
     echo $callback . '(' . json_encode($data) . ')';
     exit(0);
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:33,代码来源:PostController.php

示例3: actionCreate

 public function actionCreate($id = 0, $callback)
 {
     // @todo 暂时无用
     if (!request()->getIsAjaxRequest() || !request()->getIsPostRequest()) {
         throw new CHttpException(500);
     }
     $data = array();
     $model = new CommentForm();
     $model->attributes = $_POST['CommentForm'];
     if ($model->validate() && ($comment = $model->save())) {
         $data['errno'] = 0;
         $data['text'] = t('ajax_comment_done');
         $data['html'] = 'x';
         // @todo 反回此条评论的html代码
     } else {
         $data['errno'] = 1;
         $attributes = array_keys($model->getErrors());
         foreach ($attributes as $attribute) {
             $labels[] = $model->getAttributeLabel($attribute);
         }
         $errstr = join(' ', $labels);
         $data['text'] = sprintf(t('ajax_comment_error'), $errstr);
     }
     echo json_encode($data);
     exit(0);
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:26,代码来源:CommentController.php

示例4: 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));
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:11,代码来源:commentListWidget.php

示例5: actionUpdatecomment

 public function actionUpdatecomment($id)
 {
     //if(!Yii::$app->user->isGuest && Yii::$app->user->identity->role == 'admin'){
     $model = new CommentForm();
     if ($model->load(Yii::$app->request->post())) {
         $comment = CommentsActiveRecord::findOne($id);
         $comment->body = $model->body;
         $comment->save();
     }
     //}
     //return $this->goBack();
 }
开发者ID:kazachka,项目名称:photo-yii-site,代码行数:12,代码来源:SiteController.php

示例6: executeFormWidget

 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new CommentForm();
     if ($request->isMethod('post')) {
         $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
         $form->bind(array_merge($request->getParameter($form->getName()), array('captcha' => $captcha)));
         if ($form->isValid()) {
             $form->save();
             $this->getUser()->setFlash('form_saved', true);
             $this->redirectBack();
         }
     }
     $this->forms['Comment'] = $form;
 }
开发者ID:Regmaya,项目名称:diem-project,代码行数:14,代码来源:actions.class.php

示例7: customHead

function customHead()
{
    ?>
        <script type="text/javascript" src="<?php 
    echo osc_current_admin_theme_js_url('jquery.validate.min.js');
    ?>
"></script>
        <?php 
    CommentForm::js_validation(true);
}
开发者ID:semul,项目名称:Osclass,代码行数:10,代码来源:frm.php

示例8: 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));
 }
开发者ID:barricade86,项目名称:raui,代码行数:41,代码来源:MainController.php

示例9: _e

            ?>
                                </div>
                            </div>
                            <?php 
        }
        ?>

                            <div class="form-group col-md-12">
                                <label class="control-label" for="body">
                                    <?php 
        _e('Comment', 'osclasswizards');
        ?>
                                </label>
                                <div class="controls textarea">
                                    <?php 
        CommentForm::body_input_textarea();
        ?>
                                </div>
                            </div>
                            <div class="actions col-md-12">
                                <button type="submit" class="btn btn-success">
                                    <?php 
        _e('Send', 'osclasswizards');
        ?>
                                </button>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
开发者ID:oanav,项目名称:closetshare,代码行数:31,代码来源:item.php

示例10: addComment

 /**
  * Функция добавление комментов 
  */
 protected function addComment(&$model)
 {
     if (isset($_POST['CommentForm'])) {
         $commentForm = new CommentForm();
         $commentForm->attributes = $_POST['CommentForm'];
         if ($commentForm->validate()) {
             Yii::app()->user->setState('CommentForm', null);
             $comment = new Comment();
             $comment->attributes = $_POST['CommentForm'];
             $comment->object_type = L::r_item('CommentType', get_class($model));
             $comment->object_id = $model->id;
             $comment->created = date('Y-m-d H:i:s');
             $comment->rating = 0;
             $comment->status = L::r_item('commentStatus', 'new');
             if ($parent = Comment::model()->findbyPk((int) $commentForm->parent)) {
                 $parent->append($comment);
             } else {
                 $comment->saveNode();
             }
             Yii::app()->user->setFlash('comment', array('text' => 'Спасибо за Ваш комментарий', 'class' => 'error'));
             $this->redirect(Yii::app()->request->requestUri . '#comment-' . $comment->id);
         } else {
             Yii::app()->user->setState('CommentForm', $commentForm);
         }
     } else {
         Yii::app()->user->setState('CommentForm', null);
     }
 }
开发者ID:BGCX261,项目名称:zoomtyre-svn-to-git,代码行数:31,代码来源:Controller.php

示例11: _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);
     }
 }
开发者ID:barricade86,项目名称:raui,代码行数:11,代码来源:Comment.php

示例12: add

 /**
  * Add a comment
  * @param $args array
  * @param $request Request
  */
 function add($args, $request)
 {
     $articleId = isset($args[0]) ? (int) $args[0] : 0;
     $galleyId = isset($args[1]) ? (int) $args[1] : 0;
     $parentId = isset($args[2]) ? (int) $args[2] : 0;
     $journal =& $request->getJournal();
     $commentDao =& DAORegistry::getDAO('CommentDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
     $parent =& $commentDao->getById($parentId, $articleId);
     if (isset($parent) && $parent->getSubmissionId() != $articleId) {
         $request->redirect(null, null, 'view', array($articleId, $galleyId));
     }
     $this->validate($request, $articleId);
     $this->setupTemplate($request, $publishedArticle, $galleyId, $parent);
     // Bring in comment constants
     $enableComments = $journal->getSetting('enableComments');
     switch ($enableComments) {
         case COMMENTS_UNAUTHENTICATED:
             break;
         case COMMENTS_AUTHENTICATED:
         case COMMENTS_ANONYMOUS:
             // The user must be logged in to post comments.
             if (!$request->getUser()) {
                 Validation::redirectLogin();
             }
             break;
         default:
             // Comments are disabled.
             Validation::redirectLogin();
     }
     import('classes.comment.form.CommentForm');
     $commentForm = new CommentForm(null, $articleId, $galleyId, isset($parent) ? $parentId : null);
     $commentForm->initData();
     if (isset($args[3]) && $args[3] == 'save') {
         $commentForm->readInputData();
         if ($commentForm->validate()) {
             $commentForm->execute();
             // Send a notification to associated users
             import('classes.notification.NotificationManager');
             $notificationManager = new NotificationManager();
             $articleDao =& DAORegistry::getDAO('ArticleDAO');
             $article =& $articleDao->getArticle($articleId);
             $notificationUsers = $article->getAssociatedUserIds();
             foreach ($notificationUsers as $userRole) {
                 $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_USER_COMMENT, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId());
             }
             $request->redirect(null, null, 'view', array($articleId, $galleyId, $parentId), array('refresh' => 1));
         }
     }
     $commentForm->display();
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:57,代码来源:CommentHandler.inc.php

示例13: IntegerField

        $this->number = new IntegerField("Favorite number", 7, array(PhormValidation::Required));
        $this->message = new LargeTextField('Message', 5, 40, array(PhormValidation::Required));
        $this->notify = new BooleanField('Reply notification');
        $this->date = new DateTimeField('Date', array(PhormValidation::Required));
        // Add some help text
        $this->notify->set_help_text('Email me when my comment receives a response.');
        $this->email->set_help_text('We will never give out your email address.');
    }
    public function report()
    {
        var_dump($this->cleaned_data());
    }
}
// Set up the form
$post_id = 42;
$form = new CommentForm(Phorm::POST, false, array('post_id' => $post_id, 'notify' => true));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
		<title>Comment form</title>
		<script src="../src/javascript/scriptaculous/lib/prototype.js" type="text/javascript"></script>
		<script src="../src/javascript/scriptaculous/src/effects.js" type="text/javascript"></script>
		<script src="../src/javascript/validation.php" type="text/javascript"></script>
		<style type="text/css">
			form .phorm_help {
				margin: 0;
				padding: 2px;
				font-size: 10pt;
				font-style: oblique;
开发者ID:bistory,项目名称:phorms-ext,代码行数:31,代码来源:comment_form_ext.php

示例14: executeComment

 public function executeComment(sfWebRequest $request)
 {
     $comment = new Comment();
     $comment->setTicketId($request->getParameter('id'));
     $form = new CommentForm($comment);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('message', array('success', 'Отлично!', 'Комментарий добавлен.'));
         $comment = $form->save();
         $this->redirect('@tickets-show?id=' . $comment->getTicketId());
     } else {
         //$this->redirect('@tickets-show?id=' . $request->getParameter('id'));
         $this->form = $form;
     }
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:15,代码来源:actions.class.php

示例15: display

 /**
  * Display the form.
  */
 function display()
 {
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getById($this->reviewId);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('commentType', 'peerReview');
     $templateMgr->assign('pageTitle', 'submission.comments.review');
     $templateMgr->assign('commentAction', 'postPeerReviewComment');
     $templateMgr->assign('commentTitle', strip_tags($this->article->getScientificTitle()));
     $templateMgr->assign('isLocked', isset($reviewAssignment) && $reviewAssignment->getDateCompleted() != null);
     $templateMgr->assign('canEmail', false);
     // Previously, editors could always email.
     $templateMgr->assign('showReviewLetters', $this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR ? true : false);
     $templateMgr->assign('reviewer', ROLE_ID_REVIEWER);
     $templateMgr->assign('hiddenFormParams', array('articleId' => $this->article->getArticleId(), 'reviewId' => $this->reviewId));
     parent::display();
 }
开发者ID:elavaud,项目名称:hrp_ct,代码行数:20,代码来源:PeerReviewCommentForm.inc.php


注:本文中的CommentForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。