From: moodler Date: Tue, 11 Jan 2005 07:56:45 +0000 (+0000) Subject: 1. On category listing, don't print category count at all if it's zero anyway X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e05bcf2faed26009a9d0be638b9df0ceb8726a21;p=moodle.git 1. On category listing, don't print category count at all if it's zero anyway 2. Cleaned up some complex code to use 'strings' instead of "parsed strings". --- diff --git a/course/lib.php b/course/lib.php index 646d49f98c..9cf85dbbbd 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1139,16 +1139,16 @@ function make_categories_list(&$list, &$parents, $category=NULL, $path="") { if ($category) { if ($path) { - $path = "$path / $category->name"; + $path = $path.' / '.$category->name; } else { - $path = "$category->name"; + $path = $category->name; } $list[$category->id] = $path; } else { $category->id = 0; } - if ($categories = get_categories("$category->id")) { // Print all the children recursively + if ($categories = get_categories($category->id)) { // Print all the children recursively foreach ($categories as $cat) { if (!empty($category->id)) { if (isset($parents[$category->id])) { @@ -1166,8 +1166,9 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli /// Recursive function to print out all the categories in a nice format /// with or without courses included global $CFG; - if (isset($CFG->max_category_depth)&&($depth >= $CFG->max_category_depth)) { - return; + + if (isset($CFG->max_category_depth) && ($depth >= $CFG->max_category_depth)) { + return; } if (!$displaylist) { @@ -1213,12 +1214,12 @@ function print_category_info($category, $depth) { static $strallowguests, $strrequireskey, $strsummary; if (empty($strsummary)) { - $strallowguests = get_string("allowguests"); - $strrequireskey = get_string("requireskey"); - $strsummary = get_string("summary"); + $strallowguests = get_string('allowguests'); + $strrequireskey = get_string('requireskey'); + $strsummary = get_string('summary'); } - $catlinkcss = $category->visible ? "" : " class=\"dimmed\" "; + $catlinkcss = $category->visible ? '' : ' class="dimmed" '; if ($CFG->frontpage == FRONTPAGECOURSELIST) { $catimage = ''; @@ -1238,60 +1239,64 @@ function print_category_info($category, $depth) { $rows = count($courses) + 1; echo ''; print_spacer(10, $indent); - echo ""; + echo ''; } - echo "$catimage"; - echo ""; - echo "wwwroot/course/category.php?id=$category->id\">$category->name"; - echo ""; - echo " "; - echo "\n"; + echo ''.$catimage.''; + echo ''; + echo ''.$category->name.''; + echo ''; + echo ' '; + echo ''; if ($courses && !(isset($CFG->max_category_depth)&&($depth>=$CFG->max_category_depth-1))) { foreach ($courses as $course) { - $linkcss = $course->visible ? "" : " class=\"dimmed\" "; - echo " "; - echo "\n"; - echo "wwwroot/course/view.php?id=$course->id\">$course->fullname"; - echo "\n"; + $linkcss = $course->visible ? '' : ' class="dimmed" '; + echo ' '; + echo ''; + echo ''.$course->fullname.''; + echo ''; if ($course->guest ) { - echo "wwwroot/course/view.php?id=$course->id\">"; - echo "\"$strallowguests\"pixpath/i/guest.gif\" />"; + echo ''; + echo ''.$strallowguests.''; } else { - echo "\"\"pixpath/spacer.gif\" />"; + echo ''; } if ($course->password) { - echo "wwwroot/course/view.php?id=$course->id\">"; - echo "\"$strrequireskey\"pixpath/i/key.gif\" />"; + echo ''; + echo ''.$strrequireskey.''; } else { - echo "\"\"pixpath/spacer.gif\" />"; + echo ''; } if ($course->summary) { - link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo", - "\"$strsummary\"pixpath/i/info.gif\" />", + link_to_popup_window ('/course/info.php?id='.$course->id, 'courseinfo', + ''.$strsummary.'', 400, 500, $strsummary); } else { - echo "\"\"pixpath/spacer.gif\" />"; + echo ''; } - echo "\n"; + echo ''; } } } else { if ($depth) { $indent = $depth*20; - echo ""; + echo ''; print_spacer(10, $indent); - echo ""; + echo ''; } - echo ""; - echo "wwwroot/course/category.php?id=$category->id\">$category->name"; - echo ""; - echo "$category->coursecount"; + echo ''; + echo ''.$category->name.''; + echo ''; + echo ''; + if ($category->coursecount) { + echo $category->coursecount; + } + echo ''; } - echo "\n\n"; + echo ''; } @@ -1306,7 +1311,7 @@ function print_courses($category, $width="100%") { $category = array_shift($categories); $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher'); } else { - $courses = get_courses("all", 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher'); + $courses = get_courses('all', 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher'); } unset($categories); } else {