Maintenance for ConfirmEdit extension.
[toast/cookiecaptcha.git] / FancyCaptcha.class.php
index 3ce5670e4ecba395b4a0dfaf47820ebe447dcdfd..a204f09322f87b5a4b96bf6a6f81b76ecca99905 100644 (file)
@@ -57,24 +57,28 @@ class FancyCaptcha extends SimpleCaptcha {
                $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
 
                return "<p>" .
-                       Xml::element( 'img', array(
+                       Html::element( 'img', array(
                                'src'    => $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) ),
                                'width'  => $info['width'],
                                'height' => $info['height'],
                                'alt'    => '' ) ) .
                        "</p>\n" .
-                       Xml::element( 'input', array(
+                       Html::element( 'input', array(
                                'type'  => 'hidden',
                                'name'  => 'wpCaptchaId',
                                'id'    => 'wpCaptchaId',
                                'value' => $index ) ) .
-                       "<p>" .
+                       '<p>' .
+                       Html::element( 'label', array(
+                               'for' => 'wpCaptchaWord',
+                       ), parent::getMessage( 'label' ) . wfMessage( 'colon-separator' )->text() ) .
                        Html::element( 'input', array(
                                'name' => 'wpCaptchaWord',
                                'id'   => 'wpCaptchaWord',
+                               'type' => 'text',
                                'autocorrect' => 'off',
                                'autocapitalize' => 'off',
-                               'required',
+                               'required' => 'required',
                                'tabindex' => 1 ) ) . // tab in before the edit textarea
                        "</p>\n";
        }
@@ -97,6 +101,9 @@ class FancyCaptcha extends SimpleCaptcha {
 
                        // Check which subdirs are actually present...
                        $dir = opendir( $directory );
+                       if ( !$dir ) {
+                               return false;
+                       }
                        while ( false !== ( $entry = readdir( $dir ) ) ) {
                                if ( ctype_xdigit( $entry ) && strlen( $entry ) == 1 ) {
                                        $dirs[] = $entry;
@@ -154,6 +161,7 @@ class FancyCaptcha extends SimpleCaptcha {
 
        /**
         * Count the number of files in a directory.
+        * @param $dirname
         * @return int
         */
        function countFiles( $dirname ) {
@@ -225,10 +233,10 @@ class FancyCaptcha extends SimpleCaptcha {
         */
        function getMessage( $action ) {
                $name = 'fancycaptcha-' . $action;
-               $text = wfMsg( $name );
+               $text = wfMessage( $name )->text();
                # Obtain a more tailored message, if possible, otherwise, fall back to
                # the default for edits
-               return wfEmptyMsg( $name, $text ) ? wfMsg( 'fancycaptcha-edit' ) : $text;
+               return wfMessage( $name, $text )->isDisabled() ? wfMessage( 'fancycaptcha-edit' )->text() : $text;
        }
 
        /**