Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | <select id="category_dropdown" name="category_name"> |
164 | 164 | |
165 | 165 | END; |
166 | | - $categories = SDUtils::getTopLevelCategories(); |
| 166 | + $categories = SDUtils::getCategoriesForBrowsing(); |
167 | 167 | foreach ( $categories as $category ) { |
168 | 168 | $category = str_replace( '_', ' ', $category ); |
169 | 169 | $text .= " <option>$category</option>\n"; |
Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | // if no category was specified, go with the first |
85 | 85 | // category on the site, alphabetically |
86 | 86 | if ( ! $category ) { |
87 | | - $categories = SDUtils::getTopLevelCategories(); |
| 87 | + $categories = SDUtils::getCategoriesForBrowsing(); |
88 | 88 | if ( count( $categories ) > 0 ) { |
89 | 89 | $category = $categories[0]; |
90 | 90 | } |
— | — | @@ -856,7 +856,7 @@ |
857 | 857 | global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize; |
858 | 858 | |
859 | 859 | $skin = $wgUser->getSkin(); |
860 | | - $categories = SDUtils::getTopLevelCategories(); |
| 860 | + $categories = SDUtils::getCategoriesForBrowsing(); |
861 | 861 | // if there are no categories, escape quickly |
862 | 862 | if ( count( $categories ) == 0 ) { |
863 | 863 | return ""; |
Index: trunk/extensions/SemanticDrilldown/includes/SD_Utils.php |
— | — | @@ -79,6 +79,41 @@ |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
| 83 | + * Gets the list of names of only those categories in the wiki |
| 84 | + * that have a __SHOWINDRILLDOWN__ declaration on their page. |
| 85 | + */ |
| 86 | + static function getOnlyExplicitlyShownCategories() { |
| 87 | + $shown_cats = array(); |
| 88 | + $dbr = wfGetDB( DB_SLAVE ); |
| 89 | + extract( $dbr->tableNames( 'page', 'page_props' ) ); |
| 90 | + $cat_ns = NS_CATEGORY; |
| 91 | + $sql = "SELECT p.page_title FROM $page p JOIN $page_props pp ON p.page_id = pp.pp_page WHERE p.page_namespace = $cat_ns AND pp.pp_propname = 'showindrilldown' AND pp.pp_value = 'y'"; |
| 92 | + $res = $dbr->query( $sql ); |
| 93 | + |
| 94 | + while ( $row = $dbr->fetchRow( $res ) ) { |
| 95 | + $shown_cats[] = str_replace( '_', ' ', $row[0] ); |
| 96 | + } |
| 97 | + $dbr->freeResult( $res ); |
| 98 | + |
| 99 | + sort( $shown_cats ); |
| 100 | + return $shown_cats; |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Returns the list of categories that will show up in the |
| 105 | + * header/sidebar of the 'BrowseData' special page. |
| 106 | + */ |
| 107 | + public static function getCategoriesForBrowsing() { |
| 108 | + global $sdgHideCategoriesByDefault; |
| 109 | + |
| 110 | + if ( $sdgHideCategoriesByDefault ) { |
| 111 | + return self::getOnlyExplicitlyShownCategories(); |
| 112 | + } else { |
| 113 | + return self::getTopLevelCategories(); |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + /** |
83 | 118 | * Gets a list of the names of all properties in the wiki |
84 | 119 | */ |
85 | 120 | static function getSemanticProperties() { |
Index: trunk/extensions/SemanticDrilldown/SemanticDrilldown.php |
— | — | @@ -100,6 +100,9 @@ |
101 | 101 | # ## |
102 | 102 | # # Variables for display |
103 | 103 | # ## |
| 104 | +// Set to true to have Special:BrowseData show only categories that have |
| 105 | +// __SHOWINDRILLDOWN__ set. |
| 106 | +$sdgHideCategoriesByDefault = false; |
104 | 107 | $sdgNumResultsPerPage = 250; |
105 | 108 | // set these to a positive value to trigger the "tag cloud" display |
106 | 109 | $sdgFiltersSmallestFontSize = - 1; |