本文整理汇总了PHP中wiki_get_comments函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_get_comments函数的具体用法?PHP wiki_get_comments怎么用?PHP wiki_get_comments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_get_comments函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wiki_delete_pages
/**
* Delete pages and all related data
*
* @param mixed $context context in which page needs to be deleted.
* @param mixed $pageids id's of pages to be deleted
* @param int $subwikiid id of the subwiki for which all pages should be deleted
*/
function wiki_delete_pages($context, $pageids = null, $subwikiid = null)
{
global $DB;
if (!empty($pageids) && is_int($pageids)) {
$pageids = array($pageids);
} else {
if (!empty($subwikiid)) {
$pageids = wiki_get_page_list($subwikiid);
}
}
//If there is no pageid then return as we can't delete anything.
if (empty($pageids)) {
return;
}
/// Delete page and all it's relevent data
foreach ($pageids as $pageid) {
if (is_object($pageid)) {
$pageid = $pageid->id;
}
//Delete page comments
$comments = wiki_get_comments($context->id, $pageid);
foreach ($comments as $commentid => $commentvalue) {
wiki_delete_comment($commentid, $context, $pageid);
}
//Delete page tags
$tags = tag_get_tags_array('wiki_pages', $pageid);
foreach ($tags as $tagid => $tagvalue) {
tag_delete_instance('wiki_pages', $pageid, $tagid);
}
//Delete Synonym
wiki_delete_synonym($subwikiid, $pageid);
//Delete all page versions
wiki_delete_page_versions(array($pageid => array(0)));
//Delete all page locks
wiki_delete_locks($pageid);
//Delete all page links
wiki_delete_links(null, $pageid);
//Delete page
$params = array('id' => $pageid);
$DB->delete_records('wiki_pages', $params);
}
}
示例2: wiki_delete_pages
/**
* Delete pages and all related data
*
* @param mixed $context context in which page needs to be deleted.
* @param mixed $pageids id's of pages to be deleted
* @param int $subwikiid id of the subwiki for which all pages should be deleted
*/
function wiki_delete_pages($context, $pageids = null, $subwikiid = null)
{
global $DB, $CFG;
if (!empty($pageids) && is_int($pageids)) {
$pageids = array($pageids);
} else {
if (!empty($subwikiid)) {
$pageids = wiki_get_page_list($subwikiid);
}
}
//If there is no pageid then return as we can't delete anything.
if (empty($pageids)) {
return;
}
/// Delete page and all it's relevent data
foreach ($pageids as $pageid) {
if (is_object($pageid)) {
$pageid = $pageid->id;
}
//Delete page comments
$comments = wiki_get_comments($context->id, $pageid);
foreach ($comments as $commentid => $commentvalue) {
wiki_delete_comment($commentid, $context, $pageid);
}
//Delete page tags
core_tag_tag::remove_all_item_tags('mod_wiki', 'wiki_pages', $pageid);
//Delete Synonym
wiki_delete_synonym($subwikiid, $pageid);
//Delete all page versions
wiki_delete_page_versions(array($pageid => array(0)), $context);
//Delete all page locks
wiki_delete_locks($pageid);
//Delete all page links
wiki_delete_links(null, $pageid);
$params = array('id' => $pageid);
// Get page before deleting.
$page = $DB->get_record('wiki_pages', $params);
//Delete page
$DB->delete_records('wiki_pages', $params);
// Trigger page_deleted event.
$event = \mod_wiki\event\page_deleted::create(array('context' => $context, 'objectid' => $pageid, 'other' => array('subwikiid' => $subwikiid)));
$event->add_record_snapshot('wiki_pages', $page);
$event->trigger();
}
}
示例3: print_content
function print_content() {
global $CFG, $OUTPUT, $USER, $PAGE;
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
$page = $this->page;
$subwiki = $this->subwiki;
$wiki = $PAGE->activityrecord;
list($context, $course, $cm) = get_context_info_array($this->modcontext->id);
require_capability('mod/wiki:viewcomment', $this->modcontext, NULL, true, 'noviewcommentpermission', 'wiki');
$comments = wiki_get_comments($this->modcontext->id, $page->id);
if (has_capability('mod/wiki:editcomment', $this->modcontext)) {
echo '<div class="midpad"><a href="' . $CFG->wwwroot . '/mod/wiki/editcomments.php?action=add&pageid=' . $page->id . '">' . get_string('addcomment', 'wiki') . '</a></div>';
}
$options = array('swid' => $this->page->subwikiid, 'pageid' => $page->id);
$version = wiki_get_current_version($this->page->id);
$format = $version->contentformat;
if (empty($comments)) {
echo $OUTPUT->heading(get_string('nocomments', 'wiki'));
}
foreach ($comments as $comment) {
$user = wiki_get_user_info($comment->userid);
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', context_course::instance($course->id)));
$by = new stdclass();
$by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . $fullname . '</a>';
$by->date = userdate($comment->timecreated);
$t = new html_table();
$cell1 = new html_table_cell($OUTPUT->user_picture($user, array('popup' => true)));
$cell2 = new html_table_cell(get_string('bynameondate', 'forum', $by));
$cell3 = new html_table_cell();
$cell3->atributtes ['width'] = "80%";
$cell4 = new html_table_cell();
$cell5 = new html_table_cell();
$row1 = new html_table_row();
$row1->cells[] = $cell1;
$row1->cells[] = $cell2;
$row2 = new html_table_row();
$row2->cells[] = $cell3;
if ($format != 'html') {
if ($format == 'creole') {
$parsedcontent = wiki_parse_content('creole', $comment->content, $options);
} else if ($format == 'nwiki') {
$parsedcontent = wiki_parse_content('nwiki', $comment->content, $options);
}
$cell4->text = format_text(html_entity_decode($parsedcontent['parsed_text'], ENT_QUOTES, 'UTF-8'), FORMAT_HTML);
} else {
$cell4->text = format_text($comment->content, FORMAT_HTML);
}
$row2->cells[] = $cell4;
$t->data = array($row1, $row2);
$actionicons = false;
if ((has_capability('mod/wiki:managecomment', $this->modcontext))) {
$urledit = new moodle_url('/mod/wiki/editcomments.php', array('commentid' => $comment->id, 'pageid' => $page->id, 'action' => 'edit'));
$urldelet = new moodle_url('/mod/wiki/instancecomments.php', array('commentid' => $comment->id, 'pageid' => $page->id, 'action' => 'delete'));
$actionicons = true;
} else if ((has_capability('mod/wiki:editcomment', $this->modcontext)) and ($USER->id == $user->id)) {
$urledit = new moodle_url('/mod/wiki/editcomments.php', array('commentid' => $comment->id, 'pageid' => $page->id, 'action' => 'edit'));
$urldelet = new moodle_url('/mod/wiki/instancecomments.php', array('commentid' => $comment->id, 'pageid' => $page->id, 'action' => 'delete'));
$actionicons = true;
}
if ($actionicons) {
$cell6 = new html_table_cell($OUTPUT->action_icon($urledit, new pix_icon('t/edit', get_string('edit'),
'', array('class' => 'iconsmall'))) . $OUTPUT->action_icon($urldelet, new pix_icon('t/delete',
get_string('delete'), '', array('class' => 'iconsmall'))));
$row3 = new html_table_row();
$row3->cells[] = $cell5;
$row3->cells[] = $cell6;
$t->data[] = $row3;
}
echo html_writer::tag('div', html_writer::table($t), array('class'=>'no-overflow'));
}
}
示例4: test_comment_deleted
/**
* Test comment_deleted event.
*/
public function test_comment_deleted()
{
$this->setUp();
$page = $this->wikigenerator->create_first_page($this->wiki);
$context = context_module::instance($this->wiki->cmid);
// Add comment so we can delete it later.
wiki_add_comment($context, $page->id, 'Test comment', 'html');
$comment = wiki_get_comments($context->id, $page->id);
$this->assertCount(1, $comment);
$comment = array_shift($comment);
// Triggering and capturing the event.
$sink = $this->redirectEvents();
wiki_delete_comment($comment->id, $context, $page->id);
$events = $sink->get_events();
$this->assertCount(1, $events);
$event = reset($events);
// Checking that the event contains the expected values.
$this->assertInstanceOf('\\mod_wiki\\event\\comment_deleted', $event);
$this->assertEquals($context, $event->get_context());
$this->assertEquals($page->id, $event->other['itemid']);
$this->assertEventContextNotUsed($event);
}