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


PHP Comment::set方法代码示例

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


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

示例1: addComment

 public function addComment(Comment $comment)
 {
   $comment->set('record_model', $this->_invoker->getTable()->getComponentName());
   $comment->set('record_id', $this->_invoker->get('id'));
   $comment->save();
   
   return $this->_invoker;
 }
开发者ID:nacef,项目名称:ijani,代码行数:8,代码来源:Commentable.php

示例2: getList

 function getList($pagina = 1, $nrpp = Contants::NRPP)
 {
     $registroIni = ($pagina - 1) * $nrpp;
     $r = array();
     $this->bd->select($this->tabla, "*", "1=1", array(), "ID_comment", "{$registroIni}, {$nrpp}");
     while ($row = $this->bd->getRow()) {
         $comment = new Comment();
         $comment->set($row);
         $r[] = $comment;
     }
     return $r;
 }
开发者ID:jRosales87,项目名称:Blog,代码行数:12,代码来源:ManageComment.php

示例3: Exception

 function add_comment()
 {
     $this->assertLoggedIn();
     try {
         $this->setTitle('Add Comment');
         $content_id = $this->args('content_id');
         $content_type = $this->args('content_type');
         $content = Comment::getContent($content_id, $content_type);
         if (!is_object($content)) {
             throw new Exception("That content does not exist.");
         }
         if (!$content->isHydrated()) {
             throw new Exception("That content does not exist.");
         }
         if (!$content->canComment()) {
             throw new Exception("You cannot comment on this content.");
         }
         $form = $this->_createAddCommentForm($content_id, $content_type);
         //handle our form
         if ($form->checkSubmitAndValidate($this->args())) {
             $comment = new Comment();
             $comment->set('content_id', $form->data('content_id'));
             $comment->set('content_type', $form->data('content_type'));
             $comment->set('comment', $form->data('comment'));
             $comment->set('user_id', User::$me->id);
             $comment->set('comment_date', date("Y-m-d H:i:s"));
             $comment->save();
             Activity::log("commented on " . $content->getLink() . ".");
             $this->forwardToUrl($content->getUrl());
         }
         $this->set('form', $form);
     } catch (Exception $e) {
         $this->setTitle('Add Comment - Error');
         $this->set('megaerror', $e->getMessage());
     }
 }
开发者ID:JoonasMelin,项目名称:BotQueue,代码行数:36,代码来源:comment.php

示例4: save

        public function save()
	{
	    $form = Form::load('logbook.views.AddBlogComment');
            $capval = Captcha::validate();

	    if($form->validate()&&$capval)
	    {
	        Application::alterParam('comment_content',strip_tags(Application::param('comment_content')));
	        $item = new Comment();
		$item->parse();
                $item->set('comment_date',date('Y-m-d H:M:S'));
                $item->setSafe('author_id',Logbook::current()->authorId());
		$item->save();

                Application::setParam('author_id',Application::param('author_id'));
		Application::setParam('entry_id',Application::param('entry_id'));
		$this->redirectOnSave();
	    }
	}
开发者ID:k7n4n5t3w4rt,项目名称:SeeingSystem,代码行数:19,代码来源:add_blog_comment.class.php

示例5: tool_create_sample_comments

/**
 * Create sample comments and display a process of creating
 *
 * @param integer Blog ID
 * @param integer Number of comments
 * @param integer Number of posts
 */
function tool_create_sample_comments($blog_ID, $num_comments, $num_posts)
{
    global $DB, $posttypes_specialtypes, $localtimenow, $Hit, $Messages, $Debuglog;
    $BlogCache =& get_BlogCache();
    $selected_Blog = $BlogCache->get_by_ID($blog_ID, false, false);
    if ($selected_Blog == NULL) {
        // Incorrect blog ID, Exit here
        return;
    }
    echo T_('Creating of the sample comments...');
    evo_flush();
    /**
     * Disable log queries because it increases the memory and stops the process with error "Allowed memory size of X bytes exhausted..."
     */
    $DB->log_queries = false;
    $curr_orderby = $selected_Blog->get_setting('orderby');
    if ($curr_orderby == 'RAND') {
        $curr_orderby .= '()';
    } else {
        $curr_orderby = 'post_' . $curr_orderby;
    }
    $curr_orderdir = $selected_Blog->get_setting('orderdir');
    // find the $num_posts latest posts in blog
    $SQL = new SQL();
    $SQL->SELECT('post_ID');
    $SQL->FROM('T_items__item');
    $SQL->FROM_add('INNER JOIN T_categories ON post_main_cat_ID = cat_ID');
    $SQL->WHERE('cat_blog_ID = ' . $DB->quote($blog_ID));
    $SQL->WHERE_and('post_status = ' . $DB->quote('published'));
    // Set condition to not create sample comments for special posts
    $SQL->WHERE_and('post_ptyp_ID NOT IN ( ' . $DB->quote($posttypes_specialtypes) . ' )');
    $SQL->ORDER_BY($curr_orderby . ' ' . $curr_orderdir . ', post_ID ' . $curr_orderdir);
    $SQL->LIMIT($num_posts);
    $items_result = $DB->get_results($SQL->get(), ARRAY_A, 'Find the x latest posts in blog');
    $count = 1;
    $fix_content = 'This is an auto generated comment for testing the moderation features.
					http://www.test.com/test_comment_';
    // go through on selected items
    foreach ($items_result as $row) {
        $item_ID = $row['post_ID'];
        $ItemCache =& get_ItemCache();
        $commented_Item =& $ItemCache->get_by_ID($item_ID);
        // create $num_comments comments for each item
        for ($i = 0; $i < $num_comments; $i++) {
            $author = 'Test ' . $count;
            $email = 'test_' . $count . '@test.com';
            $url = 'http://www.test-' . rand(1, 3) . '.com/test_comment_' . $count;
            $content = $fix_content . $count;
            for ($j = 0; $j < 50; $j++) {
                // create 50 random word
                $length = rand(1, 15);
                $word = generate_random_key($length, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
                $content = $content . ' ' . $word;
            }
            // create and save a new comment
            $Comment = new Comment();
            $Comment->set_Item($commented_Item);
            $Comment->set('status', 'draft');
            $Comment->set('author', $author);
            $Comment->set('author_email', $email);
            $Comment->set('author_url', $url);
            $Comment->set('content', $content);
            $Comment->set('date', date('Y-m-d H:i:s', $localtimenow));
            $Comment->set('author_IP', $Hit->IP);
            $Comment->dbsave();
            $count++;
            if ($count % 100 == 0) {
                // Display a process of creating by one dot for 100 comments
                echo ' .';
                evo_flush();
            }
            // Clear all debug messages, To avoid an error about full memory
            $Debuglog->clear('all');
        }
    }
    echo ' OK.';
    $Messages->add(sprintf(T_('Created %d comments.'), $count - 1), 'success');
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:85,代码来源:_tool.funcs.php

示例6: xmlrpcs_new_comment

/**
 * Create a new Comment and return an XML-RPC response
 *
 * @param array of params
 *			- Item (object)
 *			- User (object) Can be NULL for anonymous comments
 *			- password (string)
 *			- username (string)
 *			- comment_parent (int)
 *			- content (string)
 *			- author (string)
 *			- author_url (string)
 *			- author_email (string)
 * @return xmlrpcmsg
 */
function xmlrpcs_new_comment($params = array(), &$commented_Item)
{
    global $DB, $Plugins, $Messages, $Hit, $localtimenow, $require_name_email, $minimum_comment_interval;
    $params = array_merge(array('password' => '', 'username' => '', 'content' => '', 'comment_parent' => 0, 'author' => '', 'author_url' => '', 'author_email' => ''), $params);
    $comment = $params['content'] = trim($params['content']);
    if (!$commented_Item->can_comment(NULL)) {
        return xmlrpcs_resperror(5, T_('You cannot leave comments on this post!'));
    }
    $commented_Item->load_Blog();
    // Make sure Blog is loaded (will be needed whether logged in or not)
    if (empty($params['username']) && empty($params['password'])) {
        // Anonymous comment
        // NO permission to edit!
        $perm_comment_edit = false;
        $User = NULL;
        $author = trim($params['author']);
        $email = trim($params['author_email']);
        if ($commented_Item->Blog->get_setting('allow_anon_url')) {
            $url = trim($params['author_url']);
        } else {
            $url = NULL;
        }
        // we need some id info from the anonymous user:
        if ($require_name_email) {
            // We want Name and EMail with comments
            if (empty($author)) {
                return xmlrpcs_resperror(5, T_('Please fill in your name.'));
            }
            if (empty($email)) {
                return xmlrpcs_resperror(5, T_('Please fill in your email.'));
            }
        }
        if (!empty($author) && antispam_check($author)) {
            return xmlrpcs_resperror(5, T_('Supplied name is invalid.'));
        }
        if (!empty($email) && (!is_email($email) || antispam_check($email))) {
            return xmlrpcs_resperror(5, T_('Supplied email address is invalid.'));
        }
        if (!stristr($url, '://') && !stristr($url, '@')) {
            // add 'http://' if no protocol defined for URL; but not if the user seems to be entering an email address alone
            $url = 'http://' . $url;
        }
        if (strlen($url) <= 8) {
            // ex: https:// is 8 chars
            $url = '';
        }
        // Note: as part of the validation we require the url to be absolute; otherwise we cannot detect bozos typing in
        // a title for their comment or whatever...
        if ($error = validate_url($url, 'commenting')) {
            return xmlrpcs_resperror(5, T_('Supplied website address is invalid: ') . $error);
        }
    } else {
        $User =& $params['User'];
        $perm_comment_edit = $User->check_perm('blog_comment!published', 'edit', false, $commented_Item->Blog->ID);
        $author = $User->ID;
        $url = $User->url;
        $email = $User->email;
    }
    // Following call says "WARNING: this does *NOT* (necessarilly) make the HTML code safe.":
    $comment = check_html_sanity($comment, $perm_comment_edit ? 'posting' : 'commenting', $User);
    if ($comment === false) {
        // ERROR! Restore original comment for further editing:
        $comment = $params['content'];
    }
    if (empty($comment)) {
        // comment should not be empty!
        return xmlrpcs_resperror(5, T_('Please do not send empty comments.'));
    }
    $now = date2mysql($localtimenow);
    /*
     * Flood-protection
     * NOTE: devs can override the flood protection delay in /conf/_overrides_TEST.php
     * TODO: Put time check into query?
     * TODO: move that as far !!UP!! as possible! We want to waste minimum resources on Floods
     * TODO: have several thresholds. For example:
     * 1 comment max every 30 sec + 5 comments max every 10 minutes + 15 comments max every 24 hours
     * TODO: factorize with trackback
     */
    $query = 'SELECT MAX(comment_date)
				FROM T_comments
				WHERE comment_author_IP = ' . $DB->quote($Hit->IP) . '
				OR comment_author_email = ' . $DB->quote($email);
    $ok = 1;
    if ($then = $DB->get_var($query)) {
        $time_lastcomment = mysql2date("U", $then);
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_xmlrpcs.funcs.php

示例7: Comment

    if (!empty($excerpt)) {
        $comment .= '<br />';
    }
}
$comment .= $excerpt;
$comment = format_to_post($comment, 1);
// includes antispam
if (empty($comment)) {
    // comment should not be empty!
    $Messages->add(T_('Please do not send empty comment'), 'error');
}
/**
 * @global Comment Trackback object
 */
$Comment = new Comment();
$Comment->set('type', 'trackback');
$Comment->set_Item($commented_Item);
$Comment->set('author', $blog_name);
$Comment->set('author_url', $url);
$Comment->set('author_IP', $Hit->IP);
$Comment->set('date', date('Y-m-d H:i:s', $localtimenow));
$Comment->set('content', $comment);
// Assign default status for new comments:
$Comment->set('status', $commented_Item->Blog->get_setting('new_feedback_status'));
// Trigger event, which may add a message of category "error":
$Plugins->trigger_event('BeforeTrackbackInsert', array('Comment' => &$Comment));
// Display errors:
if ($errstring = $Messages->get_string('Cannot insert trackback, please correct these errors:', '')) {
    trackback_response(1, $errstring);
    // tblue> Note: the spec at <http://www.sixapart.com/pronet/docs/trackback_spec>
    //	only shows error code 1 in the example response
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:trackback.php

示例8: wpxml_import

/**
 * Import WordPress data from XML file into b2evolution database
 */
function wpxml_import()
{
    global $DB, $tableprefix;
    // Load classes:
    load_class('regional/model/_country.class.php', 'Country');
    load_class('regional/model/_region.class.php', 'Region');
    load_class('regional/model/_subregion.class.php', 'Subregion');
    load_class('regional/model/_city.class.php', 'City');
    // Set Blog from request blog ID
    $wp_blog_ID = param('wp_blog_ID', 'integer', 0);
    $BlogCache =& get_BlogCache();
    $wp_Blog =& $BlogCache->get_by_ID($wp_blog_ID);
    // The import type ( replace | append )
    $import_type = param('import_type', 'string', 'replace');
    // Get XML file from request
    $xml_file = $_FILES['wp_file'];
    // Parse WordPress XML file into array
    $xml_data = wpxml_parser($xml_file['tmp_name']);
    $DB->begin();
    if ($import_type == 'replace') {
        // Remove data from selected blog
        // Get existing categories
        $SQL = new SQL();
        $SQL->SELECT('cat_ID');
        $SQL->FROM('T_categories');
        $SQL->WHERE('cat_blog_ID = ' . $DB->quote($wp_blog_ID));
        $old_categories = $DB->get_col($SQL->get());
        if (!empty($old_categories)) {
            // Get existing posts
            $SQL = new SQL();
            $SQL->SELECT('post_ID');
            $SQL->FROM('T_items__item');
            $SQL->WHERE('post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
            $old_posts = $DB->get_col($SQL->get());
        }
        echo T_('Removing the comments... ');
        evo_flush();
        if (!empty($old_posts)) {
            $SQL = new SQL();
            $SQL->SELECT('comment_ID');
            $SQL->FROM('T_comments');
            $SQL->WHERE('comment_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
            $old_comments = $DB->get_col($SQL->get());
            $DB->query('DELETE FROM T_comments WHERE comment_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
            if (!empty($old_comments)) {
                $DB->query('DELETE FROM T_comments__votes WHERE cmvt_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
            }
        }
        echo T_('OK') . '<br />';
        echo T_('Removing the posts... ');
        evo_flush();
        if (!empty($old_categories)) {
            $DB->query('DELETE FROM T_items__item WHERE post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
            if (!empty($old_posts)) {
                // Remove the post's data from related tables
                $DB->query('DELETE FROM T_items__item_settings WHERE iset_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_items__prerendering WHERE itpr_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_items__subscriptions WHERE isub_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_items__version WHERE iver_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_postcats WHERE postcat_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_slug WHERE slug_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
            }
        }
        echo T_('OK') . '<br />';
        echo T_('Removing the categories... ');
        evo_flush();
        $DB->query('DELETE FROM T_categories WHERE cat_blog_ID = ' . $DB->quote($wp_blog_ID));
        echo T_('OK') . '<br />';
        echo T_('Removing the tags that are no longer used... ');
        evo_flush();
        if (!empty($old_posts)) {
            // Remove the tags
            // Get tags from selected blog
            $SQL = new SQL();
            $SQL->SELECT('itag_tag_ID');
            $SQL->FROM('T_items__itemtag');
            $SQL->WHERE('itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
            $old_tags_this_blog = array_unique($DB->get_col($SQL->get()));
            if (!empty($old_tags_this_blog)) {
                // Get tags from other blogs
                $SQL = new SQL();
                $SQL->SELECT('itag_tag_ID');
                $SQL->FROM('T_items__itemtag');
                $SQL->WHERE('itag_itm_ID NOT IN ( ' . implode(', ', $old_posts) . ' )');
                $old_tags_other_blogs = array_unique($DB->get_col($SQL->get()));
                $old_tags_other_blogs_sql = !empty($old_tags_other_blogs) ? ' AND tag_ID NOT IN ( ' . implode(', ', $old_tags_other_blogs) . ' )' : '';
                // Remove the tags that are no longer used
                $DB->query('DELETE FROM T_items__tag
					WHERE tag_ID IN ( ' . implode(', ', $old_tags_this_blog) . ' )' . $old_tags_other_blogs_sql);
            }
            // Remove the links of tags with posts
            $DB->query('DELETE FROM T_items__itemtag WHERE itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
        }
        echo T_('OK') . '<br /><br />';
    }
    /* Import authors */
    $authors = array();
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_wp.funcs.php

示例9: Comment

// CHECK and FORMAT content
$saved_comment = $comment;
// Following call says "WARNING: this does *NOT* (necessarilly) make the HTML code safe.":
$comment = check_html_sanity($comment, $perm_comment_edit ? 'posting' : 'commenting', $User);
if ($comment === false) {
    // ERROR! Restore original comment for further editing:
    $comment = $saved_comment;
}
// Flood protection was here and SHOULD NOT have moved down!
/**
 * Create comment object. Gets validated, before recording it into DB:
 */
$Comment = new Comment();
if ($reply_ID > 0) {
    // Set parent ID if this comment is reply to other comment
    $Comment->set('in_reply_to_cmt_ID', $reply_ID);
}
$Comment->set('type', $comment_type == 'meta' ? 'meta' : 'comment');
$Comment->set_Item($commented_Item);
if ($User) {
    // User is logged in, we'll use his ID
    $Comment->set_author_User($User);
} else {
    // User is not logged in:
    $Comment->set('author', $author);
    $Comment->set('author_email', $email);
    $Comment->set('author_url', $url);
    $Comment->set('allow_msgform', $comment_allow_msgform);
}
if ($commented_Item->can_rate()) {
    // Comment rating:
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:comment_post.php

示例10: wpxml_import


//.........这里部分代码省略.........
            $SQL->FROM('T_items__item');
            $SQL->WHERE('post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
            $old_posts = $DB->get_col($SQL->get());
        }
        echo T_('Removing the comments... ');
        evo_flush();
        if (!empty($old_posts)) {
            $SQL = new SQL();
            $SQL->SELECT('comment_ID');
            $SQL->FROM('T_comments');
            $SQL->WHERE('comment_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
            $old_comments = $DB->get_col($SQL->get());
            $DB->query('DELETE FROM T_comments WHERE comment_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
            if (!empty($old_comments)) {
                $DB->query('DELETE FROM T_comments__votes WHERE cmvt_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
                $DB->query('DELETE FROM T_links WHERE link_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
            }
        }
        echo T_('OK') . '<br />';
        echo T_('Removing the posts... ');
        evo_flush();
        if (!empty($old_categories)) {
            $DB->query('DELETE FROM T_items__item WHERE post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
            if (!empty($old_posts)) {
                // Remove the post's data from related tables
                if ($delete_files) {
                    // Get the file IDs that should be deleted from hard drive
                    $SQL = new SQL();
                    $SQL->SELECT('DISTINCT link_file_ID');
                    $SQL->FROM('T_links');
                    $SQL->WHERE('link_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                    $deleted_file_IDs = $DB->get_col($SQL->get());
                }
                $DB->query('DELETE FROM T_items__item_settings WHERE iset_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_items__prerendering WHERE itpr_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_items__subscriptions WHERE isub_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_items__version WHERE iver_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_postcats WHERE postcat_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_slug WHERE slug_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE l, lv FROM T_links AS l
											 LEFT JOIN T_links__vote AS lv ON lv.lvot_link_ID = l.link_ID
											WHERE l.link_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
                $DB->query('DELETE FROM T_users__postreadstatus WHERE uprs_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
            }
        }
        echo T_('OK') . '<br />';
        echo T_('Removing the categories... ');
        evo_flush();
        $DB->query('DELETE FROM T_categories WHERE cat_blog_ID = ' . $DB->quote($wp_blog_ID));
        echo T_('OK') . '<br />';
        echo T_('Removing the tags that are no longer used... ');
        evo_flush();
        if (!empty($old_posts)) {
            // Remove the tags
            // Get tags from selected blog
            $SQL = new SQL();
            $SQL->SELECT('itag_tag_ID');
            $SQL->FROM('T_items__itemtag');
            $SQL->WHERE('itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
            $old_tags_this_blog = array_unique($DB->get_col($SQL->get()));
            if (!empty($old_tags_this_blog)) {
                // Get tags from other blogs
                $SQL = new SQL();
                $SQL->SELECT('itag_tag_ID');
                $SQL->FROM('T_items__itemtag');
                $SQL->WHERE('itag_itm_ID NOT IN ( ' . implode(', ', $old_posts) . ' )');
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:67,代码来源:_wp.funcs.php


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