本文整理汇总了PHP中comment类的典型用法代码示例。如果您正苦于以下问题:PHP comment类的具体用法?PHP comment怎么用?PHP comment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了comment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_comments
/**
* Return a list of comments
*
* @param string $contextlevel ('system, course, user', etc..)
* @param int $instanceid
* @param string $component the name of the component
* @param int $itemid the item id
* @param string $area comment area
* @param int $page page number
* @return array of comments and warnings
* @since Moodle 2.9
*/
public static function get_comments($contextlevel, $instanceid, $component, $itemid, $area = '', $page = 0)
{
$warnings = array();
$arrayparams = array('contextlevel' => $contextlevel, 'instanceid' => $instanceid, 'component' => $component, 'itemid' => $itemid, 'area' => $area, 'page' => $page);
$params = self::validate_parameters(self::get_comments_parameters(), $arrayparams);
$context = self::get_context_from_params($params);
self::validate_context($context);
require_capability('moodle/comment:view', $context);
$args = new stdClass();
$args->context = $context;
$args->area = $params['area'];
$args->itemid = $params['itemid'];
$args->component = $params['component'];
$commentobject = new comment($args);
$comments = $commentobject->get_comments($params['page']);
// False means no permissions to see comments.
if ($comments === false) {
throw new moodle_exception('nopermissions', 'error', '', 'view comments');
}
foreach ($comments as $key => $comment) {
list($comments[$key]->content, $comments[$key]->format) = external_format_text($comment->content, $comment->format, $context->id, $params['component'], '', 0);
}
$results = array('comments' => $comments, 'warnings' => $warnings);
return $results;
}
示例2: module_comment_edit
function module_comment_edit()
{
global $global, $smarty;
$obj = new comment();
$obj->set_where('com_id = ' . $global['id']);
$one = $obj->get_one();
$one['channel'] = '';
$one['title'] = '';
$obj = new channel();
$list = $obj->get_list();
for ($i = 0; $i < count($list); $i++) {
if ($list[$i]['cha_id'] == $one['com_channel_id']) {
$one['channel'] = $list[$i]['cha_code'];
$original = $list[$i]['cha_code'];
if ($list[$i]['cha_original'] != 0) {
for ($j = 0; $j < count($list); $j++) {
if ($list[$i]['cha_original'] == $list[$j]['cha_id']) {
$original = $list[$j]['cha_code'];
}
}
}
if ($original == 'goods') {
$table = 'goods';
} else {
$table = 'article';
}
$one['title'] = get_data($table, $one['com_page_id'], substr($table, 0, 3) . '_title');
}
}
$smarty->assign('comment', $one);
}
示例3: get_content
function get_content()
{
if ($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return null;
}
$this->content->footer = '';
$this->content->text = '';
if (isloggedin() && !isguestuser()) {
// Show the block
$cmt = new stdclass();
$cmt->context = $this->instance->context;
$cmt->area = 'block_comments';
$cmt->itemid = $this->instance->id;
$cmt->course = $this->page->course;
// this is a hack to adjust commenting UI
// in block_comments
$cmt->env = 'block_comments';
$cmt->linktext = get_string('showcomments');
$comment = new comment($cmt);
$this->content = new stdClass();
$this->content->text = $comment->init(true);
$this->content->footer = '';
}
return $this->content;
}
示例4: module_comment_sheet
function module_comment_sheet()
{
global $global, $smarty;
$obj = new comment();
$obj->set_page_size(10);
$obj->set_page_num($global['page']);
$sheet = $obj->get_sheet();
set_link($obj->get_page_sum());
for ($i = 0; $i < count($sheet); $i++) {
$sheet[$i]['channel'] = '';
$sheet[$i]['title'] = '';
$obj = new channel();
$list = $obj->get_list();
for ($j = 0; $j < count($list); $j++) {
if ($list[$j]['cha_id'] == $sheet[$i]['com_channel_id']) {
$sheet[$i]['channel'] = $list[$j]['cha_code'];
$original = $list[$j]['cha_code'];
if ($list[$j]['cha_original'] != 0) {
for ($k = 0; $k < count($list); $k++) {
if ($list[$j]['cha_original'] == $list[$k]['cha_id']) {
$original = $list[$k]['cha_code'];
}
}
}
if ($original == 'goods') {
$table = 'goods';
} else {
$table = 'article';
}
$sheet[$i]['title'] = get_data($table, $sheet[$i]['com_page_id'], substr($table, 0, 3) . '_title');
}
}
}
$smarty->assign('comment', $sheet);
}
示例5: get_content
function get_content()
{
global $CFG, $PAGE;
if (!$CFG->usecomments) {
$this->content->text = '';
if ($this->page->user_is_editing()) {
$this->content->text = get_string('disabledcomments');
}
return $this->content;
}
if ($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return null;
}
$this->content->footer = '';
$this->content->text = '';
list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
$args = new stdClass();
$args->context = $PAGE->context;
$args->course = $course;
$args->area = 'page_comments';
$args->itemid = 0;
// set 'env' to tell moodle tweak ui for this block
$args->env = 'block_comments';
$args->component = 'block_comments';
$args->linktext = get_string('showcomments');
$comment = new comment($args);
$comment->set_view_permission(true);
$this->content = new stdClass();
$this->content->text = $comment->output(true);
$this->content->footer = '';
return $this->content;
}
示例6: adminNotify
public function adminNotify()
{
if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) {
//no notificamos a administrador de su propio comentario.
return;
}
$id = $this->registry->lastCommentID;
$Comment = new comment();
$comment = $Comment->find($id);
$comment['content'] = utils::nl2br($comment['content']);
if (!defined('GESHI_VERSION')) {
$comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE');
} else {
$comment['content'] = $this->comment_source_code_beautifier($comment['content']);
}
$User = new user();
$user = $User->find(1);
$Post = new post();
$post = $Post->find($comment['ID_post']);
$commentsWaiting = $Comment->countCommentsByPost(null, 'waiting');
$mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t";
$conf = $this->registry->conf;
$subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}";
$this->enviaMail($user['email'], $subject, $mailStr, $user['email']);
}
示例7: getAll
public function getAll($ID_post, $status = null)
{
$C = new comment();
$rows = array();
if (is_null($status) === true) {
$rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post}");
} else {
if (is_array($status)) {
$status_sql = "";
foreach ($status as $st) {
$status_sql .= "status = '{$st}' OR ";
}
$status_sql = substr($status_sql, 0, -4);
$rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post} AND ({$status_sql})");
} else {
$rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post} AND status='{$status}'");
}
}
foreach ($rows as $key => $comment) {
$comment['content'] = utils::htmlentities($comment['content']);
$comment['content'] = utils::nl2br($comment['content']);
$rows[$key] = $comment;
}
return $rows;
}
示例8: addAction
public function addAction()
{
if (user::isGuest() && reg::getKey('/comments/only_reg')) {
system::stop();
}
if (user::isGuest() && !system::validCapcha('random_image')) {
system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
}
// Добавляем новый комментарий
$comment = new comment();
$comment->setParentId(system::POST('parent_id'));
$comment->setObjId(system::POST('obj_id'));
$comment->setUserName(system::POST('username'));
$comment->setEmail(system::POST('email'));
$comment->setText(system::POST('text'));
$comment->setSendEmail(system::POST('send_email'));
$obj_id = $comment->save();
if ($obj_id) {
page::assign('current_url', system::POST('back_url'));
$html = page::macros('comments')->view($comment->id());
system::json(array('error' => 0, 'data' => $html));
} else {
system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
}
if (!empty($_POST['back_url']) && !system::isAjax()) {
system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
} else {
system::stop();
}
}
示例9: comment_js_action
function comment_js_action() {
front::check_type(front::get('aid'));
$comment=new comment();
$this->view->comments=$comment->getrows('state=1 and aid='.front::get('aid'),20,'1');
$this->view->aid=front::get('aid');
echo tool::text_javascript($this->fetch());
exit;
}
示例10: index
public function index($id = NULL, $page = 1)
{
if (is_null($id) or is_numeric($id)) {
$this->redirect($this->conf['blog_siteurl']);
}
$tag = $id;
$post = new post();
$link = new link();
$comment = new comment();
$this->html->useTheme($this->conf['blog_current_theme']);
$info = array();
$info["isAdmin"] = false;
if ($this->cookie->check("logged") and $this->cookie->id_user == 1) {
$info["isAdmin"] = true;
}
$this->themes->info = $info;
$includes['charset'] = $this->html->charsetTag("UTF-8");
$includes['rssFeed'] = $this->html->includeRSS();
if ($page > 1) {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />";
} else {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />";
}
$this->registry->includes = $includes;
$this->plugin->call('index_includes');
$includes = null;
foreach ($this->registry->includes as $include) {
$includes .= $include;
}
$this->themes->includes = $includes;
$this->themes->links = $link->findAll();
$this->themes->single = false;
$total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag));
$page = (int) is_null($page) ? 1 : $page;
$limit = $this->conf['blog_posts_per_page'];
$offset = ($page - 1) * $limit;
$limitQuery = $offset . "," . $limit;
$targetpage = $this->path . "tag/{$tag}/";
$this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
$posts = $post->getPostsByTag($tag, $limitQuery);
foreach ($posts as $k => $p) {
$posts[$k]['title'] = htmlspecialchars($p['title']);
$posts[$k]['tags'] = $post->getTags($p['ID']);
$posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']);
$user = new user();
if ($posts[$k]['id_user'] < 2) {
$posts[$k]['autor'] = $user->find(1);
} else {
$posts[$k]['autor'] = $user->find($posts[$k]['id_user']);
}
}
$this->registry->posts = $posts;
$this->plugin->call("index_post_content");
$this->themes->posts = $this->registry->posts;
$this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}";
$this->render();
}
示例11: show
public function show($id)
{
$articles = new Article();
$comment = new comment();
$article = $articles->where('article_id=' . $id)->find();
$comments = $comment->where('article_id=' . $id)->order('created_at')->select();
//$comments = $articles->relation(true)->find($id);
$this->assign('article', $article);
$this->assign('comments', $comments);
$this->display('showArticle');
}
示例12: reply_comment
function reply_comment()
{
global $smarty, $lang;
$com_id = post('com_id');
$com_reply = post('com_reply');
$obj = new comment();
$obj->set_value('com_reply', $com_reply);
$obj->set_where("com_id = {$com_id}");
$obj->edit();
$smarty->assign('info_text', '回复评论成功');
$smarty->assign('link_text', $lang['return_list']);
$smarty->assign('link_href', url(array('channel' => 'service', 'mod' => 'comment_sheet')));
}
示例13: _create
/**
* Add a new comment to the collection.
* @see REST_Controller::_create($resource)
*/
public function _create($comment)
{
$item = ORM::factory("item", $this->input->post("item_id"));
access::required("view", $item);
$form = comment_3nids::get_add_form($item);
$valid = $form->validate();
if ($valid) {
if (user::active()->guest && !$form->add_comment->inputs["name"]->value) {
$form->add_comment->inputs["name"]->add_error("missing", 1);
$valid = false;
}
if (!$form->add_comment->text->value) {
$form->add_comment->text->add_error("missing", 1);
$valid = false;
}
}
if ($valid) {
$comment = comment::create($item, user::active(), $form->add_comment->text->value, $form->add_comment->inputs["name"]->value, $form->add_comment->email->value, $form->add_comment->url->value);
$active = user::active();
if ($active->guest) {
$form->add_comment->inputs["name"]->value("");
$form->add_comment->email->value("");
$form->add_comment->url->value("");
} else {
$form->add_comment->inputs["name"]->value($active->full_name);
$form->add_comment->email->value($active->email);
$form->add_comment->url->value($active->url);
}
}
url::redirect(url::site("comments_3nids?item_id=" . $item->id));
}
示例14: displayComments
public function displayComments($resource_id, $instance)
{
//instance ce u stvari biti ovo gde dodamo (add_instance), na stranici kursa
//Mozda prvo da se izlistaju svi resursi pa da se omoguce komentari
comment::init();
$options = new stdClass();
$options->area = 'resource_comments';
$options->course = $course;
$options->context = $context;
$options->itemid = $itemid;
$options->component = 'component_1';
$options->showcount = true;
$options->displaycancel = true;
$comment = new comment($options);
$comment->set_view_permission(true);
}
示例15: create_comment_for_user_test
public function create_comment_for_user_test()
{
$rand = rand();
$root = ORM::factory("item", 1);
$admin = user::lookup(2);
$comment = comment::create($root, $admin, "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
$this->assert_equal($admin->full_name, $comment->author_name());
$this->assert_equal($admin->email, $comment->author_email());
$this->assert_equal($admin->url, $comment->author_url());
$this->assert_equal("text_{$rand}", $comment->text);
$this->assert_equal(1, $comment->item_id);
$this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
$this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
$this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
$this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
$this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
$this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
$this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
$this->assert_equal("HTTP_HOST", $comment->server_http_host);
$this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
$this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
$this->assert_equal("QUERY_STRING", $comment->server_query_string);
$this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
$this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
$this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
$this->assert_true(!empty($comment->created));
}