Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | ); |
34 | 34 | |
35 | 35 | public function __construct() { |
36 | | - SpecialPage::SpecialPage( "Book" ); |
| 36 | + parent::__construct( "Book" ); |
37 | 37 | } |
38 | 38 | |
39 | 39 | function getDescription() { |
— | — | @@ -48,161 +48,165 @@ |
49 | 49 | |
50 | 50 | wfLoadExtensionMessages( 'Collection' ); |
51 | 51 | |
52 | | - if ( $par == 'add_article/' ) { |
53 | | - if ( self::countArticles() >= $wgCollectionMaxArticles ) { |
54 | | - self::limitExceeded(); |
| 52 | + switch ( $par ) { |
| 53 | + case 'add_article/': |
| 54 | + if ( self::countArticles() >= $wgCollectionMaxArticles ) { |
| 55 | + self::limitExceeded(); |
| 56 | + return; |
| 57 | + } |
| 58 | + $title_url = $wgRequest->getVal( 'arttitle', '' ); |
| 59 | + $oldid = $wgRequest->getInt( 'oldid', 0 ); |
| 60 | + $title = Title::newFromURL( $title_url ); |
| 61 | + $this->addArticle( $title, $oldid ); |
| 62 | + if ( $oldid == 0 ) { |
| 63 | + $redirectURL = $title->getFullURL(); |
| 64 | + } else { |
| 65 | + $redirectURL = $title->getFullURL( 'oldid=' . $oldid ); |
| 66 | + } |
| 67 | + $wgUser->invalidateCache(); |
| 68 | + $wgOut->redirect( $redirectURL ); |
55 | 69 | return; |
56 | | - } |
57 | | - $title_url = $wgRequest->getVal( 'arttitle', '' ); |
58 | | - $oldid = $wgRequest->getInt( 'oldid', 0 ); |
59 | | - $title = Title::newFromURL( $title_url ); |
60 | | - $this->addArticle( $title, $oldid ); |
61 | | - if ( $oldid == 0 ) { |
62 | | - $redirectURL = $title->getFullURL(); |
63 | | - } else { |
64 | | - $redirectURL = $title->getFullURL( 'oldid=' . $oldid ); |
65 | | - } |
66 | | - $wgUser->invalidateCache(); |
67 | | - $wgOut->redirect( $redirectURL ); |
68 | | - return; |
69 | | - } else if ( $par == 'remove_article/' ) { |
70 | | - $title_url = $wgRequest->getVal( 'arttitle', '' ); |
71 | | - $oldid = $wgRequest->getInt( 'oldid', 0 ); |
72 | | - $title = Title::newFromURL( $title_url ); |
73 | | - self::removeArticle( $title, $oldid ); |
74 | | - if ( $oldid == 0 ) { |
75 | | - $redirectURL = $title->getFullURL(); |
76 | | - } else { |
77 | | - $redirectURL = $title->getFullURL( 'oldid=' . $oldid ); |
78 | | - } |
79 | | - $wgUser->invalidateCache(); |
80 | | - $wgOut->redirect( $redirectURL ); |
81 | | - return; |
82 | | - } else if ( $par == 'clear_collection/' ) { |
83 | | - self::clearCollection(); |
84 | | - $wgUser->invalidateCache(); |
85 | | - $wgOut->redirect( $wgRequest->getVal( 'return_to', SkinTemplate::makeSpecialUrl( 'Book' ) ) ); |
86 | | - return; |
87 | | - } else if ( $par == 'set_titles/' ) { |
88 | | - self::setTitles( $wgRequest->getText( 'collectionTitle', '' ), $wgRequest->getText( 'collectionSubtitle', '') ); |
89 | | - $wgUser->invalidateCache(); |
90 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
91 | | - return; |
92 | | - } else if ( $par == 'sort_items/' ) { |
93 | | - self::sortItems(); |
94 | | - $wgUser->invalidateCache(); |
95 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
96 | | - return; |
97 | | - } else if ( $par == 'add_category/' ) { |
98 | | - $title = Title::makeTitleSafe( NS_CATEGORY, $wgRequest->getVal( 'cattitle', '' ) ); |
99 | | - if ( self::addCategory( $title ) ) { |
100 | | - self::limitExceeded(); |
| 70 | + case 'remove_article/': |
| 71 | + $title_url = $wgRequest->getVal( 'arttitle', '' ); |
| 72 | + $oldid = $wgRequest->getInt( 'oldid', 0 ); |
| 73 | + $title = Title::newFromURL( $title_url ); |
| 74 | + self::removeArticle( $title, $oldid ); |
| 75 | + if ( $oldid == 0 ) { |
| 76 | + $redirectURL = $title->getFullURL(); |
| 77 | + } else { |
| 78 | + $redirectURL = $title->getFullURL( 'oldid=' . $oldid ); |
| 79 | + } |
| 80 | + $wgUser->invalidateCache(); |
| 81 | + $wgOut->redirect( $redirectURL ); |
101 | 82 | return; |
102 | | - } else { |
103 | | - $wgOut->redirect( $title->getFullURL() ); |
104 | | - } |
105 | | - $wgUser->invalidateCache(); |
106 | | - return; |
107 | | - } else if ( $par == 'remove_item/' ) { |
108 | | - self::removeItem( $wgRequest->getInt( 'index', 0 ) ); |
109 | | - $wgUser->invalidateCache(); |
110 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
111 | | - return; |
112 | | - } else if ( $par == 'move_item/' ) { |
113 | | - self::moveItem( $wgRequest->getInt( 'index', 0 ), $wgRequest->getInt( 'delta', 0 ) ); |
114 | | - $wgUser->invalidateCache(); |
115 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
116 | | - return; |
117 | | - } else if ( $par == 'load_collection/' ) { |
118 | | - $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
119 | | - if ( $wgRequest->getVal( 'cancel' ) ) { |
120 | | - $wgOut->redirect( $title->getFullURL() ); |
| 83 | + case 'clear_collection/': |
| 84 | + self::clearCollection(); |
| 85 | + $wgUser->invalidateCache(); |
| 86 | + $wgOut->redirect( $wgRequest->getVal( 'return_to', SkinTemplate::makeSpecialUrl( 'Book' ) ) ); |
121 | 87 | return; |
122 | | - } |
123 | | - if ( !self::countArticles() |
124 | | - || $wgRequest->getVal( 'overwrite' ) |
125 | | - || $wgRequest->getVal( 'append' ) ) { |
126 | | - $collection = $this->loadCollection( $title, $wgRequest->getVal( 'append' ) ); |
127 | | - if ( $collection ) { |
128 | | - self::startSession(); |
129 | | - $_SESSION['wsCollection'] = $collection; |
130 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
| 88 | + case 'set_titles/': |
| 89 | + self::setTitles( $wgRequest->getText( 'collectionTitle', '' ), $wgRequest->getText( 'collectionSubtitle', '') ); |
| 90 | + $wgUser->invalidateCache(); |
| 91 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
| 92 | + return; |
| 93 | + case 'sort_items/': |
| 94 | + self::sortItems(); |
| 95 | + $wgUser->invalidateCache(); |
| 96 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
| 97 | + return; |
| 98 | + case 'add_category/': |
| 99 | + $title = Title::makeTitleSafe( NS_CATEGORY, $wgRequest->getVal( 'cattitle', '' ) ); |
| 100 | + if ( self::addCategory( $title ) ) { |
| 101 | + self::limitExceeded(); |
| 102 | + return; |
| 103 | + } else { |
| 104 | + $wgOut->redirect( $title->getFullURL() ); |
131 | 105 | } |
| 106 | + $wgUser->invalidateCache(); |
132 | 107 | return; |
133 | | - } |
134 | | - $this->renderLoadOverwritePage( $title ); |
135 | | - return; |
136 | | - } else if ( $par == 'order_collection/' ) { |
137 | | - $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
138 | | - $collection = $this->loadCollection( $title ); |
139 | | - $partner = $wgRequest->getVal( 'partner', 'pediapress' ); |
140 | | - return $this->postZIP( $collection, $partner ); |
141 | | - } else if ( $par == 'save_collection/' ) { |
142 | | - $collTitle = $wgRequest->getVal( 'colltitle' ); |
143 | | - if ( $wgRequest->getVal( 'overwrite' ) && !empty( $collTitle ) ) {; |
144 | | - $title = Title::newFromText( $collTitle ); |
145 | | - $this->saveCollection( $title, $overwrite=true ); |
146 | | - $wgOut->redirect( $title->getFullURL() ); |
| 108 | + case 'remove_item/': |
| 109 | + self::removeItem( $wgRequest->getInt( 'index', 0 ) ); |
| 110 | + $wgUser->invalidateCache(); |
| 111 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
147 | 112 | return; |
148 | | - } |
149 | | - $collType = $wgRequest->getVal( 'colltype' ); |
150 | | - $overwrite = $wgRequest->getBool( 'overwrite' ); |
151 | | - $saveCalled = false; |
152 | | - if ( $collType == 'personal' ) { |
153 | | - $userPageTitle = $wgUser->getUserPage()->getPrefixedText(); |
154 | | - $name = $wgRequest->getVal( 'pcollname', '' ); |
155 | | - if ( !empty( $name ) ) { |
156 | | - $title = Title::newFromText( $userPageTitle . '/' . wfMsgForContent( 'coll-collections' ) . '/' . $name ); |
157 | | - $saveCalled = true; |
158 | | - $saved = $this->saveCollection( $title, $overwrite ); |
| 113 | + case 'move_item/': |
| 114 | + self::moveItem( $wgRequest->getInt( 'index', 0 ), $wgRequest->getInt( 'delta', 0 ) ); |
| 115 | + $wgUser->invalidateCache(); |
| 116 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
| 117 | + return; |
| 118 | + case 'load_collection/': |
| 119 | + $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
| 120 | + if ( $wgRequest->getVal( 'cancel' ) ) { |
| 121 | + $wgOut->redirect( $title->getFullURL() ); |
| 122 | + return; |
159 | 123 | } |
160 | | - } else if ( $collType == 'community' ) { |
161 | | - $name = $wgRequest->getVal( 'ccollname', '' ); |
162 | | - if ( !empty( $name ) ) { |
163 | | - $title = Title::makeTitle( $wgCommunityCollectionNamespace, wfMsgForContent( 'coll-collections' ) . '/' . $name ); |
164 | | - $saveCalled = true; |
165 | | - $saved = $this->saveCollection( $title, $overwrite ); |
| 124 | + if ( !self::countArticles() |
| 125 | + || $wgRequest->getVal( 'overwrite' ) |
| 126 | + || $wgRequest->getVal( 'append' ) ) { |
| 127 | + $collection = $this->loadCollection( $title, $wgRequest->getVal( 'append' ) ); |
| 128 | + if ( $collection ) { |
| 129 | + self::startSession(); |
| 130 | + $_SESSION['wsCollection'] = $collection; |
| 131 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
| 132 | + } |
| 133 | + return; |
166 | 134 | } |
167 | | - } |
| 135 | + $this->renderLoadOverwritePage( $title ); |
| 136 | + return; |
| 137 | + case 'order_collection/': |
| 138 | + $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
| 139 | + $collection = $this->loadCollection( $title ); |
| 140 | + $partner = $wgRequest->getVal( 'partner', 'pediapress' ); |
| 141 | + return $this->postZIP( $collection, $partner ); |
| 142 | + case 'save_collection/': |
| 143 | + $collTitle = $wgRequest->getVal( 'colltitle' ); |
| 144 | + if ( $wgRequest->getVal( 'overwrite' ) && !empty( $collTitle ) ) {; |
| 145 | + $title = Title::newFromText( $collTitle ); |
| 146 | + $this->saveCollection( $title, $overwrite=true ); |
| 147 | + $wgOut->redirect( $title->getFullURL() ); |
| 148 | + return; |
| 149 | + } |
| 150 | + $collType = $wgRequest->getVal( 'colltype' ); |
| 151 | + $overwrite = $wgRequest->getBool( 'overwrite' ); |
| 152 | + $saveCalled = false; |
| 153 | + if ( $collType == 'personal' ) { |
| 154 | + $userPageTitle = $wgUser->getUserPage()->getPrefixedText(); |
| 155 | + $name = $wgRequest->getVal( 'pcollname', '' ); |
| 156 | + if ( !empty( $name ) ) { |
| 157 | + $title = Title::newFromText( $userPageTitle . '/' . wfMsgForContent( 'coll-collections' ) . '/' . $name ); |
| 158 | + $saveCalled = true; |
| 159 | + $saved = $this->saveCollection( $title, $overwrite ); |
| 160 | + } |
| 161 | + } else if ( $collType == 'community' ) { |
| 162 | + $name = $wgRequest->getVal( 'ccollname', '' ); |
| 163 | + if ( !empty( $name ) ) { |
| 164 | + $title = Title::makeTitle( $wgCommunityCollectionNamespace, wfMsgForContent( 'coll-collections' ) . '/' . $name ); |
| 165 | + $saveCalled = true; |
| 166 | + $saved = $this->saveCollection( $title, $overwrite ); |
| 167 | + } |
| 168 | + } |
168 | 169 | |
169 | | - if ( !$saveCalled) { |
170 | | - $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
171 | | - } else if ( $saved ) { |
172 | | - $wgOut->redirect( $title->getFullURL() ); |
173 | | - } else { |
174 | | - $this->renderSaveOverwritePage( $title ); |
175 | | - } |
176 | | - return; |
177 | | - } else if ( $par == 'render/' ) { |
178 | | - return $this->renderCollection( |
179 | | - $_SESSION['wsCollection'], |
180 | | - Title::makeTitle( NS_SPECIAL, 'Book' ), |
181 | | - $wgRequest->getVal( 'writer', '' ) |
182 | | - ); |
183 | | - } else if ( $par == 'forcerender/' ) { |
184 | | - return $this->forceRenderCollection(); |
185 | | - } else if ( $par == 'rendering/' ) { |
186 | | - return $this->renderRenderingPage(); |
187 | | - } else if ( $par == 'download/' ) { |
188 | | - return $this->download(); |
189 | | - } else if ( $par == 'render_article/' ) { |
190 | | - $title = Title::newFromText( $wgRequest->getVal( 'arttitle', '' ) ); |
191 | | - $oldid = $wgRequest->getInt( 'oldid', 0 ); |
192 | | - return $this->renderArticle( $title, $oldid, $wgRequest->getVal( 'writer', 'rl' ) ); |
193 | | - } else if ( $par == 'render_collection/' ) { |
194 | | - $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
195 | | - $collection = $this->loadCollection( $title ); |
196 | | - if ( $collection ) { |
197 | | - $this->renderCollection( $collection, $title, $wgRequest->getVal( 'writer', 'rl' ) ); |
198 | | - } |
199 | | - } else if ( $par == 'post_zip/' ) { |
200 | | - $partner = $wgRequest->getVal( 'partner', 'pediapress' ); |
201 | | - return $this->postZIP( $_SESSION['wsCollection'], $partner ); |
202 | | - } else if ( $par == '' ){ |
203 | | - $this->renderSpecialPage(); |
204 | | - } else { |
205 | | - $wgOut->showErrorPage( 'coll-unknown_subpage_title', 'coll-unknown_subpage_text' ); |
| 170 | + if ( !$saveCalled) { |
| 171 | + $wgOut->redirect( SkinTemplate::makeSpecialUrl( 'Book' ) ); |
| 172 | + } else if ( $saved ) { |
| 173 | + $wgOut->redirect( $title->getFullURL() ); |
| 174 | + } else { |
| 175 | + $this->renderSaveOverwritePage( $title ); |
| 176 | + } |
| 177 | + return; |
| 178 | + case 'render/': |
| 179 | + return $this->renderCollection( |
| 180 | + $_SESSION['wsCollection'], |
| 181 | + Title::makeTitle( NS_SPECIAL, 'Book' ), |
| 182 | + $wgRequest->getVal( 'writer', '' ) |
| 183 | + ); |
| 184 | + case 'forcerender/': |
| 185 | + return $this->forceRenderCollection(); |
| 186 | + case 'rendering/': |
| 187 | + return $this->renderRenderingPage(); |
| 188 | + case 'download/': |
| 189 | + return $this->download(); |
| 190 | + case 'render_article/': |
| 191 | + $title = Title::newFromText( $wgRequest->getVal( 'arttitle', '' ) ); |
| 192 | + $oldid = $wgRequest->getInt( 'oldid', 0 ); |
| 193 | + return $this->renderArticle( $title, $oldid, $wgRequest->getVal( 'writer', 'rl' ) ); |
| 194 | + case 'render_collection/': |
| 195 | + $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) ); |
| 196 | + $collection = $this->loadCollection( $title ); |
| 197 | + if ( $collection ) { |
| 198 | + $this->renderCollection( $collection, $title, $wgRequest->getVal( 'writer', 'rl' ) ); |
| 199 | + } |
| 200 | + return; |
| 201 | + case 'post_zip/': |
| 202 | + $partner = $wgRequest->getVal( 'partner', 'pediapress' ); |
| 203 | + return $this->postZIP( $_SESSION['wsCollection'], $partner ); |
| 204 | + case '': |
| 205 | + $this->renderSpecialPage(); |
| 206 | + return; |
| 207 | + default: |
| 208 | + $wgOut->showErrorPage( 'coll-unknown_subpage_title', 'coll-unknown_subpage_text' ); |
206 | 209 | } |
| 210 | + return; |
207 | 211 | } |
208 | 212 | |
209 | 213 | function renderSpecialPage() { |