本文整理汇总了PHP中comment::init方法的典型用法代码示例。如果您正苦于以下问题:PHP comment::init方法的具体用法?PHP comment::init怎么用?PHP comment::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comment
的用法示例。
在下文中一共展示了comment::init方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stdclass
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;
}
示例2: render_content
/**
*
*
*
*
*
*/
function render_content($course, $modinfo, $page_context)
{
global $DB;
$rendered_course = $DB->get_record('course', array('id' => $course->id));
$rendered_course_id = $rendered_course->id;
$sections = $DB->get_records('course_sections', array('course' => $rendered_course_id));
$modules = $DB->get_records('course_modules', array('course' => $rendered_course_id));
//must have for comments
comment::init();
render_sections($course, $sections, $modules, $modinfo, $page_context);
}
示例3: 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);
}
示例4: optional_param
require_once __DIR__ . '/../config.php';
require_once $CFG->dirroot . '/blog/lib.php';
require_once $CFG->dirroot . '/blog/locallib.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/comment/lib.php';
$id = optional_param('id', null, PARAM_INT);
$start = optional_param('formstart', 0, PARAM_INT);
$tag = optional_param('tag', '', PARAM_NOTAGS);
$userid = optional_param('userid', null, PARAM_INT);
$tagid = optional_param('tagid', null, PARAM_INT);
$modid = optional_param('modid', null, PARAM_INT);
$entryid = optional_param('entryid', null, PARAM_INT);
$groupid = optional_param('groupid', null, PARAM_INT);
$courseid = optional_param('courseid', null, PARAM_INT);
$search = optional_param('search', null, PARAM_RAW);
comment::init();
$urlparams = compact('id', 'start', 'tag', 'userid', 'tagid', 'modid', 'entryid', 'groupid', 'courseid', 'search');
foreach ($urlparams as $var => $val) {
if (empty($val)) {
unset($urlparams[$var]);
}
}
$PAGE->set_url('/blog/index.php', $urlparams);
// Correct tagid if a text tag is provided as a param.
if (!empty($tag)) {
if ($tagrec = $DB->get_record('tag', array('name' => $tag))) {
$tagid = $tagrec->id;
} else {
unset($tagid);
}
}
示例5: upgrade
/**
* Upgrade the submission from the old assignment to the new one
*
* @param context $oldcontext The context for the old assignment
* @param stdClass $oldassignment The data record for the old assignment
* @param stdClass $oldsubmission The data record for the old submission
* @param stdClass $submission The new submission record
* @param string $log Record upgrade messages in the log
* @return bool true or false - false will trigger a rollback
*/
public function upgrade(context $oldcontext, stdClass $oldassignment, stdClass $oldsubmission, stdClass $submission, &$log)
{
if ($oldsubmission->data1 != '') {
// need to used this innit() otherwise it shows up undefined !
// require js for commenting
comment::init();
$options = new stdClass();
$options->area = 'submission_comments_upgrade';
$options->course = $this->assignment->get_course();
$options->context = $this->assignment->get_context();
$options->itemid = $submission->id;
$options->component = 'assignsubmission_comments';
$options->showcount = true;
$options->displaycancel = true;
$comment = new comment($options);
$comment->add($oldsubmission->data1);
$comment->set_view_permission(true);
return $comment->output(true);
}
return true;
}
示例6: upgrade
/**
* Upgrade the submission from the old setaskment to the new one
*
* @param context $oldcontext The context for the old setaskment
* @param stdClass $oldsetaskment The data record for the old setaskment
* @param stdClass $oldsubmission The data record for the old submission
* @param stdClass $submission The new submission record
* @param string $log Record upgrade messages in the log
* @return bool true or false - false will trigger a rollback
*/
public function upgrade(context $oldcontext, stdClass $oldsetaskment, stdClass $oldsubmission, stdClass $submission, &$log)
{
if ($oldsubmission->data1 != '') {
// Need to used this init() otherwise it does not have the javascript includes.
comment::init();
$options = new stdClass();
$options->area = 'submission_comments_upgrade';
$options->course = $this->setaskment->get_course();
$options->context = $this->setaskment->get_context();
$options->itemid = $submission->id;
$options->component = 'setasksubmission_comments';
$options->showcount = true;
$options->displaycancel = true;
$comment = new comment($options);
$comment->add($oldsubmission->data1);
$comment->set_view_permission(true);
return $comment->output(true);
}
return true;
}
示例7: action_viewgallery
public function action_viewgallery()
{
global $DB;
$gallery = $this->gallery;
$params = array('context' => $this->context, 'objectid' => $this->gallery->id);
$event = event\gallery_viewed::create($params);
$event->add_record_snapshot('course_modules', $this->cm);
$event->add_record_snapshot('course', $this->course);
$event->trigger();
$output = '';
if ($gallery->user_can_contribute() || $gallery->user_can_view()) {
if ($gallery->can_comment()) {
$cmtopt = new \stdClass();
$cmtopt->area = 'gallery';
$cmtopt->context = $this->context;
$cmtopt->itemid = $gallery->id;
$cmtopt->showcount = true;
$cmtopt->component = 'mod_mediagallery';
$cmtopt->cm = $this->cm;
$cmtopt->course = $this->course;
$this->options['comments'] = new \comment($cmtopt);
\comment::init();
}
$renderable = new output\gallery\renderable($gallery, $this->options['editing'], $this->options);
$output .= $this->renderer->render_gallery($renderable);
} else {
print_error('nopermissions', 'error', $this->pageurl, 'view gallery');
}
return $output;
}
示例8: specialization
function specialization()
{
// require js for commenting
comment::init();
}
示例9: format_text
/**
* Given text in a variety of format codings, this function returns
* the text as safe HTML.
*
* This function should mainly be used for long strings like posts,
* answers, glossary items etc. For short strings @see format_string().
*
* @todo Finish documenting this function
*
* @global object
* @global object
* @global object
* @global object
* @uses FORMAT_MOODLE
* @uses FORMAT_HTML
* @uses FORMAT_PLAIN
* @uses FORMAT_WIKI
* @uses FORMAT_MARKDOWN
* @uses CLI_SCRIPT
* @staticvar array $croncache
* @param string $text The text to be formatted. This is raw text originally from user input.
* @param int $format Identifier of the text format to be used
* [FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN]
* @param object $options ?
* @param int $courseid The courseid to use, defaults to $COURSE->courseid
* @return string
*/
function format_text($text, $format = FORMAT_MOODLE, $options = NULL, $courseid = NULL)
{
global $CFG, $COURSE, $DB, $PAGE;
static $croncache = array();
$hashstr = '';
if ($text === '') {
return '';
// no need to do any filters and cleaning
}
if (!empty($options->comments) && !empty($CFG->usecomments)) {
require_once $CFG->libdir . '/commentlib.php';
$comment = new comment($options->comments);
$cmt = $comment->init(true);
} else {
$cmt = '';
}
if (!isset($options->trusted)) {
$options->trusted = false;
}
if (!isset($options->noclean)) {
if ($options->trusted and trusttext_active()) {
// no cleaning if text trusted and noclean not specified
$options->noclean = true;
} else {
$options->noclean = false;
}
}
if (!isset($options->nocache)) {
$options->nocache = false;
}
if (!isset($options->smiley)) {
$options->smiley = true;
}
if (!isset($options->filter)) {
$options->filter = true;
}
if (!isset($options->para)) {
$options->para = true;
}
if (!isset($options->newlines)) {
$options->newlines = true;
}
if (empty($courseid)) {
$courseid = $COURSE->id;
}
if ($options->filter) {
$filtermanager = filter_manager::instance();
} else {
$filtermanager = new null_filter_manager();
}
$context = $PAGE->context;
if (!empty($CFG->cachetext) and empty($options->nocache)) {
$hashstr .= $text . '-' . $filtermanager->text_filtering_hash($context, $courseid) . '-' . (int) $courseid . '-' . current_language() . '-' . (int) $format . (int) $options->trusted . (int) $options->noclean . (int) $options->smiley . (int) $options->filter . (int) $options->para . (int) $options->newlines;
$time = time() - $CFG->cachetext;
$md5key = md5($hashstr);
if (CLI_SCRIPT) {
if (isset($croncache[$md5key])) {
return $croncache[$md5key] . $cmt;
}
}
if ($oldcacheitem = $DB->get_record('cache_text', array('md5key' => $md5key), '*', IGNORE_MULTIPLE)) {
if ($oldcacheitem->timemodified >= $time) {
if (CLI_SCRIPT) {
if (count($croncache) > 150) {
reset($croncache);
$key = key($croncache);
unset($croncache[$key]);
}
$croncache[$md5key] = $oldcacheitem->formattedtext;
}
return $oldcacheitem->formattedtext . $cmt;
}
}
//.........这里部分代码省略.........
示例10: set_page
/**
* Sets the dataform page.
*
* @param string $pagefile current page file
* @param array $params
*/
public function set_page($pagefile = 'view', $params = null)
{
global $CFG, $PAGE, $USER, $OUTPUT;
$htmloutput = '';
$this->_pagefile = $pagefile == 'external' ? 'view' : $pagefile;
$params = (object) $params;
$urlparams = array();
if (!empty($params->urlparams)) {
foreach ($params->urlparams as $param => $value) {
if ($value != 0 and $value != '') {
$urlparams[$param] = $value;
}
}
}
// Make sure there is at least dataform id param.
$urlparams['d'] = $this->id;
// Get the edit mode.
$urlparams['edit'] = optional_param('edit', -1, PARAM_BOOL);
// MANAGER.
$manager = has_capability('mod/dataform:managetemplates', $this->context);
// LOGIN REQUIREMENT.
if (empty($params->nologin)) {
// Guest auto login.
$autologinguest = false;
if ($pagefile == 'view' or $pagefile == 'embed' or $pagefile == 'external') {
$autologinguest = true;
}
// Require login.
require_login($this->course->id, $autologinguest, $this->cm);
}
// RENEW if requested.
if ($manager and !empty($urlparams['renew']) and confirm_sesskey()) {
$returnurl = new \moodle_url('/mod/dataform/view.php', array('id' => $this->cm->id));
if (empty($urlparams['confirmed'])) {
$PAGE->set_url('/mod/dataform/view.php', $urlparams);
$message = get_string('renewconfirm', 'dataform');
$yesparams = array('id' => $this->cm->id, 'renew' => 1, 'sesskey' => sesskey(), 'confirmed' => 1);
$confirmedurl = new moodle_url('/mod/dataform/view.php', $yesparams);
$output = $this->renderer;
$headerparams = array('heading' => get_string('renewactivity', 'dataform') . ': ' . $this->name, 'urlparams' => $urlparams);
echo $output->header($headerparams);
// Print a confirmation page.
echo $output->confirm($message, $confirmedurl, $returnurl);
echo $output->footer();
exit;
} else {
$this->reset();
rebuild_course_cache($this->course->id);
redirect($returnurl);
}
}
// RSS.
if (!empty($params->rss)) {
$this->set_page_rss();
}
// COMMENTS.
if (!empty($params->comments)) {
require_once "{$CFG->dirroot}/comment/lib.php";
comment::init();
}
$externalpage = $pagefile == 'external';
// EDITING (not on external pages).
$this->set_page_editing_mode($pagefile, $urlparams);
// AUTO REFRESH.
if (!empty($urlparams['refresh']) and !$externalpage) {
$PAGE->set_periodic_refresh_delay($urlparams['refresh']);
}
// PAGE LAYOUT.
if (!empty($params->pagelayout) and !$externalpage) {
$PAGE->set_pagelayout($params->pagelayout);
}
// COMPLETION Mark as viewed.
if (!empty($params->completion) and !$externalpage) {
require_once $CFG->libdir . '/completionlib.php';
$completion = new completion_info($this->course);
$completion->set_module_viewed($this->cm);
}
// CSS.
$htmloutput .= !empty($params->css) ? $this->set_page_css() : '';
// JS.
if (!empty($params->js)) {
$this->set_page_js();
}
$PAGE->set_title($this->name);
$PAGE->set_heading($this->course->fullname);
// Set current view and view's page requirements only if activity ready (with default view)
// And access allowed.
if ($this->defaultview) {
$currentviewid = !empty($urlparams['view']) ? $urlparams['view'] : $this->defaultview;
// Ensure access allowed.
$params = array('dataformid' => $this->id, 'viewid' => $currentviewid);
if (mod_dataform\access\view_access::validate($params)) {
if ($this->_currentview = $this->view_manager->get_view_by_id($currentviewid)) {
$this->_currentview->set_page($pagefile, $urlparams);
//.........这里部分代码省略.........
示例11: course_list
/**
* Display a list of courses
* If $withwriteaccess = true, we display visible field,
* @param array $courses
* @param boolean $withwriteaccess
* @return string
*/
public function course_list($courses, $withwriteaccess = false, $optionalurlparams = array())
{
global $CFG;
require_once $CFG->dirroot . '/comment/lib.php';
comment::init();
$renderedhtml = '';
if (!empty($courses)) {
$courseiteration = 0;
foreach ($courses as $course) {
$courseiteration = $courseiteration + 1;
//create html specific to hub administrator
if ($withwriteaccess) {
//create site link html
$managesiteurl = new moodle_url($CFG->wwwroot . '/local/hub/admin/managesites.php', array('search' => $course->site->name, 'sesskey' => sesskey()));
$siteatag = html_writer::tag('a', get_string('site', 'local_hub') . ': ' . $course->site->name, array('href' => $managesiteurl));
$sitehtml = html_writer::tag('div', $siteatag, array('class' => 'coursesitelink'));
//bulk operation checkbox html
$checkboxhtml = html_writer::tag('div', html_writer::checkbox('bulk-' . $courseiteration, $course->id, false, '', array('class' => 'hubmanagecoursecheckbox')), array('class' => 'hubcoursedelete'));
//visible icon html
if ($course->privacy) {
$imgparams = array('src' => $this->output->pix_url('i/hide'), 'class' => 'siteimage', 'alt' => get_string('disable'));
$makevisible = false;
} else {
$imgparams = array('src' => $this->output->pix_url('i/show'), 'class' => 'siteimage', 'alt' => get_string('enable'));
$makevisible = true;
}
$hideimgtag = html_writer::empty_tag('img', $imgparams);
$visibleurlparams = array('sesskey' => sesskey(), 'visible' => $makevisible, 'courseid' => $course->id);
$visibleurl = new moodle_url("/local/hub/admin/managecourses.php", $visibleurlparams);
$visiblehtml = html_writer::tag('div', html_writer::tag('a', $hideimgtag, array('href' => $visibleurl)), array('class' => 'hubcoursevisible'));
//settings link html
$settingsurl = new moodle_url("/local/hub/admin/coursesettings.php", array('sesskey' => sesskey(), 'id' => $course->id));
$settingslinkhtml = html_writer::tag('div', html_writer::tag('a', get_string('edit'), array('href' => $settingsurl)), array('class' => 'hubcoursesettings'));
} else {
$visiblehtml = "";
$settingslinkhtml = "";
$checkboxhtml = "";
if (is_siteadmin()) {
//create Edit course link
$managecourseurl = new moodle_url($CFG->wwwroot . '/local/hub/admin/managecourses.php', array('courseid' => $course->id, 'sesskey' => sesskey()));
$courseatag = html_writer::tag('a', get_string('editcourse', 'local_hub'), array('href' => $managecourseurl));
$sitehtml = html_writer::tag('div', $courseatag, array('class' => 'coursesitelink'));
} else {
$sitehtml = "";
}
}
//create visit link html
$courseurl = '';
$linktext = '';
$visitlinkhtml = '';
if (!empty($course->courseurl)) {
$courseurl = new moodle_url($course->courseurl);
$linktext = get_string('visitsite', 'local_hub');
} else {
if (!empty($course->demourl)) {
$courseurl = new moodle_url($course->demourl);
$linktext = get_string('visitdemo', 'local_hub');
}
}
if (!empty($courseurl)) {
if (!$withwriteaccess) {
$courseurl = new moodle_url('', array('sesskey' => sesskey(), 'redirectcourseid' => $course->id));
}
$visitlinkhtml = html_writer::tag('a', $linktext, array('href' => $courseurl, 'class' => 'hubcoursedownload'));
}
// Create rating html.
$featuredhtml = "";
$rating = "";
if (has_capability('moodle/rating:rate', $course->rating->context)) {
$rating = html_writer::tag('div', $this->output->render($course->rating), array('class' => 'hubcourserating'));
} else {
if (!empty($course->rating) and $course->rating->count > 0) {
$featuredimg = array('src' => $CFG->wwwroot . '/local/hub/images/featured.png', 'class' => '', 'title' => get_string('featureddesc', 'local_hub'));
$featuredhtml = html_writer::empty_tag('img', $featuredimg);
$featuredhtml = html_writer::tag('div', $featuredhtml, array('class' => 'featuredimg'));
}
}
//create title html
$coursename = html_writer::tag('h3', $course->fullname, array('class' => 'hubcoursetitle'));
$coursenamehtml = html_writer::tag('div', $coursename, $course->privacy ? array('class' => 'hubcoursetitlepanel') : array('class' => 'dimmed_text', 'class' => 'hubcoursetitlepanel')) . $sitehtml;
// create screenshots html
$screenshothtml = '';
if (!empty($course->screenshots)) {
$baseurl = new moodle_url($CFG->wwwroot . '/local/hub/webservice/download.php', array('courseid' => $course->id, 'filetype' => HUB_SCREENSHOT_FILE_TYPE));
$screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $course->fullname));
}
$coursescreenshot = html_writer::tag('div', $screenshothtml, array('class' => 'coursescreenshot', 'id' => 'image-' . $course->id));
//create description html
$deschtml = html_writer::tag('div', $course->description, array('class' => 'hubcoursedescription'));
//create users related information html
$courseuserinfo = get_string('userinfo', 'local_hub', $course);
if ($course->contributornames) {
$courseuserinfo .= ' - ' . get_string('contributors', 'local_hub', $course->contributornames);
//.........这里部分代码省略.........