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; }
/** * * * * * */ 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); }
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); }
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); } }
/** * 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; }
/** * 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; }
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; }
function specialization() { // require js for commenting comment::init(); }
/** * 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; } } } switch ($format) { case FORMAT_HTML: if ($options->smiley) { replace_smilies($text); } if (!$options->noclean) { $text = clean_text($text, FORMAT_HTML); } $text = $filtermanager->filter_text($text, $context, $courseid); break; case FORMAT_PLAIN: $text = s($text); // cleans dangerous JS $text = rebuildnolinktag($text); $text = str_replace(' ', ' ', $text); $text = nl2br($text); break; case FORMAT_WIKI: // this format is deprecated $text = '<p>NOTICE: Wiki-like formatting has been removed from Moodle. You should not be seeing this message as all texts should have been converted to Markdown format instead. Please post a bug report to http://moodle.org/bugs with information about where you saw this message.</p>' . s($text); break; case FORMAT_MARKDOWN: $text = markdown_to_html($text); if ($options->smiley) { replace_smilies($text); } if (!$options->noclean) { $text = clean_text($text, FORMAT_HTML); } $text = $filtermanager->filter_text($text, $context, $courseid); break; default: // FORMAT_MOODLE or anything else $text = text_to_html($text, $options->smiley, $options->para, $options->newlines); if (!$options->noclean) { $text = clean_text($text, FORMAT_HTML); } $text = $filtermanager->filter_text($text, $context, $courseid); break; } // Warn people that we have removed this old mechanism, just in case they // were stupid enough to rely on it. if (isset($CFG->currenttextiscacheable)) { debugging('Once upon a time, Moodle had a truly evil use of global variables ' . 'called $CFG->currenttextiscacheable. The good news is that this no ' . 'longer exists. The bad news is that you seem to be using a filter that ' . 'relies on it. Please seek out and destroy that filter code.', DEBUG_DEVELOPER); } if (empty($options->nocache) and !empty($CFG->cachetext)) { if (CLI_SCRIPT) { // special static cron cache - no need to store it in db if its not already there if (count($croncache) > 150) { reset($croncache); $key = key($croncache); unset($croncache[$key]); } $croncache[$md5key] = $text; return $text . $cmt; } $newcacheitem = new object(); $newcacheitem->md5key = $md5key; $newcacheitem->formattedtext = $text; $newcacheitem->timemodified = time(); if ($oldcacheitem) { // See bug 4677 for discussion $newcacheitem->id = $oldcacheitem->id; try { $DB->update_record('cache_text', $newcacheitem); // Update existing record in the cache table } catch (dml_exception $e) { // It's unlikely that the cron cache cleaner could have // deleted this entry in the meantime, as it allows // some extra time to cover these cases. } } else { try { $DB->insert_record('cache_text', $newcacheitem); // Insert a new record in the cache table } catch (dml_exception $e) { // Again, it's possible that another user has caused this // record to be created already in the time that it took // to traverse this function. That's OK too, as the // call above handles duplicate entries, and eventually // the cron cleaner will delete them. } } } return $text . $cmt; }
/** * 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); } } } // Notifications for not ready, early and past due. $this->set_notification_activity_not_ready($pagefile); return $htmloutput; }
/** * 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); } $courseuserinfo .= html_writer::tag('a', html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/email'), 'class' => 'hubcoursemail', 'alt' => get_string('msgtopublisher', 'local_hub', $course->fullname))), array('href' => new moodle_url('/local/hub/sendmessage.php', array('id' => $course->id, 'admin' => $withwriteaccess)))); $courseuserinfohtml = html_writer::tag('div', $courseuserinfo, array('class' => 'hubcourseuserinfo')); //create course content related information html $course->subject = get_string($course->subject, 'edufields'); $course->audience = get_string('audience' . $course->audience, 'hub'); $course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub'); $coursecontentinfo = ''; if (empty($course->coverage)) { $course->coverage = ''; } else { $coursecontentinfo .= get_string('coverage', 'local_hub', $course->coverage); $coursecontentinfo .= ' - '; } $coursecontentinfo .= get_string('contentinfo', 'local_hub', $course); $coursecontentinfohtml = html_writer::tag('div', $coursecontentinfo, array('class' => 'hubcoursecontentinfo')); ///create course file related information html //language if (!empty($course->language)) { $languages = get_string_manager()->get_list_of_languages(); $course->lang = $languages[$course->language]; } else { $course->lang = ''; } //licence require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licenses = $licensemanager->get_licenses(); foreach ($licenses as $license) { if ($license->shortname == $course->licenceshortname) { $course->license = $license->fullname; } } $course->timeupdated = userdate($course->timemodified); $coursefileinfo = get_string('fileinfo', 'local_hub', $course); $coursefileinfohtml = html_writer::tag('div', $coursefileinfo, array('class' => 'hubcoursefileinfo')); //Create course content html $blocksandactivities = ''; if (!empty($course->contents)) { $activitieshtml = ''; $blockhtml = ''; foreach ($course->contents as $content) { if ($content->moduletype == 'block') { if (!empty($blockhtml)) { $blockhtml .= ' - '; } $blockpath = get_component_directory('block_' . $content->modulename); $blockname = !is_dir($blockpath) ? $content->modulename : get_string('pluginname', 'block_' . $content->modulename); $blockhtml .= $blockname . " (" . $content->contentcount . ")"; } else { if (!empty($activitieshtml)) { $activitieshtml .= ' - '; } $activitypath = get_component_directory($content->modulename); $activityname = !is_dir($activitypath) ? $content->modulename : get_string('modulename', $content->modulename); $activitieshtml .= $activityname . " (" . $content->contentcount . ")"; } } $blocksandactivities = html_writer::tag('div', get_string('activities', 'local_hub') . " : " . $activitieshtml); //Uncomment following lines to display blocks information // $blocksandactivities .= html_writer::tag('span', // get_string('blocks', 'local_hub') . " : " . $blockhtml); } //Create outcomes html $outcomes = ''; if (!empty($course->outcomes)) { $outcomes = get_string('outcomes', 'local_hub', implode(', ', $course->outcomes)); } $outcomeshtml = html_writer::tag('div', $outcomes, array('class' => 'hubcourseoutcomes')); //create additional information html $additionaldesc = $courseuserinfohtml . $coursecontentinfohtml . $coursefileinfohtml . $blocksandactivities . $outcomeshtml; $additionaldeschtml = html_writer::tag('div', $additionaldesc, array('class' => 'additionaldesc')); //create download button html $downloadbuttonhtml = ""; if (!$course->enrollable) { $params['courseid'] = $course->id; $params['filetype'] = HUB_BACKUP_FILE_TYPE; $params['remotemoodleurl'] = $CFG->wwwroot; $addurl = new moodle_url('/local/hub/webservice/download.php', $params); $downloadbuttonhtml = html_writer::tag('a', get_string('download', 'block_community'), array('href' => $addurl, 'class' => 'centeredbutton, hubcoursedownload')); } //create addthis button $courseurl = new moodle_url('', array('courseid' => $course->id)); $courseurl = $courseurl->out(); //TODO: admin could be able to enter their own pubid into the administration settings page $addthis = "<!-- AddThis Button BEGIN -->\n <div class=\"addthis_toolbox\">\n <div class=\"custom_images\">\n\n <a class=\"addthis_button_facebook\" addthis:url=\"" . $CFG->wwwroot . $courseurl . "\"\n addthis:title=\"" . $course->fullname . "\">\n <img src=\"" . $CFG->wwwroot . "/local/hub/images/facebook.png\" \n width=\"40\" height=\"40\" border=\"0\" alt=\"" . get_string('sharetofacebook', 'local_hub') . "\" /></a>\n <a class=\"addthis_button_twitter\" addthis:url=\"" . $CFG->wwwroot . $courseurl . "\"\n addthis:title=\"" . $course->fullname . "\">\n <img src=\"" . $CFG->wwwroot . "/local/hub/images/twitter.png\" \n width=\"40\" height=\"40\" border=\"0\" alt=\"" . get_string('sharetotwitter', 'local_hub') . "\" /></a>\n <a class=\"addthis_button_more\" addthis:url=\"" . $CFG->wwwroot . $courseurl . "\"\n addthis:title=\"" . $course->fullname . "\">\n <img src=\"" . $CFG->wwwroot . "/local/hub/images/addthis.png\" \n width=\"40\" height=\"40\" border=\"0\" alt=\"" . get_string('sharemore', 'local_hub') . "\" /></a>\n </div>\n </div>\n <script type=\"text/javascript\">\n var addthis_config = {\n \"services_exclude\" : \"print\",\n \"data_track_clickback\":true\n };\n </script>\n <!-- Note that the pubid is the default one from addthis -->\n <script type=\"text/javascript\" \n src=\"http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4db7875a502228bd\"></script> \n <!-- AddThis Button END -->"; $addthis = html_writer::tag('div', $addthis, array('class' => 'addthis')); //Create comments html $comment = html_writer::tag('div', get_string('nocomments', 'local_hub'), array('class' => 'nocomments')); if (!empty($course->comment)) { //display only if there is some comment if there is some comment $commentcount = $course->comment->count(); if ($commentcount != 0 or has_capability('moodle/comment:post', $course->comment->get_context())) { $comment = html_writer::tag('div', $course->comment->output(true), array('class' => 'hubcoursecomments')); } } //creator notes $creatornotes = ''; if (!empty($course->creatornotes)) { if (count($courses) == 1) { //creator notes $creatornotes = html_writer::tag('div', get_string('creatornotes', 'local_hub') . ':', array('class' => 'creatornotestitle')); $creatornotes .= html_writer::tag('div', format_text($course->creatornotes, $course->creatornotesformat), array('class' => 'creatornotes')); } else { //more details button $creatornotesurl = new moodle_url('', array('courseid' => $course->id)); $creatornotes = html_writer::tag('a', get_string('seecreatornotes', 'local_hub'), array('class' => 'seecreatornotes', 'href' => $creatornotesurl)); } } //the main DIV tags $buttonsdiv = html_writer::tag('div', $downloadbuttonhtml . $visitlinkhtml, array('class' => 'courseoperations')); $screenshotbuttonsdiv = html_writer::tag('div', $coursescreenshot . $buttonsdiv . $featuredhtml, array('class' => 'courselinks')); $coursedescdiv = html_writer::tag('div', $deschtml . $additionaldeschtml . $comment . $rating . $creatornotes . $addthis, array('class' => 'coursedescription')); $coursehtml = $coursenamehtml . html_writer::tag('div', $coursedescdiv . $screenshotbuttonsdiv, array('class' => 'hubcourseinfo clearfix')); $coursehtml .= html_writer::tag('div', $checkboxhtml . $visiblehtml . $settingslinkhtml, array('class' => 'hubadminoperations clearfix')); $renderedhtml .= html_writer::tag('div', $coursehtml, array('class' => 'fullhubcourse clearfix')); } $renderedhtml = html_writer::tag('div', $renderedhtml, array('class' => 'hubcourseresult')); //add the select bulk operation if ($withwriteaccess) { $selecthtml = html_writer::select(array('bulkdelete' => get_string('bulkdelete', 'local_hub'), 'bulkvisible' => get_string('bulkvisible', 'local_hub'), 'bulknotvisible' => get_string('bulknotvisible', 'local_hub')), 'bulkselect', '', array('' => get_string('bulkselectoperation', 'local_hub'))); $renderedhtml .= html_writer::tag('div', $selecthtml, array('class' => 'hubbulkselect')); //perform button $optionalurlparams['sesskey'] = sesskey(); $bulkformparam['method'] = 'post'; $bulkformparam['action'] = new moodle_url('', $optionalurlparams); $bulkbutton = html_writer::empty_tag('input', array('class' => 'bulksubmitbutton', 'name' => 'bulksubmitbutton', 'id' => 'bulksubmit', 'type' => 'submit', 'value' => get_string('bulkoperationperform', 'local_hub'))); $renderedhtml .= html_writer::tag('div', $bulkbutton, array('class' => 'hubbulkbutton')); $renderedhtml = html_writer::tag('form', $renderedhtml, $bulkformparam); $renderedhtml = html_writer::tag('div', $renderedhtml); } } return $renderedhtml; }