New strings for theme choice configuration
[moodle.git] / index.php
CommitLineData
4bab5275 1<?php // $Id$
657423c8 2 // index.php - the front page.
89adb174 3
8b5b1028 4 if (!file_exists('./config.php')) {
5 header('Location: install.php');
6 die;
7 }
8
9/// Bounds for block widths on this page
df9e0f89 10 define('BLOCK_L_MIN_WIDTH', 160);
11 define('BLOCK_L_MAX_WIDTH', 210);
12 define('BLOCK_R_MIN_WIDTH', 160);
13 define('BLOCK_R_MAX_WIDTH', 210);
14
8deb0ff5 15 require_once('config.php');
4bab5275 16 require_once($CFG->dirroot .'/course/lib.php');
17 require_once($CFG->dirroot .'/lib/blocklib.php');
18 require_once($CFG->dirroot .'/mod/resource/lib.php');
19 require_once($CFG->dirroot .'/mod/forum/lib.php');
f9903ed0 20
5921e0a0 21 $blockaction = optional_param('blockaction');
9b4b78fd 22
8553b700 23 if (! $site = get_site()) {
4bab5275 24 redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
f9903ed0 25 }
26
0a45ffe3 27 if ($CFG->forcelogin) {
28 require_login();
29 }
30
53bfe78c 31 if (isadmin()) {
32 if (moodle_needs_upgrading()) {
4bab5275 33 redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
53bfe78c 34 }
3565715c 35 }
36
37 if (empty($USER->id)) {
8a33e371 38 if (empty($CFG->loginhttps)) {
39 $wwwroot = $CFG->wwwroot;
40 } else {
4bab5275 41 $wwwroot = str_replace('http', 'https', $CFG->wwwroot);
8a33e371 42 }
4bab5275 43 $loginstring = "<font size=\"2\"><a href=\"$wwwroot/login/index.php\">".get_string('login').'</a></font>';
4efeb8c3 44 } else {
4bab5275 45 $loginstring = '<font size="1">'. user_login_string($site) .'</font>';
34dd5900 46 add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID);
a325bd2b 47 }
a5e3644b 48
984a8bf3 49 if (empty($CFG->langmenu)) {
4bab5275 50 $langmenu = '';
984a8bf3 51 } else {
52 $currlang = current_language();
53 $langs = get_list_of_languages();
4bab5275 54 $langmenu = popup_form ($CFG->wwwroot .'/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true);
984a8bf3 55 }
a5e3644b 56
60fe9736 57 $PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
f032aa7a 58 $pageblocks = blocks_get_by_page($PAGE);
60fe9736 59 $editing = $PAGE->user_is_editing();
ee00b8b9 60
60fe9736 61 if (!empty($blockaction)) {
62 blocks_execute_url_action($PAGE, $pageblocks);
63 // This re-query could be eliminated by judicious programming in blocks_execute_action(),
64 // but I'm not sure if it's worth the complexity increase...
65 $pageblocks = blocks_get_by_page($PAGE);
89adb174 66 }
ee00b8b9 67
60fe9736 68 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH);
69 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH);
df9e0f89 70
5921e0a0 71 print_header(strip_tags($site->fullname), $site->fullname, 'home', '',
72 '<meta name="description" content="'. s(strip_tags($site->summary)) .'" />',
73 true, '', $loginstring . '<br />' . $langmenu);
74
f9903ed0 75?>
76
3054741a 77
8c336db1 78<table width="100%" border="0" cellspacing="5" cellpadding="5" id="layout-table">
3565715c 79 <tr>
89adb174 80 <?PHP
81
9b4b78fd 82 if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
8c336db1 83 echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;" id="left-column">';
f032aa7a 84 blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
89adb174 85 echo '</td>';
86 }
87
8c336db1 88 echo '<td style="vertical-align: top;" id="middle-column">';
89
90
5fc2f2fd 91/// Print Section
92 if ($site->numsections > 0) {
b5768b9e 93 print_simple_box_start('center', '100%', '', 5, 'sitetopic');
8c336db1 94
5fc2f2fd 95 /// If currently moving a file then show the current clipboard
96 if (ismoving($site->id)) {
4bab5275 97 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
98 echo '<p><font size="2">';
99 echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true\">". get_string('cancel') .'</a>)';
100 echo '</font></p>';
5fc2f2fd 101 }
102
5fc2f2fd 103
45a6b40d 104 if (!$section = get_record('course_sections', 'course', $site->id, 'section', 1)) {
105 delete_records('course_sections', 'course', $site->id, 'section', 1); // Just in case
106 $section->course = $site->id;
107 $section->section = 1;
108 $section->summary = '';
109 $section->visible = 1;
110 $section->id = insert_record('course_sections', $section);
111 }
5fc2f2fd 112
45a6b40d 113 echo format_text($section->summary, FORMAT_HTML);
5fc2f2fd 114
115 if ($editing) {
45a6b40d 116 $streditsummary = get_string('editsummary');
5fc2f2fd 117 echo "<a title=\"$streditsummary\" ".
45a6b40d 118 " href=\"course/editsection.php?id=$section->id\"><img src=\"$CFG->pixpath/t/edit.gif\" ".
dfc12289 119 " height=\"11\" width=\"11\" border=\"0\" alt=\"$streditsummary\" /></a><br /><br />";
5fc2f2fd 120 }
121
45a6b40d 122 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
123 print_section($site, $section, $mods, $modnamesused, true);
5fc2f2fd 124
125 if ($editing) {
720754da 126 print_section_add_menus($site, $section->section, $modnames);
5fc2f2fd 127 }
45a6b40d 128 print_simple_box_end();
129 print_spacer(10);
5fc2f2fd 130 }
131
89adb174 132 switch ($CFG->frontpage) { /// Display the main part of the front page.
133 case FRONTPAGENEWS:
4bab5275 134 if (! $newsforum = forum_get_course_forum($site->id, 'news')) {
135 error('Could not find or create a main news forum for the site');
89adb174 136 }
137
138 if (isset($USER->id)) {
4bab5275 139 $SESSION->fromdiscussion = $CFG->wwwroot;
89adb174 140 if (forum_is_subscribed($USER->id, $newsforum->id)) {
4bab5275 141 $subtext = get_string('unsubscribe', 'forum');
89adb174 142 } else {
4bab5275 143 $subtext = get_string('subscribe', 'forum');
89adb174 144 }
98ea2a6e 145 $headertext = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"headingblockcontent\"><tr>
89adb174 146 <td>$newsforum->name</td>
98ea2a6e 147 <td align=\"right\"><font size=\"1\">
89adb174 148 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
149 </td></tr></table>";
150 } else {
151 $headertext = $newsforum->name;
152 }
8c336db1 153
63fa3f80 154 if ($site->newsitems) { //print forums only when needed
155 print_heading_block($headertext);
156 print_spacer(8,1);
157 forum_print_latest_discussions($newsforum->id, $site->newsitems);
8c336db1 158 }
89adb174 159 break;
160
161 case FRONTPAGECOURSELIST:
162 case FRONTPAGECATEGORYNAMES:
163 if (isset($USER->id) and !isset($USER->admin)) {
4bab5275 164 print_heading_block(get_string('mycourses'));
89adb174 165 print_spacer(8,1);
166 print_my_moodle();
167 } else {
4bab5275 168 if (count_records('course_categories') > 1) {
89adb174 169 if ($CFG->frontpage == FRONTPAGECOURSELIST) {
4bab5275 170 print_heading_block(get_string('availablecourses'));
89adb174 171 } else {
4bab5275 172 print_heading_block(get_string('categories'));
89adb174 173 }
174 print_spacer(8,1);
4bab5275 175 print_simple_box_start('center', '100%');
89adb174 176 print_whole_category_list();
177 print_simple_box_end();
4bab5275 178 print_course_search('', false, 'short');
89adb174 179 } else {
4bab5275 180 print_heading_block(get_string('availablecourses'));
89adb174 181 print_spacer(8,1);
4bab5275 182 print_courses(0, '100%');
89adb174 183 }
184 }
185 break;
186
187 }
188
189 echo '</td>';
9b4b78fd 190
191
192 // The right column
193 if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing || isadmin()) {
8c336db1 194 echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;" id="right-column">';
89adb174 195 if (isadmin()) {
196 echo '<div align="center">'.update_course_icon($site->id).'</div>';
197 echo '<br />';
198 }
f032aa7a 199 blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
c1d8705f 200 if ($editing) {
201 blocks_print_adminblock($PAGE, $pageblocks);
89adb174 202 }
203 echo '</td>';
204 }
205?>
d887b5a7 206
3565715c 207 </tr>
208</table>
f9903ed0 209
8c336db1 210<?php
8c336db1 211 print_footer('home'); // Please do not modify this line
b5768b9e 212?>