Index: trunk/extensions/DataTransfer/specials/DT_ViewXML.php |
— | — | @@ -5,8 +5,6 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | | - |
11 | 9 | class DTViewXML extends SpecialPage { |
12 | 10 | |
13 | 11 | /** |
— | — | @@ -18,103 +16,110 @@ |
19 | 17 | |
20 | 18 | function execute( $query ) { |
21 | 19 | $this->setHeaders(); |
22 | | - doSpecialViewXML( $query ); |
| 20 | + self::doSpecialViewXML( $query ); |
23 | 21 | } |
24 | | -} |
25 | 22 | |
26 | | -function getCategoriesList() { |
27 | | - global $wgContLang, $dtgContLang; |
28 | | - $dt_props = $dtgContLang->getPropertyLabels(); |
29 | | - $exclusion_cat_name = str_replace( ' ', '_', $dt_props[DT_SP_IS_EXCLUDED_FROM_XML] ); |
30 | | - $exclusion_cat_full_name = $wgContLang->getNSText( NS_CATEGORY ) . ':' . $exclusion_cat_name; |
31 | | - $dbr = wfGetDB( DB_SLAVE ); |
32 | | - $categorylinks = $dbr->tableName( 'categorylinks' ); |
33 | | - $res = $dbr->query( "SELECT DISTINCT cl_to FROM $categorylinks" ); |
34 | | - $categories = array(); |
35 | | - while ( $row = $dbr->fetchRow( $res ) ) { |
36 | | - $cat_name = $row[0]; |
37 | | - // add this category to the list, if it's not the |
38 | | - // "Excluded from XML" category, and it's not a child of that |
39 | | - // category |
40 | | - if ( $cat_name != $exclusion_cat_name ) { |
41 | | - $title = Title::newFromText( $cat_name, NS_CATEGORY ); |
42 | | - $parent_categories = $title->getParentCategoryTree( array() ); |
43 | | - if ( ! treeContainsElement( $parent_categories, $exclusion_cat_full_name ) ) |
44 | | - $categories[] = $cat_name; |
| 23 | + static function getCategoriesList() { |
| 24 | + global $wgContLang, $dtgContLang; |
| 25 | + $dt_props = $dtgContLang->getPropertyLabels(); |
| 26 | + $exclusion_cat_name = str_replace( ' ', '_', $dt_props[DT_SP_IS_EXCLUDED_FROM_XML] ); |
| 27 | + $exclusion_cat_full_name = $wgContLang->getNSText( NS_CATEGORY ) . ':' . $exclusion_cat_name; |
| 28 | + $dbr = wfGetDB( DB_SLAVE ); |
| 29 | + $categorylinks = $dbr->tableName( 'categorylinks' ); |
| 30 | + $res = $dbr->query( "SELECT DISTINCT cl_to FROM $categorylinks" ); |
| 31 | + $categories = array(); |
| 32 | + while ( $row = $dbr->fetchRow( $res ) ) { |
| 33 | + $cat_name = $row[0]; |
| 34 | + // Add this category to the list, if it's not the |
| 35 | + // "Excluded from XML" category, and it's not a child |
| 36 | + // of that category. |
| 37 | + if ( $cat_name != $exclusion_cat_name ) { |
| 38 | + $title = Title::newFromText( $cat_name, NS_CATEGORY ); |
| 39 | + $parent_categories = $title->getParentCategoryTree( array() ); |
| 40 | + if ( ! self::treeContainsElement( $parent_categories, $exclusion_cat_full_name ) ) |
| 41 | + $categories[] = $cat_name; |
| 42 | + } |
45 | 43 | } |
| 44 | + $dbr->freeResult( $res ); |
| 45 | + sort( $categories ); |
| 46 | + return $categories; |
46 | 47 | } |
47 | | - $dbr->freeResult( $res ); |
48 | | - sort( $categories ); |
49 | | - return $categories; |
50 | | -} |
51 | 48 | |
52 | | -function getNamespacesList() { |
53 | | - $dbr = wfGetDB( DB_SLAVE ); |
54 | | - $page = $dbr->tableName( 'page' ); |
55 | | - $res = $dbr->query( "SELECT DISTINCT page_namespace FROM $page" ); |
56 | | - $namespaces = array(); |
57 | | - while ( $row = $dbr->fetchRow( $res ) ) { |
58 | | - $namespaces[] = $row[0]; |
| 49 | + function getNamespacesList() { |
| 50 | + $dbr = wfGetDB( DB_SLAVE ); |
| 51 | + $page = $dbr->tableName( 'page' ); |
| 52 | + $res = $dbr->query( "SELECT DISTINCT page_namespace FROM $page" ); |
| 53 | + $namespaces = array(); |
| 54 | + while ( $row = $dbr->fetchRow( $res ) ) { |
| 55 | + $namespaces[] = $row[0]; |
| 56 | + } |
| 57 | + $dbr->freeResult( $res ); |
| 58 | + return $namespaces; |
59 | 59 | } |
60 | | - $dbr->freeResult( $res ); |
61 | | - return $namespaces; |
62 | | -} |
63 | 60 | |
64 | | -function getGroupings() { |
65 | | - global $dtgContLang; |
| 61 | + function getGroupings() { |
| 62 | + global $dtgContLang, $smwgIP; |
66 | 63 | |
67 | | - global $smwgIP; |
68 | | - if ( ! isset( $smwgIP ) ) { |
69 | | - return array(); |
70 | | - } else { |
71 | | - $groupings = array(); |
72 | | - $store = smwfGetStore(); |
73 | | - $grouping_prop = SMWPropertyValue::makeProperty( '_DT_XG' ); |
74 | | - $grouped_props = $store->getAllPropertySubjects( $grouping_prop ); |
75 | | - foreach ( $grouped_props as $grouped_prop ) { |
76 | | - $res = $store->getPropertyValues( $grouped_prop, $grouping_prop ); |
77 | | - $num = count( $res ); |
78 | | - if ( $num > 0 ) { |
79 | | - $grouping_label = $res[0]->getShortWikiText(); |
80 | | - $groupings[] = array( $grouped_prop, $grouping_label ); |
81 | | - } |
82 | | - } |
83 | | - return $groupings; |
84 | | - } |
85 | | -} |
86 | | - |
87 | | -function getSubpagesForPageGrouping( $page_name, $relation_name ) { |
88 | | - $dbr = wfGetDB( DB_SLAVE ); |
89 | | - $smw_relations = $dbr->tableName( 'smw_relations' ); |
90 | | - $smw_attributes = $dbr->tableName( 'smw_attributes' ); |
91 | | - $res = $dbr->query( "SELECT subject_title FROM $smw_relations WHERE object_title = '$page_name' AND relation_title = '$relation_name'" ); |
92 | | - $subpages = array(); |
93 | | - while ( $row = $dbr->fetchRow( $res ) ) { |
94 | | - $subpage_name = $row[0]; |
95 | | - $query_subpage_name = str_replace( "'", "\'", $subpage_name ); |
96 | | - // get the display order |
97 | | - $res2 = $dbr->query( "SELECT value_num FROM $smw_attributes WHERE subject_title = '$query_subpage_name' AND attribute_title = 'Display_order'" ); |
98 | | - if ( $row2 = $dbr->fetchRow( $res2 ) ) { |
99 | | - $display_order = $row2[0]; |
| 64 | + if ( ! isset( $smwgIP ) ) { |
| 65 | + return array(); |
100 | 66 | } else { |
101 | | - $display_order = - 1; |
| 67 | + $groupings = array(); |
| 68 | + $store = smwfGetStore(); |
| 69 | + // SMWDIProperty was added in SMW 1.6 |
| 70 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 71 | + $grouping_prop = SMWDIProperty::newFromUserLabel( '_DT_XG' ); |
| 72 | + } else { |
| 73 | + $grouping_prop = SMWPropertyValue::makeProperty( '_DT_XG' ); |
| 74 | + } |
| 75 | + $grouped_props = $store->getAllPropertySubjects( $grouping_prop ); |
| 76 | + foreach ( $grouped_props as $grouped_prop ) { |
| 77 | + $res = $store->getPropertyValues( $grouped_prop, $grouping_prop ); |
| 78 | + $num = count( $res ); |
| 79 | + if ( $num > 0 ) { |
| 80 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 81 | + $grouping_label = $res[0]->getSortKey(); |
| 82 | + } else { |
| 83 | + $grouping_label = $res[0]->getShortWikiText(); |
| 84 | + } |
| 85 | + $groupings[] = array( $grouped_prop, $grouping_label ); |
| 86 | + } |
| 87 | + } |
| 88 | + return $groupings; |
102 | 89 | } |
103 | | - $dbr->freeResult( $res2 ); |
104 | | - // HACK - page name is the key, display order is the value |
105 | | - $subpages[$subpage_name] = $display_order; |
106 | 90 | } |
107 | | - $dbr->freeResult( $res ); |
108 | | - uasort( $subpages, "cmp" ); |
109 | | - return array_keys( $subpages ); |
110 | | -} |
111 | 91 | |
| 92 | + static function getSubpagesForPageGrouping( $page_name, $relation_name ) { |
| 93 | + $dbr = wfGetDB( DB_SLAVE ); |
| 94 | + $smw_relations = $dbr->tableName( 'smw_relations' ); |
| 95 | + $smw_attributes = $dbr->tableName( 'smw_attributes' ); |
| 96 | + $res = $dbr->query( "SELECT subject_title FROM $smw_relations WHERE object_title = '$page_name' AND relation_title = '$relation_name'" ); |
| 97 | + $subpages = array(); |
| 98 | + while ( $row = $dbr->fetchRow( $res ) ) { |
| 99 | + $subpage_name = $row[0]; |
| 100 | + $query_subpage_name = str_replace( "'", "\'", $subpage_name ); |
| 101 | + // get the display order |
| 102 | + $res2 = $dbr->query( "SELECT value_num FROM $smw_attributes WHERE subject_title = '$query_subpage_name' AND attribute_title = 'Display_order'" ); |
| 103 | + if ( $row2 = $dbr->fetchRow( $res2 ) ) { |
| 104 | + $display_order = $row2[0]; |
| 105 | + } else { |
| 106 | + $display_order = - 1; |
| 107 | + } |
| 108 | + $dbr->freeResult( $res2 ); |
| 109 | + // HACK - page name is the key, display order is the value |
| 110 | + $subpages[$subpage_name] = $display_order; |
| 111 | + } |
| 112 | + $dbr->freeResult( $res ); |
| 113 | + uasort( $subpages, "cmp" ); |
| 114 | + return array_keys( $subpages ); |
| 115 | + } |
112 | 116 | |
113 | | -/** |
| 117 | + |
| 118 | +/* |
114 | 119 | * Get all the pages that belong to a category and all its subcategories, |
115 | 120 | * down a certain number of levels - heavily based on SMW's |
116 | 121 | * SMWInlineQuery::includeSubcategories() |
117 | 122 | */ |
118 | | - function getPagesForCategory( $top_category, $num_levels ) { |
| 123 | + static function getPagesForCategory( $top_category, $num_levels ) { |
119 | 124 | if ( 0 == $num_levels ) return $top_category; |
120 | 125 | |
121 | 126 | $db = wfGetDB( DB_SLAVE ); |
— | — | @@ -159,7 +164,7 @@ |
160 | 165 | } |
161 | 166 | |
162 | 167 | /* |
163 | | -function getPagesForCategory($category) { |
| 168 | +static function getPagesForCategory($category) { |
164 | 169 | $dbr = wfGetDB( DB_SLAVE ); |
165 | 170 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
166 | 171 | $res = $dbr->query("SELECT cl_from FROM $categorylinks WHERE cl_to = '$category'"); |
— | — | @@ -172,7 +177,7 @@ |
173 | 178 | } |
174 | 179 | */ |
175 | 180 | |
176 | | -function getPagesForNamespace( $namespace ) { |
| 181 | +static function getPagesForNamespace( $namespace ) { |
177 | 182 | $dbr = wfGetDB( DB_SLAVE ); |
178 | 183 | $page = $dbr->tableName( 'page' ); |
179 | 184 | $res = $dbr->query( "SELECT page_id FROM $page WHERE page_namespace = '$namespace'" ); |
— | — | @@ -184,28 +189,28 @@ |
185 | 190 | return $titles; |
186 | 191 | } |
187 | 192 | |
188 | | -/** |
189 | | - * Helper function for getXMLForPage() |
190 | | - */ |
191 | | -function treeContainsElement( $tree, $element ) { |
192 | | - // escape out if there's no tree (i.e., category) |
193 | | - if ( $tree == null ) |
194 | | - return false; |
| 193 | + /** |
| 194 | + * Helper function for getXMLForPage() |
| 195 | + */ |
| 196 | + static function treeContainsElement( $tree, $element ) { |
| 197 | + // escape out if there's no tree (i.e., category) |
| 198 | + if ( $tree == null ) |
| 199 | + return false; |
195 | 200 | |
196 | | - foreach ( $tree as $node => $child_tree ) { |
197 | | - if ( $node === $element ) { |
198 | | - return true; |
199 | | - } elseif ( count( $child_tree ) > 0 ) { |
200 | | - if ( treeContainsElement( $child_tree, $element ) ) { |
| 201 | + foreach ( $tree as $node => $child_tree ) { |
| 202 | + if ( $node === $element ) { |
201 | 203 | return true; |
| 204 | + } elseif ( count( $child_tree ) > 0 ) { |
| 205 | + if ( self::treeContainsElement( $child_tree, $element ) ) { |
| 206 | + return true; |
| 207 | + } |
202 | 208 | } |
203 | 209 | } |
| 210 | + // no match found |
| 211 | + return false; |
204 | 212 | } |
205 | | - // no match found |
206 | | - return false; |
207 | | -} |
208 | 213 | |
209 | | -function getXMLForPage( $title, $simplified_format, $groupings, $depth = 0 ) { |
| 214 | +static function getXMLForPage( $title, $simplified_format, $groupings, $depth = 0 ) { |
210 | 215 | if ( $depth > 5 ) { return ""; } |
211 | 216 | |
212 | 217 | global $wgContLang, $dtgContLang; |
— | — | @@ -225,11 +230,12 @@ |
226 | 231 | $dt_props = $dtgContLang->getPropertyLabels(); |
227 | 232 | // $exclusion_category = $title->newFromText($dt_props[DT_SP_IS_EXCLUDED_FROM_XML], NS_CATEGORY); |
228 | 233 | $exclusion_category = $wgContLang->getNSText( NS_CATEGORY ) . ':' . str_replace( ' ', '_', $dt_props[DT_SP_IS_EXCLUDED_FROM_XML] ); |
229 | | - if ( treeContainsElement( $parent_categories, $exclusion_category ) ) |
| 234 | + if ( self::treeContainsElement( $parent_categories, $exclusion_category ) ) |
230 | 235 | return ""; |
231 | 236 | $article = new Article( $title ); |
232 | 237 | $page_title = str_replace( '"', '"', $title->getText() ); |
233 | 238 | $page_title = str_replace( '&', '&', $page_title ); |
| 239 | + $page_namespace = $title->getNamespace(); |
234 | 240 | if ( $simplified_format ) |
235 | 241 | $text = "<$page_str><$id_str>{$article->getID()}</$id_str><$title_str>$page_title</$title_str>\n"; |
236 | 242 | else |
— | — | @@ -376,11 +382,16 @@ |
377 | 383 | $store = smwfGetStore(); |
378 | 384 | foreach ( $groupings as $pair ) { |
379 | 385 | list( $property_page, $grouping_label ) = $pair; |
380 | | - $wiki_page = SMWDataValueFactory::newTypeIDValue( '_wpg', $page_title ); |
381 | 386 | $options = new SMWRequestOptions(); |
382 | 387 | $options->sort = "subject_title"; |
383 | 388 | // get actual property from the wiki-page of the property |
384 | | - $property = SMWPropertyValue::makeProperty( $property_page->getTitle()->getText() ); |
| 389 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 390 | + $wiki_page = new SMWDIWikiPage( $page_title, $page_namespace, null ); |
| 391 | + $property = SMWDIProperty::newFromUserLabel( $property_page->getTitle()->getText() ); |
| 392 | + } else { |
| 393 | + $wiki_page = SMWDataValueFactory::newTypeIDValue( '_wpg', $page_title ); |
| 394 | + $property = SMWPropertyValue::makeProperty( $property_page->getTitle()->getText() ); |
| 395 | + } |
385 | 396 | $res = $store->getPropertySubjects( $property, $wiki_page, $options ); |
386 | 397 | $num = count( $res ); |
387 | 398 | if ( $num > 0 ) { |
— | — | @@ -388,7 +399,7 @@ |
389 | 400 | $text .= "<$grouping_label>\n"; |
390 | 401 | foreach ( $res as $subject ) { |
391 | 402 | $subject_title = $subject->getTitle(); |
392 | | - $text .= getXMLForPage( $subject_title, $simplified_format, $groupings, $depth + 1 ); |
| 403 | + $text .= self::getXMLForPage( $subject_title, $simplified_format, $groupings, $depth + 1 ); |
393 | 404 | } |
394 | 405 | $text .= "</$grouping_label>\n"; |
395 | 406 | } |
— | — | @@ -402,108 +413,113 @@ |
403 | 414 | return $text; |
404 | 415 | } |
405 | 416 | |
406 | | -function doSpecialViewXML() { |
407 | | - global $wgOut, $wgRequest, $wgUser, $wgContLang; |
408 | | - $skin = $wgUser->getSkin(); |
409 | | - $namespace_labels = $wgContLang->getNamespaces(); |
410 | | - $category_label = $namespace_labels[NS_CATEGORY]; |
411 | | - $template_label = $namespace_labels[NS_TEMPLATE]; |
412 | | - $name_str = str_replace( ' ', '_', wfMsgForContent( 'dt_xml_name' ) ); |
413 | | - $namespace_str = str_replace( ' ', '_', wfMsg( 'dt_xml_namespace' ) ); |
414 | | - $pages_str = str_replace( ' ', '_', wfMsgForContent( 'dt_xml_pages' ) ); |
| 417 | + static function doSpecialViewXML() { |
| 418 | + global $wgOut, $wgRequest, $wgUser, $wgContLang; |
415 | 419 | |
416 | | - $form_submitted = false; |
417 | | - $page_titles = array(); |
418 | | - $cats = $wgRequest->getArray( 'categories' ); |
419 | | - $nses = $wgRequest->getArray( 'namespaces' ); |
420 | | - if ( count( $cats ) > 0 || count( $nses ) > 0 ) { |
421 | | - $form_submitted = true; |
422 | | - } |
| 420 | + $skin = $wgUser->getSkin(); |
| 421 | + $namespace_labels = $wgContLang->getNamespaces(); |
| 422 | + $category_label = $namespace_labels[NS_CATEGORY]; |
| 423 | + $template_label = $namespace_labels[NS_TEMPLATE]; |
| 424 | + $name_str = str_replace( ' ', '_', wfMsgForContent( 'dt_xml_name' ) ); |
| 425 | + $namespace_str = str_replace( ' ', '_', wfMsg( 'dt_xml_namespace' ) ); |
| 426 | + $pages_str = str_replace( ' ', '_', wfMsgForContent( 'dt_xml_pages' ) ); |
423 | 427 | |
424 | | - if ( $form_submitted ) { |
425 | | - $wgOut->disable(); |
| 428 | + $form_submitted = false; |
| 429 | + $page_titles = array(); |
| 430 | + $cats = $wgRequest->getArray( 'categories' ); |
| 431 | + $nses = $wgRequest->getArray( 'namespaces' ); |
| 432 | + if ( count( $cats ) > 0 || count( $nses ) > 0 ) { |
| 433 | + $form_submitted = true; |
| 434 | + } |
426 | 435 | |
427 | | - // Cancel output buffering and gzipping if set |
428 | | - // This should provide safer streaming for pages with history |
429 | | - wfResetOutputBuffers(); |
430 | | - header( "Content-type: application/xml; charset=utf-8" ); |
| 436 | + if ( $form_submitted ) { |
| 437 | + $wgOut->disable(); |
431 | 438 | |
432 | | - $groupings = getGroupings(); |
433 | | - $simplified_format = $wgRequest->getVal( 'simplified_format' ); |
434 | | - $text = "<$pages_str>"; |
435 | | - if ( $cats ) { |
436 | | - foreach ( $cats as $cat => $val ) { |
437 | | - if ( $simplified_format ) |
438 | | - $text .= '<' . str_replace( ' ', '_', $cat ) . ">\n"; |
439 | | - else |
440 | | - $text .= "<$category_label $name_str=\"$cat\">\n"; |
441 | | - $titles = getPagesForCategory( $cat, 10 ); |
442 | | - foreach ( $titles as $title ) { |
443 | | - $text .= getXMLForPage( $title, $simplified_format, $groupings ); |
| 439 | + // Cancel output buffering and gzipping if set |
| 440 | + // This should provide safer streaming for pages with history |
| 441 | + wfResetOutputBuffers(); |
| 442 | + header( "Content-type: application/xml; charset=utf-8" ); |
| 443 | + |
| 444 | + $groupings = self::getGroupings(); |
| 445 | + $simplified_format = $wgRequest->getVal( 'simplified_format' ); |
| 446 | + $text = "<$pages_str>"; |
| 447 | + if ( $cats ) { |
| 448 | + foreach ( $cats as $cat => $val ) { |
| 449 | + if ( $simplified_format ) |
| 450 | + $text .= '<' . str_replace( ' ', '_', $cat ) . ">\n"; |
| 451 | + else |
| 452 | + $text .= "<$category_label $name_str=\"$cat\">\n"; |
| 453 | + $titles = self::getPagesForCategory( $cat, 10 ); |
| 454 | + foreach ( $titles as $title ) { |
| 455 | + $text .= self::getXMLForPage( $title, $simplified_format, $groupings ); |
| 456 | + } |
| 457 | + if ( $simplified_format ) { |
| 458 | + $text .= '</' . str_replace( ' ', '_', $cat ) . ">\n"; |
| 459 | + } else { |
| 460 | + $text .= "</$category_label>\n"; |
| 461 | + } |
444 | 462 | } |
445 | | - if ( $simplified_format ) |
446 | | - $text .= '</' . str_replace( ' ', '_', $cat ) . ">\n"; |
447 | | - else |
448 | | - $text .= "</$category_label>\n"; |
449 | 463 | } |
450 | | - } |
451 | 464 | |
452 | | - if ( $nses ) { |
453 | | - foreach ( $nses as $ns => $val ) { |
454 | | - if ( $ns == 0 ) { |
455 | | - $ns_name = "Main"; |
456 | | - } else { |
457 | | - $ns_name = MWNamespace::getCanonicalName( $ns ); |
| 465 | + if ( $nses ) { |
| 466 | + foreach ( $nses as $ns => $val ) { |
| 467 | + if ( $ns == 0 ) { |
| 468 | + $ns_name = "Main"; |
| 469 | + } else { |
| 470 | + $ns_name = MWNamespace::getCanonicalName( $ns ); |
| 471 | + } |
| 472 | + if ( $simplified_format ) { |
| 473 | + $text .= '<' . str_replace( ' ', '_', $ns_name ) . ">\n"; |
| 474 | + } else { |
| 475 | + $text .= "<$namespace_str $name_str=\"$ns_name\">\n"; |
| 476 | + } |
| 477 | + $titles = self::getPagesForNamespace( $ns ); |
| 478 | + foreach ( $titles as $title ) { |
| 479 | + $text .= self::getXMLForPage( $title, $simplified_format, $groupings ); |
| 480 | + } |
| 481 | + if ( $simplified_format ) |
| 482 | + $text .= '</' . str_replace( ' ', '_', $ns_name ) . ">\n"; |
| 483 | + else |
| 484 | + $text .= "</$namespace_str>\n"; |
458 | 485 | } |
459 | | - if ( $simplified_format ) |
460 | | - $text .= '<' . str_replace( ' ', '_', $ns_name ) . ">\n"; |
461 | | - else |
462 | | - $text .= "<$namespace_str $name_str=\"$ns_name\">\n"; |
463 | | - $titles = getPagesForNamespace( $ns ); |
464 | | - foreach ( $titles as $title ) { |
465 | | - $text .= getXMLForPage( $title, $simplified_format, $groupings ); |
466 | | - } |
467 | | - if ( $simplified_format ) |
468 | | - $text .= '</' . str_replace( ' ', '_', $ns_name ) . ">\n"; |
469 | | - else |
470 | | - $text .= "</$namespace_str>\n"; |
471 | 486 | } |
472 | | - } |
473 | | - $text .= "</$pages_str>"; |
474 | | - print $text; |
475 | | - } else { |
476 | | - // set 'title' as hidden field, in case there's no URL niceness |
477 | | - global $wgContLang; |
478 | | - $mw_namespace_labels = $wgContLang->getNamespaces(); |
479 | | - $special_namespace = $mw_namespace_labels[NS_SPECIAL]; |
480 | | - $text = <<<END |
| 487 | + $text .= "</$pages_str>"; |
| 488 | + print $text; |
| 489 | + } else { |
| 490 | + // set 'title' as hidden field, in case there's no URL niceness |
| 491 | + global $wgContLang; |
| 492 | + $mw_namespace_labels = $wgContLang->getNamespaces(); |
| 493 | + $special_namespace = $mw_namespace_labels[NS_SPECIAL]; |
| 494 | + $text = <<<END |
481 | 495 | <form action="" method="get"> |
482 | 496 | <input type="hidden" name="title" value="$special_namespace:ViewXML"> |
483 | 497 | |
484 | 498 | END; |
485 | | - $text .= "<p>" . wfMsg( 'dt_viewxml_docu' ) . "</p>\n"; |
486 | | - $text .= "<h2>" . wfMsg( 'dt_viewxml_categories' ) . "</h2>\n"; |
487 | | - $categories = getCategoriesList(); |
488 | | - foreach ( $categories as $category ) { |
489 | | - $title = Title::makeTitle( NS_CATEGORY, $category ); |
490 | | - $link = $skin->makeLinkObj( $title, htmlspecialchars( $title->getText() ) ); |
491 | | - $text .= "<input type=\"checkbox\" name=\"categories[$category]\" /> $link <br />\n"; |
492 | | - } |
493 | | - $text .= "<h2>" . wfMsg( 'dt_viewxml_namespaces' ) . "</h2>\n"; |
494 | | - $namespaces = getNamespacesList(); |
495 | | - foreach ( $namespaces as $namespace ) { |
496 | | - if ( $namespace == 0 ) { |
497 | | - $ns_name = wfMsgHtml( 'blanknamespace' ); |
498 | | - } else { |
499 | | - $ns_name = htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) ); |
| 499 | + $text .= "<p>" . wfMsg( 'dt_viewxml_docu' ) . "</p>\n"; |
| 500 | + $text .= "<h2>" . wfMsg( 'dt_viewxml_categories' ) . "</h2>\n"; |
| 501 | + $categories = getCategoriesList(); |
| 502 | + foreach ( $categories as $category ) { |
| 503 | + $title = Title::makeTitle( NS_CATEGORY, $category ); |
| 504 | + $link = $skin->makeLinkObj( $title, $title->getText() ); |
| 505 | + $text .= "<input type=\"checkbox\" name=\"categories[$category]\" /> $link <br />\n"; |
500 | 506 | } |
501 | | - $ns_name = str_replace( '_', ' ', $ns_name ); |
502 | | - $text .= "<input type=\"checkbox\" name=\"namespaces[$namespace]\" /> $ns_name <br />\n"; |
| 507 | + $text .= "<h2>" . wfMsg( 'dt_viewxml_namespaces' ) . "</h2>\n"; |
| 508 | + $namespaces = getNamespacesList(); |
| 509 | + foreach ( $namespaces as $namespace ) { |
| 510 | + if ( $namespace == 0 ) { |
| 511 | + $ns_name = wfMsgHtml( 'blanknamespace' ); |
| 512 | + } else { |
| 513 | + $ns_name = htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) ); |
| 514 | + } |
| 515 | + $ns_name = str_replace( '_', ' ', $ns_name ); |
| 516 | + $text .= "<input type=\"checkbox\" name=\"namespaces[$namespace]\" /> $ns_name <br />\n"; |
| 517 | + } |
| 518 | + $text .= "<br /><p><input type=\"checkbox\" name=\"simplified_format\" /> " . wfMsg( 'dt_viewxml_simplifiedformat' ) . "</p>\n"; |
| 519 | + $text .= "<input type=\"submit\" value=\"" . wfMsg( 'viewxml' ) . "\">\n"; |
| 520 | + $text .= "</form>\n"; |
| 521 | + |
| 522 | + $wgOut->addHTML( $text ); |
503 | 523 | } |
504 | | - $text .= "<br /><p><input type=\"checkbox\" name=\"simplified_format\" /> " . wfMsg( 'dt_viewxml_simplifiedformat' ) . "</p>\n"; |
505 | | - $text .= "<input type=\"submit\" value=\"" . wfMsg( 'viewxml' ) . "\">\n"; |
506 | | - $text .= "</form>\n"; |
| 524 | + } |
507 | 525 | |
508 | | - $wgOut->addHTML( $text ); |
509 | | - } |
510 | 526 | } |