Various little tweaks to improve the display of course home

pages and front page ... still have some work to do though
This commit is contained in:
moodler
2002-12-09 07:35:40 +00:00
parent 7a4c13797a
commit 5e367a2d56
8 changed files with 156 additions and 102 deletions
+1 -2
View File
@@ -34,7 +34,6 @@
if ($showcategories) {
echo "<TABLE WIDTH=\"100%\" CELLPADDING=10 BORDER=0>";
echo "<TR><TD WIDTH=180 VALIGN=TOP>";
print_simple_box($strcategories, "CENTER", 180, $THEME->cellheading);
print_course_categories($categories, $category, 180);
echo "</TD><TD WIDTH=\"100%\" VALIGN=TOP>";
} else {
@@ -45,7 +44,7 @@
if ($category) {
if (isset($title)) {
print_simple_box($title, "CENTER", "100%", $THEME->cellheading);
print_heading_block($title);
}
echo "<BR>";
print_all_courses($category);
+107 -33
View File
@@ -208,7 +208,7 @@ function print_all_courses($category="all", $style="full", $maxcount=999) {
}
}
$fulllist = "<P><A HREF=\"$CFG->wwwroot/course/\">".get_string("fulllistofcourses")."</A>...";
print_side_block("", $moddata, "$fulllist", $modicon);
print_side_block(get_string("courses"), "", $moddata, $modicon, $fulllist);
} else {
foreach ($courses as $course) {
@@ -251,12 +251,14 @@ function print_course($course) {
echo "</FONT></P>";
}
if ($course->guest) {
echo "<A TITLE=\"".get_string("allowguests")."\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/user/user.gif\"></A>&nbsp;&nbsp;";
$strallowguests = get_string("allowguests");
echo "<A TITLE=\"$strallowguests\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
echo "<IMG VSPACE=4 ALT=\"$strallowguests\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/user/user.gif\"></A>&nbsp;&nbsp;";
}
if ($course->password) {
echo "<A TITLE=\"".get_string("requireskey")."\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/pix/i/key.gif\"></A>";
$strrequireskey = get_string("requireskey");
echo "<A TITLE=\"$strrequireskey\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
echo "<IMG VSPACE=4 ALT=\"$strrequireskey\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/pix/i/key.gif\"></A>";
}
@@ -465,6 +467,40 @@ function get_all_categories() {
return get_records_sql("SELECT * FROM course_categories ORDER by name");
}
function print_section_block($heading, $course, $section, $mods, $modnames, $modnamesused,
$absolute=true, $width="100%", $isediting=false) {
global $CFG;
$modinfo = unserialize($course->modinfo);
$moddata = array();
$modicon = array();
$editbuttons = "";
if ($section->sequence) {
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $modnumber) {
$mod = $mods[$modnumber];
if ($isediting) {
$editbuttons = make_editing_buttons($mod->id, $absolute);
}
$instancename = urldecode($modinfo[$modnumber]->name);
$modicon[] = "<img src=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
$moddata[] = "<a title=\"$mod->modfullname\" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a><BR>$editbuttons";
}
}
if (isediting($site->id)) {
$editmenu = popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=0&add=",
$modnames, "section0", "", get_string("add")."...", "mods", get_string("activities"), true);
$editmenu = "<DIV ALIGN=right>$editmenu</DIV>";
}
print_side_block($heading, "", $moddata, $modicon, $editmenu, $width);
}
function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
global $CFG;
@@ -482,6 +518,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
echo " <FONT SIZE=2><A TITLE=\"$mod->modfullname\"";
echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</A></FONT>";
if (isediting($course->id)) {
echo "&nbsp;&nbsp;";
echo make_editing_buttons($mod->id, $absolute);
}
echo "<BR>\n";
@@ -490,33 +527,70 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
echo "</TD></TR></TABLE><BR>\n\n";
}
function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL, $width=180) {
echo "<TABLE WIDTH=\"$width\">\n";
echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
if ($list) {
foreach($list as $key => $string) {
echo "<TR><TD VALIGN=top WIDTH=12>";
if ($icons[$key]) {
echo $icons[$key];
} else {
echo "";
}
echo "</TD>\n<TD WIDTH=100% VALIGN=top>";
echo "<P><FONT SIZE=2>$string</FONT></P>";
echo "</TD></TR>\n";
}
}
if ($footer) {
echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
}
echo "</TABLE><BR>\n\n";
function print_heading_block($heading, $width="100%") {
global $THEME;
echo "<table width=\"$width\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td bgcolor=\"$THEME->borders\">";
echo "<table class=\"blockheading\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\">";
echo "<tr><td bgcolor=\"$THEME->cellheading\">";
echo stripslashes($heading);
echo "</td></tr></table>";
echo "</td></tr></table>";
}
function print_side_block($heading="", $content="", $list=NULL, $icons=NULL, $footer="", $width=180) {
// Prints a nice side block with an optional header. The content can either
// be a block of HTML or a list of text with optional icons.
global $THEME;
echo "<table width=\"$width\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td bgcolor=\"$THEME->borders\">";
echo "<table class=\"sideblock\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\">";
if ($heading) {
echo "<tr>";
echo "<td class=\"sideblockheading\" bgcolor=\"$THEME->cellheading\">$heading</td>";
echo "</tr>";
}
if ($content) {
echo "<tr>";
echo "<td class=\"sideblockmain\" bgcolor=\"$THEME->cellcontent2\">$content</td>";
echo "</tr>";
} else {
echo "<tr><td class=\"sideblocklinks\" bgcolor=\"$THEME->cellcontent2\">";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
foreach ($list as $key => $string) {
echo "<tr class=\"sideblockmain\" bgcolor=\"$THEME->cellcontent2\">";
if ($icons) {
echo "<td valign=\"top\" width=\"16\">".$icons[$key]."</td>";
}
echo "<td valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>";
echo "</tr>";
}
if ($footer) {
echo "<tr class=\"sideblockmain\" bgcolor=\"$THEME->cellcontent2\">";
if ($icons) {
echo "<td valign=\"top\" width=\"16\">&nbsp;</td>";
}
echo "<td><font size=\"-1\">$footer</td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr>";
}
echo "</table></td>";
echo "</tr>";
echo "</table><br \>";
}
function print_admin_links ($siteid, $width=180) {
global $THEME, $CFG;
print_simple_box(get_string("administration"), $align="CENTER", $width, $color="$THEME->cellheading");
$icon = "<IMG SRC=\"$CFG->wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$moddata[]="<A HREF=\"$CFG->wwwroot/admin/config.php\">".get_string("configvariables")."</A>";
$modicon[]=$icon;
@@ -551,7 +625,9 @@ function print_admin_links ($siteid, $width=180) {
$moddata[]="<A HREF=\"$CFG->wwwroot/admin/auth.php\">".get_string("authentication")."</A>";
$modicon[]=$icon;
$fulladmin = "<P><A HREF=\"$CFG->wwwroot/admin/\">".get_string("admin")."</A>...";
print_side_block("", $moddata, "$fulladmin", $modicon, $width);
print_side_block(get_string("administration"), "", $moddata, $modicon, $fulladmin, $width);
echo "<IMG SRC=\"$CFG->wwwroot/pix/spacer.gif\" WIDTH=\"$width\" HEIGHT=1><BR>";
}
@@ -590,8 +666,7 @@ function print_course_admin_links($course, $width=180) {
$adminicon[]="<IMG SRC=\"$CFG->wwwroot/mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
print_simple_box(get_string("administration"), $align="CENTER", $width, $color="$THEME->cellheading");
print_side_block("", $admindata, "", $adminicon, $width);
print_side_block(get_string("administration"), "", $admindata, $adminicon, "", $width);
}
function print_course_categories($categories, $selected="none", $width=180) {
@@ -665,7 +740,7 @@ function print_course_categories($categories, $selected="none", $width=180) {
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);
print_side_block(get_string("categories"), "", $catdata, $caticon, $showall.$mine, $width);
}
}
@@ -875,8 +950,7 @@ function make_editing_buttons($moduleid, $absolute=false) {
} else {
$path = "";
}
return "&nbsp; &nbsp;
<A TITLE=\"$delete\" HREF=\"".$path."mod.php?delete=$moduleid\"><IMG
return "<A TITLE=\"$delete\" HREF=\"".$path."mod.php?delete=$moduleid\"><IMG
SRC=".$path."../pix/t/delete.gif BORDER=0></A>
<A TITLE=\"$moveup\" HREF=\"".$path."mod.php?id=$moduleid&move=-1\"><IMG
SRC=".$path."../pix/t/up.gif BORDER=0></A>
+15 -22
View File
@@ -10,7 +10,6 @@
<TR>
<TD WIDTH="200" VALIGN="TOP">
<?
print_simple_box(get_string("people"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".
@@ -21,37 +20,31 @@
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
}
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
print_side_block("", $moddata, "", $modicon);
print_side_block(get_string("people"), "", $moddata, $modicon);
/// Then, print all the available resources (Section 0)
print_simple_box(get_string("resources"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_section($course, $sections[0], $mods, $modnamesused, true);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=0&add=",
$modnames, "section0", "", get_string("add")."...", "mods", get_string("activities"));
echo "</DIV>";
}
print_section_block(get_string("activities"), $course, $sections[0],
$mods, $modnames, $modnamesused, true, "100%", isediting($course->id));
/// Print all the recent activity
print_simple_box(get_string("recentactivity"), "CENTER", "100%", $THEME->cellheading);
print_simple_box_start("CENTER", "100%", $THEME->body, 3, 0);
print_recent_activity($course);
print_simple_box_end();
echo "<BR>";
if ($course->showrecent) {
print_heading_block(get_string("recentactivity"));
print_simple_box_start("CENTER", "100%", $THEME->body, 3, 0);
print_recent_activity($course);
print_simple_box_end();
echo "<BR>";
}
/// Print a form to search forums
print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
forum_print_search_form($course);
echo "</DIV>";
$searchform = forum_print_search_form($course, "", true);
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
print_side_block(get_string("search","forum"), $searchform);
// Admin links and controls
/// Admin links and controls
if (isteacher($course->id)) {
print_course_admin_links($course, "100%");
}
@@ -66,7 +59,7 @@
$subtext = get_string("subscribe", "forum");
}
$headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR><TD>".get_string("socialheadline")."</TD><TD ALIGN=RIGHT><FONT SIZE=1><A HREF=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</A></TD></TR></TABLE>";
print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_heading_block($headertext);
echo "<IMG ALT=\"\" HEIGHT=7 SRC=\"../pix/spacer.gif\"><BR>";
forum_print_latest_discussions($social->id, 10, "plain", "DESC", false);
+5 -8
View File
@@ -50,7 +50,6 @@
echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
/// Links to people
print_simple_box(get_string("people"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
@@ -60,7 +59,7 @@
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
}
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
print_side_block("", $moddata, "", $modicon);
print_side_block(get_string("people"), "", $moddata, $modicon);
/// Links to all activity modules by type
@@ -72,14 +71,12 @@
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
}
print_simple_box($stractivities, $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
print_side_block($stractivities, "", $moddata, $modicon);
/// Print a form to search forums
print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
forum_print_search_form($course);
echo "</DIV>";
$searchform = forum_print_search_form($course, "", true);
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
print_side_block(get_string("search","forum"), $searchform);
/// Admin links and controls
if (isteacher($course->id)) {
+8 -12
View File
@@ -39,7 +39,6 @@
echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
/// Links to people
print_simple_box(get_string("people"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
@@ -49,7 +48,7 @@
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
}
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
print_side_block("", $moddata, "", $modicon);
print_side_block(get_string("people"), "", $moddata, $modicon);
/// Then all the links to activities by type
@@ -61,14 +60,12 @@
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
}
print_simple_box($stractivities, $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
print_side_block($stractivities, "", $moddata, $modicon);
/// Print a form to search forums
print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
forum_print_search_form($course);
echo "</DIV>";
$searchform = forum_print_search_form($course, "", true);
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
print_side_block(get_string("search","forum"), $searchform);
/// Admin links and controls
@@ -79,8 +76,7 @@
/// Start main column
echo "</TD><TD WIDTH=\"*\">";
print_simple_box(get_string("weeklyoutline"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_heading_block(get_string("weeklyoutline"));
echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
@@ -207,7 +203,7 @@
// Print all the news items.
if ($news) {
print_simple_box(get_string("latestnews"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_heading_block(get_string("latestnews"));
print_simple_box_start("CENTER", "100%", $THEME->cellcontent, 3, 0);
echo "<FONT SIZE=1>";
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
@@ -218,7 +214,7 @@
// Print all the recent activity
if ($course->showrecent) {
print_simple_box(get_string("recentactivity"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_heading_block(get_string("recentactivity"));
print_simple_box_start("CENTER", "100%", $THEME->cellcontent, 3, 0);
print_recent_activity($course);
print_simple_box_end();
+4 -16
View File
@@ -42,27 +42,15 @@
if ($sections[0]->sequence or isediting($site->id)) {
get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
print_simple_box(get_string("mainmenu"), "CENTER", $side, "$THEME->cellheading");
}
if ($sections[0]->sequence) {
print_section($site, $sections[0], $mods, $modnamesused, true, $side);
}
if (isediting($site->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=",
$modnames, "section0", "", get_string("add")."...");
echo "</DIV>";
print_section_block(get_string("mainmenu"), $site, $sections[0],
$mods, $modnames, $modnamesused, true, $side, isediting($site->id));
}
if ($site->newsitems > 0 ) {
$categories = get_all_categories();
if (count($categories) > 1) {
print_simple_box(get_string("categories"), "CENTER", $side, "$THEME->cellheading");
print_course_categories($categories, "none", $side);
} else {
print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
$category = array_shift($categories);
print_all_courses($category->id, "minimal", 10);
}
@@ -83,7 +71,7 @@
echo "<TD WIDTH=70% VALIGN=TOP>";
if ($site->newsitems == 0 ) {
print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
print_heading_block(get_string("availablecourses"));
print_spacer(8,1);
$categories = get_all_categories();
if (count($categories) > 1) {
@@ -113,7 +101,7 @@
} else {
$headertext = get_string("sitenews");
}
print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
print_heading_block($headertext);
print_spacer(8,1);
forum_print_latest_discussions($newsforum->id, $site->newsitems);
}
+15 -8
View File
@@ -804,16 +804,23 @@ function forum_print_mode_form($discussion, $mode) {
echo "</P></CENTER>\n";
}
function forum_print_search_form($course, $search="") {
function forum_print_search_form($course, $search="", $return=false) {
global $CFG;
echo "<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0><TR><TD ALIGN=CENTER>";
echo "<FORM NAME=search ACTION=\"$CFG->wwwroot/mod/forum/search.php\">";
echo "<INPUT NAME=search TYPE=text SIZE=15 VALUE=\"$search\"><BR>";
echo "<INPUT VALUE=\"".get_string("searchforums", "forum")."\" TYPE=submit>";
echo "<INPUT NAME=id TYPE=hidden VALUE=\"$course->id\">";
echo "</FORM>";
echo "</TD></TR></TABLE>";
$output = "<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0><TR><TD ALIGN=CENTER>";
$output .= "<FORM NAME=search ACTION=\"$CFG->wwwroot/mod/forum/search.php\">";
$output .= "<FONT SIZE=\"-1\">";
$output .= "<INPUT NAME=search TYPE=text SIZE=15 VALUE=\"$search\"><BR>";
$output .= "<INPUT VALUE=\"".get_string("searchforums", "forum")."\" TYPE=submit>";
$output .= "</FONT>";
$output .= "<INPUT NAME=id TYPE=hidden VALUE=\"$course->id\">";
$output .= "</FORM>";
$output .= "</TD></TR></TABLE>";
if ($return) {
return $output;
}
echo $output;
}
+1 -1
View File
@@ -4,7 +4,7 @@ $THEME->body = "#FFEECE"; // Main page color
$THEME->cellheading = "#FFD991"; // Standard headings of big tables
$THEME->cellheading2 = "#FFB62D"; // Highlight headings of tables
$THEME->cellcontent = "#FFFFFF"; // For areas with text
$THEME->cellcontent2 = "#FFD991"; // Alternate colour
$THEME->cellcontent2 = "#FFEECE"; // Alternate colour
$THEME->borders = "#555555"; // Table borders
?>