本文整理汇总了PHP中CommentForm类的典型用法代码示例。如果您正苦于以下问题:PHP CommentForm类的具体用法?PHP CommentForm怎么用?PHP CommentForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommentForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: __
echo $comment['b_enabled'] == 1 ? 'DISABLE' : 'ENABLE';
?>
"><?php
echo $comment['b_enabled'] == 1 ? __('Disable') : __('Enable');
?>
</a> )
</div>
</div>
<div class="FormElement">
<label><div class="FormElementName"><?php
_e('Comment');
?>
</div></label>
<div class="FormElementInput">
<?php
CommentForm::body_input_textarea($comment);
?>
</div>
</div>
<div class="clear50"></div>
<div class="FormElement FormButtonsSubmit">
<div class="FormElementName"></div>
<div class="FormElementInput">
<input class="formButton" type="button" onclick="window.location='<?php
echo osc_admin_base_url(true);
?>
?page=comments';" value="<?php
_e('Cancel');
?>
开发者ID:randomecho,项目名称:OSClass,代码行数:31,代码来源:frm.php
示例16: _e
} else {
?>
<div class="no-comments">
<?php
_e('No comments', 'flatter');
?>
</div>
<?php
}
?>
<?php
if (osc_reg_user_post_comments() && osc_is_web_user_logged_in() || !osc_reg_user_post_comments()) {
?>
<!--<ul id="comment_error_list"></ul>-->
<?php
CommentForm::js_validation();
?>
<div class="post-comments">
<div class="comment clearfix">
<div class="pull-left avatar">
<?php
if (function_exists("profile_picture_show")) {
?>
<?php
current_user_picture();
?>
<?php
} else {
?>
<img class="img-responsive" src="http://www.gravatar.com/avatar/<?php
echo md5(strtolower(trim(osc_logged_user_email())));
开发者ID:abhi143u11,项目名称:ads,代码行数:31,代码来源:comments.php
示例17: CommentForm
/**
* I'm tired of writing comments!
* @return form for Comments
*/
public function CommentForm()
{
$siteconfig = $this->getCurrentSiteConfig();
$params = $this->getURLParams();
return CommentForm::create($this, 'CommentForm', $siteconfig, $params);
}
开发者ID:MilesSummers,项目名称:silverstripe-newsmodule,代码行数:10,代码来源:NewsHolderPage.php
示例18: Phorm_Field_URL
$this->url = new Phorm_Field_URL("Home page", 25, 255);
$this->number = new Phorm_Field_Integer("Favorite number", 20, 7, array('required'));
$this->message = new Phorm_Field_Textarea('Message', 5, 40, array('required'));
$this->notify = new Phorm_Field_Checkbox('Reply notification');
// Add some help text
$this->notify->help_text('Email me when my comment receives a response.');
$this->email->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('post', false, array('post_id' => $post_id, 'notify' => true));
// Check form validity
$valid = $form->is_valid();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Comment Form example for Phorm</title>
<link rel="stylesheet" href="assets/style.css" type="text/css" />
</head>
<body>
<h1>Add a comment</h1>
<?php
echo $form->open();
?>
开发者ID:jordanlev,项目名称:phorms,代码行数:31,代码来源:comment_form.php
示例19: sfWidgetFormTextarea
$this->setWidget('body', new sfWidgetFormTextarea());
$this->setValidator('body', new sfValidatorString(array('min_length' => 12)));
}
}
$configuration = $configuration->getApplicationConfiguration('frontend', 'test', true, null, $configuration->getEventDispatcher());
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
$enhancer = new sfFormYamlEnhancerTest($configuration->getConfigCache());
// ->enhance()
$t->diag('->enhance()');
$form = new CommentForm();
$form->bind(array('body' => '+1'));
$enhancer->enhance($form);
$t->like($form['body']->renderLabel(), '/Please enter your comment/', '->enhance() enhances labels');
$t->like($form['body']->render(), '/class="comment"/', '->enhance() enhances widgets');
$t->like($form['body']->renderError(), '/You haven\'t written enough/', '->enhance() enhances error messages');
$form = new CommentForm();
$form->bind();
$enhancer->enhance($form);
$t->like($form['body']->renderError(), '/A base required message/', '->enhance() considers inheritance');
class SpecialCommentForm extends CommentForm
{
}
$form = new SpecialCommentForm();
$form->bind();
$enhancer->enhance($form);
$t->like($form['body']->renderLabel(), '/Please enter your comment/', '->enhance() applies parent config');
$form = new BaseForm();
$form->embedForm('comment', new CommentForm());
$form->bind();
$enhancer->enhance($form);
$t->like($form['comment']['body']->renderLabel(), '/Please enter your comment/', '->enhance() enhances embedded forms');
开发者ID:kriswallsmith,项目名称:sfFormYamlEnhancementsPlugin,代码行数:31,代码来源:sfFormYamlEnhancerTest.php
示例20: add
function add($args)
{
$paperId = isset($args[0]) ? (int) $args[0] : 0;
$galleyId = isset($args[1]) ? (int) $args[1] : 0;
$parentId = isset($args[2]) ? (int) $args[2] : 0;
$conference =& Request::getConference();
$schedConf =& Request::getSchedConf();
$this->validate($paperId);
$paper =& $this->paper;
$parent =& $commentDao->getComment($parentId, $paperId);
if (isset($parent) && $parent->getPaperId() != $paperId) {
Request::redirect(null, null, null, 'view', array($paperId, $galleyId));
}
$this->setupTemplate($paper, $galleyId, $parent);
// Bring in comment constants
$commentDao =& DAORegistry::getDAO('CommentDAO');
$enableComments = $conference->getSetting('enableComments');
$commentsRequireRegistration = $conference->getSetting('commentsRequireRegistration');
$commentsAllowAnonymous = $conference->getSetting('commentsAllowAnonymous');
$closeCommentsDate = $schedConf->getSetting('closeCommentsDate');
$commentsClosed = $schedConf->getSetting('closeComments') ? true : false && strtotime($closeCommentsDate < time());
$enableComments = $enableComments && !$commentsClosed && $paper->getEnableComments();
if (!$enableComments) {
Request::redirect(null, null, 'index');
}
if ($commentsRequireRegistration && !Request::getUser()) {
Validation::redirectLogin();
}
import('comment.form.CommentForm');
$commentForm = new CommentForm(null, $paperId, $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('notification.Notification');
$paperDAO =& DAORegistry::getDAO('PaperDAO');
$paper =& $paperDAO->getPaper($paperId);
$notificationUsers = $paper->getAssociatedUserIds();
foreach ($notificationUsers as $userRole) {
$url = Request::url(null, null, null, 'view', array($paperId, $galleyId, $parentId));
Notification::createNotification($userRole['id'], "notification.type.userComment", $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_USER_COMMENT);
}
Request::redirect(null, null, null, 'view', array($paperId, $galleyId, $parentId), array('refresh' => 1));
}
}
$commentForm->display();
}
开发者ID:jalperin,项目名称:ocs,代码行数:49,代码来源:CommentHandler.inc.php
注:本文中的CommentForm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论