X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Feditpage%2FTextboxBuilder.php;h=81dc78d6d0db94c4245e5cb8b50605ef72ec23dc;hb=f6de67738dcc8b25c1343e2b1cb244641f8ede91;hp=a6ae9bcb4989f944dac8f5d786b0ad06aa35cebd;hpb=fbb86f07d222ba6c31386472c5b792348b1c89e2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/editpage/TextboxBuilder.php b/includes/editpage/TextboxBuilder.php index a6ae9bcb49..81dc78d6d0 100644 --- a/includes/editpage/TextboxBuilder.php +++ b/includes/editpage/TextboxBuilder.php @@ -24,6 +24,8 @@ namespace MediaWiki\EditPage; +use MWNamespace; +use Sanitizer; use Title; use User; @@ -50,6 +52,47 @@ class TextboxBuilder { return $wikitext; } + /** + * @param string[] $classes + * @param mixed[] $attribs + * @return mixed[] + */ + public function mergeClassesIntoAttributes( array $classes, array $attribs ) { + if ( !count( $classes ) ) { + return $attribs; + } + + return Sanitizer::mergeAttributes( + $attribs, + [ 'class' => implode( ' ', $classes ) ] + ); + } + + /** + * @param Title $title + * @return string[] + */ + public function getTextboxProtectionCSSClasses( Title $title ) { + $classes = []; // Textarea CSS + if ( $title->isProtected( 'edit' ) && + MWNamespace::getRestrictionLevels( $title->getNamespace() ) !== [ '' ] + ) { + # Is the title semi-protected? + if ( $title->isSemiProtected() ) { + $classes[] = 'mw-textarea-sprotected'; + } else { + # Then it must be protected based on static groups (regular) + $classes[] = 'mw-textarea-protected'; + } + # Is the title cascade-protected? + if ( $title->isCascadeProtected() ) { + $classes[] = 'mw-textarea-cprotected'; + } + } + + return $classes; + } + /** * @param string $name * @param mixed[] $customAttribs