New help translation
[moodle.git] / index.php
blob28f953926a85e08c266ce91f2f128631cea67440
1 <?PHP // $Id$
2 // index.php - the front page.
4 require_once("config.php");
5 require_once("course/lib.php");
6 require_once("mod/resource/lib.php");
7 require_once("mod/forum/lib.php");
9 if (! $site = get_site()) {
10 redirect("$CFG->wwwroot/admin/index.php");
13 if (isadmin()) {
14 if (moodle_needs_upgrading()) {
15 redirect("$CFG->wwwroot/admin/index.php");
19 if (empty($USER->id)) {
20 $loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
21 } else {
22 $loginstring = "<font size=1>".user_login_string($site)."</font>";
25 if (empty($CFG->langmenu)) {
26 $langmenu = "";
27 } else {
28 $currlang = current_language();
29 $langs = get_list_of_languages();
30 $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
33 print_header(strip_tags($site->fullname), "$site->fullname", "home", "",
34 "<meta name=\"description\" content=\"".s(strip_tags($site->summary))."\">",
35 true, "", "<div align=right>$loginstring$langmenu</div>");
37 $firstcolumn = false; // for now
38 $lastcolumn = false; // for now
39 $side = 175;
41 if (isediting($site->id)) {
42 $site->summary .= "<br><center><a href=\"admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
45 if ($site->summary) {
46 $lastcolumn = true;
53 <table width="100%" border="0" cellspacing="5" cellpadding="5">
54 <tr>
55 <?PHP
56 $sections = get_all_sections($site->id);
58 if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
60 echo "<td width=\"$side\" valign=top nowrap>";
61 $firstcolumn=true;
63 if ($sections[0]->sequence or isediting($site->id)) {
64 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
65 print_section_block(get_string("mainmenu"), $site, $sections[0],
66 $mods, $modnames, $modnamesused, true, $side);
69 if (isadmin()) {
70 echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
71 echo "<br />";
74 switch ($CFG->frontpage) {
75 case FRONTPAGENEWS: // print news links on the side
76 print_courses_sideblock(0, "$side");
77 break;
79 case FRONTPAGECOURSELIST:
80 case FRONTPAGECATEGORYNAMES:
81 if ($site->newsitems) {
82 if ($news = forum_get_course_forum($site->id, "news")) {
83 print_side_block_start(get_string("latestnews"), $side, "sideblocklatestnews");
84 echo "<font size=\"-2\">";
85 forum_print_latest_discussions($news->id, $site->newsitems, "minimal", "", false);
86 echo "</font>";
87 print_side_block_end();
90 break;
92 print_spacer(1,$side);
95 if (iscreator()) {
96 if (!$firstcolumn) {
97 echo "<td width=\"$side\" valign=top nowrap>";
98 $firstcolumn=true;
100 print_admin_links($site->id, $side);
103 if ($firstcolumn) {
104 echo "</td>";
106 if ($lastcolumn) {
107 echo "<td width=\"70%\" valign=\"top\">";
108 } else {
109 echo "<td width=\"100%\" valign=\"top\">";
112 switch ($CFG->frontpage) { /// Display the main part of the front page.
113 case FRONTPAGENEWS:
114 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
115 error("Could not find or create a main news forum for the site");
118 if (isset($USER->id)) {
119 $SESSION->fromdiscussion = "$CFG->wwwroot";
120 if (forum_is_subscribed($USER->id, $newsforum->id)) {
121 $subtext = get_string("unsubscribe", "forum");
122 } else {
123 $subtext = get_string("subscribe", "forum");
125 $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr>
126 <td>$newsforum->name</td>
127 <td align=right><font size=1>
128 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
129 </td></tr></table>";
130 } else {
131 $headertext = $newsforum->name;
133 print_heading_block($headertext);
134 print_spacer(8,1);
135 forum_print_latest_discussions($newsforum->id, $site->newsitems);
136 break;
138 case FRONTPAGECOURSELIST:
139 case FRONTPAGECATEGORYNAMES:
140 if (isset($USER->id) and !isset($USER->admin)) {
141 print_heading_block(get_string("mycourses"));
142 print_spacer(8,1);
143 print_my_moodle();
144 } else {
145 print_heading_block(get_string("availablecourses"));
146 print_spacer(8,1);
147 if (count_records("course_categories") > 1) {
148 print_simple_box_start("center", "100%");
149 print_whole_category_list();
150 print_simple_box_end();
151 print_course_search();
152 } else {
153 print_courses(0, "100%");
156 break;
160 echo "</td>";
162 if ($lastcolumn) {
163 echo "<td width=\"30%\" valign=\"top\">";
164 print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
165 print_spacer(1,$side);
166 echo "</td>";
170 </tr>
171 </table>
173 <?PHP print_footer("home"); // Please do not modify this line ?>