Tweaks to category display

This commit is contained in:
martin 2002-09-09 12:37:34 +00:00
parent ba2e5d7347
commit 0a26320532
3 changed files with 40 additions and 13 deletions

View File

@ -4,39 +4,50 @@
require("../config.php");
require("lib.php");
optional_variable($category, 0);
optional_variable($category, "");
$strcourses = get_string("courses");
$strcategories = get_string("categories");
$strmycourses = get_string("mycourses");
$strfulllistofcourses = get_string("fulllistofcourses");
if (!$categories = get_all_categories()) {
error("Could not find any course categories!");
}
if (isset($categories[$category])) {
$thiscatname = $categories[$category]->name;
$navigation = "<A HREF=\"index.php\">$strcourses</A> -> $thiscatname";
if ($category == "all") {
$title = $strfulllistofcourses;
$navigation = "<A HREF=\"index.php\">$strcourses</A> -> $title";
} else if ($category == "my") {
$title = $strmycourses;
$navigation = "<A HREF=\"index.php\">$strcourses</A> -> $title";
} else if (isset($categories[$category])) {
$title = $categories[$category]->name;
$navigation = "<A HREF=\"index.php\">$strcourses</A> -> $title";
} else {
$navigation = $strcourses;
}
print_header($strcourses, $strcourses, $navigation);
$showcategories = (count($categories) > 1);
if ($showcategories) {
echo "<TABLE WIDTH=\"100%\" CELLPADDING=10 BORDER=0>";
echo "<TR><TD WIDTH=180 VALIGN=TOP>";
print_simple_box(get_string("categories"), "CENTER", 180, $THEME->cellheading);
print_simple_box($strcategories, "CENTER", 180, $THEME->cellheading);
print_course_categories($categories, $category, 180);
echo "</TD><TD WIDTH=\"100%\" VALIGN=TOP>";
} else {
echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD VALIGN=top>";
$category="all";
unset($title);
}
if ($category) {
if ($category != "all") {
print_simple_box($categories[$category]->name, "CENTER", "100%", $THEME->cellheading);
echo "<BR>";
if (isset($title)) {
print_simple_box($title, "CENTER", "100%", $THEME->cellheading);
}
echo "<BR>";
print_all_courses($category);
}

View File

@ -173,10 +173,22 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
function print_all_courses($category="all", $style="full", $maxcount=999) {
global $CFG;
global $CFG, $USER;
if ($category == "all") {
$courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC");
} else if ($category == "my") {
if (isset($USER->id)) {
if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC")) {
foreach ($courses as $key => $course) {
if (!isteacher($course->id) and !isstudent($course->id)) {
unset($courses[$key]);
}
}
}
}
} else {
$courses = get_records("course", "category", $category, "fullname ASC");
}
@ -583,7 +595,7 @@ function print_course_admin_links($course, $width=180) {
}
function print_course_categories($categories, $selected="none", $width=180) {
global $CFG, $THEME;
global $CFG, $THEME, $USER;
foreach ($categories as $cat) {
$caticon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>";
@ -593,8 +605,11 @@ function print_course_categories($categories, $selected="none", $width=180) {
$catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>";
}
}
$showall = "<P><A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>...";
print_side_block("", $catdata, $showall, $caticon, $width);
$catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>";
if (isset($USER->id)) {
$catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=my\">".get_string("mycourses")."</A>";
}
print_side_block("", $catdata, $showall.$mine, $caticon, $width);
}
function print_log_graph($course, $userid=0, $type="course.png", $date=0) {

View File

@ -143,7 +143,7 @@ $string[formattopics] = "Topics format";
$string[formatweeks] = "Weekly format";
$string[frontpagedescription] = "Front page description";
$string[frontpageformat] = "Front page format";
$string[fulllistofcourses] = "Show all courses";
$string[fulllistofcourses] = "All courses";
$string[fullprofile] = "Full profile";
$string[fullname] = "Full name";
$string[fullsitename] = "Full site name";
@ -252,6 +252,7 @@ $string[moveup] = "Move up";
$string[movetoanotherfolder] = "Move to another folder";
$string[movefilestohere] = "Move files to here";
$string[mustconfirm] = "You need to confirm your login";
$string[mycourses] = "My courses";
$string[name] = "Name";
$string[namesocial] = "section";
$string[nametopics] = "topic";