Merge "Localisation updates from http://translatewiki.net."
[lhc/web/wiklou.git] / includes / HTMLForm.php
index 3b3e1b6..c149965 100644 (file)
@@ -1,4 +1,25 @@
 <?php
+/**
+ * HTML form generation and submission handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
 /**
  * Object handling generic submission, CSRF protection, layout and
  * other logic for UI forms. in a reusable manner.
@@ -271,7 +292,7 @@ class HTMLForm extends ContextSource {
 
        /**
         * The here's-one-I-made-earlier option: do the submission if
-        * posted, or display the form with or without funky valiation
+        * posted, or display the form with or without funky validation
         * errors
         * @return Bool or Status whether submission was successful.
         */
@@ -279,7 +300,7 @@ class HTMLForm extends ContextSource {
                $this->prepareForm();
 
                $result = $this->tryAuthorizedSubmit();
-               if ( $result === true || ( $result instanceof Status && $result->isGood() ) ){
+               if ( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
                        return $result;
                }
 
@@ -312,6 +333,9 @@ class HTMLForm extends ContextSource {
                }
 
                $callback = $this->mSubmitCallback;
+               if ( !is_callable( $callback ) ) {
+                       throw new MWException( 'HTMLForm: no submit callback provided. Use setSubmitCallback() to set one.' );
+               }
 
                $data = $this->filterDataForSubmit( $this->mFieldData );
 
@@ -516,7 +540,7 @@ class HTMLForm extends ContextSource {
         * @return String HTML.
         */
        function getHiddenFields() {
-               global $wgUsePathInfo;
+               global $wgArticlePath;
 
                $html = '';
                if( $this->getMethod() == 'post' ){
@@ -524,7 +548,7 @@ class HTMLForm extends ContextSource {
                        $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
                }
 
-               if ( !$wgUsePathInfo && $this->getMethod() == 'get' ) {
+               if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() == 'get' ) {
                        $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
                }
 
@@ -664,7 +688,7 @@ class HTMLForm extends ContextSource {
         * @param $msg String message key
         */
        public function setSubmitTextMsg( $msg ) {
-               return $this->setSubmitText( $this->msg( $msg )->escaped() );
+               return $this->setSubmitText( $this->msg( $msg )->text() );
        }
 
        /**
@@ -1096,6 +1120,11 @@ abstract class HTMLFormField {
                                $msg = wfMessage( array_shift( $helpMessage ), $helpMessage );
 
                                if( $msg->exists() ) {
+                                       if( is_null( $helptext ) ) {
+                                               $helptext = '';
+                                       } else {
+                                               $helptext .= wfMessage( 'word-separator' )->escaped(); // some space
+                                       }
                                        $helptext .= $msg->parse(); // Append message
                                }
                        }
@@ -1306,6 +1335,10 @@ class HTMLTextAreaField extends HTMLFormField {
                        $attribs['readonly'] = 'readonly';
                }
 
+               if ( isset( $this->mParams['placeholder'] ) ) {
+                       $attribs['placeholder'] = $this->mParams['placeholder'];
+               }
+
                foreach ( array( 'required', 'autofocus' ) as $param ) {
                        if ( isset( $this->mParams[$param] ) ) {
                                $attribs[$param] = '';