]> git.mjollnir.org Git - moodle.git/commitdiff
course search: MDL-10801 Search terms were not being highlighted consistently in...
authortjhunt <tjhunt>
Thu, 11 Dec 2008 10:47:48 +0000 (10:47 +0000)
committertjhunt <tjhunt>
Thu, 11 Dec 2008 10:47:48 +0000 (10:47 +0000)
course/index.php
course/lib.php
course/search.php

index f711fa85eb3e9680cc5dd1e3ed5fdec1e5b34189..cd58288092aac52dedc85456b3967ecd7841f45e 100644 (file)
         print_category_edit_header();
         print_heading($heading);
 
-        if ($data->fulldelete) {
+        if ($datadelete) {
             category_delete_full($deletecat, true);
         } else {
             category_delete_move($deletecat, $data->newparent, true);
     echo '</tr>';
 
     print_category_edit(NULL, $displaylist, $parentlist);
-
     echo '</table>';
 
     echo '<div class="buttons">';
-
     if (has_capability('moodle/course:create', $systemcontext)) {
         // print create course link to first category
         $options = array();
     }
 
     print_course_request_buttons($systemcontext);
+    echo '</div>';
 
     admin_externalpage_print_footer();
 
index a3b1bc4b3323f00fde0345e5b0eaea6168e0b8cf..22b4036411d36ccd19f7086b4f9a80b8eff93461 100644 (file)
@@ -2077,8 +2077,13 @@ function print_courses($category) {
     }
 }
 
-
-function print_course($course) {
+/**
+ * Print a description of a course, suitable for browsing in a list.
+ *
+ * @param object $course the course object.
+ * @param string $highlightterms (optional) some search terms that should be highlighted in the display.
+ */
+function print_course($course, $highlightterms = '') {
     global $CFG, $USER, $DB;
 
     if (isset($course->context)) {
@@ -2093,7 +2098,7 @@ function print_course($course) {
     echo '<div class="info">';
     echo '<div class="name"><a title="'.get_string('entercourse').'"'.
          $linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
-         format_string($course->fullname).'</a></div>';
+         highlight($highlightterms, format_string($course->fullname)).'</a></div>';
 
     /// first find all roles that are supposed to be displayed
 
@@ -2180,7 +2185,7 @@ function print_course($course) {
     $options = NULL;
     $options->noclean = true;
     $options->para = false;
-    echo format_text($course->summary, FORMAT_MOODLE, $options,  $course->id);
+    echo highlight($highlightterms, format_text($course->summary, FORMAT_MOODLE, $options,  $course->id));
     echo '</div>';
     echo '</div>';
 }
@@ -2213,7 +2218,7 @@ function print_my_moodle() {
                     continue;
                 }
                 echo '<li>';
-                print_course($course, "100%");
+                print_course($course);
                 echo "</li>\n";
             }
             echo "</ul>\n";
index 0abf631fd7c4d31db9317e88802d46397976b546..299bb1400f95076f76839fa403737beca609b46b 100644 (file)
         require_login();
     }
 
-    if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) {
+    if (update_category_button()) {
         if ($edit !== -1) {
             $USER->categoryediting = $edit;
-            // If the edit mode we are leaving has higher per page than the one we are entering,
-            // with pages, chances are you will get a no courses found error. So when we are switching
-            // modes, set page to 0.
-            $page = 0;
         }
+        $adminediting = !empty($USER->categoryediting);
+    } else {
+        $adminediting = false;
     }
 
 /// Editing functions
-
     if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM))) {
-
     /// Hide or show a course
-
         if ($hide or $show and confirm_sesskey()) {
             if ($hide) {
                 $course = $DB->get_record("course", array("id"=>$hide));
@@ -63,7 +59,6 @@
                 }
             }
         }
-
     }
 
     if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM)) && $perpage != 99999) {
     }
 
     if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) {   // Some courses are being moved
-
         if (! $destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
             print_error('cannotfindcategory', '', '', $data->moveto);
         }
         }
     }
     else {
-        $courses = get_courses_search($searchterms, "fullname ASC", 
+        $courses = get_courses_search($searchterms, "fullname ASC",
             $page, $perpage, $totalcount);
     }
 
 
     print_header("$site->fullname : $strsearchresults", $site->fullname, $navigation, "", "", "", $searchform);
 
-
     $lastcategory = -1;
     if ($courses) {
-
         print_heading("$strsearchresults: $totalcount");
-
         $encodedsearch = urlencode($search);
-        
+
      ///add the module parameter to the paging bar if they exists
         $modulelink = "";
         if (!empty($modulelist) and confirm_sesskey()) {
             $modulelink = "&amp;modulelist=".$modulelist."&amp;sesskey=".$USER->sesskey;
         }
-             
-        print_navigation_bar($totalcount,$page,$perpage,$encodedsearch,$modulelink);
 
-        if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+        print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink);
+
+        if (!$adminediting) {
             foreach ($courses as $course) {
-                $course->fullname = highlight(trim($search, '+'), $course->fullname);
-                $course->summary = highlight(trim($search, '+'), $course->summary);
                 $course->summary .= "<br /><p class=\"category\">";
                 $course->summary .= "$strcategory: <a href=\"category.php?id=$course->category\">";
                 $course->summary .= $displaylist[$course->category];
                 $course->summary .= "</a></p>";
-                print_course($course);
+                print_course($course, $search);
                 print_spacer(5,5);
             }
-        } else { // slightly more sophisticated
-
+        } else {
+        /// Show editing UI.
             echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
             echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
             echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
             echo "<th scope=\"col\">$strselect</th>\n";
             echo "<th scope=\"col\">$stredit</th></tr>\n";
 
-            foreach ($courses as $course) {                        
-                
+            foreach ($courses as $course) {
+
                 if (isset($course->context)) {
                     $coursecontext = $course->context;
                 } else {
                     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
                 }
 
-                $course->fullname = highlight(trim($search, '+'), $course->fullname);
                 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
 
                 // are we displaying the front page (courseid=1)?
 
                 echo "<tr>\n";
                 echo "<td><a $linkcss href=\"view.php?id=$course->id\">"
-                    . format_string($course->fullname) . "</a></td>\n";
+                    . highlight($search, format_string($course->fullname)) . "</a></td>\n";
                 echo "<td>".$displaylist[$course->category]."</td>\n";
                 echo "<td>\n";