mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-19792 Fixed number of bugs in URLs
This commit is contained in:
parent
f4e6a86e41
commit
b0e90a0ccd
@ -52,7 +52,7 @@ class block_blog_menu extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $USER, $PAGE;
|
||||
global $CFG, $USER, $PAGE, $OUTPUT;
|
||||
|
||||
$context = $PAGE->get_context();
|
||||
|
||||
@ -72,7 +72,7 @@ class block_blog_menu extends block_base {
|
||||
$this->content = new stdClass;
|
||||
$this->content->footer = '';
|
||||
|
||||
$viewblogentries_url = blog_get_context_url();
|
||||
$viewblogentriesurl = blog_get_context_url();
|
||||
$strlevel = '';
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
@ -92,63 +92,48 @@ class block_blog_menu extends block_base {
|
||||
/// 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
|
||||
$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'));
|
||||
|
||||
$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";
|
||||
$menulist->add_item($OUTPUT->form($searchform, $formcontents));
|
||||
$this->content->text = $OUTPUT->htmllist($menulist);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class block_blog_tags extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $SITE, $USER, $DB;
|
||||
global $CFG, $SITE, $USER, $DB, $OUTPUT;
|
||||
|
||||
if (empty($CFG->usetags) || empty($CFG->bloglevel)) {
|
||||
$this->content->text = '';
|
||||
@ -139,11 +139,10 @@ class block_blog_tags extends block_base {
|
||||
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";
|
||||
|
||||
|
@ -37,6 +37,8 @@ $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tab - d
|
||||
|
||||
$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') {
|
||||
@ -229,8 +231,6 @@ if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
|
||||
$blog_headers = blog_get_headers();
|
||||
|
||||
$PAGE->requires->js('blog/edit_form.js');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
@ -68,7 +68,7 @@ class blog_edit_form extends moodleform {
|
||||
|
||||
$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();
|
||||
|
37
blog/lib.php
37
blog/lib.php
@ -179,14 +179,29 @@ function blog_remove_associations_for_user($userid) {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,7 +321,7 @@ function blog_fetch_external_entries($external_blog) {
|
||||
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;
|
||||
@ -341,10 +356,10 @@ function blog_get_context_url($context=null) {
|
||||
}
|
||||
|
||||
if (!empty($filterparam)) {
|
||||
$viewblogentries_url .= "$filterparam=$context->instanceid";
|
||||
$viewblogentriesurl->param($filterparam, $context->instanceid);
|
||||
}
|
||||
|
||||
return $viewblogentries_url;
|
||||
return $viewblogentriesurl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,12 @@ require_once($CFG->dirroot.'/blog/lib.php');
|
||||
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();
|
||||
|
@ -126,7 +126,7 @@ if (has_capability('moodle/blog:view', $systemcontext)) { // You have to see bl
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
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'));
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
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))) {
|
||||
@ -81,7 +81,7 @@
|
||||
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'));
|
||||
}
|
||||
|
||||
/**************************************
|
||||
@ -139,7 +139,7 @@
|
||||
) // 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))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user