Skip to content

Instantly share code, notes, and snippets.

@joakin
Created May 12, 2016 17:58
Show Gist options
  • Save joakin/78bb7f9554e4593b0829c48f8480678f to your computer and use it in GitHub Desktop.
Save joakin/78bb7f9554e4593b0829c48f8480678f to your computer and use it in GitHub Desktop.
Less branching, no empty returns
<?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