Revert "Convert SpecialPrefixIndex to class HTMLForm"
[lhc/web/wiklou.git] / includes / specials / SpecialBotPasswords.php
index 9975e41..f76c318 100644 (file)
@@ -123,7 +123,7 @@ class SpecialBotPasswords extends FormSpecialPage {
                                        $showGrants
                                ),
                                'default' => array_map(
-                                       function( $g ) {
+                                       function ( $g ) {
                                                return "grant-$g";
                                        },
                                        $this->botPassword->getGrants()
@@ -131,14 +131,14 @@ class SpecialBotPasswords extends FormSpecialPage {
                                'tooltips' => array_combine(
                                        array_map( 'MWGrants::getGrantsLink', $showGrants ),
                                        array_map(
-                                               function( $rights ) use ( $lang ) {
+                                               function ( $rights ) use ( $lang ) {
                                                        return $lang->semicolonList( array_map( 'User::getRightDescription', $rights ) );
                                                },
                                                array_intersect_key( MWGrants::getRightsByGrant(), array_flip( $showGrants ) )
                                        )
                                ),
                                'force-options-on' => array_map(
-                                       function( $g ) {
+                                       function ( $g ) {
                                                return "grant-$g";
                                        },
                                        MWGrants::getHiddenGrants()
@@ -146,19 +146,9 @@ class SpecialBotPasswords extends FormSpecialPage {
                        ];
 
                        $fields['restrictions'] = [
-                               'type' => 'textarea',
-                               'label-message' => 'botpasswords-label-restrictions',
+                               'class' => HTMLRestrictionsField::class,
                                'required' => true,
-                               'default' => $this->botPassword->getRestrictions()->toJson( true ),
-                               'rows' => 5,
-                               'validation-callback' => function ( $v ) {
-                                       try {
-                                               MWRestrictions::newFromJson( $v );
-                                               return true;
-                                       } catch ( InvalidArgumentException $ex ) {
-                                               return $ex->getMessage();
-                                       }
-                               },
+                               'default' => $this->botPassword->getRestrictions(),
                        ];
 
                } else {
@@ -234,7 +224,7 @@ class SpecialBotPasswords extends FormSpecialPage {
                                        'name' => 'op',
                                        'value' => 'create',
                                        'label-message' => 'botpasswords-label-create',
-                                       'flags' => [ 'primary', 'constructive' ],
+                                       'flags' => [ 'primary', 'progressive' ],
                                ] );
                        }
 
@@ -282,7 +272,7 @@ class SpecialBotPasswords extends FormSpecialPage {
                $bp = BotPassword::newUnsaved( [
                        'centralId' => $this->userId,
                        'appId' => $this->par,
-                       'restrictions' => MWRestrictions::newFromJson( $data['restrictions'] ),
+                       'restrictions' => $data['restrictions'],
                        'grants' => array_merge(
                                MWGrants::getHiddenGrants(),
                                preg_replace( '/^grant-/', '', $data['grants'] )