http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73454

Revision: 73454
Author:   jojo
Date:     2010-09-21 09:40:50 +0000 (Tue, 21 Sep 2010)

Log Message:
-----------
added $wgCollectionHierarchyDelimiter

Modified Paths:
--------------
    trunk/extensions/Collection/Collection.body.php
    trunk/extensions/Collection/Collection.php
    trunk/extensions/Collection/Collection.session.php
    trunk/extensions/Collection/README.txt

Modified: trunk/extensions/Collection/Collection.body.php
===================================================================
--- trunk/extensions/Collection/Collection.body.php     2010-09-21 09:05:29 UTC 
(rev 73453)
+++ trunk/extensions/Collection/Collection.body.php     2010-09-21 09:40:50 UTC 
(rev 73454)
@@ -606,6 +606,8 @@
        }
 
        static function addArticle( $title, $oldid = 0 ) {
+               global $wgCollectionHierarchyDelimiter;
+
                $article = new Article( $title, $oldid );
                $latest = $article->getLatest();
 
@@ -614,7 +616,10 @@
                        $currentVersion = 1;
                        $oldid = $latest;
                }
-               $index = CollectionSession::findArticle( 
$title->getPrefixedText(), $oldid );
+
+               $prefixedText = $title->getPrefixedText();
+
+               $index = CollectionSession::findArticle( $prefixedText, $oldid 
);
                if ( $index != - 1 ) {
                        return false;
                }
@@ -624,16 +629,26 @@
                }
                $collection = CollectionSession::getCollection();
                $revision = Revision::newFromTitle( $title, $oldid );
-               $collection['items'][] = array(
+
+               $item = array(
                        'type' => 'article',
                        'content_type' => 'text/x-wiki',
-                       'title' => $title->getPrefixedText(),
+                       'title' => $prefixedText,
                        'revision' => strval( $oldid ),
                        'latest' => strval( $latest ),
                        'timestamp' => wfTimestamp( TS_UNIX, 
$revision->mTimestamp ),
                        'url' => $title->getFullURL(),
                        'currentVersion' => $currentVersion,
                );
+
+               if ($wgCollectionHierarchyDelimiter != null) {
+                       $parts = explode( $wgCollectionHierarchyDelimiter, 
$prefixedText );
+                       if ( count( $parts > 1 ) && end( $parts ) != '' ) {
+                               $item['displaytitle'] = end( $parts );
+                       }
+               }
+
+               $collection['items'][] = $item;
                CollectionSession::setCollection( $collection );
                return true;
        }

Modified: trunk/extensions/Collection/Collection.php
===================================================================
--- trunk/extensions/Collection/Collection.php  2010-09-21 09:05:29 UTC (rev 
73453)
+++ trunk/extensions/Collection/Collection.php  2010-09-21 09:40:50 UTC (rev 
73454)
@@ -51,6 +51,10 @@
 /** PEM-encoded SSL certificate for the mw-serve render server to pass to CURL 
*/
 $wgCollectionMWServeCert = null;
 
+/** if not null, treat this string as hierarchy delimiter in page titles,
+ * i.e. support subpages */
+$wgCollectionHierarcyDelimiter = null;
+
 /** Array of namespaces that can be added to a collection */
 $wgCollectionArticleNamespaces = array(
        NS_MAIN,

Modified: trunk/extensions/Collection/Collection.session.php
===================================================================
--- trunk/extensions/Collection/Collection.session.php  2010-09-21 09:05:29 UTC 
(rev 73453)
+++ trunk/extensions/Collection/Collection.session.php  2010-09-21 09:40:50 UTC 
(rev 73454)
@@ -126,7 +126,7 @@
                        foreach ( $coll['items'] as $index => $item ) {
                                if ( $item['type'] == 'article' ) {
                                        $t = Title::newFromText( $item['title'] 
);
-                                       if ( !$lc->isBadLink( 
$t->getPrefixedDbKey() ) ) {
+                                       if ( $t && !$lc->isBadLink( 
$t->getPrefixedDbKey() ) ) {
                                                $newitems[] = $item;
                                        }
                                } else {

Modified: trunk/extensions/Collection/README.txt
===================================================================
--- trunk/extensions/Collection/README.txt      2010-09-21 09:05:29 UTC (rev 
73453)
+++ trunk/extensions/Collection/README.txt      2010-09-21 09:40:50 UTC (rev 
73454)
@@ -126,6 +126,20 @@
 
         i.e. there's one link "Download as PDF".
 
+       *$wgCollectionHierarchyDelimiter (string or null)*
+        If not null, treat wiki pages whose title contains the configured 
delimiter
+        as subpages.
+
+         For example, to treat article [[Foo/Bar]] as subpage of article 
[[Foo]]
+        set this variable to "/". This makes sense e.g. on wikibooks.org, but 
it's
+        questionable on wikipedia.org (cf. [[AC/DC]]).
+
+        The (only) effect is that the display title for subpages in collections
+         is set to the title of the (deepest) subpage. For example, the title 
of
+         article [[Foo/Bar]] will be displayed/rendered as "Bar".
+
+        The defaul value is null, which means that no hierarchy is assumed.
+
   *$wgCollectionArticleNamespaces (array)*
    List of namespace numbers for pages which can be added to a collection.
    Category pages (NS_CATEGORY) are always an exception (all articles in a



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to