http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95946
Revision: 95946
Author: dantman
Date: 2011-09-01 07:49:37 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
Add Title::isSubpageOf to use when you want to make tests like
$title->isSubpageOf( $someUserpage );
Modified Paths:
--------------
trunk/phase3/includes/Title.php
Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php 2011-09-01 07:42:56 UTC (rev 95945)
+++ trunk/phase3/includes/Title.php 2011-09-01 07:49:37 UTC (rev 95946)
@@ -3860,6 +3860,18 @@
}
/**
+ * Check if this title is a subpage of another title
+ *
+ * @param $title Title
+ * @return Bool
+ */
+ public function isSubpageOf( Title $title ) {
+ return $this->getInterwiki() === $title->getInterwiki()
+ && $this->getNamespace() == $title->getNamespace()
+ && strpos( $this->getDBkey(), $title->getDBkey() . '/'
) === 0;
+ }
+
+ /**
* Callback for usort() to do title sorts by (namespace, title)
*
* @param $a Title
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs