Index: trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php |
— | — | @@ -35,3 +35,8 @@ |
36 | 36 | 'CampusAmbassador' => array( 'CampusAmbassador' ), |
37 | 37 | 'OnlineAmbassador' => array( 'OnlineAmbassador' ), |
38 | 38 | ); |
| 39 | + |
| 40 | +/** Dutch (Nederlands) */ |
| 41 | +$specialPageAliases['nl'] = array( |
| 42 | + 'MyCourses' => array( 'MijnCursusen' ), |
| 43 | +); |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
— | — | @@ -55,16 +55,8 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
59 | | - $links = array(); |
| 59 | + $this->displayNavigation(); |
60 | 60 | |
61 | | - if ( $this->getUser()->isAllowed( 'ep-org' ) ) { |
62 | | - $links[wfMsg( 'ep-institution-nav-edit' )] = |
63 | | - array( SpecialPage::getTitleFor( 'EditInstitution', $this->subPage ) ) |
64 | | - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-institution' ); |
65 | | - } |
66 | | - |
67 | | - $this->displayNavigation( $links ); |
68 | | - |
69 | 61 | $this->displaySummary( $org ); |
70 | 62 | |
71 | 63 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-courses' ) ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - parent::__construct( 'EditInstitution', 'ep-org', 'EPOrg', 'Institutions' ); |
| 23 | + parent::__construct( 'EditInstitution', 'ep-org', 'EPOrg', 'Institutions', 'Institution' ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -55,16 +55,8 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
59 | | - $links = array(); |
| 59 | + $this->displayNavigation(); |
60 | 60 | |
61 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
62 | | - $links[wfMsg( 'ep-course-nav-edit' )] = |
63 | | - array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) ) |
64 | | - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' ); |
65 | | - } |
66 | | - |
67 | | - $this->displayNavigation( $links ); |
68 | | - |
69 | 61 | $this->displaySummary( $course ); |
70 | 62 | |
71 | 63 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - parent::__construct( 'EditCourse', 'ep-course', 'EPCourse', 'Courses' ); |
| 23 | + parent::__construct( 'EditCourse', 'ep-course', 'EPCourse', 'Courses', 'Course' ); |
24 | 24 | |
25 | 25 | $this->getOutput()->addModules( 'ep.datepicker' ); |
26 | 26 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php |
— | — | @@ -55,16 +55,8 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
59 | | - $links = array(); |
| 59 | + $this->displayNavigation(); |
60 | 60 | |
61 | | - if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
62 | | - $links[wfMsg( 'ep-mc-nav-edit' )] = |
63 | | - array( SpecialPage::getTitleFor( 'EditMasterCourse', $this->subPage ) ) |
64 | | - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-mc' ); |
65 | | - } |
66 | | - |
67 | | - $this->displayNavigation( $links ); |
68 | | - |
69 | 61 | $this->displaySummary( $masterCourse ); |
70 | 62 | |
71 | 63 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-description' ) ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEditMasterCourse.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - parent::__construct( 'EditMasterCourse', 'ep-mc', 'EPMC', 'MasterCourses' ); |
| 23 | + parent::__construct( 'EditMasterCourse', 'ep-mc', 'EPMC', 'MasterCourses', 'MasterCourse' ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php |
— | — | @@ -39,6 +39,15 @@ |
40 | 40 | protected $listPage; |
41 | 41 | |
42 | 42 | /** |
| 43 | + * Name of the special page displaying individual items. |
| 44 | + * For example, for "EditLolcat", it could be "Lolcat". |
| 45 | + * |
| 46 | + * @since 0.1 |
| 47 | + * @var string |
| 48 | + */ |
| 49 | + protected $itemPage; |
| 50 | + |
| 51 | + /** |
43 | 52 | * Constructor. |
44 | 53 | * |
45 | 54 | * @since 0.1 |
— | — | @@ -47,10 +56,12 @@ |
48 | 57 | * @param string $right Right needed to access the page |
49 | 58 | * @param string $itemClass Name of the item class |
50 | 59 | * @param string $listPage Name of the page listing the items |
| 60 | + * @param string $itemPage Name of the page displaying individual items |
51 | 61 | */ |
52 | | - public function __construct( $name, $right, $itemClass, $listPage ) { |
| 62 | + public function __construct( $name, $right, $itemClass, $listPage, $itemPage ) { |
53 | 63 | $this->itemClass = $itemClass; |
54 | 64 | $this->listPage = $listPage; |
| 65 | + $this->itemPage = $itemPage; |
55 | 66 | |
56 | 67 | parent::__construct( $name, $right, false ); |
57 | 68 | |
— | — | @@ -210,10 +221,17 @@ |
211 | 222 | if ( $this->isNew() ) { |
212 | 223 | $fields['isnew'] = array( |
213 | 224 | 'type' => 'hidden', |
214 | | - 'default' => 1 |
| 225 | + 'default' => 1, |
215 | 226 | ); |
216 | 227 | } |
217 | 228 | |
| 229 | + if ( $this->getRequest()->getCheck( 'wpreturnto' ) ) { |
| 230 | + $fields['returnto'] = array( |
| 231 | + 'type' => 'hidden', |
| 232 | + 'default' => $this->getRequest()->getText( 'wpreturnto' ), |
| 233 | + ); |
| 234 | + } |
| 235 | + |
218 | 236 | $form = new HTMLForm( $fields, $this->getContext() ); |
219 | 237 | |
220 | 238 | $form->setSubmitCallback( array( $this, 'handleSubmission' ) ); |
— | — | @@ -318,7 +336,15 @@ |
319 | 337 | * @since 0.1 |
320 | 338 | */ |
321 | 339 | public function onSuccess() { |
322 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->listPage )->getLocalURL() ); |
| 340 | + if ( $this->getRequest()->getCheck( 'wpreturnto' ) ) { |
| 341 | + $parts = explode( '/', $this->getRequest()->getText( 'wpreturnto' ), 2 ); |
| 342 | + $title = SpecialPage::getTitleFor( $parts[0], count( $parts ) === 2 ? $parts[1] : false )->getLocalURL(); |
| 343 | + } |
| 344 | + else { |
| 345 | + $title = SpecialPage::getTitleFor( $this->itemPage )->getLocalURL(); |
| 346 | + } |
| 347 | + |
| 348 | + $this->getOutput()->redirect( $title ); |
323 | 349 | } |
324 | 350 | |
325 | 351 | /** |
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -152,7 +152,9 @@ |
153 | 153 | if ( $this->getUser()->isAllowed( 'ep-org' ) ) { |
154 | 154 | $links[] = $value = Linker::linkKnown( |
155 | 155 | SpecialPage::getTitleFor( 'EditInstitution', $item->getField( 'name' ) ), |
156 | | - wfMsgHtml( 'edit' ) |
| 156 | + wfMsgHtml( 'edit' ), |
| 157 | + array(), |
| 158 | + array( 'wpreturnto' => $this->getTitle()->getText() ) |
157 | 159 | ); |
158 | 160 | |
159 | 161 | $links[] = $this->getDeletionLink( 'org', $item->getId() ); |
Index: trunk/extensions/EducationProgram/includes/EPMCPager.php |
— | — | @@ -142,7 +142,9 @@ |
143 | 143 | if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
144 | 144 | $links[] = $value = Linker::linkKnown( |
145 | 145 | SpecialPage::getTitleFor( 'EditMasterCourse', $item->getField( 'name' ) ), |
146 | | - wfMsgHtml( 'edit' ) |
| 146 | + wfMsgHtml( 'edit' ), |
| 147 | + array(), |
| 148 | + array( 'wpreturnto' => $this->getTitle()->getText() ) |
147 | 149 | ); |
148 | 150 | |
149 | 151 | $links[] = $this->getDeletionLink( 'course', $item->getId() ); |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -187,7 +187,9 @@ |
188 | 188 | if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
189 | 189 | $links[] = $value = Linker::linkKnown( |
190 | 190 | SpecialPage::getTitleFor( 'EditCourse', $item->getId() ), |
191 | | - wfMsgHtml( 'edit' ) |
| 191 | + wfMsgHtml( 'edit' ), |
| 192 | + array(), |
| 193 | + array( 'wpreturnto' => $this->getTitle()->getText() ) |
192 | 194 | ); |
193 | 195 | |
194 | 196 | $links[] = $this->getDeletionLink( 'course', $item->getId() ); |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -153,16 +153,75 @@ |
154 | 154 | |
155 | 155 | $title = $sktemplate->getTitle(); |
156 | 156 | |
157 | | - switch ( $title->getBaseText() ) { |
158 | | - case 'Institution': case 'EditInstitution': |
159 | | - $editTitle = SpecialPage::getTitleFor( 'EditInstitution', $title->getSubpageText() ); |
| 157 | + // The Title getBaseText and getSubpageText methods only do what we want when |
| 158 | + // the special pages NS is in teh list of NS with subpages. |
| 159 | + $textParts = SpecialPageFactory::resolveAlias( $sktemplate->getTitle()->getText() ); |
| 160 | + $baseText = $textParts[0]; |
| 161 | + |
| 162 | + $specials = array( |
| 163 | + array( |
| 164 | + 'view' => 'Institution', |
| 165 | + 'edit' => 'EditInstitution', |
| 166 | + //'history' => 'InstitutionHistory', |
| 167 | + ), |
| 168 | + array( |
| 169 | + 'view' => 'MasterCourse', |
| 170 | + 'edit' => 'EditMasterCourse', |
| 171 | + //'history' => 'MasterCourseHistory', |
| 172 | + ), |
| 173 | + array( |
| 174 | + 'view' => 'Course', |
| 175 | + 'edit' => 'EditCourse', |
| 176 | + //'history' => 'CourseHistory', |
| 177 | + ), |
| 178 | + ); |
| 179 | + |
| 180 | + $editRights = array( |
| 181 | + 'EditInstitution' => 'ep-org', |
| 182 | + 'EditMasterCourse' => 'ep-mc', |
| 183 | + 'EditCourse' => 'ep-course', |
| 184 | + ); |
| 185 | + |
| 186 | + $specialSet = false; |
| 187 | + $type = false; |
| 188 | + |
| 189 | + foreach ( $specials as $set ) { |
| 190 | + if ( in_array( $baseText, $set ) ) { |
| 191 | + $specialSet = $set; |
| 192 | + $flipped = array_flip( $set ); |
| 193 | + $type = $flipped[$baseText]; |
| 194 | + break; |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + // TODO: messages |
| 199 | + if ( $specialSet !== false ) { |
| 200 | + $editRight = $editRights[$specialSet['edit']]; |
| 201 | + |
| 202 | + foreach ( $specialSet as &$special ) { |
| 203 | + $special = SpecialPageFactory::getLocalNameFor( $special ); |
| 204 | + } |
| 205 | + |
| 206 | + $viewLinks['view'] = array( |
| 207 | + 'class' => $type === 'view' ? 'selected' : false, |
| 208 | + 'text' => wfMsg( 'vector-view-view' ), |
| 209 | + 'href' => SpecialPage::getTitleFor( $specialSet['view'], $textParts[1] )->getLocalUrl() |
| 210 | + ); |
| 211 | + |
| 212 | + if ( $sktemplate->getUser()->isAllowed( $editRight ) ) { |
160 | 213 | $viewLinks['edit'] = array( |
161 | | - 'class' => $title->getBaseText() == 'EditInstitution' ? 'selected' : false, |
162 | | - 'text' => wfMsg( 'edit' ), |
163 | | - 'href' => $editTitle->getLocalUrl() |
| 214 | + 'class' => $type === 'edit' ? 'selected' : false, |
| 215 | + 'text' => wfMsg( 'vector-view-edit' ), |
| 216 | + 'href' => SpecialPage::getTitleFor( $specialSet['edit'], $textParts[1] )->getLocalUrl() |
164 | 217 | ); |
165 | | - break; |
166 | | - // TODO: test & add other links |
| 218 | + } |
| 219 | + |
| 220 | + $viewLinks['history'] = array( |
| 221 | + 'class' => $type === 'history' ? 'selected' : false, |
| 222 | + 'text' => wfMsg( 'vector-view-history' ), |
| 223 | + 'href' => '' // TODO |
| 224 | + //SpecialPage::getTitleFor( $specialSet['history'], $textParts[1] )->getLocalUrl() |
| 225 | + ); |
167 | 226 | } |
168 | 227 | |
169 | 228 | $links['views'] = $viewLinks; |