}
function get_content() {
- global $CFG, $USER, $PAGE;
+ global $CFG, $USER, $PAGE, $OUTPUT;
$context = $PAGE->get_context();
$this->content = new stdClass;
$this->content->footer = '';
- $viewblogentries_url = blog_get_context_url();
+ $viewblogentriesurl = blog_get_context_url();
$strlevel = '';
switch ($context->contextlevel) {
/// Accessibility: markup as a list.
$blogmodon = false;
+ $menulist = new html_list();
+ $menulist->add_class('list');
if (!empty($strlevel)) {
- $output = '<li><a href="'.$viewblogentries_url.'">'.get_string('viewblogentries', 'blog', $strlevel).'</a></li>';
- }
-
- $parts = array();
- $query = parse_url($viewblogentries_url);
-
- if (!empty($query['query'])) {
- parse_str($query['query'], $parts);
+ $menulist->add_item($OUTPUT->link(html_link::make($viewblogentriesurl, get_string('viewblogentries', 'blog', $strlevel))));
}
// show View site entries link
if ($CFG->bloglevel >= BLOG_SITE_LEVEL && $canviewblogs) {
- $output .= '<li><a href="'. $CFG->wwwroot .'/blog/index.php">';
- $output .= get_string('viewsiteentries', 'blog')."</a></li>\n";
+ $menulist->add_item($OUTPUT->link(html_link::make($CFG->wwwroot .'/blog/index.php', get_string('viewsiteentries', 'blog'))));
}
$output .= '';
// show View my entries link
if ($context->contextlevel != CONTEXT_USER) {
- $output .= '<li><a href="'. $CFG->wwwroot .'/blog/index.php?userid='. $USER->id;
-
- foreach ($parts as $var => $val) {
- $output .= "&$var=$val";
- }
- $output .= '">'.get_string('viewmyentries', 'blog'). "</a></li>\n";
+ $myentrieslink = html_link::make(new moodle_url($CFG->wwwroot .'/blog/index.php', array('userid' => $USER->id)), get_string('viewmyentries', 'blog'));
+ $myentrieslink->url->params($viewblogentriesurl->params());
+ $menulist->add_item($OUTPUT->link($myentrieslink));
}
// show link to manage blog prefs
- $output .= '<li><a href="'. $CFG->wwwroot. '/blog/preferences.php?userid='.
- $USER->id .'">'.
- get_string('blogpreferences', 'blog')."</a></li>\n";
+ $blogpreflink = html_link::make(new moodle_url($CFG->wwwroot .'/blog/preferences.php', array('userid' => $USER->id)), get_string('blogpreferences', 'blog'));
+
+ $menulist->add_item($OUTPUT->link($blogpreflink));
// show Add entry link
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/blog:create', $sitecontext)) {
- $output .= '<li><a href="'. $CFG->wwwroot. '/blog/edit.php?action=add';
- foreach ($parts as $var => $val) {
- $output .= "&$var=$val";
- }
- $output .= '">'.get_string('addnewentry', 'blog') ."</a></li>\n";
+ $addentrylink = html_link::make(new moodle_url($CFG->wwwroot .'/blog/edit.php', array('action' => 'add')), get_string('addnewentry', 'blog'));
+ $addentrylink->url->params($viewblogentriesurl->params());
+ $menulist->add_item($OUTPUT->link($addentrylink));
}
// Full-text search field
-
- $output .= '<li><form method="get" action="'.$viewblogentries_url.'">';
- $output .= '<div><input type="text" name="search" /><input type="submit" value="'.get_string('search').'" />';
-
- if (!empty($parts)) {
- foreach ($parts as $var => $val) {
- $output .= '<input type="hidden" name="'.$var.'" value="'.$val.'" />';
- }
- }
-
- $output .= '</div></form></li>';
- $this->content->text = '<ul class="list">'. $output ."</ul>\n";
+ $searchform = new html_form();
+ $searchform->method = 'get';
+ $searchform->url = new moodle_url($viewblogentriesurl);
+ $searchform->button->text = get_string('search');
+ $formcontents = $OUTPUT->field(html_field::make_text('search'));
+
+ $menulist->add_item($OUTPUT->form($searchform, $formcontents));
+ $this->content->text = $OUTPUT->htmllist($menulist);
}
}
}
function get_content() {
- global $CFG, $SITE, $USER, $DB;
+ global $CFG, $SITE, $USER, $DB, $OUTPUT;
if (empty($CFG->usetags) || empty($CFG->bloglevel)) {
$this->content->text = '';
break;
}
- $link = blog_get_blogs_url(array($filtertype => $filterselect, 'tag'=>$tag->id));
- $this->content->text .= '<li><a href="'.$link.'" '.
- 'class="'.$tag->class.'" '.
- 'title="'.get_string('numberofentries','blog',$tag->ct).'">'.
- tag_display_name($tag) .'</a></li> ';
+ $link = html_link::make(blog_get_blogs_url(array($filtertype => $filterselect, 'tag'=>$tag->id)), tag_display_name($tag));
+ $link->add_class($tag->class);
+ $link->title = get_string('numberofentries','blog',$tag->ct);
+ $this->content->text .= '<li>' . $OUTPUT->link($link) . '</li> ';
}
$this->content->text .= "\n</ul>\n";
$PAGE->set_url('blog/edit.php', array('action' => $action, 'entryid' => $id, 'confirm' => $confirm, 'modid' => $modid, 'courseid' => $courseid));
+$blog_headers = blog_get_headers();
+
require_login($courseid);
if ($action == 'edit') {
print_error('invaliduserid');
}
-$blog_headers = blog_get_headers();
-
$PAGE->requires->js('blog/edit_form.js');
echo $OUTPUT->header();
$mform->addElement('format', 'format', get_string('format'));
- $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
+ $mform->addElement('filepicker', 'attachment', get_string('attachment', 'forum'), null, array('filetypes' => '*'));
//disable publishstate options that are not allowed
$publishstates = array();
*/
function blog_get_blogs_url($filters) {
global $CFG;
- return $CFG->wwwroot.'/blog/index.php?'.
- (empty($filters['course']) ? '' : 'courseid='.$filters['course'].'&').
- (empty($filters['mod']) ? '' : 'modid='.$filters['mod'].'&').
- (empty($filters['group']) ? '' : 'groupid='.$filters['group'].'&').
- (empty($filters['user']) ? '' : 'userid='.$filters['user'].'&').
- (empty($filters['entry']) ? '' : 'entryid='.$filters['entry'].'&').
- (empty($filters['tag']) ? '' : 'tagid='.$filters['tag'].'&').
- (empty($filters['tagtext']) ? '' : 'tag='.$filters['tagtext']);
+ $blogsurl = new moodle_url($CFG->wwwroot . '/blog/index.php');
+ if (!empty($filters['course'])) {
+ $blogsurl->param('courseid', $filters['course']);
+ }
+ if (!empty($filters['mod'])) {
+ $blogsurl->param('modid', $filters['mod']);
+ }
+ if (!empty($filters['group'])) {
+ $blogsurl->param('groupid', $filters['group']);
+ }
+ if (!empty($filters['user'])) {
+ $blogsurl->param('userid', $filters['user']);
+ }
+ if (!empty($filters['entry'])) {
+ $blogsurl->param('entryid', $filters['entry']);
+ }
+ if (!empty($filters['tag'])) {
+ $blogsurl->param('tagid', $filters['tag']);
+ }
+ if (!empty($filters['tagtext'])) {
+ $blogsurl->param('tag', $filters['tagtext']);
+ }
+ return $blogsurl;
}
/**
function blog_get_context_url($context=null) {
global $CFG;
- $viewblogentries_url = $CFG->wwwroot . '/blog/index.php?';
+ $viewblogentriesurl = new moodle_url($CFG->wwwroot . '/blog/index.php');
if (empty($context)) {
global $PAGE;
}
if (!empty($filterparam)) {
- $viewblogentries_url .= "$filterparam=$context->instanceid";
+ $viewblogentriesurl->param($filterparam, $context->instanceid);
}
- return $viewblogentries_url;
+ return $viewblogentriesurl;
}
/**
require_once('preferences_form.php');
$courseid = optional_param('courseid', SITEID, PARAM_INT);
-$PAGE->set_url('blog/preferences.php', array('courseid' => $courseid));
+$modid = optional_param('modid', null, PARAM_INT);
+$userid = optional_param('userid', null, PARAM_INT);
+$tagid = optional_param('tagid', null, PARAM_INT);
+$groupid = optional_param('groupid', null, PARAM_INT);
+
+$PAGE->set_url('blog/preferences.php', array('courseid' => $courseid, 'modid' => $modid, 'userid' => $userid, 'tagid' => $tagid, 'groupid' => $groupid));
if ($courseid == SITEID) {
require_login();
}
echo '</ul>';
- echo '<p class="moreblogs"><a href="'.blog_get_blogs_url(array('tag'=>$tag->id)).'">'.get_string('seeallblogs', 'tag', $tagname).'</a></p>';
+ echo '<p class="moreblogs"><a href="'.blog_get_blogs_url(array('tag'=>$tag->id))->out().'">'.get_string('seeallblogs', 'tag', $tagname).'</a></p>';
echo $OUTPUT->box_end();
}
get_string('participants'));
}
- $toprow[] = new tabobject('blogs', blog_get_blogs_url(array()),
+ $toprow[] = new tabobject('blogs', blog_get_blogs_url(array())->out(),
get_string('blogs','blog'));
}
get_string('participants'));
if ($CFG->bloglevel >= 3) {
- $toprow[] = new tabobject('blogs', blog_get_blogs_url(array('course'=>$filterselect)), get_string('blogs','blog'));
+ $toprow[] = new tabobject('blogs', blog_get_blogs_url(array('course'=>$filterselect))->out(), get_string('blogs','blog'));
}
if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $coursecontext) || has_capability('moodle/notes:view', $coursecontext))) {
get_string('participants'));
- $toprow[] = new tabobject('blogs', blog_get_blogs_url(array('group'=>$filterselect)), get_string('blogs','blog'));
+ $toprow[] = new tabobject('blogs', blog_get_blogs_url(array('group'=>$filterselect))->out(), get_string('blogs','blog'));
}
/**************************************
) // able to read blogs in site or course context
) { //end if
- $toprow[] = new tabobject('blogs', blog_get_blogs_url(array('user'=>$user->id,'course'=>$course->id)), get_string('blog', 'blog'));
+ $toprow[] = new tabobject('blogs', blog_get_blogs_url(array('user'=>$user->id,'course'=>$course->id))->out(), get_string('blog', 'blog'));
}
if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $coursecontext) || has_capability('moodle/notes:view', $coursecontext))) {