Index: trunk/phase3/includes/Xml.php |
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | . implode( "\n", $options ) |
175 | 175 | . self::closeElement( 'select' ); |
176 | 176 | } |
177 | | - |
| 177 | + |
178 | 178 | /** |
179 | 179 | * @param $year Integer |
180 | 180 | * @param $month Integer |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | * @param $text content of the element, will be escaped |
250 | 250 | * @param $class class name of the span element |
251 | 251 | * @param $attribs other attributes |
252 | | - * @return string |
| 252 | + * @return string |
253 | 253 | */ |
254 | 254 | public static function span( $text, $class, $attribs=array() ) { |
255 | 255 | return self::element( 'span', array( 'class' => $class ) + $attribs, $text ); |
— | — | @@ -260,7 +260,7 @@ |
261 | 261 | * @param $class class name of the span element |
262 | 262 | * @param $tag element name |
263 | 263 | * @param $attribs other attributes |
264 | | - * @return string |
| 264 | + * @return string |
265 | 265 | */ |
266 | 266 | public static function wrapClass( $text, $class, $tag='span', $attribs=array() ) { |
267 | 267 | return self::tags( $tag, array( 'class' => $class ) + $attribs, $text ); |
— | — | @@ -275,10 +275,18 @@ |
276 | 276 | * @return string HTML |
277 | 277 | */ |
278 | 278 | public static function input( $name, $size=false, $value=false, $attribs=array() ) { |
279 | | - return self::element( 'input', array( |
280 | | - 'name' => $name, |
281 | | - 'size' => $size, |
282 | | - 'value' => $value ) + $attribs ); |
| 279 | + $attributes = array(); |
| 280 | + if( $size ) { |
| 281 | + $attributes['size'] = $size; |
| 282 | + } |
| 283 | + |
| 284 | + if( $size ) { |
| 285 | + $attributes['value'] = $value; |
| 286 | + } |
| 287 | + |
| 288 | + $attributes['name'] = $name; |
| 289 | + |
| 290 | + return self::element( 'input', $attributes + $attribs ); |
283 | 291 | } |
284 | 292 | |
285 | 293 | /** |
— | — | @@ -337,7 +345,7 @@ |
338 | 346 | * Convenience function to build an HTML form label |
339 | 347 | * @param $label text of the label |
340 | 348 | * @param $id |
341 | | - * @param $attribs Array, other attributes |
| 349 | + * @param $attribs Array, other attributes |
342 | 350 | * @return string HTML |
343 | 351 | */ |
344 | 352 | public static function label( $label, $id, $attribs=array() ) { |
— | — | @@ -506,7 +514,7 @@ |
507 | 515 | |
508 | 516 | return $s; |
509 | 517 | } |
510 | | - |
| 518 | + |
511 | 519 | /** |
512 | 520 | * Shortcut for creating textareas. |
513 | 521 | * |
— | — | @@ -660,7 +668,7 @@ |
661 | 669 | array( '"', '>', '<' ), |
662 | 670 | $in ); |
663 | 671 | } |
664 | | - |
| 672 | + |
665 | 673 | /** |
666 | 674 | * Generate a form (without the opening form element). |
667 | 675 | * Output optionally includes a submit button. |
— | — | @@ -671,7 +679,7 @@ |
672 | 680 | public static function buildForm( $fields, $submitLabel = null ) { |
673 | 681 | $form = ''; |
674 | 682 | $form .= "<table><tbody>"; |
675 | | - |
| 683 | + |
676 | 684 | foreach( $fields as $labelmsg => $input ) { |
677 | 685 | $id = "mw-$labelmsg"; |
678 | 686 | $form .= Xml::openElement( 'tr', array( 'id' => $id ) ); |
— | — | @@ -686,13 +694,13 @@ |
687 | 695 | $form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMsg( $submitLabel ) ) . Xml::closeElement( 'td' ); |
688 | 696 | $form .= Xml::closeElement( 'tr' ); |
689 | 697 | } |
690 | | - |
| 698 | + |
691 | 699 | $form .= "</tbody></table>"; |
692 | 700 | |
693 | | - |
| 701 | + |
694 | 702 | return $form; |
695 | 703 | } |
696 | | - |
| 704 | + |
697 | 705 | /** |
698 | 706 | * Build a table of data |
699 | 707 | * @param $rows An array of arrays of strings, each to be a row in a table |
— | — | @@ -717,7 +725,7 @@ |
718 | 726 | $s .= Xml::closeElement( 'table' ); |
719 | 727 | return $s; |
720 | 728 | } |
721 | | - |
| 729 | + |
722 | 730 | /** |
723 | 731 | * Build a row for a table |
724 | 732 | * @param $attribs An array of attributes to apply to the tr tag |
— | — | @@ -768,7 +776,7 @@ |
769 | 777 | $value = ($value !== false) ? $value : $name; |
770 | 778 | $this->options[] = Xml::option( $name, $value, $value === $this->default ); |
771 | 779 | } |
772 | | - |
| 780 | + |
773 | 781 | // This accepts an array of form |
774 | 782 | // label => value |
775 | 783 | // label => ( label => value, label => value ) |
— | — | @@ -778,7 +786,7 @@ |
779 | 787 | |
780 | 788 | // This accepts an array of form |
781 | 789 | // label => value |
782 | | - // label => ( label => value, label => value ) |
| 790 | + // label => ( label => value, label => value ) |
783 | 791 | static function formatOptions( $options, $default = false ) { |
784 | 792 | $data = ''; |
785 | 793 | foreach( $options as $label => $value ) { |
— | — | @@ -789,7 +797,7 @@ |
790 | 798 | $data .= Xml::option( $label, $value, $value === $default ) . "\n"; |
791 | 799 | } |
792 | 800 | } |
793 | | - |
| 801 | + |
794 | 802 | return $data; |
795 | 803 | } |
796 | 804 | |