Page MenuHomePhabricator

Make a nice way of building HTML tables
Open, LowestPublic

Description

$out->addHTML( Html::openElement( 'table', [ 'class' => 'TablePager' ] ) );
$out->addHTML( '<thead>' );
$out->addHTML( '<tr>' );
$out->addHTML( '<th>' );

Things like that, just suck

Having a table object(or something)..

$table->openTable();

$table->addHeaderRow( array( 'foo', 'bar, 'baz' ) );

$table->openBody();

$table->addRow( array( 'lol', '1', '2' ) );
$table->addRow( array( 'zing', '3', '4' ) );

$table->closeBody();

$table->closeTable();

Or something, whatever, would be nicer...

Maybe some part of OutputPage or something?

Details

Reference
bz30371

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:51 PM
bzimport set Reference to bz30371.
bzimport added a subscriber: Unknown Object (MLST).

Ew not OutputPage, it could be used in lots of other places too. Make a TableBuilder class or something.

We've got HTMLForm. Writing a HTMLTable class makes sense.

Is this still an interesting feature? What possibilities would it bring to, say, Wikipedia editors compared with the current options of wikitext tables + basic html tables?

I guess nobody is currently planning to work on this?

(In reply to comment #2)

We've got HTMLForm. Writing a HTMLTable class makes sense.

Would this still be a good idea? Is this a task simple enough for a Google Code-in student?

https://www.mediawiki.org/wiki/Google_Code-In

(In reply to comment #2)

We've got HTMLForm. Writing a HTMLTable class makes sense.

Ugh, I'd say that not really. The class we're imagining here would probably be more akin to XmlSelect.

(In reply to comment #3)

What possibilities would it bring to,
say, Wikipedia editors compared with the current options of wikitext tables +
basic html tables?

None, because it's not related. This is only about nicer methods of generating tables on PHP-side.

It should be simple enough for GCI, assuming that a) we want this and b) we have some use-cases.

We have the TablePager class now: https://github.com/wikimedia/mediawiki/blob/4acef2dd82f9b0c87905129f377d0983bb7f23c8/includes/pager/TablePager.php

@Reedy is there still a need for an HTML Table builder? Where would it be used in our code?