r47168 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47167‎ | r47168 | r47169 >
Date:22:57, 11 February 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added handling for sites with no URL niceness
Modified paths:
  • /trunk/extensions/DataTransfer/specials/DT_ViewXML.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransfer/specials/DT_ViewXML.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Shows list of all forms on the site.
 4+ * Displays an interface to let the user export pages from the wiki in XML form
55 *
66 * @author Yaron Koren
77 */
@@ -27,7 +27,7 @@
2828
2929 function getCategoriesList() {
3030 global $wgContLang, $dtgContLang;
31 - $dt_props = $dtgContLang->getSpecialPropertiesArray();
 31+ $dt_props = $dtgContLang->getPropertyLabels();
3232 $exclusion_cat_name = str_replace(' ', '_', $dt_props[DT_SP_IS_EXCLUDED_FROM_XML]);
3333 $exclusion_cat_full_name = $wgContLang->getNSText(NS_CATEGORY) . ':' . $exclusion_cat_name;
3434 $dbr = wfGetDB( DB_SLAVE );
@@ -66,7 +66,7 @@
6767 function getGroupings() {
6868 global $dtgContLang;
6969
70 - $dt_props = $dtgContLang->getSpecialPropertiesArray();
 70+ $dt_props = $dtgContLang->getPropertyLabels();
7171 $xml_grouping_prop = str_replace(' ', '_', $dt_props[DT_SP_HAS_XML_GROUPING]);
7272
7373 global $smwgIP;
@@ -241,7 +241,7 @@
242242
243243 // if this page belongs to the exclusion category, exit
244244 $parent_categories = $title->getParentCategoryTree(array());
245 - $dt_props = $dtgContLang->getSpecialPropertiesArray();
 245+ $dt_props = $dtgContLang->getPropertyLabels();
246246 //$exclusion_category = $title->newFromText($dt_props[DT_SP_IS_EXCLUDED_FROM_XML], NS_CATEGORY);
247247 $exclusion_category = $wgContLang->getNSText(NS_CATEGORY) . ':' . str_replace(' ', '_', $dt_props[DT_SP_IS_EXCLUDED_FROM_XML]);
248248 if (treeContainsElement($parent_categories, $exclusion_category))
@@ -491,31 +491,38 @@
492492 $text .= "</Pages>";
493493 print $text;
494494 } else {
495 - $text = "<form action=\"\" method=\"get\">\n";
496 - $text .= "<p>" . wfMsg('dt_viewxml_docu') . "</p>\n";
497 - $text .= "<h2>" . wfMsg('dt_viewxml_categories') . "</h2>\n";
498 - $categories = getCategoriesList();
499 - foreach ($categories as $category) {
500 - $title = Title::makeTitle( NS_CATEGORY, $category );
501 - $link = $skin->makeLinkObj( $title, $title->getText() );
502 - $text .= "<input type=\"checkbox\" name=\"categories[$category]\" /> $link <br />\n";
503 - }
504 - $text .= "<h2>" . wfMsg('dt_viewxml_namespaces') . "</h2>\n";
505 - $namespaces = getNamespacesList();
506 - foreach ($namespaces as $namespace) {
507 - if ($namespace == 0) {
508 - $ns_name = "Main";
509 - } else {
510 - $ns_name = $wgCanonicalNamespaceNames["$namespace"];
 495+ // set 'title' as hidden field, in case there's no URL niceness
 496+ global $wgContLang;
 497+ $mw_namespace_labels = $wgContLang->getNamespaces();
 498+ $special_namespace = $mw_namespace_labels[NS_SPECIAL];
 499+ $text =<<<END
 500+ <form action="" method="get">
 501+ <input type="hidden" name="title" value="$special_namespace:ViewXML">
 502+
 503+END;
 504+ $text .= "<p>" . wfMsg('dt_viewxml_docu') . "</p>\n";
 505+ $text .= "<h2>" . wfMsg('dt_viewxml_categories') . "</h2>\n";
 506+ $categories = getCategoriesList();
 507+ foreach ($categories as $category) {
 508+ $title = Title::makeTitle( NS_CATEGORY, $category );
 509+ $link = $skin->makeLinkObj( $title, $title->getText() );
 510+ $text .= "<input type=\"checkbox\" name=\"categories[$category]\" /> $link <br />\n";
511511 }
512 - $ns_name = str_replace('_', ' ', $ns_name);
513 - $text .= "<input type=\"checkbox\" name=\"namespaces[$namespace]\" /> $ns_name <br />\n";
514 - }
515 - $text .= "<br /><p><input type=\"checkbox\" name=\"simplified_format\" /> " . wfMsg('dt_viewxml_simplifiedformat') . "</p>\n";
516 - $text .= "<input type=\"submit\" value=\"" . wfMsg('viewxml') . "\">\n";
517 - $text .= "</form>\n";
 512+ $text .= "<h2>" . wfMsg('dt_viewxml_namespaces') . "</h2>\n";
 513+ $namespaces = getNamespacesList();
 514+ foreach ($namespaces as $namespace) {
 515+ if ($namespace == 0) {
 516+ $ns_name = "Main";
 517+ } else {
 518+ $ns_name = $wgCanonicalNamespaceNames["$namespace"];
 519+ }
 520+ $ns_name = str_replace('_', ' ', $ns_name);
 521+ $text .= "<input type=\"checkbox\" name=\"namespaces[$namespace]\" /> $ns_name <br />\n";
 522+ }
 523+ $text .= "<br /><p><input type=\"checkbox\" name=\"simplified_format\" /> " . wfMsg('dt_viewxml_simplifiedformat') . "</p>\n";
 524+ $text .= "<input type=\"submit\" value=\"" . wfMsg('viewxml') . "\">\n";
 525+ $text .= "</form>\n";
518526
519 - $wgOut->addHTML($text);
520 -
 527+ $wgOut->addHTML($text);
521528 }
522529 }

Status & tagging log