Created
May 12, 2016 17:58
-
-
Save joakin/78bb7f9554e4593b0829c48f8480678f to your computer and use it in GitHub Desktop.
Less branching, no empty returns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* SpecialMobileCite.php | |
*/ | |
/** | |
* Provides a list of citiations available for a page | |
*/ | |
class SpecialMobileCite extends MobileSpecialPage { | |
// ... | |
/** | |
* Render the page with a list of references for the given revision identifier | |
* @param string $pagename The revision number | |
*/ | |
public function executeWhenAvailable( $param ) { | |
$out = $this->getOutput(); | |
$revision = null; | |
if ( $param ) { | |
$args = explode( '/', $param ); | |
if ( ctype_digit( $args[0] ) ) { | |
$revId = intval( $args[0] ); | |
$revision = Revision::newFromId( $revId ); | |
} | |
} | |
if ( $revision ) { | |
$title = $revision->getTitle(); | |
$html = $this->getReferenceBodyHtml( $title, $revId ); | |
$html = MobileUI::contentElement( $html ); | |
$out->setPageTitle( $title->getText() ); | |
$out->addHTML( $html ); | |
} else { | |
$out->setPageTitle( $this->msg( 'mobile-frontend-cite-error-title' ) ); | |
$out->addHTML( MobileUI::errorBox( $this->msg( 'mobile-frontend-cite-error' ) ) ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment