Index: trunk/extensions/Collection/CollectionCore.i18n.php |
— | — | @@ -60,6 +60,8 @@ |
61 | 61 | 'coll-make_suggestions_tooltip' => 'Show suggestions based on the pages in your book', |
62 | 62 | 'coll-suggest_enabled' => '1', |
63 | 63 | 'coll-suggest_empty' => 'empty', |
| 64 | + 'coll-user_book_prefix' => '-', |
| 65 | + 'coll-community_book_prefix' => '-', |
64 | 66 | ); |
65 | 67 | |
66 | 68 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Collection/README.txt |
— | — | @@ -150,6 +150,9 @@ |
151 | 151 | Namespace for "community collections", i.e. the namespace where non-personal |
152 | 152 | article collection pages are saved. |
153 | 153 | |
| 154 | + Note: This configuration setting is only used if the system message |
| 155 | + Coll-community_book_prefix has not been set (see below). |
| 156 | + |
154 | 157 | Default is ``NS_PROJECT``. |
155 | 158 | |
156 | 159 | *$wgCollectionMaxArticles (integer)* |
— | — | @@ -243,6 +246,23 @@ |
244 | 247 | The default for English language is "Help:Books", and there exist translations |
245 | 248 | for lots of different languages. |
246 | 249 | |
| 250 | +* Coll-user_book_prefix: Prefix for titles of "user books" (i.e. books for |
| 251 | + personal use, as opposed to "community books"). If the system message is empty |
| 252 | + or '-' (the default), the title of user book pages is constructed |
| 253 | + as User:USERNAME/Books/BOOKTITLE. If the system message is set and its content |
| 254 | + is PREFIX, the title of user book pages is constructed by directly concatenating |
| 255 | + PREFIX and the BOOKTITLE, i.e. there's no implicitly inserted '/' inbetween! |
| 256 | + |
| 257 | +* Coll-community_book_prefix: Prefix for titles of "community books" (cf. "user |
| 258 | + books" above). If the system message is empty or '-' (the default), the title |
| 259 | + of community pages is constructed as NAMESPACE:Books/BOOKTITLE, where |
| 260 | + NAMESPACE depends on the value of $wgCommunityCollectionNamespace (see above). |
| 261 | + If the system message is set and its content is PREFIX, the title of community |
| 262 | + book pages is constructed by directly concatenating PREFIX and BOOKTITLE, |
| 263 | + i.e. there's no implicitly inserted '/' inbetween. Thus it's possible to |
| 264 | + define a custom namespace 'Book' and set the system message to 'Book:' to |
| 265 | + produce community book page titles Book:BOOKTITLE. |
| 266 | + |
247 | 267 | * Coll-savedbook_template: The name of the template (w/out the Template: prefix) |
248 | 268 | included at the top of saved book pages (see above). |
249 | 269 | The default is: 'saved_book', and there exist translations for lots of |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -210,24 +210,19 @@ |
211 | 211 | return; |
212 | 212 | } |
213 | 213 | $colltype = $wgRequest->getVal( 'colltype' ); |
| 214 | + $prefixes = self::getBookPagePrefixes(); |
214 | 215 | if ( $colltype == 'personal' ) { |
215 | 216 | $collname = $wgRequest->getVal( 'pcollname' ); |
216 | 217 | if ( !$wgUser->isAllowed( 'collectionsaveasuserpage' ) || empty( $collname ) ) { |
217 | 218 | return; |
218 | 219 | } |
219 | | - $userPageTitle = $wgUser->getUserPage()->getPrefixedText(); |
220 | | - $title = Title::newFromText( |
221 | | - $userPageTitle . '/' . wfMsgForContent( 'coll-collections' ) . '/' . $collname |
222 | | - ); |
| 220 | + $title = Title::newFromText( $prefixes['user-prefix'] . $collname ); |
223 | 221 | } elseif ( $colltype == 'community' ) { |
224 | 222 | $collname = $wgRequest->getVal( 'ccollname' ); |
225 | 223 | if ( !$wgUser->isAllowed( 'collectionsaveascommunitypage' ) || empty( $collname ) ) { |
226 | 224 | return; |
227 | 225 | } |
228 | | - $title = Title::makeTitle( |
229 | | - $wgCommunityCollectionNamespace, |
230 | | - wfMsgForContent( 'coll-collections' ) . '/' . $collname |
231 | | - ); |
| 226 | + $title = Title::newFromText( $prefixes['community-prefix'] . $collname ); |
232 | 227 | } |
233 | 228 | if ( !$title ) { |
234 | 229 | return; |
— | — | @@ -467,7 +462,36 @@ |
468 | 463 | ); |
469 | 464 | } |
470 | 465 | |
| 466 | + static function getBookPagePrefixes() { |
| 467 | + global $wgUser; |
| 468 | + global $wgCommunityCollectionNamespace; |
471 | 469 | |
| 470 | + wfLoadExtensionMessages( 'CollectionCore' ); |
| 471 | + |
| 472 | + $result = array(); |
| 473 | + |
| 474 | + $t = wfMsgForContent( 'coll-user_book_prefix', $wgUser->getName() ); |
| 475 | + if ( wfEmptyMsg( 'coll-user_book_prefix', $t ) || $t == '-' ) { |
| 476 | + $userPageTitle = $wgUser->getUserPage()->getPrefixedText(); |
| 477 | + $result['user-prefix'] = $userPageTitle . '/' |
| 478 | + . wfMsgForContent( 'coll-collections' ) . '/'; |
| 479 | + } else { |
| 480 | + $result['user-prefix'] = $t; |
| 481 | + } |
| 482 | + |
| 483 | + $t = wfMsgForContent( 'coll-community_book_prefix' ); |
| 484 | + if ( wfEmptyMsg( 'coll-community_book_prefix', $t) || $t == '-' ) { |
| 485 | + $title = Title::makeTitle( |
| 486 | + $wgCommunityCollectionNamespace, |
| 487 | + wfMsgForContent( 'coll-collections' ) |
| 488 | + ); |
| 489 | + $result['community-prefix'] = $title->getPrefixedText() . '/'; |
| 490 | + } else { |
| 491 | + $result['community-prefix'] = $t; |
| 492 | + } |
| 493 | + return $result; |
| 494 | + } |
| 495 | + |
472 | 496 | function renderSpecialPage() { |
473 | 497 | global $wgCollectionFormats; |
474 | 498 | global $wgCollectionVersion; |
— | — | @@ -494,6 +518,9 @@ |
495 | 519 | $template->set( 'collection', $_SESSION['wsCollection'] ); |
496 | 520 | $template->set( 'podpartners', $this->mPODPartners ); |
497 | 521 | $template->set( 'formats', $wgCollectionFormats); |
| 522 | + $prefixes = self::getBookPagePrefixes(); |
| 523 | + $template->set( 'user-book-prefix', $prefixes['user-prefix'] ); |
| 524 | + $template->set( 'community-book-prefix', $prefixes['community-prefix'] ); |
498 | 525 | $wgOut->addTemplate( $template ); |
499 | 526 | } |
500 | 527 | |
Index: trunk/extensions/Collection/Collection.templates.php |
— | — | @@ -151,7 +151,7 @@ |
152 | 152 | <?php } else { ?> |
153 | 153 | <input type="hidden" name="colltype" value="personal" /> |
154 | 154 | <?php } ?> |
155 | | - <label for="personalCollTitle"><a href="<?php echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Prefixindex', 'prefix=' . wfUrlencode($GLOBALS['wgUser']->getName()) . '/' . wfUrlencode($bookname) . '/&namespace=2')) ?>"><?php echo htmlspecialchars($GLOBALS['wgUser']->getUserPage()->getPrefixedText() . '/' . $bookname . '/') ?></a></label> |
| 155 | + <label for="personalCollTitle"><a href="<?php echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Prefixindex', 'prefix=' . wfUrlencode($this->data['user-book-prefix']))) ?>"><?php echo htmlspecialchars($this->data['user-book-prefix']) ?></a></label> |
156 | 156 | </td> |
157 | 157 | <td style="text-align:right;"> |
158 | 158 | <input id="personalCollTitle" type="text" name="pcollname" /> |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | <?php } else { ?> |
166 | 166 | <input type="hidden" name="colltype" value="community" /> |
167 | 167 | <?php } ?> |
168 | | - <label for="communityCollTitle"><a href="<?php echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Prefixindex', 'prefix=' . wfUrlencode($bookname) . '/&namespace=' . $communityCollNS)) ?>"><?php echo htmlspecialchars(Title::makeTitle($communityCollNS, $bookname)->getPrefixedText() . '/') ?></a></label> |
| 168 | + <label for="communityCollTitle"><a href="<?php echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Prefixindex', 'prefix=' . wfUrlencode($this->data['community-book-prefix']))) ?>"><?php echo htmlspecialchars($this->data['community-book-prefix']) ?></a></label> |
169 | 169 | </td> |
170 | 170 | <td style="text-align:right;"> |
171 | 171 | <input id="communityCollTitle" type="text" name="ccollname" disabled="disabled" /> |