本文整理汇总了PHP中Comment::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::write方法的具体用法?PHP Comment::write怎么用?PHP Comment::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCommenterURLWrite
function testCommenterURLWrite()
{
$comment = new Comment();
// We only care about the CommenterURL, so only set that
// Check a http and https URL. Add more test urls here as needed.
$protocols = array('Http', 'Https');
$url = '://example.com';
foreach ($protocols as $protocol) {
$comment->CommenterURL = $protocol . $url;
// The protocol should stay as if, assuming it is valid
$comment->write();
$this->assertEquals($comment->CommenterURL, $protocol . $url, $protocol . ':// is a valid protocol');
}
}
示例2: create
public function create(Comment &$comment)
{
$this->validate();
$comment->validate();
if ($this->hasError() || $comment->hasError()) {
throw new ValidationException('Invalid thread or comment.');
}
$db = DB::conn();
$db->begin();
try {
$params = array('title' => $this->title, 'user_id' => $this->user_id, 'category_name' => $this->category);
$db->insert(self::TABLE_NAME, $params);
$comment->id = $db->lastInsertId();
$comment->write();
$db->commit();
} catch (PDOException $e) {
$db->rollback();
}
}
示例3: requireDefaultRecords
/**
* Migrates the old {@link PageComment} objects to {@link Comment}
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (DB::getConn()->hasTable('PageComment')) {
$comments = DB::query("SELECT * FROM \"PageComment\"");
if ($comments) {
while ($pageComment = $comments->nextRecord()) {
// create a new comment from the older page comment
$comment = new Comment();
$comment->update($pageComment);
// set the variables which have changed
$comment->BaseClass = 'SiteTree';
$comment->URL = isset($pageComment['CommenterURL']) ? $pageComment['CommenterURL'] : "";
$comment->write();
}
}
DB::alteration_message("Migrated PageComment to Comment", "changed");
DB::getConn()->dontRequireTable('PageComment');
}
}
示例4: create
/**
* Validate first the Thread & Comment.
* If both hasError() -> throw Exception
* Get title of Thread, Get Comment
* Insert to the Database.
* @param $comment
*/
public function create(Comment $comment)
{
$this->validate();
$comment->validate();
if ($this->hasError() || $comment->hasError()) {
throw new ValidationException('Invalid thread or comment');
}
$db = DB::conn();
try {
$db->begin();
$params = array('user_id' => $this->user_id, 'title' => $this->title);
$db->insert('thread', $params);
$this->id = $db->lastInsertId();
$comment->write($this->id);
$db->commit();
} catch (ValidationException $e) {
$db->rollback();
throw $e;
}
}
示例5: write
public function write()
{
$thread = Thread::getById(Param::get('thread_id'));
$comment = new Comment();
$page = Param::get('page_next', 'write');
switch ($page) {
case self::CURRENT_PAGE_WRITE:
break;
case self::RENDER_PAGE_AFTER_WRITE:
$comment->id = $thread->id;
$comment->user_id = get_authenticated_user_id($_SESSION['userid']);
$comment->body = Param::get('body');
try {
$comment->write();
} catch (ValidationException $e) {
$page = self::CURRENT_PAGE_WRITE;
}
break;
default:
throw new NotFoundException("{$page} is not found");
}
$this->set(get_defined_vars());
$this->render($page);
}
示例6: write
/**
* Get Thread thru id
* Write comment to existing Thread
*/
public function write()
{
$comment = new Comment();
$thread = Thread::get(Param::get('thread_id'));
$page = Param::get('page_next', 'write');
switch ($page) {
case 'write':
break;
case 'write_end':
try {
$comment->username = $_SESSION['username'];
$comment->body = Param::get('body');
$comment->write($thread->id);
} catch (ValidationException $a) {
$page = 'write';
}
break;
default:
throw new PageNotFoundException("{$page} is not found");
break;
}
$this->set(get_defined_vars());
$this->render($page);
}
示例7: __construct
/**
* @param Comment $comment Comment to generate this token for
*/
public function __construct($comment)
{
if (!$comment->SecretToken) {
$comment->SecretToken = $this->generate();
$comment->write();
}
$this->secret = $comment->SecretToken;
}
示例8: importComments
protected function importComments($item, $post)
{
$source = $item->getSource();
$client = $source->getClient();
$struct = new Struct(array('post_id' => $item->PostID, 'number' => 999999));
$comments = $client->call('wp.getComments', array($source->BlogId, $source->Username, $source->Password, $struct));
if ($comments) {
foreach ($comments as $data) {
$comment = new Comment();
$comment->BaseClass = "SiteTree";
$comment->Name = $data['author'];
$comment->Comment = $data['content'];
$comment->CommenterURL = $data['author_url'];
$comment->ParentID = $post->ID;
$comment->write();
$comment->Created = date('Y-m-d H:i:s', strtotime($data['date_created_gmt']));
$comment->write();
}
}
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-wordpressconnector,代码行数:20,代码来源:WordpressPostTransformer.php
示例9: testDefaultTemplateRendersHtmlWithAllowHtml
public function testDefaultTemplateRendersHtmlWithAllowHtml()
{
if (!class_exists('HTMLPurifier')) {
$this->markTestSkipped('HTMLPurifier class not found');
}
$origAllowed = Commenting::get_config_value('CommentableItem', 'html_allowed');
$item = new CommentableItem();
$item->write();
// Without HTML allowed
$comment = new Comment();
$comment->Comment = '<p>my comment</p>';
$comment->ParentID = $item->ID;
$comment->BaseClass = 'CommentableItem';
$comment->write();
$html = $item->customise(array('CommentsEnabled' => true))->renderWith('CommentsInterface');
$this->assertContains('<p>my comment</p>', $html);
Commenting::set_config_value('CommentableItem', 'html_allowed', true);
$html = $item->customise(array('CommentsEnabled' => true))->renderWith('CommentsInterface');
$this->assertContains('<p>my comment</p>', $html);
Commenting::set_config_value('CommentableItem', 'html_allowed', $origAllowed);
}