本文整理汇总了PHP中Comment::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::setContent方法的具体用法?PHP Comment::setContent怎么用?PHP Comment::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::setContent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveWithIdShouldReturnTrue
/**
* Test
*
* @return void
*/
public function testSaveWithIdShouldReturnTrue()
{
$this->object->setContent('test');
$this->object->setTemplateId(1);
$this->object->save();
$this->assertTrue($this->object->save());
$this->object->delete();
}
示例2: makeComment
private function makeComment(CommentFO $fo, $type, $typeId)
{
$user = Session::get('user');
$comment = new Comment();
$comment->setContent($fo->getComment());
$comment->setType($type);
$comment->setTypeId($typeId);
$comment->setDate(null);
$comment->setUserId($user->getId());
return $comment;
}
示例3: testPut
public function testPut()
{
$comment = new Comment();
$comment->setId(50);
$comment->setContent('Très bien');
$comment->setPostDate('2012-12-21 00:00:00');
$comment->setIdUser(1);
$comment->setIdAnnouncement(10);
$commentMapper = new CommentMapper();
$commentMapper->setId(50);
$commentMapper->updateComment($comment);
$this->assertEquals($comment, $commentMapper->selectComment());
}
示例4: commenter
/**
* Instancie un commentaire et fait appel au modèle du commentaire pour l'ajouter à la BD
*/
public function commenter()
{
$comment = new Comment();
$pseudo = Validate::_sanitString($_POST['pseudo']);
$content = Validate::_sanitString($_POST['commentaire']);
$titre = Validate::_sanitString($_POST['titreArticle']);
$comment->setPseudo($pseudo);
$comment->setContent($content);
$comment->setTitreArticle($titre);
MdlComment::addComment($comment);
$_REQUEST['action'] = null;
new Front();
}
示例5: add
/**
* Action to adds a comment to a post
*
* This method should only be called via HTTP POST.
*
* The user of the comment is taken from the {@link BaseController::currentUser}
* property.
* The expected HTTP parameters are:
* <ul>
* <li>id: Id of the post (via HTTP POST)</li>
* <li>content: Content of the comment (via HTTP POST)</li>
* </ul>
*
* The views are:
* <ul>
* <li>posts/view?id=post: If comment was successfully added of,
* or if it was not validated (via redirect). Includes these view variables:</li>
* <ul>
* <li>errors (flash): Array including per-field validation errors</li>
* <li>comment (flash): The current Comment instance, empty or being added</li>
* </ul>
* </ul>
*
* @return void
*/
public function add()
{
if (!isset($this->currentUser)) {
throw new Exception("Not in session. Adding posts requires login");
}
if (isset($_POST["id"])) {
// reaching via HTTP Post...
// Get the Post object from the database
$postid = $_POST["id"];
$post = $this->postmapper->findById($postid);
// Does the post exist?
if ($post == NULL) {
throw new Exception("no such post with id: " . $postid);
}
// Create and populate the Comment object
$comment = new Comment();
$comment->setContent($_POST["content"]);
$comment->setAuthor($this->currentUser);
$comment->setPost($post);
try {
// validate Comment object
$comment->checkIsValidForCreate();
// if it fails, ValidationException
// save the Comment object into the database
$this->commentmapper->save($comment);
// POST-REDIRECT-GET
// Everything OK, we will redirect the user to the list of posts
// We want to see a message after redirection, so we establish
// a "flash" message (which is simply a Session variable) to be
// get in the view after redirection.
$this->view->setFlash("Comment \"" . $post->getTitle() . "\" successfully added.");
// perform the redirection. More or less:
// header("Location: index.php?controller=posts&action=view&id=$postid")
// die();
$this->view->redirect("posts", "view", "id=" . $post->getId());
} catch (ValidationException $ex) {
$errors = $ex->getErrors();
// Go back to the form to show errors.
// However, the form is not in a single page (comments/add)
// It is in the View Post page.
// We will save errors as a "flash" variable (third parameter true)
// and redirect the user to the referring page
// (the View post page)
$this->view->setVariable("comment", $comment, true);
$this->view->setVariable("errors", $errors, true);
$this->view->redirect("posts", "view", "id=" . $post->getId());
}
} else {
throw new Exception("No such post id");
}
}
示例6: executeInsertComment
function executeInsertComment(sfWebRequest $request)
{
$name = $request->getParameter('author');
$content = $request->getParameter('content');
$article_id = $request->getParameter('article_id');
$comment = new Comment();
$comment->setAuthor($name);
$comment->setContent($content);
$comment->setArticleId($article_id);
$comment->save();
echo 'ok';
$this->redirect('view/showComments?id=' . $article_id);
//$this->redirect("view/ShowComments",$comment);
}
示例7: add
/**
* Metodo del controlador Comments cuya funcionalidad es insertar un comentario
* en un post.
* Verifica que el usuario ha iniciado sesion y que el post existe
*
* @throws Exception Si el usuario no inicio sesion
* @return void
*/
public function add()
{
if (!isset($this->currentUser)) {
throw new Exception("Not in session. Adding comments requires login");
}
if (isset($_GET["id"])) {
// reaching via HTTP Post...
// Se obtiene el post de la BD
$idPost = $_GET["id"];
$post = $this->postDAO->findByIdPost($idPost);
// Si no existe el post lanza una excepcion
if ($post == NULL) {
throw new Exception("no such post with id: " . $idPost);
}
// Crea el objeto Comment
$comment = new Comment();
$comment->setDate(date("Y-m-d H:i:s"));
$comment->setContent($_POST["content"]);
$comment->setAuthor($this->currentUser->getEmail());
$comment->setIdPost($post->getIdPost());
try {
// Valida el comentario, si falla lanza una excepcion
$comment->checkIsValidForCreate();
// Guarda el comentario en la BD
$this->commentDAO->save($comment);
// Redirige al post
$this->view->redirect("posts", "viewPosts", "id=" . $post->getIdPost());
} catch (ValidationException $ex) {
$errors = $ex->getErrors();
$this->view->setVariable("comment", $comment, true);
$this->view->setVariable("errors", $errors, true);
$this->view->redirect("posts", "viewPosts", "id=" . $post->getIdPost());
}
} else {
throw new Exception("No such post id");
}
}
示例8: alias
$nbArticles = $finder->count();
$t->is($nbArticles, 2, 'join() allows to join to another table using an alias (many-to-one)');
$t->is($finder->getLatestQuery(), propel_sql('SELECT COUNT([P13*][P12article.ID]) FROM article INNER JOIN category c ON (article.CATEGORY_ID=c.ID) WHERE c.NAME=\'cat1\''), 'join() uses aliased table names when using an alias relation');
ArticlePeer::doDeleteAll();
CommentPeer::doDeleteAll();
$article1 = new Article();
$article1->setTitle('aaaaa');
$article1->setCategory($category1);
$article1->save();
$article2 = new Article();
$article2->setTitle('bbbbb');
$article2->setCategory($category1);
$article2->save();
$comment = new Comment();
$comment->setContent('foo');
$comment->setArticleId($article2->getId());
$comment->save();
$finder = sfPropelFinder::from('Article')->
join('Comment c', 'Article.Id', 'c.ArticleId', 'INNER JOIN')->
where('c.Content', 'foo');
$nbArticles = $finder->count();
$t->is($nbArticles, 1, 'join() allows to join to another table using an alias (one-to-many)');
$t->is($finder->getLatestQuery(), propel_sql('SELECT COUNT([P13*][P12article.ID]) FROM article INNER JOIN comment c ON (article.ID=c.ARTICLE_ID) WHERE c.CONTENT=\'foo\''), 'join() uses aliased table names when using an alias relation');
/*************************************************************/
/* sfPropelFinder::join($classAndAlias, $start, $end, $type) and subsequent finder method calls */
/*************************************************************/
$t->diag('sfPropelFinder::join() and subsequent finder method calls');
示例9: createComment
public function createComment($postId, $data)
{
$currentUser = parent::authenticateUser();
$post = $this->postMapper->findById($postId);
if ($post == NULL) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad request');
echo "Post with id " . $postId . " not found";
}
$comment = new Comment();
$comment->setContent($data->content);
$comment->setAuthor($currentUser);
$comment->setPost($post);
try {
$comment->checkIsValidForCreate();
// if it fails, ValidationException
$this->commentMapper->save($comment);
header($_SERVER['SERVER_PROTOCOL'] . ' 201 Created');
} catch (ValidationException $e) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad request');
echo json_encode($e->getErrors());
}
}
示例10: Comment
<?php
include 'control/ArticleControls.php';
include_once 'business/Comment.php';
$comment = new Comment();
$control = new ArticleControls();
$comment->setTitle($_POST['title']);
$comment->setContent($_POST['content']);
$comment->setUser_name($_POST['name']);
$comment->setNews_id($_POST['id']);
$comment->setIp($_POST['ip']);
if ($control->addComment($comment)) {
header("location:../news.php?art_id=" . $_POST['id']);
} else {
echo "La requête n'a pu être exécutée";
}