/home/elearningsmalsas/public_html/comment/lib.php
$replacements[] = html_writer::link($cmt->profileurl, $cmt->fullname);
$replacements[] = $cmt->content;
$replacements[] = $cmt->time;
// use html template to format a single comment.
return str_replace($patterns, $replacements, $this->template);
}
/**
* Revoke validate callbacks
*
* @param array $params addtionall parameters need to add to callbacks
*/
protected function validate($params=array()) {
foreach ($params as $key=>$value) {
$this->comment_param->$key = $value;
}
$validation = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'validate', array($this->comment_param), false);
if (!$validation) {
throw new comment_exception('invalidcommentparam');
}
}
/**
* Returns true if the user is able to view comments
* @return bool
*/
public function can_view() {
$this->validate();
return !empty($this->viewcap);
}
/**
* Returns true if the user can add comments against this comment description
* @return bool
*/
public function can_post() {
$this->validate();
return isloggedin() && !empty($this->postcap);
}
/home/elearningsmalsas/public_html/comment/lib.php
* Revoke validate callbacks
*
* @param array $params addtionall parameters need to add to callbacks
*/
protected function validate($params=array()) {
foreach ($params as $key=>$value) {
$this->comment_param->$key = $value;
}
$validation = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'validate', array($this->comment_param), false);
if (!$validation) {
throw new comment_exception('invalidcommentparam');
}
}
/**
* Returns true if the user is able to view comments
* @return bool
*/
public function can_view() {
$this->validate();
return !empty($this->viewcap);
}
/**
* Returns true if the user can add comments against this comment description
* @return bool
*/
public function can_post() {
$this->validate();
return isloggedin() && !empty($this->postcap);
}
/**
* Returns true if the user can delete this comment.
*
* The user can delete comments if it is one they posted and they can still make posts,
* or they have the capability to delete comments.
*
* A database call is avoided if a comment record is passed.
*
/home/elearningsmalsas/public_html/comment/lib.php
* Prepare comment code in html
* @param boolean $return
* @return string|void
*/
public function output($return = true) {
global $PAGE, $OUTPUT;
static $template_printed;
$this->initialise_javascript($PAGE);
if (!empty(self::$nonjs)) {
// return non js comments interface
return $this->print_comments(self::$comment_page, $return, true);
}
$html = '';
// print html template
// Javascript will use the template to render new comments
if (empty($template_printed) && $this->can_view()) {
$html .= html_writer::tag('div', $this->template, array('style' => 'display:none', 'id' => 'cmt-tmpl'));
$template_printed = true;
}
if ($this->can_view()) {
// print commenting icon and tooltip
$html .= html_writer::start_tag('div', array('class' => 'mdl-left'));
$html .= html_writer::link($this->get_nojslink($PAGE), get_string('showcommentsnonjs'), array('class' => 'showcommentsnonjs'));
if (!$this->notoggle) {
// If toggling is enabled (notoggle=false) then print the controls to toggle
// comments open and closed
$countstring = '';
if ($this->displaytotalcount) {
$countstring = '(' . html_writer::span($this->count(), 'comment-link-count') . ')';
}
$collapsedimage= 't/collapsed';
if (right_to_left()) {
$collapsedimage= 't/collapsed_rtl';
} else {
/home/elearningsmalsas/public_html/theme/edash/renderers/blog-renderer.php
// Comments.
if (!empty($entry->renderable->comment)) {
global $DB, $CFG, $PAGE, $USER, $COURSE;
$cmt = new stdClass();
$cmt->context = context_user::instance($entry->userid);
$cmt->courseid = $PAGE->course->id;
$cmt->area = 'format_blog';
$cmt->itemid = $entry->id;
$cmt->notoggle = true;
$cmt->showcount = $CFG->blogshowcommentscount;
$cmt->component = 'blog';
$cmt->autostart = true;
$cmt->displaycancel = false;
$edash_comments = new comment($cmt);
$edash_comments->set_view_permission(true);
$edash_comments->set_fullwidth();
$o .= $edash_comments->output(true);
}
$o .= $this->output->container_end();
// Closing maincontent div.
$o .= $this->output->container('', 'side options');
$o .= $this->output->container_end();
endif;
return $o;
}
/**
* Renders an entry attachment
*
* Print link for non-images and returns images as HTML
*
* @param blog_entry_attachment $attachment
* @return string List of attachments depending on the $return input
*/
public function render_blog_entry_attachment(blog_entry_attachment $attachment) {
/home/elearningsmalsas/public_html/lib/classes/output/plugin_renderer_base.php
* @param renderable $widget instance with renderable interface
* @return string
*/
public function render(renderable $widget) {
$classname = get_class($widget);
// Strip namespaces.
$classname = preg_replace('/^.*\\\/', '', $classname);
// Keep a copy at this point, we may need to look for a deprecated method.
$deprecatedmethod = "render_{$classname}";
// Remove _renderable suffixes.
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = "render_{$classname}";
if (method_exists($this, $rendermethod)) {
// Call the render_[widget_name] function.
// Note: This has a higher priority than the named_templatable to allow the theme to override the template.
return $this->$rendermethod($widget);
}
if ($widget instanceof named_templatable) {
// This is a named templatable.
// Fetch the template name from the get_template_name function instead.
// Note: This has higher priority than the deprecated method which is not overridable by themes anyway.
return $this->render_from_template(
$widget->get_template_name($this),
$widget->export_for_template($this)
);
}
if ($rendermethod !== $deprecatedmethod && method_exists($this, $deprecatedmethod)) {
// This is exactly where we don't want to be.
// If you have arrived here you have a renderable component within your plugin that has the name
// blah_renderable, and you have a render method render_blah_renderable on your plugin.
// In 2.8 we revamped output, as part of this change we changed slightly how renderables got rendered
// and the _renderable suffix now gets removed when looking for a render method.
// You need to change your renderers render_blah_renderable to render_blah.
// Until you do this it will not be possible for a theme to override the renderer to override your method.
/home/elearningsmalsas/public_html/blog/locallib.php
'search' => optional_param('search', null, PARAM_INT));
$urlparams = array_filter($urlparams);
$addurl->params($urlparams);
$addlink = '<div class="addbloglink">';
$addlink .= '<a href="'.$addurl->out().'">'. $blogheaders['stradd'].'</a>';
$addlink .= '</div>';
echo $addlink;
}
}
if ($entries) {
$count = 0;
foreach ($entries as $entry) {
$blogentry = new blog_entry(null, $entry);
// Get the required blog entry data to render it.
$blogentry->prepare_render();
echo $output->render($blogentry);
$count++;
}
echo $OUTPUT->render($pagingbar);
if (!$count) {
print '<br /><div style="text-align:center">'. get_string('noentriesyet', 'blog') .'</div><br />';
}
print $morelink.'<br />'."\n";
return;
}
}
// Find the base url from $_GET variables, for print_paging_bar.
public function get_baseurl() {
$getcopy = $_GET;
unset($getcopy['blogpage']);
/home/elearningsmalsas/public_html/blog/index.php
echo $OUTPUT->header();
if (!empty($user)) {
$backurl = new moodle_url('/user/view.php', ['id' => $user->id, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
$headerinfo = array('heading' => fullname($user), 'user' => $user);
echo $OUTPUT->context_header($headerinfo, 2);
}
} else if (isset($userid)) {
$PAGE->set_heading(fullname($user));
echo $OUTPUT->header();
} else if ($courseid == SITEID) {
echo $OUTPUT->header();
}
echo $OUTPUT->heading($blogheaders['heading'], 2);
$bloglisting = new blog_listing($blogheaders['filters']);
$bloglisting->print_entries();
if ($CFG->enablerssfeeds) {
blog_rss_print_link($rsscontext, $filtertype, $thingid, $tagid, get_string('rssfeed', 'blog'));
}
echo $OUTPUT->footer();
$eventparams = array(
'other' => array('entryid' => $entryid, 'tagid' => $tagid, 'userid' => $userid, 'modid' => $modid, 'groupid' => $groupid,
'search' => $search, 'fromstart' => $start)
);
if (!empty($userid)) {
$eventparams['relateduserid'] = $userid;
}
$eventparams['other']['courseid'] = ($courseid === SITEID) ? 0 : $courseid;
$event = \core\event\blog_entries_viewed::create($eventparams);
$event->trigger();