From: Daniel Friesen Date: Thu, 1 Sep 2011 07:49:37 +0000 (+0000) Subject: Add Title::isSubpageOf to use when you want to make tests like $title->isSubpageOf... X-Git-Tag: 1.31.0-rc.0~27986 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=3f37423e4e7e4139e07e34b5610adf50175bdd15;p=lhc%2Fweb%2Fwiklou.git Add Title::isSubpageOf to use when you want to make tests like $title->isSubpageOf( $someUserpage ); --- 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) *