MDL-46127 core_calendar: Removed tables when rendering a single event

This commit is contained in:
Brian Barnes 2014-06-25 16:33:12 +12:00
parent d07b0302a9
commit 11edf09c61
6 changed files with 82 additions and 77 deletions

View file

@ -268,7 +268,7 @@ class core_calendar_renderer extends plugin_renderer_base {
// There is nothing to display today.
$output .= $this->output->heading(get_string('daywithnoevents', 'calendar'), 3);
} else {
$output .= html_writer::start_tag('div', array('class'=>'eventlist'));
$output .= html_writer::start_tag('div', array('class' => 'eventlist'));
$underway = array();
// First, print details about events that start today
foreach ($events as $event) {
@ -309,32 +309,25 @@ class core_calendar_renderer extends plugin_renderer_base {
$event = calendar_add_event_metadata($event);
$context = $event->context;
$anchor = html_writer::tag('a', '', array('name'=>'event_'.$event->id));
$table = new html_table();
$table->attributes = array('class'=>'event', 'cellspacing'=>'0');
$table->data = array(
0 => new html_table_row(),
1 => new html_table_row(),
);
$output = '';
if (!empty($event->icon)) {
$table->data[0]->cells[0] = new html_table_cell($anchor.$event->icon);
$output .= $event->icon;
} else {
$table->data[0]->cells[0] = new html_table_cell($anchor.$this->output->spacer(array('height'=>16, 'width'=>16, 'br'=>true)));
$output .= $this->output->spacer(array('height' => 16, 'width' => 16));
}
$table->data[0]->cells[0]->attributes['class'] .= ' picture';
$table->data[0]->cells[1] = new html_table_cell();
$table->data[0]->cells[1]->attributes['class'] .= ' topic';
if (!empty($event->referer)) {
$table->data[0]->cells[1]->text .= html_writer::tag('div', $event->referer, array('class'=>'referer'));
$output .= $this->output->heading($event->referer, 3, array('class' => 'referer'));
} else {
$table->data[0]->cells[1]->text .= html_writer::tag('div', format_string($event->name, false, array('context' => $context)), array('class'=>'name'));
$output .= $this->output->heading(
format_string($event->name, false, array('context' => $context)),
3,
array('class' => 'name')
);
}
if (!empty($event->courselink)) {
$table->data[0]->cells[1]->text .= html_writer::tag('div', $event->courselink, array('class'=>'course'));
$output .= html_writer::tag('div', $event->courselink, array('class' => 'course'));
}
// Show subscription source if needed.
if (!empty($event->subscription) && $CFG->calendar_showicalsource) {
@ -344,23 +337,25 @@ class core_calendar_renderer extends plugin_renderer_base {
// File based ical.
$source = get_string('subsource', 'calendar', $event->subscription);
}
$table->data[0]->cells[1]->text .= html_writer::tag('div', $source, array('class' => 'subscription'));
$output .= html_writer::tag('div', $source, array('class' => 'subscription'));
}
if (!empty($event->time)) {
$table->data[0]->cells[1]->text .= html_writer::tag('span', $event->time, array('class'=>'date'));
$output .= html_writer::tag('span', $event->time, array('class' => 'date'));
} else {
$table->data[0]->cells[1]->text .= html_writer::tag('span', calendar_time_representation($event->timestart), array('class'=>'date'));
$output .= html_writer::tag('span', calendar_time_representation($event->timestart), array('class' => 'date'));
}
$table->data[1]->cells[0] = new html_table_cell(' ');
$table->data[1]->cells[0]->attributes['class'] .= 'side';
$eventdetailshtml = '';
$eventdetailsclasses = '';
$table->data[1]->cells[1] = new html_table_cell(format_text($event->description, $event->format, array('context' => $context)));
$table->data[1]->cells[1]->attributes['class'] .= ' description';
$eventdetailshtml .= format_text($event->description, $event->format, array('context' => $context));
$eventdetailsclasses .= 'description';
if (isset($event->cssclass)) {
$table->data[1]->cells[1]->attributes['class'] .= ' '.$event->cssclass;
$eventdetailsclasses .= ' '.$event->cssclass;
}
$output .= html_writer::tag('div', $eventdetailshtml, array('class' => $eventdetailsclasses));
if (calendar_edit_event_allowed($event) && $showactions) {
if (empty($event->cmid)) {
$editlink = new moodle_url(CALENDAR_URL.'event.php', array('action'=>'edit', 'id'=>$event->id));
@ -384,9 +379,9 @@ class core_calendar_renderer extends plugin_renderer_base {
$commands .= html_writer::end_tag('a');
}
$commands .= html_writer::end_tag('div');
$table->data[1]->cells[1]->text .= $commands;
$output .= $commands;
}
return html_writer::table($table);
return html_writer::tag('div', $output , array('class' => 'event', 'id' => 'event_' . $event->id));
}
/**
@ -621,7 +616,7 @@ class core_calendar_renderer extends plugin_renderer_base {
$output .= html_writer::end_tag('div');
if ($events) {
$output .= html_writer::start_tag('div', array('class'=>'eventlist'));
$output .= html_writer::start_tag('div', array('class' => 'eventlist'));
foreach ($events as $event) {
// Convert to calendar_event object so that we transform description
// accordingly