Bump PHP version requirement to 7.0.0+
[lhc/web/wiklou.git] / includes / EditPage.php
index 08c4a72..a1d9ae8 100644 (file)
@@ -1706,7 +1706,7 @@ class EditPage {
        }
 
        /**
-        * Wrap status errors in an errorbox for increased visiblity
+        * Wrap status errors in an errorbox for increased visibility
         *
         * @param Status $status
         * @return string Wikitext
@@ -2473,9 +2473,11 @@ ERROR;
                if ( $namespace == NS_MEDIAWIKI ) {
                        # Show a warning if editing an interface message
                        $out->wrapWikiMsg( "<div class='mw-editinginterface'>\n$1\n</div>", 'editinginterface' );
-                       # If this is a default message (but not css or js),
+                       # If this is a default message (but not css, json, or js),
                        # show a hint that it is translatable on translatewiki.net
-                       if ( !$this->mTitle->hasContentModel( CONTENT_MODEL_CSS )
+                       if (
+                               !$this->mTitle->hasContentModel( CONTENT_MODEL_CSS )
+                               && !$this->mTitle->hasContentModel( CONTENT_MODEL_JSON )
                                && !$this->mTitle->hasContentModel( CONTENT_MODEL_JAVASCRIPT )
                        ) {
                                $defaultMessageText = $this->mTitle->getDefaultMessageText();
@@ -3095,10 +3097,12 @@ ERROR;
                                }
                                if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
                                        $isUserCssConfig = $this->mTitle->isUserCssConfigPage();
+                                       $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
+                                       $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
 
                                        $warning = $isUserCssConfig
                                                ? 'usercssispublic'
-                                               : 'userjsispublic';
+                                               : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' );
 
                                        $out->wrapWikiMsg( '<div class="mw-userconfigpublic">$1</div>', $warning );
 
@@ -3109,9 +3113,12 @@ ERROR;
                                                                "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
                                                                [ 'usercssyoucanpreview' ]
                                                        );
-                                               }
-
-                                               if ( $this->mTitle->isJsSubpage() && $config->get( 'AllowUserJs' ) ) {
+                                               } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) {
+                                                       $out->wrapWikiMsg(
+                                                               "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
+                                                               [ 'userjsonyoucanpreview' ]
+                                                       );
+                                               } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) {
                                                        $out->wrapWikiMsg(
                                                                "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
                                                                [ 'userjsyoucanpreview' ]
@@ -3153,62 +3160,6 @@ ERROR;
                ];
        }
 
-       /**
-        * Standard summary input and label (wgSummary), abstracted so EditPage
-        * subclasses may reorganize the form.
-        * Note that you do not need to worry about the label's for=, it will be
-        * inferred by the id given to the input. You can remove them both by
-        * passing [ 'id' => false ] to $userInputAttrs.
-        *
-        * @deprecated since 1.30 Use getSummaryInputWidget() instead
-        * @param string $summary The value of the summary input
-        * @param string $labelText The html to place inside the label
-        * @param array $inputAttrs Array of attrs to use on the input
-        * @param array $spanLabelAttrs Array of attrs to use on the span inside the label
-        * @return array An array in the format [ $label, $input ]
-        */
-       public function getSummaryInput( $summary = "", $labelText = null,
-               $inputAttrs = null, $spanLabelAttrs = null
-       ) {
-               wfDeprecated( __METHOD__, '1.30' );
-               $inputAttrs = $this->getSummaryInputAttributes( $inputAttrs );
-               $inputAttrs += Linker::tooltipAndAccesskeyAttribs( 'summary' );
-
-               $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
-                       'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
-                       'id' => "wpSummaryLabel"
-               ];
-
-               $label = null;
-               if ( $labelText ) {
-                       $label = Xml::tags(
-                               'label',
-                               $inputAttrs['id'] ? [ 'for' => $inputAttrs['id'] ] : null,
-                               $labelText
-                       );
-                       $label = Xml::tags( 'span', $spanLabelAttrs, $label );
-               }
-
-               $input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs );
-
-               return [ $label, $input ];
-       }
-
-       /**
-        * Builds a standard summary input with a label.
-        *
-        * @deprecated since 1.30 Use getSummaryInputWidget() instead
-        * @param string $summary The value of the summary input
-        * @param string $labelText The html to place inside the label
-        * @param array $inputAttrs Array of attrs to use on the input
-        *
-        * @return OOUI\FieldLayout OOUI FieldLayout with Label and Input
-        */
-       function getSummaryInputOOUI( $summary = "", $labelText = null, $inputAttrs = null ) {
-               wfDeprecated( __METHOD__, '1.30' );
-               return $this->getSummaryInputWidget( $summary, $labelText, $inputAttrs );
-       }
-
        /**
         * Builds a standard summary input with a label.
         *
@@ -3904,6 +3855,11 @@ ERROR;
                                        if ( $level === 'user' && !$config->get( 'AllowUserCss' ) ) {
                                                $format = false;
                                        }
+                               } elseif ( $content->getModel() == CONTENT_MODEL_JSON ) {
+                                       $format = 'json';
+                                       if ( $level === 'user' /* No comparable 'AllowUserJson' */ ) {
+                                               $format = false;
+                                       }
                                } elseif ( $content->getModel() == CONTENT_MODEL_JAVASCRIPT ) {
                                        $format = 'js';
                                        if ( $level === 'user' && !$config->get( 'AllowUserJs' ) ) {
@@ -3914,7 +3870,8 @@ ERROR;
                                }
 
                                # Used messages to make sure grep find them:
-                               # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
+                               # Messages: usercsspreview, userjsonpreview, userjspreview,
+                               #   sitecsspreview, sitejsonpreview, sitejspreview
                                if ( $level && $format ) {
                                        $note = "<div id='mw-{$level}{$format}preview'>" .
                                                $this->context->msg( "{$level}{$format}preview" )->text() .
@@ -4225,76 +4182,6 @@ ERROR;
                return $checkboxes;
        }
 
-       /**
-        * Returns an array of html code of the following checkboxes old style:
-        * minor and watch
-        *
-        * @deprecated since 1.30 Use getCheckboxesWidget() or getCheckboxesDefinition() instead
-        * @param int &$tabindex Current tabindex
-        * @param array $checked See getCheckboxesDefinition()
-        * @return array
-        */
-       public function getCheckboxes( &$tabindex, $checked ) {
-               wfDeprecated( __METHOD__, '1.30' );
-               $checkboxes = [];
-               $checkboxesDef = $this->getCheckboxesDefinition( $checked );
-
-               // Backwards-compatibility for the EditPageBeforeEditChecks hook
-               if ( !$this->isNew ) {
-                       $checkboxes['minor'] = '';
-               }
-               $checkboxes['watch'] = '';
-
-               foreach ( $checkboxesDef as $name => $options ) {
-                       $legacyName = isset( $options['legacy-name'] ) ? $options['legacy-name'] : $name;
-                       $label = $this->context->msg( $options['label-message'] )->parse();
-                       $attribs = [
-                               'tabindex' => ++$tabindex,
-                               'id' => $options['id'],
-                       ];
-                       $labelAttribs = [
-                               'for' => $options['id'],
-                       ];
-                       if ( isset( $options['tooltip'] ) ) {
-                               $attribs['accesskey'] = $this->context->msg( "accesskey-{$options['tooltip']}" )->text();
-                               $labelAttribs['title'] = Linker::titleAttrib( $options['tooltip'], 'withaccess' );
-                       }
-                       if ( isset( $options['title-message'] ) ) {
-                               $labelAttribs['title'] = $this->context->msg( $options['title-message'] )->text();
-                       }
-                       if ( isset( $options['label-id'] ) ) {
-                               $labelAttribs['id'] = $options['label-id'];
-                       }
-                       $checkboxHtml =
-                               Xml::check( $name, $options['default'], $attribs ) .
-                               '&#160;' .
-                               Xml::tags( 'label', $labelAttribs, $label );
-
-                       $checkboxes[ $legacyName ] = $checkboxHtml;
-               }
-
-               // Avoid PHP 7.1 warning of passing $this by reference
-               $editPage = $this;
-               Hooks::run( 'EditPageBeforeEditChecks', [ &$editPage, &$checkboxes, &$tabindex ], '1.29' );
-               return $checkboxes;
-       }
-
-       /**
-        * Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and
-        * any other added by extensions.
-        *
-        * @deprecated since 1.30 Use getCheckboxesWidget() or getCheckboxesDefinition() instead
-        * @param int &$tabindex Current tabindex
-        * @param array $checked Array of checkbox => bool, where bool indicates the checked
-        *                 status of the checkbox
-        *
-        * @return array Associative array of string keys to OOUI\FieldLayout instances
-        */
-       public function getCheckboxesOOUI( &$tabindex, $checked ) {
-               wfDeprecated( __METHOD__, '1.30' );
-               return $this->getCheckboxesWidget( $tabindex, $checked );
-       }
-
        /**
         * Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and
         * any other added by extensions.