http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88707
Revision: 88707
Author: demon
Date: 2011-05-24 01:08:18 +0000 (Tue, 24 May 2011)
Log Message:
-----------
MFT r88634
Modified Paths:
--------------
branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
Property Changed:
----------------
branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
Modified:
branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
===================================================================
---
branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
2011-05-24 00:42:42 UTC (rev 88706)
+++
branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
2011-05-24 01:08:18 UTC (rev 88707)
@@ -500,9 +500,9 @@
* @param Title $title
* @return Array of String: list of keywords
*/
- public function getKeywords ( $title ) {
+ public function getKeywords ( Title $title ) {
wfProfileIn( __METHOD__ );
- $cats = $title->getParentCategories();
+ $cats = $this->getVisibleCategories( $title );
$res = array();
# the following code is based (stolen) from r56954 of flagged
revs.
@@ -519,7 +519,7 @@
if ( !$targetTitle ) {
continue;
}
- $target =
$targetTitle->getPrefixedDBkey();
+ $target = $targetTitle->getDBkey();
$mapTo = trim( $mapping[1] );
if ( $mapTo === '__MASK__' ) {
@@ -530,7 +530,7 @@
}
}
}
- foreach ( $cats as $cat => $val ) {
+ foreach ( $cats as $cat ) {
if ( !isset( $catMask[$cat] ) ) {
if ( isset( $catMap[$cat] ) ) {
// Its mapped.
@@ -545,4 +545,48 @@
wfProfileOut( __METHOD__ );
return $res;
}
+
+ /**
+ * Get all non-hidden categories for a title.
+ *
+ * Kind of similar to title::getParentCategories.
+ *
+ * @param Title $title Which title to get the categories for.
+ * @return Array of String's that are the (non-prefixed) db-keys of the
cats.
+ */
+ private function getVisibleCategories ( Title $title ) {
+ $dbr = wfGetDB( DB_SLAVE );
+
+ $where = array(
+ 'cl_from' => $title->getArticleID(),
+ 'pp_propname' => null
+ );
+
+ $joins = array(
+ 'page' => array(
+ 'LEFT OUTER JOIN',
+ array( 'page_namespace' => NS_CATEGORY,
'page_title=cl_to' )
+ ),
+ 'page_props' => array(
+ 'LEFT OUTER JOIN',
+ array( 'pp_page=page_id', 'pp_propname' =>
'hiddencat' )
+ )
+ );
+
+ $res = $dbr->select(
+ array( 'categorylinks', 'page', 'page_props' ),
+ 'cl_to',
+ $where,
+ __METHOD__,
+ array(), /* options */
+ $joins
+ );
+ $finalResult = array();
+ if ( $res !== false ) {
+ foreach( $res as $row ) {
+ $finalResult[] = $row->cl_to;
+ }
+ }
+ return $finalResult;
+ }
}
Property changes on:
branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/REL1_15/phase3/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:51646
/branches/new-installer/phase3/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:43664-66004
/branches/sqlite/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:58211-58321
/branches/wmf/1.16wmf4/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:67177,69199,76243,77266
/branches/wmf-deployment/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:60970
/trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:87153,87157,87236,87458,88402,88634
/trunk/phase3/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,80406,81833,83212,83590
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs