Commit 367a75fa authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

themes lib MDL-24895 Multiple fixes to better handle overflow.

Major tasks undertaken in this patch:
* New format_text argument, overflowdiv.
* New page layout Report.
* Review of all format_text calls.
* Added support for the report layout to all themes.
* Changed forum post display from tables to divs.
parent 2412f8b8
......@@ -267,7 +267,7 @@ function print_user_entry($user, $keywords, $count) {
$user->descriptionformat = FORMAT_MOODLE;
}
$html .= '<td align="left">'.format_text($user->description, $user->descriptionformat).'</td>';
$html .= '<td align="left">'.format_text($user->description, $user->descriptionformat, array('overflowdiv'=>true)).'</td>';
$html .= '<td width="100px" align="center">';
$html .= '<button onclick="M.report_spamcleaner.del_user(this,'.$user->id.')">'.get_string('deleteuser', 'admin').'</button><br />';
$html .= '<button onclick="M.report_spamcleaner.ignore_user(this,'.$user->id.')">'.get_string('ignore', 'admin').'</button>';
......
......@@ -587,7 +587,7 @@ class core_backup_renderer extends plugin_renderer_base {
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$category->id)),
$category->name,
format_text($category->description, $category->descriptionformat)
format_text($category->description, $category->descriptionformat, array('overflowdiv'=>true))
);
$table->data[] = $row;
}
......
......@@ -25,6 +25,7 @@ class block_course_summary extends block_base {
$this->content = new stdClass();
$options = new stdClass();
$options->noclean = true; // Don't clean Javascripts etc
$options->overflowdiv = true;
$context = get_context_instance(CONTEXT_COURSE, $this->page->course->id);
$this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
$this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
......
......@@ -84,6 +84,7 @@ class block_glossary_random extends block_base {
$options = new stdClass();
$options->trusted = $entry->definitiontrust;
$options->overflowdiv = true;
$text .= format_text($entry->definition, $entry->definitionformat, $options);
$this->config->nexttime = usergetmidnight(time()) + DAYSECS * $this->config->refresh;
......
......@@ -46,12 +46,11 @@ class block_html extends block_base {
return $this->content;
}
$filteropt = new stdClass;
$filteropt->overflowdiv = true;
if ($this->content_is_trusted()) {
// fancy html allowed only on course, category and system blocks.
$filteropt = new stdClass;
$filteropt->noclean = true;
} else {
$filteropt = null;
}
$this->content = new stdClass;
......
.block.block_html .content {padding:0;}
.block.block_html .content .no-overflow {padding:4px;}
\ No newline at end of file
......@@ -185,7 +185,7 @@
}
$r.='<ul class="list">'."\n";
$r.='<ul class="list no-overflow">'."\n";
$feeditems = $feed->get_items(0, $maxentries);
foreach($feeditems as $item){
......
......@@ -34,13 +34,14 @@ class block_site_main_menu extends block_list {
/// extra fast view mode
if (!$isediting) {
if (!empty($modinfo->sections[0])) {
$options = array('overflowdiv'=>true);
foreach($modinfo->sections[0] as $cmid) {
$cm = $modinfo->cms[$cmid];
if (!$cm->uservisible) {
continue;
}
if ($cm->modname == 'label') {
$this->content->items[] = format_text($cm->extra, FORMAT_HTML);
$this->content->items[] = format_text($cm->extra, FORMAT_HTML, $options);
$this->content->icons[] = '';
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
......@@ -85,6 +86,7 @@ class block_site_main_menu extends block_list {
if (!empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
$options = array('overflowdiv'=>true);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
......@@ -127,7 +129,7 @@ class block_site_main_menu extends block_list {
}
if ($mod->modname == 'label') {
$this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
$this->content->items[] = format_text($extra, FORMAT_HTML,$options).$editbuttons;
$this->content->icons[] = '';
} else {
//Accessibility: incidental image - should be empty Alt text
......
......@@ -36,13 +36,14 @@ class block_social_activities extends block_list {
/// extra fast view mode
if (!$isediting) {
if (!empty($modinfo->sections[0])) {
$options = array('overflowdiv'=>true);
foreach($modinfo->sections[0] as $cmid) {
$cm = $modinfo->cms[$cmid];
if (!$cm->uservisible) {
continue;
}
if ($cm->modname == 'label') {
$this->content->items[] = format_text($cm->extra, FORMAT_HTML);
$this->content->items[] = format_text($cm->extra, FORMAT_HTML, $options);
$this->content->icons[] = '';
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
......@@ -94,6 +95,7 @@ class block_social_activities extends block_list {
if (!empty($section) && !empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
$options = array('overflowdiv'=>true);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
......@@ -136,7 +138,7 @@ class block_social_activities extends block_list {
}
if ($mod->modname == 'label') {
$this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
$this->content->items[] = format_text($extra, FORMAT_HTML, $options).$editbuttons;
$this->content->icons[] = '';
} else {
//Accessibility: incidental image - should be empty Alt text
......
......@@ -114,7 +114,8 @@ class blog_entry {
}
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
$template['body'] = format_text($this->summary, $this->summaryformat).$cmttext;
$options = array('overflowdiv'=>true);
$template['body'] = format_text($this->summary, $this->summaryformat, $options).$cmttext;
$template['title'] = format_string($this->subject);
$template['userid'] = $user->id;
$template['author'] = fullname($user);
......
......@@ -54,7 +54,7 @@ if (!$manager) {
$strcohorts = get_string('cohorts', 'cohort');
if ($category) {
$PAGE->set_pagelayout('admin');
$PAGE->set_pagelayout('report');
$PAGE->set_context($context);
$PAGE->set_url('/cohort/index.php', array('contextid'=>$context->id));
$PAGE->set_title($strcohorts);
......@@ -62,7 +62,7 @@ if ($category) {
$PAGE->navbar->add($category->name, new moodle_url('/course/index.php', array('categoryedit'=>'1')));
$PAGE->navbar->add($strcohorts);
} else {
admin_externalpage_setup('cohorts');
admin_externalpage_setup('cohorts', '', null, '', array('pagelayout'=>'report'));
}
echo $OUTPUT->header();
......
......@@ -23,7 +23,7 @@ require_once($CFG->libdir.'/adminlib.php');
require_once('locallib.php');
require_login();
admin_externalpage_setup('comments');
admin_externalpage_setup('comments', '', null, '', array('pagelayout'=>'report'));
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/comment:delete', $context);
......
......@@ -413,6 +413,7 @@ EOD;
$comments = array();
$candelete = has_capability('moodle/comment:delete', $this->context);
$formatoptions = array('overflowdiv' => true);
$rs = $DB->get_recordset_sql($sql, $params, $start, $CFG->commentsperpage);
foreach ($rs as $u) {
$c = new stdClass();
......@@ -424,7 +425,7 @@ EOD;
$c->profileurl = $url->out();
$c->fullname = fullname($u);
$c->time = userdate($c->timecreated, get_string('strftimerecent', 'langconfig'));
$c->content = format_text($c->content, $c->format);
$c->content = format_text($c->content, $c->format, $formatoptions);
$c->avatar = $OUTPUT->user_picture($u, array('size'=>18));
if (($USER->id == $u->id) || !empty($candelete)) {
......@@ -513,7 +514,7 @@ EOD;
$newcmt->fullname = fullname($USER);
$url = new moodle_url('/user/view.php', array('id'=>$USER->id, 'course'=>$this->courseid));
$newcmt->profileurl = $url->out();
$newcmt->content = format_text($newcmt->content, $format);
$newcmt->content = format_text($newcmt->content, $format, array('overflowdiv'=>true));
$newcmt->avatar = $OUTPUT->user_picture($USER, array('size'=>16));
return $newcmt;
} else {
......
......@@ -47,11 +47,12 @@ class comment_manager {
WHERE u.id=c.userid ORDER BY c.timecreated ASC";
$comments = array();
$formatoptions = array('overflowdiv' => true);
if ($records = $DB->get_records_sql($sql, array(), $start, $this->perpage)) {
foreach ($records as $item) {
$item->fullname = fullname($item);
$item->time = userdate($item->timecreated);
$item->content = format_text($item->content);
$item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
$comments[] = $item;
unset($item->firstname);
unset($item->lastname);
......
......@@ -196,6 +196,7 @@
$options = new stdClass;
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
if (!isset($category->descriptionformat)) {
$category->descriptionformat = FORMAT_MOODLE;
}
......
......@@ -107,6 +107,7 @@ if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing())
$summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
$summaryformatoptions = new stdClass();
$summaryformatoptions->noclean = true;
$summaryformatoptions->overflowdiv = true;
echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) {
......@@ -229,6 +230,7 @@ while ($section <= $course->numsections) {
$summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
$summaryformatoptions = new stdClass();
$summaryformatoptions->noclean = true;
$summaryformatoptions->overflowdiv = true;
echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
} else {
echo '&nbsp;';
......
......@@ -99,8 +99,9 @@ defined('MOODLE_INTERNAL') || die();
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
$summaryformatoptions = new stdClass();
$summaryformatoptions = new stdClass;
$summaryformatoptions->noclean = true;
$summaryformatoptions->overflowdiv = true;
echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
......@@ -230,8 +231,9 @@ defined('MOODLE_INTERNAL') || die();
echo '<div class="summary">';
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
$summaryformatoptions = new stdClass();
$summaryformatoptions = new stdClass;
$summaryformatoptions->noclean = true;
$summaryformatoptions->overflowdiv = true;
echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
......
......@@ -54,7 +54,7 @@
echo $OUTPUT->box_start('generalbox info');
$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
echo format_text($course->summary, $course->summaryformat, NULL, $course->id);
echo format_text($course->summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
if (!empty($CFG->coursecontact)) {
$coursecontactroles = explode(',', $CFG->coursecontact);
......
......@@ -1272,6 +1272,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
$labelformatoptions = new stdClass();
$labelformatoptions->noclean = true;
$labelformatoptions->overflowdiv = true;
/// Casting $course->modinfo to string prevents one notice when the field is null
$modinfo = get_fast_modinfo($course);
......@@ -2322,6 +2323,7 @@ function print_course($course, $highlightterms = '') {
$options = NULL;
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
if (!isset($course->summaryformat)) {
$course->summaryformat = FORMAT_MOODLE;
}
......@@ -2468,6 +2470,7 @@ function print_remote_course($course, $width="100%") {
$options = NULL;
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
echo format_text($course->summary, $course->summaryformat, $options);
echo '</div>';
echo '</div>';
......
......@@ -12,7 +12,7 @@
}
$PAGE->set_url('/course/report/outline/index.php', array('id'=>$id));
$PAGE->set_pagelayout('admin');
$PAGE->set_pagelayout('report');
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
......@@ -47,6 +47,7 @@
$outlinetable = new html_table();
$outlinetable->attributes['class'] = 'generaltable boxaligncenter';
$outlinetable->attributes['style'] = 'width:2000px;';
$outlinetable->cellpadding = 5;
$outlinetable->id = 'outlinetable';
$outlinetable->head = array($stractivity, $strviews);
......
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