r98363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98362‎ | r98363 | r98364 >
Date:20:18, 28 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added nav stuff
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContest.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -38,6 +38,13 @@
3939 'special-contestwelcome' => 'Contest',
4040 'special-editcontest' => 'Edit contest',
4141
 42+ // Navigatio links
 43+ 'contest-nav-contests' => 'Contests list',
 44+ 'contest-nav-editcontest' => 'Edit contest',
 45+ 'contest-nav-contest' => 'Summary and participants',
 46+ 'contest-nav-contestwelcome' => 'Landing page',
 47+ 'contest-nav-contestsignup' => 'Signup page',
 48+
4249 // Special:Contests
4350 'contest-special-addnew' => 'Add a new contest',
4451 'contest-special-namedoc' => 'The name of the contest is the identifier used in URLs. ie "name" in Special:Contest/name',
Index: trunk/extensions/Contest/specials/SpecialContestPage.php
@@ -14,6 +14,8 @@
1515 */
1616 abstract class SpecialContestPage extends SpecialPage {
1717
 18+ protected $subPage;
 19+
1820 /**
1921 * @see SpecialPage::getDescription
2022 *
@@ -43,6 +45,8 @@
4446 * @param string $arg
4547 */
4648 public function execute( $subPage ) {
 49+ $this->subPage = $subPage;
 50+
4751 $this->setHeaders();
4852 $this->outputHeader();
4953
@@ -82,13 +86,72 @@
8387 }
8488
8589 /**
 90+ * Get an array of navigation links.
 91+ *
 92+ * @param boolean $excludeSelf
 93+ * @param string|null $contestName
 94+ *
 95+ * @since 0.1
 96+ *
 97+ * @return array
 98+ */
 99+ protected function getNavigationLinks( $excludeSelf = true, $contestName = null ) {
 100+ if ( is_null( $contestName ) ) {
 101+ $contestName = $this->subPage;
 102+ }
 103+
 104+ $pages = array();
 105+
 106+ $pages['contest-nav-contests'] = array( 'Contests' );
 107+
 108+ if ( $this->getUser()->isAllowed( 'contestjudge' ) ) {
 109+ $pages['contest-nav-contest'] = array( 'Contest', $contestName );
 110+ }
 111+
 112+ if ( $this->getUser()->isAllowed( 'contestadmin' ) ) {
 113+ $pages['contest-nav-editcontest'] = array( 'EditContest', $contestName );
 114+ }
 115+
 116+ $pages['contest-nav-contestwelcome'] = array( 'ContestWelcome', $contestName );
 117+
 118+ if ( $this->getUser()->isAllowed( 'contestparticipant' ) ) {
 119+ $pages['contest-nav-contestsignup'] = array( 'ContestSignup', $contestName );
 120+ }
 121+
 122+ $links = array();
 123+
 124+ // Yeah, array map would be nice... if only we could use anon functions :/
 125+ foreach ( $pages as $message => $page ) {
 126+ $page = (array)$page;
 127+
 128+ if ( $excludeSelf && $page[0] == $this->getName() ) {
 129+ continue;
 130+ }
 131+
 132+ $subPage = count( $page ) > 1 ? $page[1] : false;
 133+
 134+ $links[] = Html::element(
 135+ 'a',
 136+ array( 'href' => SpecialPage::getTitleFor( $page[0], $subPage )->getLocalURL() ),
 137+ wfMsgExt( $message, 'parseinline', $subPage )
 138+ );
 139+ }
 140+
 141+ return $links;
 142+ }
 143+
 144+ /**
86145 * Display navigation links.
87146 *
88147 * @since 0.1
89148 *
90149 * @param array $links
91150 */
92 - protected function displayNavigation( array $links ) {
 151+ protected function displayNavigation( array $links = null ) {
 152+ if ( is_null( $links ) ) {
 153+ $links = $this->getNavigationLinks();
 154+ }
 155+
93156 $this->getOutput()->addHTML( Html::rawElement( 'p', array(), $this->getLang()->pipeList( $links ) ) );
94157 }
95158
Index: trunk/extensions/Contest/specials/SpecialContest.php
@@ -43,6 +43,7 @@
4444 }
4545 else {
4646 $out->setPageTitle( wfMsgExt( 'contest-contest-title', 'parseinline', $contest->getField( 'name' ) ) );
 47+ $this->displayNavigation();
4748 $this->showGeneralInfo( $contest );
4849 $this->showContestants( $contest );
4950 }

Status & tagging log