Improved category and course list display on front page- see bug Bug #5965 - Frontpage Category List also showing courses; new Combo List(categories + courses), fixed categories list and separate settings for not logged in / logged in users; merged from MOODLE_16_STABLE

This commit is contained in:
skodak 2006-07-19 12:10:07 +00:00
parent fa145ae1af
commit 6f24e48e1f
6 changed files with 76 additions and 25 deletions

View file

@ -14,11 +14,13 @@ define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); // courses
define('COURSE_MAX_COURSES_PER_DROPDOWN',1000); // max courses in log dropdown before switching to optional
define('COURSE_MAX_USERS_PER_DROPDOWN',1000); // max users in log dropdown before switching to optional
define('FRONTPAGENEWS', 0);
define('FRONTPAGECOURSELIST', 1);
define('FRONTPAGECATEGORYNAMES', 2);
define('FRONTPAGETOPICONLY', 3);
define("EXCELROWS", 65535);
define("FIRSTUSEDEXCELROW", 3);
define('FRONTPAGECOURSELIST', 1);
define('FRONTPAGECATEGORYNAMES', 2);
define('FRONTPAGETOPICONLY', 3);
define('FRONTPAGECATEGORYCOMBO', 4);
define('FRONTPAGECOURSELIMIT', 200); // maximum number of courses displayed on the frontpage
define('EXCELROWS', 65535);
define('FIRSTUSEDEXCELROW', 3);
function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0, $selecteddate="lastlogin",
@ -1314,7 +1316,7 @@ function make_categories_list(&$list, &$parents, $category=NULL, $path="") {
}
function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1) {
function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1, $files = false) {
/// Recursive function to print out all the categories in a nice format
/// with or without courses included
global $CFG;
@ -1329,7 +1331,7 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli
if ($category) {
if ($category->visible or iscreator()) {
print_category_info($category, $depth);
print_category_info($category, $depth, $files);
} else {
return; // Don't bother printing children of invisible categories
}
@ -1352,7 +1354,7 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli
$down = $last ? false : true;
$first = false;
print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1);
print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1, $files);
}
}
}
@ -1373,7 +1375,7 @@ function make_categories_options() {
return $cats;
}
function print_category_info($category, $depth) {
function print_category_info($category, $depth, $files = false) {
/// Prints the category info in indented fashion
/// This function is only used by print_whole_category_list() above
@ -1388,10 +1390,8 @@ function print_category_info($category, $depth) {
$catlinkcss = $category->visible ? '' : ' class="dimmed" ';
$frontpage = explode(',', $CFG->frontpage);
$frontpage = $frontpage?array_flip($frontpage):array();
$coursecount = count_records('course') <= 200;
if (isset($frontpage[FRONTPAGECATEGORYNAMES]) && !isset($frontpage[FRONTPAGECOURSELIST]) && $coursecount) {
$coursecount = count_records('course') <= FRONTPAGECOURSELIMIT;
if ($files and $coursecount) {
$catimage = '<img src="'.$CFG->pixpath.'/i/course.gif" width="16" height="16" border="0" alt="" />';
} else {
$catimage = "&nbsp;";
@ -1399,7 +1399,7 @@ function print_category_info($category, $depth) {
echo "\n\n".'<table border="0" cellpadding="3" cellspacing="0" width="100%">';
if (isset($frontpage[FRONTPAGECATEGORYNAMES]) && !isset($frontpage[FRONTPAGECOURSELIST]) && $coursecount) {
if ($files and $coursecount) {
$courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.guest,c.cost,c.currency');
echo "<tr>";