+
+ /**
+ * Return a list of templates used by this article.
+ * Uses the links table to find the templates
+ *
+ * @return array
+ */
+ function getUsedTemplates() {
+ $result = array();
+ $id = $this->mTitle->getArticleID();
+
+ $db =& wfGetDB( DB_SLAVE );
+ $res = $db->select( array( 'pagelinks' ),
+ array( 'pl_title' ),
+ array(
+ 'pl_from' => $id,
+ 'pl_namespace' => NS_TEMPLATE ),
+ 'Article:getUsedTemplates' );
+ if ( false !== $res ) {
+ if ( $db->numRows( $res ) ) {
+ while ( $row = $db->fetchObject( $res ) ) {
+ $result[] = $row->pl_title;
+ }
+ }
+ }
+ $db->freeResult( $res );
+ return $result;
+ }
+
+