]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19792 Fixed number of bugs in URLs
authornicolasconnault <nicolasconnault>
Wed, 9 Sep 2009 03:26:18 +0000 (03:26 +0000)
committernicolasconnault <nicolasconnault>
Wed, 9 Sep 2009 03:26:18 +0000 (03:26 +0000)
blocks/blog_menu/block_blog_menu.php
blocks/blog_tags/block_blog_tags.php
blog/edit.php
blog/edit_form.php
blog/lib.php
blog/preferences.php
tag/index.php
user/tabs.php

index 19823d92e3ed9799d90430cec76c2c1d0cf174c9..bfd6b2a1e5b41b607e0ea32562d0fee6c46c5158 100755 (executable)
@@ -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 .= "&amp;$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 .= "&amp;$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);
     }
 }
index 6b410d4bf882941e618d3b6cbe5f7605d82bcb90..8dfbab78f78f6b25610ea214c1bbcf1746307d87 100644 (file)
@@ -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";
 
index e76e6f9f27001a00f060a90ef40b925f9cdc32e8..2d0214c64257c54885d0f5f1082e613459e410dd 100755 (executable)
@@ -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();
index 34df8ec8fcd5ea102037bfeab560a4c0072119e7..ba0087b801165bfc243c7602b0740825ed7ebf10 100644 (file)
@@ -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();
index 73eec5baafbeb2db2f4567d95dc878a70a395ea4..957b697c2513df4a6fa4ca6a8d9c659fae9d4489 100755 (executable)
@@ -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'].'&amp;').
-        (empty($filters['mod']) ? '' : 'modid='.$filters['mod'].'&amp;').
-        (empty($filters['group']) ? '' : 'groupid='.$filters['group'].'&amp;').
-        (empty($filters['user']) ? '' : 'userid='.$filters['user'].'&amp;').
-        (empty($filters['entry']) ? '' : 'entryid='.$filters['entry'].'&amp;').
-        (empty($filters['tag']) ? '' : 'tagid='.$filters['tag'].'&amp;').
-        (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;
 }
 
 /**
index 6b28503fd308afb94a895f601858b335cf5fabe3..66c16579531802bf85ff06e92f08eac8b0072cce 100755 (executable)
@@ -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();
index 1d43d3295ee922d1d476ad78114f9ebb098a8458..af78d6140ad8a76cacc2a51a104c444fe031b6c7 100644 (file)
@@ -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();
     }
index 00d7f16de7a7bc126405cc0fffe06fe4f142e580..344dfa33bbbbbc50efd6b956d81af01e2cc89eb6 100644 (file)
@@ -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'));
         }
 
     /**************************************
             ) // 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))) {