Changes to allow choice of format on home page of site
[moodle.git] / index.php
1 <?  // $Id$
2     // index.php - the front page.
3     
4     require("config.php");
5     include("mod/reading/lib.php"); 
7     if (! $site = get_record("course", "category", 0)) {
8         redirect("$CFG->wwwroot/admin/");
9     }
11     print_header("$site->fullname", "$site->fullname", "", "",
12                  "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">");
15 ?>
18 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
19   <TR>
20     <TD WIDTH="15%" VALIGN="TOP" NOWRAP>
21       <? print_simple_box("Main Menu", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
23           <LI>Home</LI>
24       <? if ($site->format > 0 ) { ?>
25       <LI><A TITLE="Available courses on this server" HREF="course/"><B>Courses</B></A><BR></LI>
26       <LI><A TITLE="Site-level Forums" HREF="mod/discuss/index.php?id=<?=$site->id?>">Forums</A></LI>
27       <? } ?>
29       <? 
30          if ($readings = list_all_readings()) {
31              foreach ($readings as $reading) {
32                  echo "<LI>$reading";
33              }
34          }
35      
36          if ($USER->editing) {
37              echo "<P align=right><A HREF=\"$CFG->wwwroot/course/mod.php?id=$site->id&week=0&add=reading\">Add Reading</A>...</P>";
38          }
39       ?>
41         <BR><BR>
43       <?
44          if (isadmin()) {
45              print_simple_box("Admin", $align="CENTER", $width="100%", $color="$THEME->cellheading");
46              echo "<LI><A HREF=\"$CFG->wwwroot/admin/\">Admin Page</A></LI>";
47              echo "<LI>";
48              print_editing_switch($site->id); 
49          }
50       ?>
52     </TD>
54     <TD WIDTH="55%" VALIGN="TOP">
55       <? if ($site->format == 0 ) {
56              print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading");
57              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
58              include("course/lib.php");
59              print_all_courses();
61          } else {
62              print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
63              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
64              include("mod/discuss/lib.php");
65              forum_latest_topics(0, $site->format);
66          }
67       ?>
69     </TD>
70     <TD WIDTH="30%" VALIGN="TOP"> 
71       <? 
72          if ($USER->editing) {
73              $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
74          }
75          print_simple_box($site->summary, $align="", $width="100%", $color="$THEME->cellheading");
76       ?>
77     </TD>
78   </TR>
79 </TABLE>
81 <? include("$CFG->dirroot/theme/$CFG->theme/footer.html"); ?>
83 <P ALIGN=center>
84 <A WIDTH=85 HEIGHT=25 HREF="http://moodle.com/"><IMG SRC="pix/madewithmoodle.gif" BORDER=0></A>
85 </P>