Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -38,6 +38,13 @@ |
39 | 39 | 'special-contestwelcome' => 'Contest', |
40 | 40 | 'special-editcontest' => 'Edit contest', |
41 | 41 | |
| 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 | + |
42 | 49 | // Special:Contests |
43 | 50 | 'contest-special-addnew' => 'Add a new contest', |
44 | 51 | '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 @@ |
15 | 15 | */ |
16 | 16 | abstract class SpecialContestPage extends SpecialPage { |
17 | 17 | |
| 18 | + protected $subPage; |
| 19 | + |
18 | 20 | /** |
19 | 21 | * @see SpecialPage::getDescription |
20 | 22 | * |
— | — | @@ -43,6 +45,8 @@ |
44 | 46 | * @param string $arg |
45 | 47 | */ |
46 | 48 | public function execute( $subPage ) { |
| 49 | + $this->subPage = $subPage; |
| 50 | + |
47 | 51 | $this->setHeaders(); |
48 | 52 | $this->outputHeader(); |
49 | 53 | |
— | — | @@ -82,13 +86,72 @@ |
83 | 87 | } |
84 | 88 | |
85 | 89 | /** |
| 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 | + /** |
86 | 145 | * Display navigation links. |
87 | 146 | * |
88 | 147 | * @since 0.1 |
89 | 148 | * |
90 | 149 | * @param array $links |
91 | 150 | */ |
92 | | - protected function displayNavigation( array $links ) { |
| 151 | + protected function displayNavigation( array $links = null ) { |
| 152 | + if ( is_null( $links ) ) { |
| 153 | + $links = $this->getNavigationLinks(); |
| 154 | + } |
| 155 | + |
93 | 156 | $this->getOutput()->addHTML( Html::rawElement( 'p', array(), $this->getLang()->pipeList( $links ) ) ); |
94 | 157 | } |
95 | 158 | |
Index: trunk/extensions/Contest/specials/SpecialContest.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | } |
45 | 45 | else { |
46 | 46 | $out->setPageTitle( wfMsgExt( 'contest-contest-title', 'parseinline', $contest->getField( 'name' ) ) ); |
| 47 | + $this->displayNavigation(); |
47 | 48 | $this->showGeneralInfo( $contest ); |
48 | 49 | $this->showContestants( $contest ); |
49 | 50 | } |