From d1eef046af23a6d02182ff547026e05e2f314e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Sat, 11 Oct 2014 16:13:04 +0200 Subject: [PATCH] Cleanup MathMathML.php after the PNG fallback removal. - Remove the special handling for the PNG fallback in getFallbackImageUrl, getFallbackImage and getClassName. - Make these functions private and remove useless parameters. Bug: 71912 Change-Id: I569f2dd3d32a0c9690a5d9674a1c6ae0b8698f08 --- MathMathML.php | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/MathMathML.php b/MathMathML.php index d1554c2..08b7bf2 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -326,14 +326,13 @@ class MathMathML extends MathRenderer { } /** - * @param int $mode * @param boolean $noRender * @return type */ - private function getFallbackImageUrl( $mode = MW_MATH_MATHML, $noRender = false ) { + private function getFallbackImageUrl( $noRender = false ) { return SpecialPage::getTitleFor( 'MathShowImage' )->getLocalURL( array( 'hash' => $this->getMd5(), - 'mode' => $mode, + 'mode' => $this->getMode(), 'noRender' => $noRender ) ); } @@ -366,30 +365,22 @@ class MathMathML extends MathRenderer { /** * Gets img tag for math image - * @param int $mode if MW_MATH_PNG a png is used instead of an svg image * @param boolean $noRender if true no rendering will be performed if the image is not stored in the database * @param boolean|string $classOverride if classOverride is false the class name will be calculated by getClassName * @return string XML the image html tag */ - public function getFallbackImage( $mode = MW_MATH_MATHML, $noRender = false, $classOverride = false ) { - $url = $this->getFallbackImageUrl( $mode , $noRender ); - if ( $mode == MW_MATH_PNG ) { - $png = true; - } else { - $png = false; - } + private function getFallbackImage( $noRender = false, $classOverride = false ) { + $url = $this->getFallbackImageUrl( $noRender ); $attribs = array(); if ( $classOverride === false ) { // $class = '' suppresses class attribute - $class = $this->getClassName( true, $png ); + $class = $this->getClassName( true ); } else { $class = $classOverride; } $style = ''; - if ( !$png ) { - $this->correctSvgStyle( $this->getSvg(), $style ); - } + $this->correctSvgStyle( $this->getSvg(), $style ); if ( $class ) { $attribs['class'] = $class; } if ( $style ) { $attribs['style'] = $style; } // an alternative for svg might be an object with type="image/svg+xml" @@ -403,18 +394,12 @@ class MathMathML extends MathRenderer { /** * Calculates the default class name for a math element * @param boolean $fallback - * @param boolean $png * @return string the class name */ - protected function getClassName( $fallback = false, $png = false ) { + private function getClassName( $fallback = false ) { $class = "mwe-math-"; if ( $fallback ) { - $class .= 'fallback-'; - if ( $png ) { - $class .= 'png-'; - } else { - $class .= 'svg-'; - } + $class .= 'fallback-svg-'; } else { $class .= 'mathml-'; } @@ -450,7 +435,7 @@ class MathMathML extends MathRenderer { $mml = preg_replace( '/ $this->getClassName(), 'style' => 'display: none;' ), $mml ); - $output .= $this->getFallbackImage( $this->getMode() ) . "\n"; + $output .= $this->getFallbackImage( ) . "\n"; $output .= HTML::closeElement( $element ); return $output; }