X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=a1d9ae82d5816b094adffa1f9123387cb572d5b3;hb=a9c02b13f646762e6d43ce8ff6fdeed07ae14ce6;hp=f9c7fb29e8d8459ee3bf5f5407da820033d6c3d7;hpb=e46d0694ac253df5f91fcfcd65ff19b0b3a2982c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index f9c7fb29e8..a1d9ae82d5 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -238,30 +238,6 @@ class EditPage { /** @var bool */ public $isConflict = false; - /** - * @deprecated since 1.30 use Title::isCssJsSubpage() - * @var bool - */ - public $isCssJsSubpage = false; - - /** - * @deprecated since 1.30 use Title::isCssSubpage() - * @var bool - */ - public $isCssSubpage = false; - - /** - * @deprecated since 1.30 use Title::isJsSubpage() - * @var bool - */ - public $isJsSubpage = false; - - /** - * @deprecated since 1.30 - * @var bool - */ - public $isWrongCaseCssJsPage = false; - /** @var bool New page or new section */ public $isNew = false; @@ -660,13 +636,6 @@ class EditPage { } $this->isConflict = false; - // css / js subpages of user pages get a special treatment - // The following member variables are deprecated since 1.30, - // the functions should be used instead. - $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); - $this->isCssSubpage = $this->mTitle->isCssSubpage(); - $this->isJsSubpage = $this->mTitle->isJsSubpage(); - $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage(); # Show applicable editing introductions if ( $this->formtype == 'initial' || $this->firsttime ) { @@ -877,9 +846,9 @@ class EditPage { * * @return bool */ - protected function isWrongCaseCssJsPage() { - if ( $this->mTitle->isCssJsSubpage() ) { - $name = $this->mTitle->getSkinFromCssJsSubpage(); + protected function isWrongCaseUserConfigPage() { + if ( $this->mTitle->isUserConfigPage() ) { + $name = $this->mTitle->getSkinFromConfigSubpage(); $skins = array_merge( array_keys( Skin::getSkinNames() ), [ 'common' ] @@ -1737,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 @@ -2504,9 +2473,11 @@ ERROR; if ( $namespace == NS_MEDIAWIKI ) { # Show a warning if editing an interface message $out->wrapWikiMsg( "
\n$1\n
", '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(); @@ -2879,7 +2850,7 @@ ERROR; $out->addHTML( $editConflictHelper->getEditFormHtmlBeforeContent() ); } - if ( !$this->mTitle->isCssJsSubpage() && $showToolbar && $user->getOption( 'showtoolbar' ) ) { + if ( !$this->mTitle->isUserConfigPage() && $showToolbar && $user->getOption( 'showtoolbar' ) ) { $out->addHTML( self::getEditToolbar( $this->mTitle ) ); } @@ -3116,29 +3087,38 @@ ERROR; ); } } else { - if ( $this->mTitle->isCssJsSubpage() ) { + if ( $this->mTitle->isUserConfigPage() ) { # Check the skin exists - if ( $this->isWrongCaseCssJsPage() ) { + if ( $this->isWrongCaseUserConfigPage() ) { $out->wrapWikiMsg( - "
\n$1\n
", - [ 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ] + "
\n$1\n
", + [ 'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ] ); } if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) { - $isCssSubpage = $this->mTitle->isCssSubpage(); - $out->wrapWikiMsg( '
$1
', - $isCssSubpage ? 'usercssispublic' : 'userjsispublic' - ); + $isUserCssConfig = $this->mTitle->isUserCssConfigPage(); + $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage(); + $isUserJsConfig = $this->mTitle->isUserJsConfigPage(); + + $warning = $isUserCssConfig + ? 'usercssispublic' + : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' ); + + $out->wrapWikiMsg( '
$1
', $warning ); + if ( $this->formtype !== 'preview' ) { $config = $this->context->getConfig(); - if ( $isCssSubpage && $config->get( 'AllowUserCss' ) ) { + if ( $isUserCssConfig && $config->get( 'AllowUserCss' ) ) { $out->wrapWikiMsg( "
\n$1\n
", [ 'usercssyoucanpreview' ] ); - } - - if ( $this->mTitle->isJsSubpage() && $config->get( 'AllowUserJs' ) ) { + } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) { + $out->wrapWikiMsg( + "
\n$1\n
", + [ 'userjsonyoucanpreview' ] + ); + } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) { $out->wrapWikiMsg( "
\n$1\n
", [ 'userjsyoucanpreview' ] @@ -3165,73 +3145,21 @@ ERROR; * @return array */ private function getSummaryInputAttributes( array $inputAttrs = null ) { - // Note: the maxlength is overridden in JS to 255 and to make it use UTF-8 bytes, not characters. + $conf = $this->context->getConfig(); + $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD; + // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP + // (e.g. emojis) count for two each. This limit is overridden in JS to instead count + // Unicode codepoints (or 255 UTF-8 bytes for old schema). return ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [ 'id' => 'wpSummary', 'name' => 'wpSummary', - 'maxlength' => '200', + 'maxlength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT, 'tabindex' => 1, 'size' => 60, 'spellcheck' => 'true', ]; } - /** - * 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. * @@ -3702,7 +3630,7 @@ ERROR; $out->addHTML( $this->editFormTextAfterWarn ); $out->addHTML( "
\n" ); - $out->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" ); + $out->addHTML( implode( "\n", $this->getEditButtons( $tabindex ) ) . "\n" ); $cancel = $this->getCancelLink(); @@ -3812,30 +3740,30 @@ ERROR; protected function getLastDelete() { $dbr = wfGetDB( DB_REPLICA ); $commentQuery = CommentStore::getStore()->getJoin( 'log_comment' ); + $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' ); $data = $dbr->selectRow( - [ 'logging', 'user' ] + $commentQuery['tables'], + array_merge( [ 'logging' ], $commentQuery['tables'], $actorQuery['tables'], [ 'user' ] ), [ 'log_type', 'log_action', 'log_timestamp', - 'log_user', 'log_namespace', 'log_title', 'log_params', 'log_deleted', 'user_name' - ] + $commentQuery['fields'], [ + ] + $commentQuery['fields'] + $actorQuery['fields'], + [ 'log_namespace' => $this->mTitle->getNamespace(), 'log_title' => $this->mTitle->getDBkey(), 'log_type' => 'delete', 'log_action' => 'delete', - 'user_id=log_user' ], __METHOD__, [ 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ], [ - 'user' => [ 'JOIN', 'user_id=log_user' ], - ] + $commentQuery['joins'] + 'user' => [ 'JOIN', 'user_id=' . $actorQuery['fields']['log_user'] ], + ] + $commentQuery['joins'] + $actorQuery['joins'] ); // Quick paranoid permission checks... if ( is_object( $data ) ) { @@ -3913,10 +3841,10 @@ ERROR; } # don't parse non-wikitext pages, show message about preview - if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) { - if ( $this->mTitle->isCssJsSubpage() ) { + if ( $this->mTitle->isUserConfigPage() || $this->mTitle->isSiteConfigPage() ) { + if ( $this->mTitle->isUserConfigPage() ) { $level = 'user'; - } elseif ( $this->mTitle->isCssOrJsPage() ) { + } elseif ( $this->mTitle->isSiteConfigPage() ) { $level = 'site'; } else { $level = false; @@ -3927,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' ) ) { @@ -3937,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 = "
" . $this->context->msg( "{$level}{$format}preview" )->text() . @@ -4248,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 ) . - ' ' . - 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.