Page MenuHomePhabricator

Separate the XmlSelect class (generates <select ...>...</select> comboboxes) and implement where it should be used
Closed, ResolvedPublic

Description

Currently, to write an combobox in MediaWiki, the steps are:

  • a call to Xml:openElement for <select...
  • as many calls to Html:element( 'option', ...) as the count of options
  • a call to Xml:closeElement to get the </select>

This makes operations like "write a combobox with this array as options and set the option ... as default" rather long and tedious to write.

A widget class would be interesting to abstract the process.

Move XmlSelect to its own file, and use it where it should be used in various codez.

See P673 for codes to replace

Event Timeline

Dereckson updated the task description. (Show Details)
Dereckson raised the priority of this task from to Needs Triage.
Dereckson added a subscriber: Dereckson.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 19 2015, 6:19 PM
Dereckson updated the task description. (Show Details)Mar 19 2015, 7:17 PM
Dereckson set Security to None.
Aklapper triaged this task as Lowest priority.Mar 20 2015, 11:02 AM
Sn1per claimed this task.May 22 2015, 2:28 PM
Sn1per added a subscriber: Sn1per.

I might work on this? Especially because school is out.

There is one, actually! XmlSelect, in includes/Xml.php. We should probably split it to separate file to make it easier to find.

What you can do in this case is to implement this XmlSelect in the following files to simplify our code:

  • includes/ProtectionForm.php
  • includes/installer/WebInstallerPage.php
  • includes/specials/SpecialListusers.php

See P673 for the output of the ag -Q "openElement( 'select'" command.

Sn1per renamed this task from An helper class to generate <select ...>...</select> comboboxes to Separate the XmlSelect class (generates <select ...>...</select> comboboxes) and implement where it should be used.Jun 1 2015, 3:23 AM
Sn1per updated the task description. (Show Details)

Change 215551 had a related patch set uploaded (by Sn1per):
Move XmlSelect to its own file

https://gerrit.wikimedia.org/r/215551

Change 215551 merged by jenkins-bot:
Move XmlSelect to its own file

https://gerrit.wikimedia.org/r/215551

Change 216511 had a related patch set uploaded (by Sn1per):
Use XmlSelect to "simplify" stuff in class Xml

https://gerrit.wikimedia.org/r/216511

Change 216511 merged by jenkins-bot:
Use XmlSelect to simplify Xml::monthSelector

https://gerrit.wikimedia.org/r/216511

Sn1per updated the task description. (Show Details)Jul 25 2015, 3:33 PM

Change 228054 had a related patch set uploaded (by Sn1per):
Use XmlSelect in WebInstallerPage

https://gerrit.wikimedia.org/r/228054

Change 228127 had a related patch set uploaded (by Sn1per):
Use XmlSelect in ProtectionForm

https://gerrit.wikimedia.org/r/228127

Change 228054 merged by jenkins-bot:
Use XmlSelect in WebInstallerPage

https://gerrit.wikimedia.org/r/228054

Change 228127 merged by jenkins-bot:
Use XmlSelect in ProtectionForm

https://gerrit.wikimedia.org/r/228127

Change 228566 had a related patch set uploaded (by Sn1per):
Use XmlSelect in SpecialListusers

https://gerrit.wikimedia.org/r/228566

Change 228566 merged by jenkins-bot:
Use XmlSelect in SpecialListusers

https://gerrit.wikimedia.org/r/228566

Sn1per updated the task description. (Show Details)Sep 9 2015, 8:12 PM

Change 238075 had a related patch set uploaded (by Sn1per):
Enable multiple default values for XmlSelect

https://gerrit.wikimedia.org/r/238075

Change 238076 had a related patch set uploaded (by Sn1per):
Use XmlSelect in SpecialEditTags

https://gerrit.wikimedia.org/r/238076

Change 238075 merged by jenkins-bot:
Enable multiple default values for XmlSelect

https://gerrit.wikimedia.org/r/238075

Change 238076 merged by jenkins-bot:
Use XmlSelect in SpecialEditTags

https://gerrit.wikimedia.org/r/238076

@Sn1per, are there any instances left that still need fixing?

@Legoktm hey, there are still a few instances (see P673), but for the most part, all of the "easy" drop-in replacements are done; some of the remaining replacements may require a little work to get working.

Should we keep this assigned to you then (are you planning to work on the rest)? Or maybe file other tasks for the remaining instances and close this one?

@Legoktm I am going to get around to the rest, eventually :P but others are welcome to do it if they want to.

The remaining replacements are kinda too small to be separate tasks, but if they are not trivial, separate tasks could be filed. e.g. I tried to convert Xml::listDropDown() a while back (it was in one of the merged gerrit changes, but I removed it), but the logic was so heavily based around Xml::openElement and Xml::select that I ended up making it messier; at one point it was suggested that listDropDown could, if needed, be separated into a separate class :P

matmarex closed this task as Resolved.Oct 27 2015, 11:04 PM

Let's close this then, if this doesn't actually improve the code in other cases, it's probably not worth spending time on. (If you decide that it does, feel free to submit more patches though!)

Thank you @Sn1per for this work.

@matmarex Sounds good, thanks.

@Dereckson Thanks for the broccoli tree