Fz-29 has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/372563 )
Change subject: Perform literal "drilldown" in the applied filter line for
hierarchy field in case of within filter.
......................................................................
Perform literal "drilldown" in the applied filter line for hierarchy field in
case of within filter.
Change-Id: I4eff3f1660538cb75930123543940192e62b24ba
---
M drilldown/CargoSpecialDrilldown.php
1 file changed, 41 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo
refs/changes/63/372563/1
diff --git a/drilldown/CargoSpecialDrilldown.php
b/drilldown/CargoSpecialDrilldown.php
index f7ff850..8df5003 100644
--- a/drilldown/CargoSpecialDrilldown.php
+++ b/drilldown/CargoSpecialDrilldown.php
@@ -413,6 +413,9 @@
* at least one value set
*/
function printAppliedFilterLine( $af ) {
+ if ( $af->filter->fieldDescription->mIsHierarchy ) {
+ return $this->printAppliedFilterLineForHierarchy( $af );
+ }
$results_line = "";
$current_filter_values = array();
foreach ( $this->applied_filters as $af2 ) {
@@ -486,6 +489,36 @@
return $this->printFilterLine( $af->filter->name, true, true,
$results_line );
}
+ function printAppliedFilterLineForHierarchy( $af ) {
+ $applied_filters = $this->applied_filters;
+ $cur_url = $this->makeBrowseURL( $this->tableName,
$this->fullTextSearchTerm, array() );
+ $cur_url .= ( strpos( $cur_url, '?' ) ) ? '&' : '?';
+ // Drilldown for hierarchy is designed for literal 'drilldown'
and focuses on single filter value in case of 'within'
+ if ( count($af->values) > 0 ) {
+ $filter_value = $af->values[0]->text;
+ $matches = array();
+ if ( preg_match( "/^~within (.+)/", $filter_value,
$matches ) ) {
+ $filter_value = $matches[1];
+ }
+ }
+ $drilldownHierarchyRoot =
CargoDrilldownHierarchy::newFromWikiText(
$af->filter->fieldDescription->mHierarchyStructure );
+ $stack = new SplStack();
+ // preorder traversal of the tree
+ $stack->push( $drilldownHierarchyRoot );
+ while ( !$stack->isEmpty() ) {
+ $node = $stack->pop();
+ if ( $node->mRootValue === $filter_value ) {
+ $drilldownHierarchyRoot = $node;
+ break;
+ }
+ for( $i = count( $node->mChildren ) - 1; $i >= 0; $i--
) {
+ $stack->push( $node->mChildren[$i] );
+ }
+ }
+ $results_line = $this->printFilterValuesForHierarchy( $cur_url,
$af->filter, null, $applied_filters, $drilldownHierarchyRoot );
+ return $this->printFilterLine( $af->filter->name, true, true,
$results_line );
+ }
+
function printUnappliedFilterValues( $cur_url, $f, $filter_values ) {
$results_line = "";
// now print the values
@@ -502,16 +535,20 @@
}
function printUnappliedFilterValuesForHierarchy( $cur_url, $f,
$fullTextSearchTerm, $applied_filters ) {
- $results_line = "";
// construct the tree of CargoDrilldownHierarchy
- $drilldownHierarchyTreeRoot =
CargoDrilldownHierarchy::newFromWikiText(
$f->fieldDescription->mHierarchyStructure );
+ $drilldownHierarchyRoot =
CargoDrilldownHierarchy::newFromWikiText(
$f->fieldDescription->mHierarchyStructure );
+ return $this->printFilterValuesForHierarchy( $cur_url, $f,
$fullTextSearchTerm, $applied_filters, $drilldownHierarchyRoot );
+ }
+
+ function printFilterValuesForHierarchy( $cur_url, $f,
$fullTextSearchTerm, $applied_filters, $drilldownHierarchyRoot ) {
// compute counts
- $filter_values =
CargoDrilldownHierarchy::computeNodeCountForTreeByFilter(
$drilldownHierarchyTreeRoot,
+ $filter_values =
CargoDrilldownHierarchy::computeNodeCountForTreeByFilter(
$drilldownHierarchyRoot,
$f, $fullTextSearchTerm, $applied_filters );
+ $results_line = "";
$num_printed_values = 0;
$stack = new SplStack();
// preorder traversal of the tree
- $stack->push( $drilldownHierarchyTreeRoot );
+ $stack->push( $drilldownHierarchyRoot );
while ( !$stack->isEmpty() ) {
$node = $stack->pop();
if ( $node != ")" ) {
--
To view, visit https://gerrit.wikimedia.org/r/372563
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4eff3f1660538cb75930123543940192e62b24ba
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Fz-29 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits