Skip to content

Commit

Permalink
themes lib MDL-24895 Multiple fixes to better handle overflow.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sam Hemelryk committed Nov 5, 2010
1 parent 2412f8b commit 367a75f
Show file tree
Hide file tree
Showing 125 changed files with 3,362 additions and 2,058 deletions.
2 changes: 1 addition & 1 deletion admin/report/spamcleaner/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Expand Down
2 changes: 1 addition & 1 deletion backup/util/ui/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public function render_restore_category_search(restore_category_search $componen
$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;
}
Expand Down
1 change: 1 addition & 0 deletions blocks/course_summary/block_course_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function get_content() {
$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);
Expand Down
1 change: 1 addition & 0 deletions blocks/glossary_random/block_glossary_random.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function specialization() {

$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;
Expand Down
5 changes: 2 additions & 3 deletions blocks/html/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ function get_content() {
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;
Expand Down
2 changes: 2 additions & 0 deletions blocks/html/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.block.block_html .content {padding:0;}
.block.block_html .content .no-overflow {padding:4px;}
2 changes: 1 addition & 1 deletion blocks/rss_client/block_rss_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function get_feed_html($feedrecord, $maxentries, $showtitle){
}


$r.='<ul class="list">'."\n";
$r.='<ul class="list no-overflow">'."\n";

$feeditems = $feed->get_items(0, $maxentries);
foreach($feeditems as $item){
Expand Down
6 changes: 4 additions & 2 deletions blocks/site_main_menu/block_site_main_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ function get_content() {
/// 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" ';
Expand Down Expand Up @@ -85,6 +86,7 @@ function get_content() {

if (!empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
$options = array('overflowdiv'=>true);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
Expand Down Expand Up @@ -127,7 +129,7 @@ function get_content() {
}

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
Expand Down
6 changes: 4 additions & 2 deletions blocks/social_activities/block_social_activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ function get_content() {
/// 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" ';
Expand Down Expand Up @@ -94,6 +95,7 @@ function get_content() {

if (!empty($section) && !empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
$options = array('overflowdiv'=>true);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
Expand Down Expand Up @@ -136,7 +138,7 @@ function get_content() {
}

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
Expand Down
3 changes: 2 additions & 1 deletion blog/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function print_html($return=false) {
}
$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);
Expand Down
4 changes: 2 additions & 2 deletions cohort/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
$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);
$PAGE->set_heading($COURSE->fullname);
$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();
Expand Down
2 changes: 1 addition & 1 deletion comment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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);
Expand Down
5 changes: 3 additions & 2 deletions comment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ public function get_comments($page = '') {

$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();
Expand All @@ -424,7 +425,7 @@ public function get_comments($page = '') {
$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)) {
Expand Down Expand Up @@ -513,7 +514,7 @@ public function add($content, $format = FORMAT_MOODLE) {
$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 {
Expand Down
3 changes: 2 additions & 1 deletion comment/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ function get_comments($page) {
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);
Expand Down
1 change: 1 addition & 0 deletions course/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
$options = new stdClass;
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
if (!isset($category->descriptionformat)) {
$category->descriptionformat = FORMAT_MOODLE;
}
Expand Down
2 changes: 2 additions & 0 deletions course/format/topics/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
$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)) {
Expand Down Expand Up @@ -229,6 +230,7 @@
$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;';
Expand Down
6 changes: 4 additions & 2 deletions course/format/weeks/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@

$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))) {
Expand Down Expand Up @@ -230,8 +231,9 @@
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))) {
Expand Down
2 changes: 1 addition & 1 deletion course/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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>';
Expand Down
3 changes: 2 additions & 1 deletion course/report/outline/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions grade/edit/tree/grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
print_error('nocourseid');
}

$PAGE->set_pagelayout('incourse');
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/grade:manage', $context)) {
Expand Down
6 changes: 5 additions & 1 deletion grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,11 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
$title = $PAGE->course->fullname.': ' . $stractive_plugin;
}

$PAGE->set_pagelayout('admin');
if ($active_type == 'report') {
$PAGE->set_pagelayout('report');
} else {
$PAGE->set_pagelayout('admin');
}
$PAGE->set_title(get_string('grades') . ': ' . $stractive_type);
$PAGE->set_heading($title);
if ($buttons instanceof single_button) {
Expand Down
7 changes: 3 additions & 4 deletions grade/report/grader/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@

$reportname = get_string('pluginname', 'gradereport_grader');

/// Print header
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);

//Initialise the grader report object that produces the table
//the class grade_report_grader_ajax was removed as part of MDL-21562
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);

// make sure separate group does not prevent view
if ($report->currentgroup == -2) {
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
echo $OUTPUT->heading(get_string("notingroup"));
echo $OUTPUT->footer();
exit;
Expand All @@ -136,9 +138,6 @@
$numusers = $report->get_numusers();
$report->load_final_grades();

/// Print header
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);

echo $report->group_selector;
echo '<div class="clearer"></div>';
// echo $report->get_toggles_html();
Expand Down
5 changes: 2 additions & 3 deletions grade/report/user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
print_error('nocourseid');
}
require_login($course);
$PAGE->set_pagelayout('report');

$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('gradereport/user:view', $context);
Expand Down Expand Up @@ -148,6 +149,4 @@
}
}

echo $OUTPUT->footer();


echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion grade/report/user/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private function fill_table_recursive(&$element) {

} else {
$data['feedback']['class'] = $class.' feedbacktext';
$data['feedback']['content'] = format_text($grade_grade->feedback, $grade_grade->feedbackformat);
$data['feedback']['content'] = format_text($grade_grade->feedback, $grade_grade->feedbackformat, array('overflowdiv'=>true));
}

/// Range
Expand Down
Loading

0 comments on commit 367a75f

Please sign in to comment.