Skip to content

Commit

Permalink
MDL-21652 html_table rendering refactored
Browse files Browse the repository at this point in the history
* class html_component does not exist any more
* class html_table rendered via html_writer::table()
* html_table, html_table_row and html_table_cell have public $attributes property to set their CSS classes
* dropped rotateheaders feature, should be added again after more research of possible ways (<svg> is not nice IMHO)
* dropped possibility to define CSS classes for table heading, body and footer - can be easily done and better done using just table class and context
  • Loading branch information
mudrd8mz committed Mar 20, 2010
1 parent ad70376 commit 16be897
Show file tree
Hide file tree
Showing 106 changed files with 561 additions and 673 deletions.
2 changes: 1 addition & 1 deletion admin/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
}
asort($table->data);

echo $OUTPUT->table($table);
echo html_writer::table($table);

echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n";
echo "</div>";
Expand Down
2 changes: 1 addition & 1 deletion admin/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
$table->rowclasses[] = 'dimmed_text';
}

echo $OUTPUT->table($table);
echo html_writer::table($table);
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
echo $OUTPUT->footer();

Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/access_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
}

if (!empty($table)) {
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo '<p>&nbsp;</p>';
$baseurl = new moodle_url('/admin/mnet/access_control.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
echo $OUTPUT->paging_bar($aclcount, $page, $perpage, $baseurl);
Expand Down
4 changes: 2 additions & 2 deletions admin/mnet/peers.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
$registerrow
),
);
echo $OUTPUT->table($table);
echo html_writer::table($table);

// print the list of all hosts, with little action links and buttons
$table = new html_table();
Expand Down Expand Up @@ -250,7 +250,7 @@
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
);
}
echo $OUTPUT->table($table);
echo html_writer::table($table);

// finally, print the initial form to add a new host
echo $OUTPUT->box_start();
Expand Down
6 changes: 3 additions & 3 deletions admin/mnet/testclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
);

}
echo $OUTPUT->table($table);
echo html_writer::table($table);


$mnet_request->set_method('system/listMethods');
Expand Down Expand Up @@ -156,7 +156,7 @@
html_writer::link($newurl, get_string('inspect', 'mnet'))
);
}
echo $OUTPUT->table($table);
echo html_writer::table($table);

if (isset($methodid) && array_key_exists($methodid-1, $methods)) {
$method = $methods[$methodid-1];
Expand Down Expand Up @@ -194,7 +194,7 @@
$signature['return']['description']
);

echo $OUTPUT->table($table);
echo html_writer::table($table);

$mnet_request->set_method('system/methodHelp');
$mnet_request->add_param($method, 'string');
Expand Down
2 changes: 1 addition & 1 deletion admin/report/configlog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
}
$rs->close();

echo $OUTPUT->table($table);
echo html_writer::table($table);

echo $OUTPUT->footer();
4 changes: 2 additions & 2 deletions admin/report/courseoverview/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
'<input type="submit" value="'.get_string('view').'" />') ;

echo $OUTPUT->table($table);
echo html_writer::table($table);
echo '</div>';
echo '</form>';

Expand Down Expand Up @@ -117,7 +117,7 @@
}
$table->data[] = $a;
}
echo $OUTPUT->table($table);
echo html_writer::table($table);
}
}
echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion admin/report/questioninstances/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
$totalhidden);

// Print it.
echo $OUTPUT->table($table);
echo html_writer::table($table);
}

// Footer.
Expand Down
4 changes: 2 additions & 2 deletions admin/report/security/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

$table->data[] = $row;

echo $OUTPUT->table($table);
echo html_writer::table($table);

echo $OUTPUT->box($result->details, 'generalbox boxwidthnormal boxaligncenter'); // TODO: add proper css

Expand Down Expand Up @@ -121,7 +121,7 @@

$table->data[] = $row;
}
echo $OUTPUT->table($table);
echo html_writer::table($table);
}

echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion admin/roles/allow.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

echo '<form action="' . $baseurl . '" method="post">';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo '<div class="buttons"><input type="submit" name="submit" value="'.get_string('savechanges').'"/>';
echo '</div></form>';

Expand Down
2 changes: 1 addition & 1 deletion admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
$table->data[] = $row;
}

echo $OUTPUT->table($table);
echo html_writer::table($table);

if ($context->contextlevel > CONTEXT_USER) {
echo '<div class="backlink"><a href="' . get_context_url($context) . '">' . get_string('backto', '', $contextname) . '</a></div>';
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@

$table->data[] = $row;
}
echo $OUTPUT->table($table);
echo html_writer::table($table);

echo $OUTPUT->container_start('buttons');
echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'role'), 'get');
Expand Down
6 changes: 3 additions & 3 deletions admin/uploaduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@

$table = new html_table();
$table->id = "uupreview";
$table->set_classes = 'generaltable';
$table->attributes['class'] = 'generaltable';
$table->tablealign = 'center';
$table->summary = get_string('uploaduserspreview', 'admin');
$table->head = array();
Expand Down Expand Up @@ -887,7 +887,7 @@
$value = get_string($content[$key]);
}
$cells->text = $value;
$cells->set_classes($errclass);
$cells->attributes['class'] = $errclass;
$rows->cells[] = $cells;
}
$countcontent++;
Expand Down Expand Up @@ -928,7 +928,7 @@
$countcontent++;
}
}
echo $OUTPUT->table($table);
echo html_writer::table($table);

if ($haserror) {

Expand Down
2 changes: 1 addition & 1 deletion admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
}
if (!empty($table)) {
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
if (has_capability('moodle/user:create', $sitecontext)) {
echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
Expand Down
2 changes: 1 addition & 1 deletion admin/user/user_bulk_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function sort_compare($a, $b) {
}

echo $OUTPUT->heading("$usercount / $usertotal ".get_string('users'));
echo $OUTPUT->table($table);
echo html_writer::table($table);

echo $OUTPUT->continue_button($return);

Expand Down
2 changes: 1 addition & 1 deletion admin/user/user_bulk_enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function sort_compare($a, $b) {
$table->data[] = $temparray;
}
echo $OUTPUT->heading("$usercount / $usertotal ".get_string('users'));
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo '<div class="continuebutton">';
echo '<input type="submit" name="multienrolsubmit" value="save changes" />';
echo '</div>';
Expand Down
2 changes: 1 addition & 1 deletion admin/webservice/service_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
}
}

echo $OUTPUT->table($table);
echo html_writer::table($table);


// we can edit only custom functions, the build-in would be overridden after each upgrade
Expand Down
14 changes: 7 additions & 7 deletions backup/backup_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
}
}
$table->data = $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code,$instancestopass);
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";
}
}
Expand All @@ -219,7 +219,7 @@
echo $user_options[$backupprefs->backup_users].'</b>';
//Print info
$table->data = user_check_backup($id,$backupprefs->backup_unique_code,$backupprefs->backup_users,$backupprefs->backup_messages, $backupprefs->backup_blogs);
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";

}
Expand All @@ -231,7 +231,7 @@
echo get_string("includelogentries").'</b>';
//Print info
$table->data = log_check_backup($id);
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";
}

Expand All @@ -242,7 +242,7 @@
echo get_string("includeuserfiles").'</b>';
//Print info
$table->data = user_files_check_backup($id,$backupprefs->backup_unique_code);
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";
}

Expand All @@ -253,7 +253,7 @@
echo get_string("includecoursefiles").'</b>';
//Print info
$table->data = course_files_check_backup($id,$backupprefs->backup_unique_code);
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";
}

Expand All @@ -264,7 +264,7 @@
echo get_string("includesitefiles").'</b>';
//Print info
$table->data = site_files_check_backup($id,$backupprefs->backup_unique_code);
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";
}

Expand All @@ -275,7 +275,7 @@
echo get_string("includeroleassignments").'</b>';
//Print info
$table->data = array(array(get_string('roles'), count($backupprefs->backuproleassignments)));
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo "</td></tr>";
}
}
Expand Down
6 changes: 3 additions & 3 deletions backup/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function restore_print_info ($info) {
echo $OUTPUT->heading(get_string("backup").":");
$table->data = $tab;
//Print backup general info
echo $OUTPUT->table($table);
echo html_writer::table($table);

if ($info->backup_backup_version <= 2005070500) {
echo $OUTPUT->notification(get_string('backupnonisowarning')); // Message informing that this backup may not work!
Expand Down Expand Up @@ -643,7 +643,7 @@ function restore_print_info ($info) {
//Print title
echo $OUTPUT->heading(get_string("backupdetails").":");
//Print backup general info
echo $OUTPUT->table($table);
echo html_writer::table($table);
} else {
$status = false;
}
Expand Down Expand Up @@ -672,7 +672,7 @@ function restore_print_course_header ($course_header) {
//Print title
echo $OUTPUT->heading(get_string("course").":");
//Print backup course header info
echo $OUTPUT->table($table);
echo html_writer::table($table);
} else {
$status = false;
}
Expand Down
4 changes: 2 additions & 2 deletions blog/external_blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
if (!empty($blogs)) {
$table = new html_table();
$table->cellpadding = 4;
$table->add_class('generaltable boxaligncenter');
$table->attributes['class'] = 'generaltable boxaligncenter';
$table->head = array(get_string('name'), get_string('url'), get_string('timefetched', 'blog'), get_string('valid', 'blog'), get_string('actions'));

foreach ($blogs as $blog) {
Expand All @@ -87,7 +87,7 @@

$table->data[] = new html_table_row(array($blog->name, $blog->url, userdate($blog->timefetched), $validicon, $editicon . $deleteicon));
}
echo $OUTPUT->table($table);
echo html_writer::table($table);
}

$newexternalurl = new moodle_url('/blog/external_blog_edit.php');
Expand Down
14 changes: 7 additions & 7 deletions blog/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,17 @@ public function print_html($return=false) {
// Start printing of the blog
$table = new html_table();
$table->cellspacing = 0;
$table->add_classes('forumpost blog_entry blog'. ($unassociatedentry ? 'draft' : $template['publishstate']));
$table->attributes['class'] = 'forumpost blog_entry blog'. ($unassociatedentry ? 'draft' : $template['publishstate']);
$table->width = '100%';

$picturecell = new html_table_cell();
$picturecell->add_classes('picture left');
$picturecell->attributes['class'] = 'picture left';
$picturecell->text = $OUTPUT->user_picture($user);

$table->head[] = $picturecell;

$topiccell = new html_table_cell();
$topiccell->add_classes('topic starter');
$topiccell->attributes['class'] = 'topic starter';
$topiccell->text = $OUTPUT->container($template['title'], 'subject');
$topiccell->text .= $OUTPUT->container_start('author');

Expand All @@ -169,11 +169,11 @@ public function print_html($return=false) {
$mainrow = new html_table_row();

$leftsidecell = new html_table_cell();
$leftsidecell->add_classes('left side');
$leftsidecell->attributes['class'] = 'left side';
$mainrow->cells[] = $leftsidecell;

$contentcell = new html_table_cell();
$contentcell->add_class('content');
$contentcell->attributes['class'] = 'content';

$attachedimages = $OUTPUT->container($this->print_attachments(), 'attachments');

Expand Down Expand Up @@ -299,9 +299,9 @@ public function print_html($return=false) {
$table->data = array($mainrow);

if ($return) {
return $OUTPUT->table($table);
return html_writer::table($table);
} else {
echo $OUTPUT->table($table);
echo html_writer::table($table);
}
}

Expand Down
2 changes: 1 addition & 1 deletion comment/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function print_comments($page=0) {
}
$table->data[] = array($checkbox, $c->username, $c->content, $action);
}
echo $OUTPUT->table($table);
echo html_writer::table($table);
echo $OUTPUT->paging_bar($count, $page, $this->perpage, $CFG->wwwroot.'/comment/index.php');
}

Expand Down
2 changes: 1 addition & 1 deletion course/import/activities/mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@
}
}
if (!empty($table)) {
echo $OUTPUT->table($table);
echo html_writer::table($table);
}

2 changes: 1 addition & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
$table->data[] = $row;
}

echo $OUTPUT->table($table);
echo html_writer::table($table);
echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
}

Expand Down
Loading

0 comments on commit 16be897

Please sign in to comment.