Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -28,10 +28,23 @@ |
29 | 29 | if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
30 | 30 | $out->addWikiMsg( 'ep-course-create', $name ); |
31 | 31 | |
| 32 | + $bracketPos = strpos( $name, '(' ); |
| 33 | + |
| 34 | + if ( $bracketPos !== false ) { |
| 35 | + if ( $bracketPos > 0 && in_array( $name{$bracketPos - 1}, array( ' ', '_' ) ) ) { |
| 36 | + $bracketPos -= 1; |
| 37 | + } |
| 38 | + |
| 39 | + $newName = substr( $name, 0, $bracketPos ); |
| 40 | + } |
| 41 | + |
32 | 42 | EPCourse::displayAddNewRegion( |
33 | 43 | $this->getContext(), |
34 | 44 | array( |
35 | | - 'name' => $this->getRequest()->getText( 'newname', '' ), |
| 45 | + 'name' => $this->getRequest()->getText( |
| 46 | + 'newname', |
| 47 | + $newName |
| 48 | + ), |
36 | 49 | 'term' => $this->getRequest()->getText( 'newterm', '' ), |
37 | 50 | ) |
38 | 51 | ); |
Index: trunk/extensions/EducationProgram/actions/ViewOrgAction.php |
— | — | @@ -25,11 +25,8 @@ |
26 | 26 | $org = EPOrg::get( $name ); |
27 | 27 | |
28 | 28 | if ( $org === false ) { |
29 | | - $this->displayNavigation(); |
30 | | - |
31 | 29 | if ( $this->getUser()->isAllowed( 'ep-org' ) ) { |
32 | | - $out->addWikiMsg( 'ep-institution-create', $name ); |
33 | | - EPOrg::displayAddNewControl( $this->getContext(), array( 'name' => $name ) ); |
| 30 | + $out->redirect( $this->getTitle()->getLocalURL( array( 'action' => 'edit' ) ) ); |
34 | 31 | } |
35 | 32 | else { |
36 | 33 | $out->addWikiMsg( 'ep-institution-none', $name ); |
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php |
— | — | @@ -45,35 +45,20 @@ |
46 | 46 | protected function showContent() { |
47 | 47 | $c = $this->getItemClass(); // Yeah, this is needed in PHP 5.3 >_> |
48 | 48 | |
49 | | - if ( $this->isNew() ) { |
50 | | - $data = $this->getNewData(); |
51 | | - |
52 | | - $object = $c::selectRow( null, $data ); |
53 | | - |
54 | | - if ( $object === false ) { |
55 | | - $object = new $c( $data, true ); |
56 | | - } |
57 | | - else { |
58 | | - $this->showWarning( wfMessage( 'educationprogram-' . strtolower( $this->getName() ) . '-exists-already' ) ); |
59 | | - } |
60 | | - } |
61 | | - else { |
62 | | - $object = $c::selectRow( null, $this->getTitleConditions() ); |
63 | | - } |
64 | | - |
| 49 | + $data = $this->getNewData(); |
| 50 | + |
| 51 | + $object = $c::selectRow( null, $data ); |
| 52 | + |
65 | 53 | if ( $object === false ) { |
66 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( $c::getListPage() )->getLocalURL() ); |
| 54 | + $this->isNew = true; |
| 55 | + $object = new $c( $data, true ); |
67 | 56 | } |
68 | 57 | else { |
69 | | -// if ( !$this->isNew() ) { |
70 | | -// $this->getOutput()->addHTML( |
71 | | -// SpecialContestPage::getNavigation( $contest->getField( 'name' ), $this->getUser(), $this->getLanguage(), $this->getName() ) |
72 | | -// ); |
73 | | -// } |
74 | | - |
75 | | - $this->item = $object; |
76 | | - $this->showForm(); |
| 58 | + $this->showWarning( wfMessage( 'educationprogram-' . strtolower( $this->getName() ) . '-exists-already' ) ); |
77 | 59 | } |
| 60 | + |
| 61 | + $this->item = $object; |
| 62 | + $this->showForm(); |
78 | 63 | } |
79 | 64 | |
80 | 65 | /** |
— | — | @@ -84,15 +69,17 @@ |
85 | 70 | * @return boolean |
86 | 71 | */ |
87 | 72 | protected function isNew() { |
88 | | - static $isNew = null; |
89 | | - |
90 | | - if ( is_null( $isNew ) ) { |
91 | | - $isNew = $this->getRequest()->wasPosted() && |
92 | | - ( $this->getRequest()->getCheck( 'isnew' ) || $this->getRequest()->getCheck( 'wpisnew' ) ); |
| 73 | + if ( is_null( $this->isNew ) ) { |
| 74 | + $isNew = $this->isNewPost(); |
93 | 75 | } |
94 | 76 | |
95 | | - return $isNew; |
| 77 | + return $this->isNew; |
96 | 78 | } |
| 79 | + |
| 80 | + protected function isNewPost() { |
| 81 | + return $this->getRequest()->wasPosted() && |
| 82 | + ( $this->getRequest()->getCheck( 'isnew' ) || $this->getRequest()->getCheck( 'wpisnew' ) ); |
| 83 | + } |
97 | 84 | |
98 | 85 | /** |
99 | 86 | * Show the form. |
— | — | @@ -123,7 +110,16 @@ |
124 | 111 | * @return array |
125 | 112 | */ |
126 | 113 | protected function getNewData() { |
127 | | - return array( 'name' => $this->getRequest()->getVal( 'newname' ) ); |
| 114 | + $data = array(); |
| 115 | + |
| 116 | + if ( $this->isNewPost() ) { |
| 117 | + $data['name'] = $this->getRequest()->getVal( 'newname' ); |
| 118 | + } |
| 119 | + else { |
| 120 | + $data['name'] = $this->getTitle()->getText(); |
| 121 | + } |
| 122 | + |
| 123 | + return $data; |
128 | 124 | } |
129 | 125 | |
130 | 126 | /** |
— | — | @@ -268,13 +264,13 @@ |
269 | 265 | $this->getOutput()->redirect( $this->getReturnToTitle( true )->getLocalURL() ); |
270 | 266 | } |
271 | 267 | |
272 | | - protected function getReturnToTitle( $newToItem = false ) { |
| 268 | + protected function getReturnToTitle( $addedItem = false ) { |
273 | 269 | if ( $this->getRequest()->getCheck( 'wpreturnto' ) ) { |
274 | 270 | return Title::newFromText( $this->getRequest()->getText( 'wpreturnto' ) ); |
275 | 271 | } |
276 | | - elseif ( $newToItem && $this->isNew() ) { |
| 272 | + elseif ( !$addedItem && $this->isNew() ) { |
277 | 273 | $c = $this->getItemClass(); // Yeah, this is needed in PHP 5.3 >_> |
278 | | - return $c::getTitleFor( $this->getRequest()->getText( 'wpitem-' . $c::getIdentifierField() ) ); |
| 274 | + return SpecialPage::getTitleFor( $c::getListPage() ); |
279 | 275 | } |
280 | 276 | else { |
281 | 277 | return $this->getTitle(); |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -251,11 +251,13 @@ |
252 | 252 | $type = $sktemplate->getRequest()->getText( 'action' ); |
253 | 253 | $isSpecial = $sktemplate->getTitle()->isSpecialPage(); |
254 | 254 | |
255 | | - $links['views']['view'] = array( |
256 | | - 'class' => ( !$isSpecial && $type === '' ) ? 'selected' : false, |
257 | | - 'text' => wfMsg( 'ep-tab-view' ), |
258 | | - 'href' => $title->getLocalUrl() |
259 | | - ); |
| 255 | + if ( $type !== 'edit' || $exists ) { |
| 256 | + $links['views']['view'] = array( |
| 257 | + 'class' => ( !$isSpecial && $type === '' ) ? 'selected' : false, |
| 258 | + 'text' => wfMsg( 'ep-tab-view' ), |
| 259 | + 'href' => $title->getLocalUrl() |
| 260 | + ); |
| 261 | + } |
260 | 262 | |
261 | 263 | if ( $user->isAllowed( $class::getEditRight() ) ) { |
262 | 264 | $links['views']['edit'] = array( |