Permalink
Browse files

Changes to allow choice of format on home page of site

  • Loading branch information...
1 parent b5460e6 commit d887b5a7bd00dcdf96d497aa69d7df93b3fa133f martin committed Jun 10, 2002
Showing with 63 additions and 24 deletions.
  1. +19 −0 admin/site.html
  2. +1 −0 admin/site.php
  3. +5 −10 course/index.php
  4. +23 −7 course/lib.php
  5. +15 −7 index.php
View
19 admin/site.html
@@ -18,6 +18,25 @@
<? formerr($err["summary"]) ?>
</td>
</tr>
+<tr valign=top>
+ <td><P>Front page format:</td>
+ <td><?
+ $options = array("0" => "Show list of courses",
+ "1" => "1 news item",
+ "2" => "2 news items",
+ "3" => "3 news items",
+ "4" => "4 news items",
+ "5" => "5 news items",
+ "6" => "6 news items",
+ "7" => "7 news items",
+ "8" => "8 news items",
+ "9" => "9 news items",
+ "10" => "10 news items");
+ choose_from_menu ($options, "format", "$form->format");
+ formerr($err["format"]);
+ ?>
+ </td>
+</tr>
<tr>
<td></td>
<td><input type="submit" value="Update the site"></td>
View
1 admin/site.php
@@ -49,6 +49,7 @@
$form = $course;
} else {
$form->category = 0;
+ $form->format = 1;
}
print_header("Admin: Setting up site", "Administration: Setting up site",
View
15 course/index.php
@@ -7,16 +7,11 @@
optional_variable($cat, 1);
- if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
-
- foreach ($courses as $course) {
- print_course($course);
- echo "<BR>\n";
- }
-
- } else {
- echo "<H3>No courses have been defined yet</H3>";
- }
+ print_simple_box_start("CENTER", "80%");
+
+ print_all_courses($cat);
+
+ print_simple_box_end();
print_footer();
View
30 course/lib.php
@@ -115,35 +115,51 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
}
+function print_all_courses($cat=1) {
+
+ if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
+ foreach ($courses as $course) {
+ print_course($course);
+ echo "<BR>\n";
+ }
+
+ } else {
+ echo "<H3>No courses have been defined yet</H3>";
+ }
+}
+
+
function print_course($course) {
+ global $CFG;
+
if (! $site = get_record("course", "category", "0") ) {
error("Could not find a site!");
}
- print_simple_box_start("CENTER", "80%");
+ print_simple_box_start("CENTER", "100%");
echo "<TABLE WIDTH=100%>";
echo "<TR VALIGN=top>";
echo "<TD VALIGN=top WIDTH=50%>";
- echo "<P><FONT SIZE=3><B><A HREF=\"view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
+ echo "<P><FONT SIZE=3><B><A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t
WHERE u.id = t.user AND t.course = '$course->id'
ORDER BY t.authority ASC")) {
echo "<P><FONT SIZE=1>\n";
foreach ($teachers as $teacher) {
- echo "$course->teacher: <A HREF=\"../user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>";
+ echo "$course->teacher: <A HREF=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>";
}
echo "</FONT></P>";
}
if ($course->guest or ($course->password == "")) {
- echo "<A TITLE=\"Guest user allowed\" HREF=\"view.php?id=$course->id\">";
- echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"../user/user.gif\"></A>&nbsp;&nbsp;";
+ echo "<A TITLE=\"Guest user allowed\" 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;";
}
if ($course->password) {
- echo "<A TITLE=\"Requires a Course entry key\" HREF=\"view.php?id=$course->id\">";
- echo "<IMG VSPACE=4 ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"../pix/i/key.gif\"></A>";
+ echo "<A TITLE=\"Requires a Course entry key\" 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>";
}
View
22 index.php
@@ -21,8 +21,10 @@
<? print_simple_box("Main Menu", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
<LI>Home</LI>
+ <? if ($site->format > 0 ) { ?>
<LI><A TITLE="Available courses on this server" HREF="course/"><B>Courses</B></A><BR></LI>
<LI><A TITLE="Site-level Forums" HREF="mod/discuss/index.php?id=<?=$site->id?>">Forums</A></LI>
+ <? } ?>
<?
if ($readings = list_all_readings()) {
@@ -50,14 +52,20 @@
</TD>
<TD WIDTH="55%" VALIGN="TOP">
- <? print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
-
- <IMG HEIGHT=8 SRC="pix/spacer.gif" ALT=""><BR>
-
- <? include("mod/discuss/lib.php");
- forum_latest_topics();
+ <? if ($site->format == 0 ) {
+ print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading");
+ echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
+ include("course/lib.php");
+ print_all_courses();
+
+ } else {
+ print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
+ echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
+ include("mod/discuss/lib.php");
+ forum_latest_topics(0, $site->format);
+ }
?>
-
+
</TD>
<TD WIDTH="30%" VALIGN="TOP">
<?

0 comments on commit d887b5a

Please sign in to comment.