Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -51,6 +51,10 @@ |
52 | 52 | /** PEM-encoded SSL certificate for the mw-serve render server to pass to CURL */ |
53 | 53 | $wgCollectionMWServeCert = null; |
54 | 54 | |
| 55 | +/** if not null, treat this string as hierarchy delimiter in page titles, |
| 56 | + * i.e. support subpages */ |
| 57 | +$wgCollectionHierarcyDelimiter = null; |
| 58 | + |
55 | 59 | /** Array of namespaces that can be added to a collection */ |
56 | 60 | $wgCollectionArticleNamespaces = array( |
57 | 61 | NS_MAIN, |
Index: trunk/extensions/Collection/Collection.session.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | foreach ( $coll['items'] as $index => $item ) { |
128 | 128 | if ( $item['type'] == 'article' ) { |
129 | 129 | $t = Title::newFromText( $item['title'] ); |
130 | | - if ( !$lc->isBadLink( $t->getPrefixedDbKey() ) ) { |
| 130 | + if ( $t && !$lc->isBadLink( $t->getPrefixedDbKey() ) ) { |
131 | 131 | $newitems[] = $item; |
132 | 132 | } |
133 | 133 | } else { |
Index: trunk/extensions/Collection/README.txt |
— | — | @@ -126,6 +126,20 @@ |
127 | 127 | |
128 | 128 | i.e. there's one link "Download as PDF". |
129 | 129 | |
| 130 | + *$wgCollectionHierarchyDelimiter (string or null)* |
| 131 | + If not null, treat wiki pages whose title contains the configured delimiter |
| 132 | + as subpages. |
| 133 | + |
| 134 | + For example, to treat article [[Foo/Bar]] as subpage of article [[Foo]] |
| 135 | + set this variable to "/". This makes sense e.g. on wikibooks.org, but it's |
| 136 | + questionable on wikipedia.org (cf. [[AC/DC]]). |
| 137 | + |
| 138 | + The (only) effect is that the display title for subpages in collections |
| 139 | + is set to the title of the (deepest) subpage. For example, the title of |
| 140 | + article [[Foo/Bar]] will be displayed/rendered as "Bar". |
| 141 | + |
| 142 | + The defaul value is null, which means that no hierarchy is assumed. |
| 143 | + |
130 | 144 | *$wgCollectionArticleNamespaces (array)* |
131 | 145 | List of namespace numbers for pages which can be added to a collection. |
132 | 146 | Category pages (NS_CATEGORY) are always an exception (all articles in a |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -606,6 +606,8 @@ |
607 | 607 | } |
608 | 608 | |
609 | 609 | static function addArticle( $title, $oldid = 0 ) { |
| 610 | + global $wgCollectionHierarchyDelimiter; |
| 611 | + |
610 | 612 | $article = new Article( $title, $oldid ); |
611 | 613 | $latest = $article->getLatest(); |
612 | 614 | |
— | — | @@ -614,7 +616,10 @@ |
615 | 617 | $currentVersion = 1; |
616 | 618 | $oldid = $latest; |
617 | 619 | } |
618 | | - $index = CollectionSession::findArticle( $title->getPrefixedText(), $oldid ); |
| 620 | + |
| 621 | + $prefixedText = $title->getPrefixedText(); |
| 622 | + |
| 623 | + $index = CollectionSession::findArticle( $prefixedText, $oldid ); |
619 | 624 | if ( $index != - 1 ) { |
620 | 625 | return false; |
621 | 626 | } |
— | — | @@ -624,16 +629,26 @@ |
625 | 630 | } |
626 | 631 | $collection = CollectionSession::getCollection(); |
627 | 632 | $revision = Revision::newFromTitle( $title, $oldid ); |
628 | | - $collection['items'][] = array( |
| 633 | + |
| 634 | + $item = array( |
629 | 635 | 'type' => 'article', |
630 | 636 | 'content_type' => 'text/x-wiki', |
631 | | - 'title' => $title->getPrefixedText(), |
| 637 | + 'title' => $prefixedText, |
632 | 638 | 'revision' => strval( $oldid ), |
633 | 639 | 'latest' => strval( $latest ), |
634 | 640 | 'timestamp' => wfTimestamp( TS_UNIX, $revision->mTimestamp ), |
635 | 641 | 'url' => $title->getFullURL(), |
636 | 642 | 'currentVersion' => $currentVersion, |
637 | 643 | ); |
| 644 | + |
| 645 | + if ($wgCollectionHierarchyDelimiter != null) { |
| 646 | + $parts = explode( $wgCollectionHierarchyDelimiter, $prefixedText ); |
| 647 | + if ( count( $parts > 1 ) && end( $parts ) != '' ) { |
| 648 | + $item['displaytitle'] = end( $parts ); |
| 649 | + } |
| 650 | + } |
| 651 | + |
| 652 | + $collection['items'][] = $item; |
638 | 653 | CollectionSession::setCollection( $collection ); |
639 | 654 | return true; |
640 | 655 | } |