From 3f37423e4e7e4139e07e34b5610adf50175bdd15 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Thu, 1 Sep 2011 07:49:37 +0000 Subject: [PATCH] Add Title::isSubpageOf to use when you want to make tests like $title->isSubpageOf( $someUserpage ); --- includes/Title.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/Title.php b/includes/Title.php index b0cd7ca7d2..fb0e6d35de 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3859,6 +3859,18 @@ class Title { && $this->getDBkey() === $title->getDBkey(); } + /** + * 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) * -- 2.20.1