In Special:Drilldown and in query results, each page is displayed with its namespace. Often it would look neater not to have the namespace displayed (particularly if all results are in the same namespace).
Here is a patch which I hope fixes this.
- It adds a new global variable $wgCargoDrilldownHideNamespace with a default of false. If this is set to true in LocalSettings.php then Special:Drilldown will hide every page's namespace (though the links still go to the right namespace). In hindsight, this could have been an array to set the option per table.
- It allows for a new query parameter in the form {{ # cargo_query:...|hidenamespace=true}} which has the same effect for query results. I've checked this out in table, dymanic table and googlemaps result formats and it appears to work fine.
- It seems to work with compound queries in the format {{ # cargo_compound_query:tables=...;hidenamespace=true|tables=...;hidenamespace=true|...}}
diff --git a/Cargo.php b/Cargo.php index 19b8a34..9a8b747 100644 --- a/Cargo.php +++ b/Cargo.php @@ -331,6 +331,7 @@ $wgCargoDrilldownSmallestFontSize = -1; $wgCargoDrilldownLargestFontSize = -1; $wgCargoDrilldownMinValuesForComboBox = 40; $wgCargoDrilldownNumRangesForNumbers = 5; +$wgCargoDrilldownHideNamespace = false; #xxx $wgCargoPageDataColumns = array(); $wgCargoFileDataColumns = array(); \ No newline at end of file diff --git a/CargoQueryDisplayer.php b/CargoQueryDisplayer.php index 30a20f4..1a909f2 100644 --- a/CargoQueryDisplayer.php +++ b/CargoQueryDisplayer.php @@ -94,6 +94,11 @@ class CargoQueryDisplayer { } $fieldDescription = $this->mFieldDescriptions[$fieldName]; + + if ( $this->mDisplayParams['hidenamespace'] == 'true' ) { #xxx + $fieldDescription->mOtherParams['hidenamespace'] = true; + } + $tableName = $this->mFieldTables[$fieldName]; $fieldType = $fieldDescription->mType; @@ -176,7 +181,11 @@ class CargoQueryDisplayer { $wgCargoDigitGroupingCharacter ); } elseif ( $type == 'Page' ) { $title = Title::newFromText( $value ); - return Linker::link( $title ); + if ( $fieldDescription->mOtherParams['hidenamespace'] == 'true' ) { #xxx + return Linker::link( $title , $title->getRootText() ); + } else { + return Linker::link( $title ); + } } elseif ( $type == 'File' ) { // 'File' values are basically pages in the File: // namespace; they are displayed as thumbnails within diff --git a/drilldown/CargoSpecialDrilldown.php b/drilldown/CargoSpecialDrilldown.php index 7618e29..919a047 100644 --- a/drilldown/CargoSpecialDrilldown.php +++ b/drilldown/CargoSpecialDrilldown.php @@ -1332,6 +1332,12 @@ END; $queryDisplayer = new CargoQueryDisplayer(); $fieldDescription = new CargoFieldDescription(); $fieldDescription->mType = 'Page'; + + global $wgCargoDrilldownHideNamespace; #xxx + if ($wgCargoDrilldownHideNamespace) { + $fieldDescription->mOtherParams['hidenamespace'] = true; + } + $queryDisplayer->mFieldDescriptions = array( 'title' => $fieldDescription ); if ( $this->fullTextSearchTerm != null ) { diff --git a/parserfunctions/CargoCompoundQuery.php b/parserfunctions/CargoCompoundQuery.php index e6d12bc..0019ed8 100644 --- a/parserfunctions/CargoCompoundQuery.php +++ b/parserfunctions/CargoCompoundQuery.php @@ -137,6 +137,9 @@ class CargoCompoundQuery { $queryResults = $sqlQuery->run(); $allQueryResults = array_merge( $allQueryResults, $queryResults ); $queryDisplayer->mFieldDescriptions = $sqlQuery->mFieldDescriptions; + + $queryDisplayer->mDisplayParams = $querySpecificParams[$rowNum]; #xxx + $formattedQueryResults = array_merge( $formattedQueryResults, $queryDisplayer->getFormattedQueryResults( $queryResults ) ); //$formattedQueryResultsArray[] = $formattedQueryResults;