From: Sam Reed Date: Sun, 1 May 2011 21:28:00 +0000 (+0000) Subject: Refactor out common code X-Git-Tag: 1.31.0-rc.0~30473 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=f8fb526ea618af41a31cec93b02f2b84cc0be5bd;p=lhc%2Fweb%2Fwiklou.git Refactor out common code --- diff --git a/includes/specials/SpecialComparePages.php b/includes/specials/SpecialComparePages.php index fe5d8db78e..6b9ef0a958 100644 --- a/includes/specials/SpecialComparePages.php +++ b/includes/specials/SpecialComparePages.php @@ -100,28 +100,8 @@ class SpecialComparePages extends SpecialPage { } public static function showDiff( $data ){ - - if( $data['Revision1'] ){ - $rev1 = $data['Revision1']; - } elseif( $data['Page1'] ) { - $title = Title::newFromText( $data['Page1'] ); - if( $title instanceof Title ){ - $rev1 = $title->getLatestRevID(); - } - } else { - $rev1 = null; - } - - if( $data['Revision2'] ){ - $rev2 = $data['Revision2']; - } elseif( $data['Page2'] ) { - $title = Title::newFromText( $data['Page2'] ); - if( $title instanceof Title ){ - $rev2 = $title->getLatestRevID(); - } - } else { - $rev2 = null; - } + $rev1 = self::revOrTitle( $data['Revision1'], $data['Page1'] ); + $rev2 = self::revOrTitle( $data['Revision2'], $data['Page2'] ); if( $rev1 && $rev2 ) { $de = new DifferenceEngine( null, @@ -133,4 +113,16 @@ class SpecialComparePages extends SpecialPage { $de->showDiffPage( true ); } } + + public static function revOrTitle( $revision, $title ) { + if( $revision ){ + return $revision; + } elseif( $title ) { + $title = Title::newFromText( $title ); + if( $title instanceof Title ){ + return $title->getLatestRevID(); + } + } + return null; + } }