From: martin Date: Tue, 10 Sep 2002 13:47:56 +0000 (+0000) Subject: Changes to course display on front page when there is more than one category X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0c6561819b840be723d70e63be176f517d561c0d;p=moodle.git Changes to course display on front page when there is more than one category --- diff --git a/course/lib.php b/course/lib.php index 552e091b25..6fa7e0bc5b 100644 --- a/course/lib.php +++ b/course/lib.php @@ -597,19 +597,62 @@ function print_course_admin_links($course, $width=180) { function print_course_categories($categories, $selected="none", $width=180) { global $CFG, $THEME, $USER; - foreach ($categories as $cat) { - $caticon[]="wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>"; - if ($cat->id == $selected) { - $catdata[]="$cat->name"; - } else { - $catdata[]="wwwroot/course/index.php?category=$cat->id\">$cat->name"; + if ($selected == "index") { // Print comprehensive index of categories with courses + if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY shortname")) { + if (isset($USER->id) and !isadmin()) { + print_simple_box_start("LEFT", "100%"); + print_heading("".get_string("mycourses")."", "LEFT"); + $some = false; + echo ""; + print_simple_box_end(); + print_spacer(8,1); + } + foreach ($categories as $category) { + print_simple_box_start("LEFT", "100%"); + print_heading("$category->name", "LEFT"); + $some = false; + echo ""; + print_simple_box_end(); + print_spacer(8,1); + } } + + } else { // Print short list of categories only + foreach ($categories as $cat) { + $caticon[]="wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>"; + if ($cat->id == $selected) { + $catdata[]="$cat->name"; + } else { + $catdata[]="wwwroot/course/index.php?category=$cat->id\">$cat->name"; + } + } + $catdata[] = "wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses").""; + if (isset($USER->id)) { + $catdata[] = "wwwroot/course/index.php?category=my\">".get_string("mycourses").""; + } + print_side_block("", $catdata, $showall.$mine, $caticon, $width); } - $catdata[] = "wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses").""; - if (isset($USER->id)) { - $catdata[] = "wwwroot/course/index.php?category=my\">".get_string("mycourses").""; - } - print_side_block("", $catdata, $showall.$mine, $caticon, $width); } function print_log_graph($course, $userid=0, $type="course.png", $date=0) { diff --git a/index.php b/index.php index 0303e12b99..c6b397e499 100644 --- a/index.php +++ b/index.php @@ -85,7 +85,12 @@ if ($site->newsitems == 0 ) { print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading"); print_spacer(8,1); - print_all_courses("all"); + $categories = get_all_categories(); + if (count($categories) > 1) { + print_course_categories($categories, "index"); + } else { + print_all_courses("all"); + } } else { if (! $newsforum = forum_get_course_forum($site->id, "news")) { diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 395a019ad1..d39a966a44 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -288,7 +288,7 @@ $string[newsitems] = "news items"; $string[newsitemsnumber] = "News items to show"; $string[never] = "Never"; $string[no] = "No"; -$string[nocoursesyet] = "There are no courses yet"; +$string[nocoursesyet] = "No courses in this category"; $string[noexistingteachers] = "No existing teachers"; $string[nograde] = "No grade"; $string[nopotentialteachers] = "No potential teachers";