Commit e1638d61 authored by patrickslee's avatar patrickslee
Browse files

Site frontpage now supports displaying of all avaliable options with ordering

parent ce531767
......@@ -29,19 +29,34 @@
</tr>
<tr valign="top">
<td align="right"><?php print_string("frontpageformat") ?>:</td>
<td><?php
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<td>
<?php
$options = array(FRONTPAGENEWS => get_string("frontpagenews"),
FRONTPAGECOURSELIST => get_string("frontpagecourselist"),
FRONTPAGECATEGORYNAMES => get_string("frontpagecategorynames"),
FRONTPAGETOPICONLY => get_string("frontpagetopiconly"));
);
$values = array(get_string('hide'), 1, 2);
$seq = array_flip(explode(',',$form->frontpage));
foreach ($seq as $k => $s) {
$seq[$k]++;
}
if (count_records("course") > 200) {
unset($options[1]);
if ($form->frontpage == 1) {
unset($options[FRONTPAGECOURSELIST]);
if (isset($seq[FRONTPAGECOURSELIST])) {
$form->frontpage = 2;
}
} else {
$values[] = 3;
}
foreach ($options as $key => $option) {
echo "<td>$option<br />";
choose_from_menu ($values, "frontpage[$key]", isset($seq[$key])?$seq[$key]:0, "");
}
choose_from_menu ($options, "frontpage", "$form->frontpage", "");
?>
</tr>
</table>
</td>
</tr>
<tr valign="top">
......
......@@ -25,8 +25,13 @@
if (count($err) == 0) {
$form->frontpage = array_flip($form->frontpage);
unset($form->frontpage[0]);
$form->frontpage = array_flip($form->frontpage);
asort($form->frontpage);
$form->frontpage = implode(',',array_flip($form->frontpage));
set_config("frontpage", $form->frontpage);
if ($form->frontpage == FRONTPAGETOPICONLY) {
if (!$form->frontpage) {
$form->numsections = 1; // Force the topic display for this format
}
......
......@@ -1288,7 +1288,9 @@ function print_category_info($category, $depth) {
$catlinkcss = $category->visible ? '' : ' class="dimmed" ';
if ($CFG->frontpage == FRONTPAGECOURSELIST) {
$frontpage = explode(',', $CFG->frontpage);
$frontpage = $frontpage?array_flip($frontpage):array();
if (isset($frontpage[FRONTPAGECOURSELIST])) {
$catimage = '<img src="'.$CFG->pixpath.'/i/course.gif" width="16" height="16" border="0" alt="" />';
} else {
$catimage = "&nbsp";
......@@ -1296,7 +1298,7 @@ function print_category_info($category, $depth) {
echo "\n\n".'<table border="0" cellpadding="3" cellspacing="0" width="100%">';
if ($CFG->frontpage == FRONTPAGECOURSELIST) {
if (isset($frontpage[FRONTPAGECOURSELIST])) {
$courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.guest,c.cost,c.currency');
echo "<tr>";
......
......@@ -119,62 +119,65 @@
}
}
switch ($CFG->frontpage) { /// Display the main part of the front page.
case FRONTPAGENEWS:
if ($SITE->newsitems) { // Print forums only when needed
require_once($CFG->dirroot .'/mod/forum/lib.php');
if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
error('Could not find or create a main news forum for the site');
}
if (isset($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
if (forum_is_subscribed($USER->id, $newsforum->id)) {
$subtext = get_string('unsubscribe', 'forum');
foreach (explode(',',$CFG->frontpage) as $v) {
switch ($v) { /// Display the main part of the front page.
case strval(FRONTPAGENEWS):
if ($SITE->newsitems) { // Print forums only when needed
require_once($CFG->dirroot .'/mod/forum/lib.php');
if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
error('Could not find or create a main news forum for the site');
}
if (isset($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
if (forum_is_subscribed($USER->id, $newsforum->id)) {
$subtext = get_string('unsubscribe', 'forum');
} else {
$subtext = get_string('subscribe', 'forum');
}
$headertext = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'.
'<td><div class="title">'.$newsforum->name.'</div></td>'.
'<td><div class="link"><a href="mod/forum/subscribe.php?id='.$newsforum->id.'">'.$subtext.'</a></div></td>'.
'</tr></table>';
} else {
$subtext = get_string('subscribe', 'forum');
$headertext = $newsforum->name;
}
$headertext = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'.
'<td><div class="title">'.$newsforum->name.'</div></td>'.
'<td><div class="link"><a href="mod/forum/subscribe.php?id='.$newsforum->id.'">'.$subtext.'</a></div></td>'.
'</tr></table>';
} else {
$headertext = $newsforum->name;
print_heading_block($headertext);
forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems);
}
print_heading_block($headertext);
forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems);
}
break;
break;
case FRONTPAGECOURSELIST:
case FRONTPAGECATEGORYNAMES:
case FRONTPAGECOURSELIST:
case FRONTPAGECATEGORYNAMES:
if (isloggedin() && !isset($USER->admin) && empty($CFG->disablemycourses)) {
print_heading_block(get_string('mycourses'));
print_my_moodle();
} else {
if (count_records('course_categories') > 1) {
if ($CFG->frontpage == FRONTPAGECOURSELIST) {
print_heading_block(get_string('availablecourses'));
if (isloggedin() && !isset($USER->admin) && empty($CFG->disablemycourses)) {
print_heading_block(get_string('mycourses'));
print_my_moodle();
} else {
if (count_records('course_categories') > 1) {
if ($v == FRONTPAGECOURSELIST) {
print_heading_block(get_string('availablecourses'));
} else {
print_heading_block(get_string('categories'));
}
print_simple_box_start('center', '100%', '', 5, 'categorybox');
print_whole_category_list();
print_simple_box_end();
print_course_search('', false, 'short');
} else {
print_heading_block(get_string('categories'));
print_heading_block(get_string('availablecourses'));
print_courses(0, '100%');
}
print_simple_box_start('center', '100%', '', 5, 'categorybox');
print_whole_category_list();
print_simple_box_end();
print_course_search('', false, 'short');
} else {
print_heading_block(get_string('availablecourses'));
print_courses(0, '100%');
}
}
break;
break;
case FRONTPAGETOPICONLY: // Do nothing!! :-)
break;
case FRONTPAGETOPICONLY: // Do nothing!! :-)
break;
}
echo '<br />';
}
echo '</td>';
......
......@@ -536,12 +536,12 @@ $string['formattopics'] = 'Topics format';
$string['formatweeks'] = 'Weekly format';
$string['formatwiki'] = 'Wiki-like format';
$string['from'] = 'From';
$string['frontpagecategorynames'] = 'Show a list of categories';
$string['frontpagecourselist'] = 'Show a list of courses';
$string['frontpagecategorynames'] = 'List of categories';
$string['frontpagecourselist'] = 'List of courses';
$string['frontpagedescription'] = 'Front Page Description';
$string['frontpageformat'] = 'Front page format';
$string['frontpagenews'] = 'Show news items';
$string['frontpagetopiconly'] = 'Show arbitrary HTML or activities (topic section)';
$string['frontpagenews'] = 'News items';
$string['frontpagetopiconly'] = 'Topic section';
$string['fulllistofcourses'] = 'All courses';
$string['fullname'] = 'Full name';
$string['fullnamedisplay'] = '$a->firstname $a->lastname';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment