Commit graph

80 commits

Author SHA1 Message Date
robin
5a59d9b8bb Maintenance in Html::openElement regarding input types
Followup to c22000

Remove unset() for 'search' type, it will now simply be unset through the regular checking (removed it in the validTypes for that, but it is still in validTypes in HTML5 mode).

Update / remove outdated code comments.

Change-Id: I452462b81360b67b76dd8baa732d52113b6aafe6
2012-09-17 03:30:56 +02:00
Antoine Musso
1a7da4f625 test: full coverage of Html::dropDefaults()
This closely match Html::dropDefaults() logic and hopefully test out
all default dropping.

Introduce a test case that match a failure in f34547ab where attribute
default values passed in an array are not cleaned up.

Change-Id: If8d16b066015ed1bcaf38408511ac3713eaa6540
2012-09-14 21:26:56 -07:00
Daniel Friesen
81f1cace4c Fix broken value="" stripping for HTML5
The default value for value="" on <input> elements is not always an
empty string.

In particular the default value for type="radio" is "on" and by
stripping value="" out of the attributes a "" becomes "on" and our
cleanup code ends up breaking forms.

Change-Id: Ibe5a3be3f45a2f93ef95dbe42729b8f8c94a41cb
2012-09-14 21:26:56 -07:00
Antoine Musso
a45e20ff11 HTML5 new types for input element
HTML5 introduced new types for the input element. For some reasons we
never added them to Html::openElement which would thus strip them even
in HTML5 mode.

The issue is:
 $wgHtml5 = true;
 Html::element( 'input', array( 'type' => 'color' );
 # -> "<input />"

With this patch, we returns: <input type="color" />

Change-Id: I7de373635d0eb47f788d1d664c3a913c8801efd6
2012-09-14 21:26:55 -07:00
Tyler Anthony Romeo
f34547ab44 (bug 39875) Fixed conversion of array attributes in Html.
Changed Html::dropDefaults() so that when an array is
passed as an attribute value, it does not call strval(),
thus triggering a PHP notice. Instead arrays are
imploded with a space as the separator.

Change-Id: I2521b78c7de94c183b7de7e7d4b2b510ab0c7770
2012-08-31 21:25:27 -04:00
Alex Monk
2fabea7eea Use wfMessage instead of deprecated wfMsg*
Or $this->msg in special pages.

Change-Id: I774a89d646615053c8424050e42ad95601f92543
2012-08-18 14:11:05 +02:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
Krinkle
1e5689852b [Html::namespaceSelector] Remove default id/name attributes
* Remove default id/name attributes
* Remove now redundant tests introduced in r110274
* Add tests to make sure label has no 'for' attribute when label isn't null but name/id are unset
* Update tests to not include id="" and name="" when calling with no arguments
* Updating calls to add name/id if needed, and while at it remove useless 'null' params


* Context:
-- Introduced in r109990, r111376, r111315
-- No callers exist that assume these defaults. Forcing an ID that should be unique is annoying and redundant. The name used in the query when submitting a form should be mentioned in the same file where it is used from the submission, never assume what name="" is from unrelated code
-- Same for ID, this is often used in CSS or JavaScript, shouldn't be assumed. (It should be simple to but two simple namespace selectors on a page without getting DOM conflicts)
2012-03-07 19:14:20 +00:00
Krinkle
78c157faf9 [Html] Follow-up r109990: Add support for excluding and disabling options 2012-02-13 15:08:26 +00:00
Krinkle
9815dff76f [Html.php] Follow-up r110275, comment fixes.
* $options does not contain <option> elements, but associative array between option-values and option-labels
2012-02-12 18:58:28 +00:00
Antoine Musso
fc6bc233be Fix doxygen docs before REL1_19 branching 2012-02-01 20:53:38 +00:00
Antoine Musso
11c166bf92 comment / style for Html::namespaceSelector()
Xml.php:
* align array values. Easier to the eyes.

Html.php:
* Various comments
* Switched the way the HTML is forged

Ping r109990
2012-01-30 11:02:56 +00:00
Krinkle
3c9d05055b [Html] Unit test + bugfix Html::namespaceSelector
* Previously it was passing $selectAttribs['name'] to Xml::label, which uses its value for the <label for=""> attribute. This works as long as $selectAttribs['id'] and $selectAttribs['name'] match, but when they don't it fails. <label for=""> always corresponds with <{input,text area,select} id=""> in browsers, never with "name".
* Make name/id match eachother by default to avoid backwards compatibility breakages (they used to match in the Xml class method as well)
* Add HtmlTest.php entries similar to the ones in XmlTest
* Fix E_NOTICE about $params['selected'], default to ''

-- Follows-up r109974, r109698, r109990
-- Bug originally introduced in r41425
-- XmlTest.php still runs successfully
-- HtmlTest.php runs successfully
2012-01-25 03:25:54 +00:00
Krinkle
11b0b2e7d3 [Xml/Html] new method Html::namespaceSelector
* Using params and option arrays instead of 4 random parameters like Xml::namespaceSelector did
* Right now it's passing $selectAttribs['name'] to Xml::label, this is done because that's what Xml::namespaceSelector did. However it's wrong since labels associate over ID not NAME. Will fix in the next commit, making sure unit tests stay functional first. This bug has been in Xml::namespaceSelector for a long time but usually unnoticed as people kept either defaults. Although it was easy to get wrong as the NAME was configurable but the ID was hardcoded in Xml::namespaceSelector.
* Deprecated Xml::namespaceSelector and made it cal Html::namespaceSelector

* Follows-up r109974, r109698
* XmlTest.php still runs successfully
2012-01-25 03:01:20 +00:00
Antoine Musso
b4913d5b96 makes HTML5 five only attributes a global property
This patch move an array hidden in Html::expandAttributes() to the top of
the class definition as self::$HTMLFiveOnlyAttribs.
That also make the Html::expandAttributes() method a bit more concise.
2011-10-24 13:58:03 +00:00
Brion Vibber
969cec9322 * (bug 12130) Initial newlines are now preserved correctly during editing
HTML browsers strip the first newline from the literal contents of a <textarea>, but keep any additional newlines beyond that.

Prepending an extra newline in Html::textarea() when the contained text started with a newline makes our output basically look like this:

<textarea>             <-- (this added newline is ignored)
                       <-- (any original newline here is preserved)
blah blah</textarea>

This seems to consistently resolve the stripping of single initial newlines from every edit operation as seen on bug 12130; as noted on comments there <https://bugzilla.wikimedia.org/show_bug.cgi?id=12130#c17> this had deleterious effects on Wikisource, where transcription/proofreading tends to involve breaking up lots of little pages, which may have a significant newline at the start of a page boundary.

Text that didn't have initial newlines won't see any difference in the HTML output.

Followup to test cases in r98576, which confirm that supported browsers consistently have this behavior.
2011-09-30 22:50:48 +00:00
Jeroen De Dauw
3c4a3f16a0 Follow up to r97128; 2011-09-15 16:07:40 +00:00
Krinkle
fc226de996 Add documentation for r96170 and r96188. 2011-09-04 21:18:27 +00:00
Daniel Friesen
cebad72f95 Expand r96170's support for space separated attributes with support for boolean keys such as array( 'class' => array( 'selected' => true ) ) to match our array( 'checked' => false ) support.
As per discussion with Krinkle make sure that in array( 'foo', 'foo' => false, 'foo' ) the 'foo' key is authoritive.
2011-09-03 14:36:58 +00:00
Krinkle
73db9698a3 Html.php: The "future"[1] is here. Add features for space-separated value attributes of html elements.
* Has been suggested since August 2009 in r54767 (doc-comment from rawElement/element function)
* Implements normalization for these attributes (removal of duplicates and redundant space)
* Adds support for arrays (instead of just string) for these attributes. 
* String are still supported, and are converted to arrays to get the same normalization.
* Wrote unit tests (which pass locally: $ php phpunit.php includes/HtmlTest.php)
* Not trigger for the media-attribute. Reason: Although some people think it's space-separated, it's actually comma-separated. Treating them as space separated might even destroy the value. [2] [3]. Neither the html4 or html5 spec documents media-attribute as space-separated, and as of HTML5/CSS3 the media attribute may contain "media queries".


[1] "In the future, other HTML-specific features might be added, like allowing arrays for the values of attributes like class= and media=" in r54767 by Simetrical.
[2] http://www.w3.org/TR/1999/REC-html401-19991224/types.html#h-6.13
[3] http://dev.w3.org/csswg/css3-mediaqueries/#background

Implementation note: I choose to have a single list of attributes that trigger this feature. Some of these attributes only support multiple values and/or are documented as space-separated as of html5 (such as accesskey), but since those attributes in general have existed in html4 as well (just different w3c spec), they are not stripped if wgHtml5 is not true. So if this feature would (eg. for accesskey) would only be done if wgHtml5=true, then people could get output like <a accesskey=Array /> depending on a configuration variable, which will get messy and make developers' life hard.
2011-09-03 03:55:23 +00:00
Krinkle
bc1532c31c Html.php: Move html5-validation blacklist check to *AFTER* the check the might continue (and skip this loop entirely) if we're not in HTML5 with an html5-only attribute.
* Performance :)
2011-09-03 00:35:08 +00:00
Daniel Friesen
30d1962eed Add html5 microdata's itemscope to the list of boolean attributes. 2011-08-28 23:03:19 +00:00
Derk-Jan Hartman
69bde7f3ae Update the Html5 void elements and boolean attributes, in accordance with the latest draft. 2011-08-12 21:04:25 +00:00
Jure Kajzer
ca33b4903d * used Html static functions instead og Xml. (r89260#c17418) 2011-06-01 14:18:12 +00:00
Siebrand Mazeland
1ef2f71ccf Whitespace updates. 2011-06-01 14:12:53 +00:00
Jure Kajzer
62a12d2454 * moved infobox to Html (r88109#c16937) 2011-06-01 13:57:50 +00:00
Siebrand Mazeland
75c6696aa8 Use consistent notation for "@todo FIXME". Should update http://svn.wikimedia.org/doc/todo.html nicely. 2011-05-17 22:03:20 +00:00
Sam Reed
15df9a9d5c Kill off the long deprecated $wgInputEncoding and $wgOutputEncoding globals 2011-05-06 22:09:47 +00:00
Sam Reed
5db2450c55 Documentation
Remove unused variables
2011-05-04 21:23:25 +00:00
Mark A. Hershberger
b3df4babc2 misc w/s cleanups, “svn diff -x-w” clean 2011-03-08 18:12:17 +00:00
Daniel Friesen
95e6386122 Html::expandAttributes( array( 'foo' => null ) ); ' foo=""' -> ''
Outputting ' foo="" on `foo = null` promotes the writing of overly verbose code to avoid it, and ugly methods like our old Linker::getLinkAttributesInternal, both of which are completely counter to the purpose of Html::.
2011-02-05 20:28:04 +00:00
Jeroen De Dauw
36f4b7a6e6 Added since notice to indicate method was not present in MW 1.16 yet 2011-01-20 19:26:30 +00:00
Sam Reed
84fed26fd4 Add missing credits from r75975
Remove a few unused array keys in API foreach loops

Remove part of Html::Hidden comment
2010-11-06 15:10:18 +00:00
Alexandre Emsenhuber
85e0c158ee * Standardised file description headers
* added @file where needed
* added file description headers where needed
2010-10-23 14:16:26 +00:00
Sam Reed
ecf56c33fa Braces and spaces 2010-09-04 03:43:33 +00:00
Sam Reed
04f68827d0 Removal of unused globals
Removal of one setting of a variable to '', then not using further
2010-07-24 19:11:52 +00:00
Niklas Laxström
55493f65e8 Introduce $wgBetterDirectionality that lets us work on support for rtl ui in ltr wiki and vice versa. 2010-07-08 13:34:03 +00:00
Aryeh Gregor
45db6ec98d Use <!DOCTYPE html> unconditionally
See r67090 for context.  Everywhere that I've found this breaking
well-formedness is fixed.  Tested with the following Python:

import xml.sax
class Myhandler(xml.sax.ContentHandler):
    pass

h = Myhandler()
for page in ('BrokenRedirects', 'Deadendpages', 'DoubleRedirects', 'Longpages', 'Ancientpages', 'Lonelypages', 'Fewestrevisions', 'Withoutinterwiki', 'Protectedpages', 'Protectedtitles', 'Shortpages', 'Uncategorizedcategories', 'Uncategorizedimages', 'Uncategorizedpages', 'Uncategorizedtemplates', 'Unusedcategories', 'Unusedimages', 'Unusedtemplates', 'Unwatchedpages', 'Wantedcategories', 'Wantedfiles', 'Wantedpages', 'Wantedtemplates', 'Allpages', 'Prefixindex', 'Categories', 'Disambiguations', 'Listredirects', 'Userlogin', 'CreateAccount', 'Blockip', 'Ipblocklist', 'Unblock', 'Resetpass', 'DeletedContributions', 'Preferences', 'Contributions', 'Listgrouprights', 'Listusers', 'Activeusers', 'Userrights', 'Newimages', 'Log', 'Watchlist', 'Newpages', 'Recentchanges', 'Recentchangeslinked', 'Tags', 'Listfiles', 'Filepath', 'MIMEsearch', 'FileDuplicateSearch', 'Upload', 'Statistics', 'Allmessages', 'Version', 'Lockdb', 'Unlockdb', 'LinkSearch', 'Randompage', 'Randomredirect', 'Mostlinkedcategories', 'Mostimages', 'Mostlinked', 'Mostlinkedtemplates', 'Mostcategories', 'Mostrevisions', 'ComparePages', 'Export', 'Import', 'Undelete', 'Whatlinkshere', 'MergeHistory', 'Booksources', 'Blankpage', 'Blockme', 'Emailuser', 'Listadmins', 'Listbots', 'Movepage', 'Mycontributions', 'Mypage', 'Mytalk', 'Revisiondelete', 'RevisionMove', 'Specialpages', 'Userlogout'):
    xml.sax.parse("http://localhost/git-trunk/phase3/index.php?title=Special:" + page, h)

I had to manually skip some of these for unrelated reasons, but none of
them became malformed because of this commit.  Also tested the main page
and Special:Random a bunch of separate times.  There are probably other
well-formedness errors lurking, but they can be fixed as they're
reported.
2010-06-30 23:08:49 +00:00
Aryeh Gregor
76a543ea30 Disable form validation more thoroughly
Expands on r67283 by not using any HTML5 input types either, except
search.  Otherwise you'd still have problems when changing integer
fields in Special:Preferences, say.  Sad, since in Opera it had a cute
little widget for incrementing/decrementing, and types like email have
some neat effects on platforms like the iPhone (see
<http://diveintohtml5.org/forms.html#type-email>).  But there's no other
way to disable the constraints these impose without using JS, and given
how broken WebKit is right now . . .
2010-06-30 22:14:36 +00:00
Aryeh Gregor
9fb4b59f35 Don't allow boolean HTML5 attribs into XHTML1
The code didn't handle the case where a non-associative array was passed
for the attributes, like array( 'autofocus' ) instead of array(
'autofocus' => '' ).  In retrospect, allowing this syntax was a bad
decision and I wish I hadn't.  Associative arrays shouldn't pretend to
be lists.  Probably too much trouble to change it now.
2010-06-11 21:57:20 +00:00
Aryeh Gregor
14da10c663 Update boolean attribute list from HTML5 draft 2010-06-07 21:07:13 +00:00
Aryeh Gregor
e347b2bab5 (bug 23769) Disable HTML5 form validation for now
Is implemented in recent WebKit but with no UI, so it's worse than just
giving a server-side error.  The only other implementation right now is
Opera and its UI is pretty ugly, so not yet worth the effort to do UA
sniffing.  Will backport to 1.16, as a regression fix.
2010-06-03 17:18:21 +00:00
Chad Horohoe
af304dfd44 (bug 23440) Add "selected" to $boolAttribs 2010-05-09 09:32:43 +00:00
Niklas Laxström
0e3ed4741c Installer is no longer hardcoded to xhtml doctype
Refactored the doctype and html tag building into Html::htmlHeader()
from OutputPage.
2010-05-08 13:45:14 +00:00
Aryeh Gregor
eefe1b13a3 Omit some start/end tags if not well-formed XML 2010-03-21 05:12:02 +00:00
Niklas Laxström
e1065a1d57 Little docs to help developers keep track of versions... 2010-02-24 16:06:55 +00:00
Aryeh Gregor
23bc48ea35 Fix comment, remove unused global 2010-02-21 01:44:25 +00:00
Chad Horohoe
02a59dce9f Use isset() instead of array_key_exists() 2010-01-27 19:14:18 +00:00
Aryeh Gregor
010c456825 Merge all skins' output of opening <body> tag
This fixes a few minor discrepancies, like Vector outputting dir=""
(redundant to the one on <html>), and non-Monobook-based skins omitting
the capitalize-all-nouns class (!).  This adds Html::openElement() and
refactors Html::rawElement() accordingly, so I checked that all parser
tests still pass.

I wasn't able to figure out if I broke some feature of right-floating
quickbars in the Standard skin, because I wasn't able to figure out what
the feature was in the first place.  Hopefully either it works, or
nobody cares, or someone else will figure out what it was supposed to
do.  (This is the stuff in getBodyOptions() in Standard.php I deleted;
I'm not sure the addition to sticky.js does what I want.)
2010-01-15 01:16:52 +00:00
Raimond Spekking
18ed54d077 Tweak 'HMTL 5' -> 'HTML5' per suggestion on translatewiki: http://translatewiki.net/wiki/Thread:Support/HTML5
See http://en.wikipedia.org/wiki/HTML5 too.
2009-12-30 07:08:52 +00:00