function get_content() { global $CFG; // detect if blog enabled if ($this->content !== NULL) { return $this->content; } if (empty($CFG->enableblogs)) { $this->content = new stdClass(); $this->content->text = ''; if ($this->page->user_is_editing()) { $this->content->text = get_string('blogdisable', 'blog'); } return $this->content; } else { if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL and (!isloggedin() or isguestuser())) { $this->content = new stdClass(); $this->content->text = ''; return $this->content; } } // require necessary libs and get content require_once $CFG->dirroot . '/blog/lib.php'; // Prep the content $this->content = new stdClass(); $options = blog_get_all_options($this->page); if (count($options) == 0) { $this->content->text = ''; return $this->content; } // Iterate the option types $menulist = array(); foreach ($options as $types) { foreach ($types as $link) { $menulist[] = html_writer::link($link['link'], $link['string']); } $menulist[] = '<hr />'; } // Remove the last element (will be an HR) array_pop($menulist); // Display the content as a list $this->content->text = html_writer::alist($menulist, array('class' => 'list')); // Prepare the footer for this block if (has_capability('moodle/blog:search', context_system::instance())) { // Full-text search field $form = html_writer::tag('label', get_string('search', 'admin'), array('for' => 'blogsearchquery', 'class' => 'accesshide')); $form .= html_writer::empty_tag('input', array('id' => 'blogsearchquery', 'type' => 'text', 'name' => 'search')); $form .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('search'))); $this->content->footer = html_writer::tag('form', html_writer::tag('div', $form), array('class' => 'blogsearchform', 'method' => 'get', 'action' => new moodle_url('/blog/index.php'))); } else { // No footer to display $this->content->footer = ''; } // Return the content object return $this->content; }
function get_content() { // Check if we've already generated content if (!empty($this->content)) { return $this->content; } // Prep the content $this->content = new stdClass(); /** * Prepare the content for this block */ $options = blog_get_all_options($this->page); if (count($options) == 0) { // Don't display menu block if block is set at site level, and user is not logged in $this->content->text = ''; if ($this->page->user_is_editing()) { // If editing is enabled show an informative message $this->content->text = get_string('blogdisable', 'blog'); } return $this->content; } // Iterate the option types $menulist = array(); foreach ($options as $types) { foreach ($types as $link) { $menulist[] = html_writer::link($link['link'], $link['string']); } $menulist[] = '<hr />'; } // Remove the last element (will be an HR) array_pop($menulist); // Display the content as a list $this->content->text = html_writer::alist($menulist, array('class' => 'list')); /** * Prepare the footer for this block */ if (has_capability('moodle/blog:search', get_context_instance(CONTEXT_SYSTEM))) { // Full-text search field $form = html_writer::tag('label', get_string('search', 'admin'), array('for' => 'blogsearchquery', 'class' => 'accesshide')); $form .= html_writer::empty_tag('input', array('id' => 'blogsearchquery', 'type' => 'text', 'name' => 'search')); $form .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('search'))); $this->content->footer = html_writer::tag('form', html_writer::tag('div', $form), array('class' => 'blogsearchform', 'method' => 'get', 'action' => new moodle_url('/blog/index.php'))); } else { // No footer to display $this->content->footer = ''; } // Return the content object return $this->content; }