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


PHP Comment::load方法代码示例

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


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

示例1: viewComments

function viewComments($dvd = 0)
{
    $dbh = new Database();
    $sth = $dbh->prepare("SELECT id FROM " . DB_PREFIX . "comments WHERE dvd = ? ORDER BY id DESC");
    $sth->execute(array($dvd));
    $commentCount = 0;
    while ($id = $sth->fetchColumn()) {
        $commentCount++;
        $comment = new Comment();
        $comment->load($id);
        include '../views/showDVD/singleComment.php';
    }
}
开发者ID:jtiala,项目名称:xqdvd,代码行数:13,代码来源:showDVD.php

示例2: addOrUpdateComment

 /**
  *   addOrUpdateComment.
  *
  *   Updates or creates a Comment
  *
  *   @param array $comment
  *
  *   @return Comment $obj with User relationship loaded
  */
 public function addOrUpdateComment(array $comment)
 {
     $obj = new Comment();
     $obj->text = $comment['text'];
     $obj->user_id = $comment['user']['id'];
     $obj->doc_id = $this->doc_id;
     if (isset($comment['id'])) {
         $obj->id = $comment['id'];
     }
     $obj->parent_id = $this->id;
     $obj->save();
     $obj->load('user');
     return $obj;
 }
开发者ID:krues8dr,项目名称:madison,代码行数:23,代码来源:Comment.php

示例3: load

 public function load($iCommentID)
 {
     $connection = new Connection();
     $sSQL = "SELECT CommentID, Comment, UserID, RecipeID, CreatedAt, OriginalID\n                     FROM tbcomment\n                     WHERE CommentID=" . $iCommentID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store data into attributes:
     $this->iCommentID = $row["CommentID"];
     $this->sComment = $row["Comment"];
     $this->iUserID = $row["UserID"];
     $this->iRecipeID = $row["RecipeID"];
     $this->tCreatedAt = $row["CreatedAt"];
     $this->iOriginalID = $row["OriginalID"];
     $sSQL = "SELECT CommentID \n                    FROM tbcomment\n                    WHERE OriginalID=" . $iCommentID;
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iCommentID = $row["CommentID"];
         $oComment = new Comment();
         $oComment->load($iCommentID);
         $this->aReplies[] = $oComment;
     }
     $connection->close_connection();
 }
开发者ID:leanne-abarro,项目名称:getInMyBelly,代码行数:23,代码来源:comments.php

示例4: load

 public function load($iRecipeID)
 {
     $connection = new Connection();
     $sSQL = "SELECT RecipeID, Title, AuthorNotes, Ingredients, Directions, ImagePath, CreatedAt, UserID, RecipeTypeID\n                     FROM tbrecipe\n                     WHERE RecipeID = " . $iRecipeID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store into attributes:
     $this->iRecipeID = $row["RecipeID"];
     $this->sTitle = $row["Title"];
     $this->sAuthorNotes = $row["AuthorNotes"];
     $this->sIngredients = $row["Ingredients"];
     $this->sDirections = $row["Directions"];
     $this->sImagePath = $row["ImagePath"];
     $this->tCreatedAt = $row["CreatedAt"];
     $this->iUserID = $row["UserID"];
     $this->iRecipeTypeID = $row["RecipeTypeID"];
     // get all likes from recipe:
     $sSQL = "SELECT LikeID\n                     FROM tblike\n                     WHERE RecipeID = " . $iRecipeID;
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iLikeID = $row["LikeID"];
         $oLike = new Like();
         $oLike->load($iLikeID);
         $this->aLikes[] = $iLikeID;
     }
     // get all comments on a recipe:
     $sSQL = "SELECT CommentID\n                    FROM tbcomment\n                    WHERE RecipeID = " . $iRecipeID . " ORDER BY CreatedAt DESC";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iCommentID = $row["CommentID"];
         $oComment = new Comment();
         $oComment->load($iCommentID);
         $this->aComments[] = $oComment;
     }
     $connection->close_connection();
 }
开发者ID:leanne-abarro,项目名称:getInMyBelly,代码行数:36,代码来源:recipe.php

示例5: Comment

<?php

#1. LOGIC
Auth::kickout('/pokecart/');
$comment = new Comment();
$comment->load(Route::param('id'));
if ($comment->user_id == Auth::user_id()) {
    if (Input::posted()) {
        $comment->content = Input::get('message');
        $comment->save();
        URL::restore();
    }
}
Sticky::set('message', $comment->content);
#2. LOAD VIEWS
include VIEWS . 'header.php';
include VIEWS . 'edit_comment.php';
include VIEWS . 'footer.php';
开发者ID:sean01,项目名称:pokecart,代码行数:18,代码来源:edit_comment.php

示例6: trim

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* @author [creator, or "Original Author"]
* @license http://bit.ly/aVWqRV PayAsYouGo License
* @copyright Copyright (c) 2010 Broadband Mechanics
* @package PeopleAggregator
*/
$login_required = TRUE;
$use_theme = 'Beta';
//TODO : Remove this when new UI is completely implemented.
include_once "web/includes/page.php";
require_once "api/Comment/Comment.php";
require_once "api/Permissions/PermissionsHandler.class.php";
if ($_GET['comment_id']) {
    $comment_id = trim($_GET['comment_id']);
    $comment = new Comment();
    $comment->load($comment_id);
    if ($comment->parent_type == TYPE_USER) {
        $recipient_id = $comment->parent_id;
        $redirect_url = PA::$url . PA_ROUTE_USER_PUBLIC . "/" . $comment->parent_id;
    } else {
        if ($comment->parent_type == TYPE_CONTENT) {
            $redirect_url = PA::$url . PA_ROUTE_CONTENT . "/cid=" . $comment->content_id;
        } else {
            if (!empty($_REQUEST['back_page'])) {
                $redirect_url = $_REQUEST['back_page'];
            }
        }
    }
    $cid = $comment->content_id;
    //Content id for which comment has been posted.
    $params = array('comment_info' => array('user_id' => $comment->user_id, 'content_id' => $comment->content_id, 'recipient_id' => $recipient_id), 'permissions' => 'delete_comment');
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:deletecomment.php

示例7: render_main_page_area

function render_main_page_area($user)
{
    global $admin_password;
    $page_url = PA::$url . "/comment_management.php";
    $paging_url = "{$page_url}?";
    // url to pass to the pager object
    $msg = "";
    $path_info = @$_SERVER['PATH_INFO'];
    // see if the user is logged in as an admin
    if ($path_info == "/login") {
        if (@$_REQUEST['admin_password'] == $admin_password) {
            $_SESSION['comment_management_is_admin'] = TRUE;
        } else {
            $msg = "Incorrect password!  Try again...";
        }
    } else {
        if ($path_info == "/logout") {
            $_SESSION['comment_management_is_admin'] = FALSE;
            $msg = "You are now logged out (of admin mode).";
        }
    }
    $is_admin = @$_SESSION['comment_management_is_admin'];
    $limit_set = NULL;
    // set this to an array with keys 'comment_id' to limit display to those keys
    $current_search_terms = NULL;
    // current search terms
    switch ($path_info) {
        case '/analyze_comment':
            $comment_id = (int) @$_REQUEST['comment'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can analyze comments at the moment :(";
            } elseif ($comment_id) {
                $cmt = new Comment();
                $cmt->load($comment_id);
                $cmt->index_spam_domains();
                $msg = "<p>Analysis of comment {$comment_id}:</p><hr/><p>" . nl2br(htmlspecialchars($cmt->comment)) . "</p><hr/><ul>";
                $hosts = $cmt->get_link_hosts();
                foreach ($hosts as $domain => $links) {
                    $msg .= "<li><b>" . htmlspecialchars($domain) . "</b> (<a href=\"{$page_url}/analyze_domain?domain=" . htmlspecialchars($domain) . "\">analyze</a>): ";
                    $dom = new SpamDomain($domain);
                    if ($dom->blacklisted) {
                        $msg .= " BLACKLISTED";
                    }
                    $msg .= "<ul>";
                    foreach ($links as $link) {
                        list($url, $linktexts) = $link;
                        $msg .= "<li>" . htmlspecialchars($url) . " -> " . implode(" | ", array_map("htmlspecialchars", $linktexts)) . "</li>";
                    }
                    $msg .= "</ul></li>";
                }
                $msg .= "</ul><hr/>";
            }
            break;
        case '/search':
            $current_search_terms = @$_REQUEST['q'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can search comments at the moment :(";
            } elseif ($current_search_terms) {
                $paging_url = "{$page_url}/search?q=" . urlencode($current_search_terms) . "&";
                $limit_set = Comment::search($current_search_terms);
            }
            break;
        case '/stats':
            $msg = "<p>Stats:</p>";
            list($n) = Dal::query_one("SELECT COUNT(*) FROM {comments}");
            list($n_deleted) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=0");
            $n_active = $n - $n_deleted;
            $msg .= "<li>{$n} comments ({$n_active} active / {$n_deleted} deleted)</li>";
            list($n_ham) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=1 AND spam_state=0");
            $n_spam = $n_active - $n_ham;
            $msg .= "<li>{$n_spam} active+spam / {$n_ham} active+not spam</li>";
            list($n_no_class) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=1 AND akismet_spam IS NULL");
            $msg .= "<li>{$n_no_class} active comments not (yet?) classified by Akismet</li>";
            list($n_akismet_del) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=0 AND akismet_spam=1");
            $msg .= "<li>{$n_akismet_del} comments flagged as spam by akismet and deleted</li>";
            break;
        case '/add_spam_term':
            $spam_term = @$_REQUEST['term'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can add spam terms at the moment.";
            } elseif ($spam_term) {
                // find the comments
                $matches = Comment::search($spam_term);
                $n_deleted = count($matches);
                // add the term
                Comment::add_spam_term($spam_term);
                // and delete the comments
                $blk_size = 1000;
                $F_fetch_ids = create_function('$item', 'return $item["comment_id"];');
                for ($i = 0; $i < count($matches); $i += $blk_size) {
                    Comment::set_spam_state(array_map($F_fetch_ids, array_slice($matches, $i, $blk_size)), SPAM_STATE_SPAM_WORDS);
                }
                $msg = "Added <b>" . htmlspecialchars($spam_term) . '</b> to the spam term database, and deleted ' . $n_deleted . ' comments containing it.';
            }
            break;
        case '/analyze_domain':
            $domain = @$_REQUEST['domain'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can analyze domains.";
            } else {
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:101,代码来源:comment_management.php

示例8: testLoadExistent

 /**
  * test #9.
  * Loading a valid, existing key overrides all the attributes with the
  * loaded values. The load() function returns true, indicating that
  * data was found.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  */
 public function testLoadExistent()
 {
     global $testTripId1, $testCommentId1, $testUserId1;
     global $testTripId2, $testCommentId2, $testUserId2;
     // create a first instance
     $object = new Comment($testTripId1, $testCommentId1);
     $object->setUserId($testUserId1);
     $object->setReferenceId('-test-reference-id-1');
     $object->setCommentText('comment text');
     $object->setDeleted('Y');
     $object->save();
     $this->assertEquals(1, $this->countTestRows());
     // Get the automatically created attributes for this instance
     $created1 = $object->getCreated();
     $updated1 = $object->getUpdated();
     $hash1 = $object->getHash();
     // create a second instance
     $object = new Comment($testTripId2, $testCommentId2);
     $object->setUserId($testUserId2);
     $object->setReferenceId('-test-reference-id-2');
     $object->setCommentText('comment text 2');
     $object->setDeleted('N');
     $object->save();
     $this->assertEquals(2, $this->countTestRows());
     // Get the automatically created attributes for this instance, and
     // make sure they are different from those of the first instance.
     $created2 = $object->getCreated();
     $updated2 = $object->getUpdated();
     $hash2 = $object->getHash();
     $this->assertNotEquals($created1, $created2);
     $this->assertNotEquals($updated1, $updated2);
     $this->assertNotEquals($hash1, $hash2);
     // Load the first object, which overrides all the attributes
     $this->assertTrue($object->load($testTripId1, $testCommentId1));
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testCommentId1, $object->getCommentId());
     $this->assertEquals($created1, $object->getCreated());
     $this->assertEquals($updated1, $object->getUpdated());
     $this->assertEquals($testUserId1, $object->getUserId());
     $this->assertEquals('-test-reference-id-1', $object->getReferenceId());
     $this->assertEquals('comment text', $object->getCommentText());
     $this->assertEquals('Y', $object->getDeleted());
     $this->assertEquals($hash1, $object->getHash());
     // Load the second object, which overrides all the attributes
     $this->assertTrue($object->load($testTripId2, $testCommentId2));
     $this->assertEquals($testTripId2, $object->getTripId());
     $this->assertEquals($testCommentId2, $object->getCommentId());
     $this->assertEquals($created2, $object->getCreated());
     $this->assertEquals($updated2, $object->getUpdated());
     $this->assertEquals($testUserId2, $object->getUserId());
     $this->assertEquals('-test-reference-id-2', $object->getReferenceId());
     $this->assertEquals('comment text 2', $object->getCommentText());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals($hash2, $object->getHash());
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:63,代码来源:CommentTest.php

示例9: list

{
    list($remaining) = Dal::query_one("SELECT COUNT(*) FROM comments WHERE is_active=1 AND akismet_spam IS NULL");
    return (int) $remaining;
}
echo "Looking for comments which have not been checked for spam yet.\n";
$ct = get_remaining();
echo "... {$ct} comments to check.  Checking them...\n";
$checked = 0;
while ($checked < $ct) {
    $remaining = get_remaining();
    echo "Progress: {$checked} checked out of total {$ct} (remaining: {$remaining})\n";
    if (!$remaining) {
        echo "No comments left to classify!\n";
        break;
    }
    $sth = Dal::query("SELECT comment_id FROM comments WHERE is_active=1 AND akismet_spam IS NULL LIMIT 10");
    while ($r = Dal::row($sth)) {
        list($comment_id) = $r;
        echo "- checking comment {$comment_id}... ";
        flush();
        $c = new Comment();
        $c->load((int) $comment_id);
        if (!$c->homepage) {
            $c->homepage = "";
        }
        $c->akismet_check();
        echo var_export($c->akismet_spam, TRUE) . "\n";
        ++$checked;
        sleep(1);
    }
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:check_new_comments_for_spam.php

示例10: testAddDeleteContentComments

 function testAddDeleteContentComments()
 {
     //    Dal::register_query_callback("explain_query");
     echo "getting a user\n";
     $user = Test::get_test_user();
     echo "test user = {$user->first_name} {$user->last_name}\n";
     echo "adding some content\n";
     $post = new BlogPost();
     $post->author_id = $user->user_id;
     $post->parent_collection_id = -1;
     $post->title = "Test blog post (from testAddDeleteContentComments)";
     $post->body = "<p>This is the post body!</p><p>Foo <b>foo</b> foo</p>";
     $post->allow_comments = 1;
     $post->is_active = 1;
     $post->display_on = DISPLAY_ON_HOMEPAGE;
     $post->save();
     echo "... saved as content_id={$post->content_id}\n";
     echo "testing that it is retrievable\n";
     $post_retr = Content::load_content($post->content_id, $user->user_id);
     $this->assertEquals($post_retr->content_id, $post->content_id);
     $this->assertEquals($post_retr->title, $post->title);
     $this->assertEquals($post_retr->body, $post->body);
     $this->assertEquals($post_retr->author_id, $user->user_id);
     $this->assertEquals($post_retr->is_active, 1);
     echo "posting a comment\n";
     $cmt = new Comment();
     $cmt->content_id = $post->content_id;
     $cmt_comment = "This is an automatic comment - on an autogenerated post";
     $cmt->comment = $cmt_comment;
     $cmt->user_id = $user->user_id;
     $cmt->name = $cmt->email = $cmt->homepage = '';
     $cmt->ip_addr = '127.0.0.1';
     $cmt->referrer = 'http://example.com/';
     $cmt->user_agent = 'phpunit auto-test';
     $cmt->save();
     echo "... saved as comment_id={$cmt->comment_id}\n";
     echo "testing that the comment is retrievable\n";
     $cmt_retr = new Comment();
     $cmt_retr->load($cmt->comment_id);
     $this->assertEquals($cmt_retr->comment_id, $cmt->comment_id);
     $this->assertEquals($cmt_retr->content_id, $post->content_id);
     $this->assertEquals($cmt_retr->comment, $cmt_comment);
     $this->assertEquals($cmt_retr->is_active, 1);
     echo "testing that we see one comment on the post\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     echo count($comments) . " comments\n";
     //var_dump($comments);
     $this->assertEquals(count($comments), 1);
     echo "testing that we have no trackbacks on the post\n";
     $trackbacks = Content::get_trackbacks_for_content($post->content_id);
     echo count($trackbacks) . " trackbacks\n";
     //var_dump($trackbacks);
     $this->assertEquals(count($trackbacks), 0);
     echo "posting ANOTHER comment\n";
     $cmt2 = new Comment();
     $cmt2->content_id = $post->content_id;
     $cmt2_comment = "This is ANOTHER automatic comment - on the same autogenerated post";
     $cmt2->comment = $cmt_comment;
     $cmt2->user_id = $user->user_id;
     $cmt2->name = $cmt2->email = $cmt2->homepage = '';
     $cmt2->ip_addr = '127.0.0.1';
     $cmt2->referrer = 'http://example.com/';
     $cmt2->user_agent = 'phpunit auto-test';
     $cmt2->save();
     echo "... saved as comment_id={$cmt2->comment_id}\n";
     echo "testing that we see two comments on the post\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     $this->assertEquals(count($comments), 2);
     echo "deleting the first comment\n";
     $cmt_retr->delete();
     echo "testing that we see one comment on the post again (not seeing the deleted one)\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     $this->assertEquals(count($comments), 1);
     echo "testing that the first comment (now deleted) is not retrievable\n";
     $cmt_retr_fail = new Comment();
     try {
         $cmt_retr_fail->load($cmt->comment_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
     }
     echo "deleting the post\n";
     Content::delete_by_id($post->content_id);
     echo "testing that the post is not retrievable\n";
     try {
         $post_retr_fail = Content::load_content($post->content_id, $user->user_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), CONTENT_NOT_FOUND);
     }
     echo "testing that the last comment is not retrievable\n";
     $cmt_retr_fail = new Comment();
     try {
         $cmt_retr_fail->load($cmt->comment_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
//.........这里部分代码省略.........
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:101,代码来源:ContentCommentsTest.php

示例11: show

 function show()
 {
     $comment = Comment::load('Comment', $this->parameters['id']);
     $this->redirect('/posts/' . $comment->post_id . '#' . $comment->id);
 }
开发者ID:jpic,项目名称:Jetfuel,代码行数:5,代码来源:CommentsController.php


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