Index: trunk/extensions/CodeReview/ui/SpecialCode.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | } |
9 | 9 | |
10 | 10 | function execute( $subpage ) { |
11 | | - global $wgOut, $wgRequest, $wgUser, $wgExtensionAssetsPath, $wgCodeReviewStyleVersion; |
| 11 | + global $wgOut, $wgUser, $wgExtensionAssetsPath, $wgCodeReviewStyleVersion; |
12 | 12 | |
13 | 13 | if ( !$this->userCanExecute( $wgUser ) ) { |
14 | 14 | $this->displayRestrictionError(); |
— | — | @@ -16,6 +16,30 @@ |
17 | 17 | |
18 | 18 | $this->setHeaders(); |
19 | 19 | $wgOut->addStyle( "$wgExtensionAssetsPath/CodeReview/codereview.css?$wgCodeReviewStyleVersion" ); |
| 20 | + |
| 21 | + if( $view = self::getViewFrom( $subpage ) ) { |
| 22 | + $view->execute(); |
| 23 | + } else { |
| 24 | + $wgOut->addWikiText( wfMsg( 'nosuchactiontext' ) ); |
| 25 | + $wgOut->returnToMain( null, SpecialPage::getTitleFor( 'Code' ) ); |
| 26 | + return; |
| 27 | + } |
| 28 | + |
| 29 | + // Add subtitle for easy navigation |
| 30 | + if ( $view instanceof CodeView && ( $repo = $view->getRepo() ) ) { |
| 31 | + $wgOut->setSubtitle( |
| 32 | + wfMsgExt( 'codereview-subtitle', 'parse', CodeRepoListView::getNavItem( $repo ) ) |
| 33 | + ); |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Get a view object from a sub page path. |
| 39 | + * @return View object or null if no valid action could be found |
| 40 | + */ |
| 41 | + private static function getViewFrom( $subpage ) { |
| 42 | + global $wgRequest; |
| 43 | + |
20 | 44 | # Remove stray slashes |
21 | 45 | $subpage = preg_replace( '/\/$/', '', $subpage ); |
22 | 46 | if ( $subpage == '' ) { |
— | — | @@ -49,10 +73,10 @@ |
50 | 74 | $view = new CodeReleaseNotes( $params[0] ); |
51 | 75 | break; |
52 | 76 | } else if ( $wgRequest->wasPosted() && !$wgRequest->getCheck( 'wpPreview' ) ) { |
| 77 | + # This is not really a view, but we return it nonetheless. |
53 | 78 | # Add any tags, Set status, Adds comments |
54 | | - $submit = new CodeRevisionCommitter( $params[0], $params[1] ); |
55 | | - $submit->execute(); |
56 | | - return; |
| 79 | + $view = new CodeRevisionCommitter( $params[0], $params[1] ); |
| 80 | + break; |
57 | 81 | } else { // revision details |
58 | 82 | $view = new CodeRevisionView( $params[0], $params[1] ); |
59 | 83 | break; |
— | — | @@ -89,27 +113,18 @@ |
90 | 114 | $view = new CodeRevisionView( $params[0], $params[1], $params[3] ); |
91 | 115 | break; |
92 | 116 | } |
93 | | - $wgOut->addWikiText( wfMsg( 'nosuchactiontext' ) ); |
94 | | - $wgOut->returnToMain( null, SpecialPage::getTitleFor( 'Code' ) ); |
95 | | - return; |
| 117 | + return null; |
96 | 118 | } |
97 | 119 | |
98 | 120 | // If a repository was specified, but it does not exist, redirect to the |
99 | 121 | // repository list with an appropriate message. |
100 | 122 | if ( !$view->mRepo ) { |
101 | 123 | $view = new CodeRepoListView(); |
| 124 | + global $wgOut; |
102 | 125 | $wgOut->addWikiMsg( 'code-repo-not-found', wfEscapeWikiText( $params[0] ) ); |
103 | 126 | } |
104 | 127 | } |
105 | | - $view->execute(); |
106 | | - |
107 | | - // Add subtitle for easy navigation |
108 | | - global $wgOut; |
109 | | - if ( $view instanceof CodeView && ( $repo = $view->getRepo() ) ) { |
110 | | - $wgOut->setSubtitle( |
111 | | - wfMsgExt( 'codereview-subtitle', 'parse', CodeRepoListView::getNavItem( $repo ) ) |
112 | | - ); |
113 | | - } |
| 128 | + return $view; |
114 | 129 | } |
115 | 130 | } |
116 | 131 | |