Merge "Use generalizeSQL for DBPerformance log entries"
[lhc/web/wiklou.git] / includes / ProtectionForm.php
index 4aa65d9..76ad252 100644 (file)
@@ -321,7 +321,7 @@ class ProtectionForm {
                 *             you can also return an array of message name and its parameters
                 */
                $errorMsg = '';
-               if ( !wfRunHooks( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg, $reasonstr ) ) ) {
+               if ( !Hooks::run( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg, $reasonstr ) ) ) {
                        if ( $errorMsg == '' ) {
                                $errorMsg = array( 'hookaborted' );
                        }
@@ -352,7 +352,7 @@ class ProtectionForm {
                        $output->addJsConfigVars( 'wgCascadeableLevels', $cascadingRestrictionLevels );
                        $out .= Xml::openElement( 'form', array( 'method' => 'post',
                                'action' => $this->mTitle->getLocalURL( 'action=protect' ),
-                               'id' => 'mw-Protect-Form', 'onsubmit' => 'ProtectionForm.enableUnchainedInputs(true)' ) );
+                               'id' => 'mw-Protect-Form' ) );
                }
 
                $out .= Xml::openElement( 'fieldset' ) .
@@ -384,13 +384,18 @@ class ProtectionForm {
                        );
 
                        $expiryFormOptions = '';
-                       if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] != 'infinity' ) {
-                               $timestamp = $lang->timeanddate( $this->mExistingExpiry[$action], true );
-                               $d = $lang->date( $this->mExistingExpiry[$action], true );
-                               $t = $lang->time( $this->mExistingExpiry[$action], true );
+                       if ( $this->mExistingExpiry[$action] ) {
+                               if ( $this->mExistingExpiry[$action] == 'infinity' ) {
+                                       $existingExpiryMessage = wfMessage( 'protect-existing-expiry-infinity' );
+                               } else {
+                                       $timestamp = $lang->timeanddate( $this->mExistingExpiry[$action], true );
+                                       $d = $lang->date( $this->mExistingExpiry[$action], true );
+                                       $t = $lang->time( $this->mExistingExpiry[$action], true );
+                                       $existingExpiryMessage = wfMessage( 'protect-existing-expiry', $timestamp, $d, $t );
+                               }
                                $expiryFormOptions .=
                                        Xml::option(
-                                               wfMessage( 'protect-existing-expiry', $timestamp, $d, $t )->text(),
+                                               $existingExpiryMessage->text(),
                                                'existing',
                                                $this->mExpirySelection[$action] == 'existing'
                                        ) . "\n";
@@ -426,16 +431,13 @@ class ProtectionForm {
                                                                array(
                                                                        'id' => "mwProtectExpirySelection-$action",
                                                                        'name' => "wpProtectExpirySelection-$action",
-                                                                       'onchange' => "ProtectionForm.updateExpiryList(this)",
                                                                        'tabindex' => '2' ) + $this->disabledAttrib,
                                                                $expiryFormOptions ) .
                                                "</td>
                                        </tr></table>";
                        }
                        # Add custom expiry field
-                       $attribs = array( 'id' => "mwProtect-$action-expires",
-                               'onkeyup' => 'ProtectionForm.updateExpiry(this)',
-                               'onchange' => 'ProtectionForm.updateExpiry(this)' ) + $this->disabledAttrib;
+                       $attribs = array( 'id' => "mwProtect-$action-expires" ) + $this->disabledAttrib;
                        $out .= "<table><tr>
                                        <td class='mw-label'>" .
                                                $mProtectother .
@@ -450,7 +452,7 @@ class ProtectionForm {
                        "</td></tr>";
                }
                # Give extensions a chance to add items to the form
-               wfRunHooks( 'ProtectionForm::buildForm', array( $this->mArticle, &$out ) );
+               Hooks::run( 'ProtectionForm::buildForm', array( $this->mArticle, &$out ) );
 
                $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
 
@@ -556,7 +558,6 @@ class ProtectionForm {
                                $user->getEditToken( array( 'protect', $this->mTitle->getPrefixedDBkey() ) )
                        );
                        $out .= Xml::closeElement( 'form' );
-                       $output->addScript( $this->buildCleanupScript() );
                }
 
                return $out;
@@ -581,8 +582,7 @@ class ProtectionForm {
                        'id' => $id,
                        'name' => $id,
                        'size' => count( $levels ),
-                       'onchange' => 'ProtectionForm.updateLevels(this)',
-                       ) + $this->disabledAttrib;
+               ) + $this->disabledAttrib;
 
                $out = Xml::openElement( 'select', $attribs );
                foreach ( $levels as $key ) {
@@ -611,19 +611,6 @@ class ProtectionForm {
                }
        }
 
-       function buildCleanupScript() {
-               $options = array(
-                       'tableId' => 'mwProtectSet',
-                       'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
-                       'numTypes' => count( $this->mApplicableTypes ),
-                       'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
-               );
-
-               $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) );
-
-               return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) );
-       }
-
        /**
         * Show protection long extracts for this page
         *
@@ -636,6 +623,6 @@ class ProtectionForm {
                $out->addHTML( Xml::element( 'h2', null, $protectLogPage->getName()->text() ) );
                LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
                # Let extensions add other relevant log extracts
-               wfRunHooks( 'ProtectionForm::showLogExtract', array( $this->mArticle, $out ) );
+               Hooks::run( 'ProtectionForm::showLogExtract', array( $this->mArticle, $out ) );
        }
 }