X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontent%2FTextContent.php;h=750b958eab2a5e30c943ed6924dd9d5f8be2d795;hb=1dfd59a4e3d4f9c20bbe584bd1ad7a622c22f823;hp=c0582962b5fdf4bc251f3aafd49ce56a2ebb5aa2;hpb=ac2665d4d12eda2ec1638a96763d7f34112a25ab;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index c0582962b5..750b958eab 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -25,6 +25,8 @@ * @author Daniel Kinzler */ +use MediaWiki\MediaWikiServices; + /** * Content object implementation for representing flat text. * @@ -71,13 +73,10 @@ class TextContent extends AbstractContent { } public function getTextForSummary( $maxlength = 250 ) { - global $wgContLang; - - $text = $this->getNativeData(); + $text = $this->getText(); - $truncatedtext = $wgContLang->truncateForDatabase( - preg_replace( "/[\n\r]/", ' ', $text ), - max( 0, $maxlength ) ); + $truncatedtext = MediaWikiServices::getInstance()->getContentLanguage()-> + truncateForDatabase( preg_replace( "/[\n\r]/", ' ', $text ), max( 0, $maxlength ) ); return $truncatedtext; } @@ -88,7 +87,7 @@ class TextContent extends AbstractContent { * @return int */ public function getSize() { - $text = $this->getNativeData(); + $text = $this->getText(); return strlen( $text ); } @@ -119,9 +118,22 @@ class TextContent extends AbstractContent { /** * Returns the text represented by this Content object, as a string. * - * @return string The raw text. + * @deprecated since 1.33 use getText() instead. + * + * @return string The raw text. Subclasses may guarantee a specific syntax here. */ public function getNativeData() { + return $this->getText(); + } + + /** + * Returns the text represented by this Content object, as a string. + * + * @since 1.33 + * + * @return string The raw text. + */ + public function getText() { return $this->mText; } @@ -131,7 +143,7 @@ class TextContent extends AbstractContent { * @return string The raw text. */ public function getTextForSearchIndex() { - return $this->getNativeData(); + return $this->getText(); } /** @@ -146,7 +158,7 @@ class TextContent extends AbstractContent { $wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' ); if ( $wikitext ) { - return $wikitext->getNativeData(); + return $wikitext->getText(); } else { return false; } @@ -182,7 +194,7 @@ class TextContent extends AbstractContent { * @return Content */ public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { - $text = $this->getNativeData(); + $text = $this->getText(); $pst = self::normalizeLineEndings( $text ); return ( $text === $pst ) ? $this : new static( $pst, $this->getModel() ); @@ -195,24 +207,22 @@ class TextContent extends AbstractContent { * * @param Content $that The other content object to compare this content object to. * @param Language|null $lang The language object to use for text segmentation. - * If not given, $wgContentLang is used. + * If not given, the content language is used. * * @return Diff A diff representing the changes that would have to be * made to this content object to make it equal to $that. */ public function diff( Content $that, Language $lang = null ) { - global $wgContLang; - $this->checkModelID( $that->getModel() ); // @todo could implement this in DifferenceEngine and just delegate here? if ( !$lang ) { - $lang = $wgContLang; + $lang = MediaWikiServices::getInstance()->getContentLanguage(); } - $otext = $this->getNativeData(); - $ntext = $that->getNativeData(); + $otext = $this->getText(); + $ntext = $that->getText(); # Note: Use native PHP diff, external engines don't give us abstract output $ota = explode( "\n", $lang->segmentForDiff( $otext ) ); @@ -247,7 +257,7 @@ class TextContent extends AbstractContent { if ( in_array( $this->getModel(), $wgTextModelsToParse ) ) { // parse just to get links etc into the database, HTML is replaced below. - $output = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId ); + $output = $wgParser->parse( $this->getText(), $title, $options, true, true, $revId ); } if ( $generateHtml ) { @@ -256,6 +266,7 @@ class TextContent extends AbstractContent { $html = ''; } + $output->clearWrapperDivClass(); $output->setText( $html ); } @@ -293,7 +304,7 @@ class TextContent extends AbstractContent { * @return string An HTML representation of the content */ protected function getHighlightHtml() { - return htmlspecialchars( $this->getNativeData() ); + return htmlspecialchars( $this->getText() ); } /** @@ -320,7 +331,7 @@ class TextContent extends AbstractContent { if ( $toHandler instanceof TextContentHandler ) { // NOTE: ignore content serialization format - it's just text anyway. - $text = $this->getNativeData(); + $text = $this->getText(); $converted = $toHandler->unserializeContent( $text ); }