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


PHP Comment::setCommentText方法代码示例

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


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

示例1: wfCommentSubmit

function wfCommentSubmit($page_id, $parent_id, $comment_text)
{
    global $wgUser;
    // Blocked users cannot submit new comments
    if ($wgUser->isBlocked()) {
        return '';
    }
    if ($comment_text != '') {
        $comment = new Comment($page_id);
        $comment->setCommentText($comment_text);
        $comment->setCommentParentID($parent_id);
        $comment->add();
        if (class_exists('UserStatsTrack')) {
            $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName());
            $stats->incStatField('comment');
        }
    }
    return 'ok';
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:Comments_AjaxFunctions.php

示例2: testLongText

 /**
  * Extra test
  * Make sure that a long text is saved in the comment, one that has
  * at least more than 256 characters.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  */
 public function testLongText()
 {
     global $testTripId1, $testCommentId1;
     $longText = "This is a long text. This is a very long text. This is a ver, very long text. In fact, this text will just go on and on and on, for up to 400 characters. So when we set and retrieve this text, we will know for sure that the system supports these long texts. Of course, if this fails, we won't know any such thing for sure. Would that be to happen, we will have to go and spend some quality debugging time with the system.";
     $object = new Comment($testTripId1, $testCommentId1);
     $object->setCommentText($longText);
     $this->assertTrue($object->save());
     $object = new Comment($testTripId1, $testCommentId1);
     $this->assertEquals($longText, $object->getCommentText());
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:17,代码来源:CommentTest.php

示例3: connectToEncryptedMySQL

<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "comment.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini");
$comment = new Comment(null, 1, 2, "text", null);
$comment->insert($pdo);
$comment->setCommentText("More text");
$comment->update($pdo);
$comment->delete($pdo);
开发者ID:jfindley2,项目名称:amazon-product,代码行数:10,代码来源:comment-shakedown.php

示例4: errorResponse

    }
    if ($tripId === '' || $commentId === '') {
        $response = errorResponse(RESPONSE_BAD_REQUEST, 'Need tripId and commentId');
    } else {
        if (!$auth->canPutComment($tripId, $commentId)) {
            $response = errorResponse(RESPONSE_UNAUTHORIZED);
        } else {
            $object = new Comment($tripId, $commentId);
            if (isset($data['userId'])) {
                $object->setUserId($data['userId']);
            }
            if (isset($data['referenceId'])) {
                $object->setReferenceId($data['referenceId']);
            }
            if (isset($data['commentText'])) {
                $object->setCommentText($data['commentText']);
            }
            if (isset($data['deleted'])) {
                $object->setDeleted($data['deleted']);
            }
            if ($object->save()) {
                $response = successResponse();
            } else {
                // @codeCoverageIgnoreStart
                // cannot unit test database errors
                $response = errorResponse(RESPONSE_INTERNAL_ERROR);
                // @codeCoverageIgnoreEnd
            }
        }
    }
} else {
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:putComment.php

示例5: execute

 function execute()
 {
     global $wgUser, $wgOut, $wgVoteDirectory, $IP;
     require_once 'CommentClass.php';
     require_once "{$wgVoteDirectory}/VoteClass.php";
     require_once "{$wgVoteDirectory}/Publish.php";
     require_once "{$IP}/extensions/UserStats/UserStatsClass.php";
     $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName);
     // Vote for a Comment
     if ($_POST["mk"] == md5($_POST["cid"] . 'pants' . $wgUser->mName)) {
         if (is_numeric($_GET["Action"]) && $_GET["Action"] == 1 && is_numeric($_POST["cid"])) {
             if (is_numeric($_POST["cid"]) && is_numeric($_POST["vt"])) {
                 $dbr =& wfGetDB(DB_MASTER);
                 $sql = "SELECT comment_page_id,comment_user_id, comment_username FROM Comments WHERE CommentID = " . $_POST["cid"];
                 $res = $dbr->query($sql);
                 $row = $dbr->fetchObject($res);
                 if ($row) {
                     $PageID = $row->comment_page_id;
                     $Comment = new Comment($PageID);
                     $Comment->setUser($wgUser->mName, $wgUser->mId);
                     $Comment->CommentID = $_POST["cid"];
                     $Comment->setCommentVote($_POST["vt"]);
                     $Comment->setVoting($_POST["vg"]);
                     $Comment->addVote();
                     $out = $Comment->getCommentScore();
                     //must update stats for user doing the voting
                     $stats->incCommentScoreGiven($_POST["vt"]);
                     //also must update the stats for user receiving the vote
                     $stats_comment_owner = new UserStatsTrack(1, $row->comment_user_id, $row->comment_username);
                     $stats_comment_owner->updateCommentScoreRec($_POST["vt"]);
                     echo $out;
                 }
             }
         }
     }
     // get new Comment list
     if (is_numeric($_GET["Action"]) && $_GET["Action"] == 2 && is_numeric($_POST["pid"])) {
         $Comment = new Comment($_POST["pid"]);
         $Comment->setUser($wgUser->mName, $wgUser->mId);
         $Comment->setOrderBy($_POST["ord"]);
         if ($_POST["shwform"] == 1) {
             $output .= $Comment->displayOrderForm();
         }
         $output .= $Comment->display();
         if ($_POST["shwform"] == 1) {
             $output .= $Comment->diplayForm();
         }
         echo $output;
     }
     if ($_POST['ct'] != "" && is_numeric($_GET["Action"]) && $_GET["Action"] == 3) {
         $input = $_POST['ct'];
         $host = $_SERVER['SERVER_NAME'];
         $input = str_replace($host, "", $input);
         $AddComment = true;
         if ($AddComment == true) {
             $Comment = new Comment($_POST["pid"]);
             $Comment->setUser($wgUser->mName, $wgUser->mId);
             $Comment->setCommentText($_POST['ct']);
             $Comment->setCommentParentID($_POST['par']);
             $Comment->add();
             //$stats->incCommentCount();
             //score check after comment add
             $Vote = new Vote($_POST["pid"]);
             $publish = new Publish();
             $publish->PageID = $_POST["pid"];
             $publish->VoteCount = $Vote->count(1);
             $publish->CommentCount = $Comment->count();
             $publish->check_score();
         }
     }
     if (is_numeric($_GET["Action"]) && $_GET["Action"] == 4 && is_numeric($_GET["pid"])) {
         $Comment = new Comment($_GET["pid"]);
         $Comment->setUser($wgUser->mName, $wgUser->mId);
         echo $Comment->getLatestCommentID();
     }
     // This line removes the navigation and everything else from the
     // page, if you don't set it, you get what looks like a regular wiki
     // page, with the body you defined above.
     $wgOut->setArticleBodyOnly(true);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:80,代码来源:CommentAction.php

示例6: testUpdateValidComment

 /**
  * test inserting comment,editing it, then updating it
  *
  *
  */
 public function testUpdateValidComment()
 {
     // count the number of rows and save it
     $numRows = $this->getConnection()->getRowCount("comment");
     //create a new Comment and insert it into mySQL
     $comment = new Comment(null, $this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_COMMENTPHOTO, $this->VALID_COMMENTPHOTOTYPE, $this->VALID_COMMENTTEXT);
     $comment->insert($this->getPDO());
     //edit the profile and update it in mySQL
     $comment->setCommentText($this->VALID_COMMENTTEXT1);
     $comment->update($this->getPDO());
     // grab the data from mySQL and enforce the fields match expectations
     $pdoComment = Comment::getCommentByCommentId($this->getPDO(), $comment->getCommentId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("comment"));
     $this->assertSame($pdoComment->getTrailId(), $this->trail->getTrailId());
     $this->assertSame($pdoComment->getUserId(), $this->user->getUserId());
     $this->assertSame($pdoComment->getBrowser(), $this->VALID_BROWSER);
     $this->assertEquals($pdoComment->getCreateDate(), $this->VALID_CREATEDATE);
     $this->assertSame($pdoComment->getIpAddress(), $this->VALID_IPADDRESS);
     $this->assertSame($pdoComment->getCommentPhoto(), $this->VALID_COMMENTPHOTO);
     $this->assertSame($pdoComment->getCommentPhotoType(), $this->VALID_COMMENTPHOTOTYPE);
     $this->assertSame($pdoComment->getCommentText(), $this->VALID_COMMENTTEXT1);
 }
开发者ID:jmsaul,项目名称:open-trails,代码行数:27,代码来源:comment-test.php

示例7: testSynchGet

 /**
  * Test #11. SYNCH get an existent object.
  * @depends testDataWipedBeforeTest
  * @depends testGetExistent
  */
 public function testSynchGet()
 {
     global $synchAuthToken;
     global $testTripId1;
     global $testCommentId1;
     // Create the object and set attributes
     $object = new Comment($testTripId1, $testCommentId1);
     $object->setUserId('user');
     $object->setReferenceId('-reference-1');
     $object->setCommentText('Comment Text');
     $object->setDeleted('Y');
     // Save the object and confirm a row is added to the database
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $data = array('hash' => $object->getHash());
     $result = getApi('synchComment.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertTrue(isset($result['tripId']));
     $this->assertTrue(isset($result['commentId']));
     $this->assertTrue(isset($result['created']));
     $this->assertTrue(isset($result['updated']));
     $this->assertTrue(isset($result['userId']));
     $this->assertTrue(isset($result['referenceId']));
     $this->assertTrue(isset($result['commentText']));
     $this->assertTrue(isset($result['deleted']));
     $this->assertTrue(isset($result['hash']));
     $this->assertEquals($testTripId1, $result['tripId']);
     $this->assertEquals($testCommentId1, $result['commentId']);
     $this->assertEquals($object->getCreated(), $result['created']);
     $this->assertEquals($object->getUpdated(), $result['updated']);
     $this->assertEquals('user', $result['userId']);
     $this->assertEquals('-reference-1', $result['referenceId']);
     $this->assertEquals('Comment Text', $result['commentText']);
     $this->assertEquals('Y', $result['deleted']);
     $this->assertEquals($object->getHash(), $result['hash']);
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:41,代码来源:CommentApiTest.php

示例8: Comment

require_once '../database_access.php';
$comment = new Comment();
if (isset($_POST['creation_date'])) {
    $comment->setCreationDate($_POST['creation_date']);
}
if (isset($_POST['edit_date'])) {
    $comment->setEditDate($_POST['edit_date']);
}
if (isset($_POST['author_user_id'])) {
    $comment->setAuthorUserId($_POST['author_user_id']);
}
if (isset($_POST['target_event_id'])) {
    $comment->setTargetEventId($_POST['target_event_id']);
}
if (isset($_POST['comment_text'])) {
    $comment->setCommentText($_POST['comment_text']);
}
if (!$comment->validate()) {
    foreach ($comment->getValidationFailures() as $failure) {
        echo '<p><strong>Error in ' . $failure->getPropertyPath() . ' field!</strong> ' . $failure->getMessage() . '</p>';
    }
    unset($failure);
} else {
    $comment->save();
    // add the author name and return the JSON
    $comment_json = json_decode($comment->toJSON());
    $author = $comment->getAuthor();
    $comment_json->authorFirstName = $author->getFirstName();
    $comment_json->authorLastName = $author->getLastName();
    echo json_encode($comment_json);
}
开发者ID:Web-Systems-Development-Team,项目名称:RPIwannahangout,代码行数:31,代码来源:create_comment_ajax.php


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