Yaron Koren has submitted this change and it was merged.

Change subject: Changed handling of blank aliases in Cargo queries
......................................................................


Changed handling of blank aliases in Cargo queries

Blank aliases are assigned internal aliases of the form
"Blank value X", where X is different for each blank alias.
The alias is mapped back to blank before being displayed.

Bug: T91222
Change-Id: I32c92d3167d8bb9647c7a0ec32acdeb4df2a7c09
---
M CargoSQLQuery.php
M formats/CargoDynamicTableFormat.php
M formats/CargoListFormat.php
M formats/CargoTableFormat.php
4 files changed, 28 insertions(+), 5 deletions(-)

Approvals:
  Yaron Koren: Verified; Looks good to me, approved



diff --git a/CargoSQLQuery.php b/CargoSQLQuery.php
index 0dae5e5..fa8c7cb 100644
--- a/CargoSQLQuery.php
+++ b/CargoSQLQuery.php
@@ -127,7 +127,10 @@
                                . "please use \"group by=\" instead." );
                        }
                }
-
+               // For using "Blank value $countBlankAlias" as key in case of 
blank aliases,
+               // as aliases are used as keys and hence cannot be left 
blank.This is done so
+               // that field values in query results can be displayed without 
field name.
+               $countBlankAlias = 0;
                foreach ( $fieldNames as $i => $fieldName ) {
                        $fieldNameParts = CargoUtils::smartSplit( '=', 
$fieldName );
                        if ( count( $fieldNameParts ) == 2 ) {
@@ -149,6 +152,10 @@
                                        $alias = $realFieldName;
                                }
                        }
+                       if ( empty( $alias ) ) {
+                               $countBlankAlias++;
+                               $alias = "Blank value $countBlankAlias";
+                       }
                        $this->mAliasedFieldNames[$alias] = $fieldName;
                }
        }
diff --git a/formats/CargoDynamicTableFormat.php 
b/formats/CargoDynamicTableFormat.php
index 6967cb8..ad91168 100644
--- a/formats/CargoDynamicTableFormat.php
+++ b/formats/CargoDynamicTableFormat.php
@@ -32,7 +32,12 @@
 
 END;
                foreach ( $fieldDescriptions as $fieldName => $fieldDescription 
) {
-                       $text .= "\t\t\t\t" . Html::element( 'th', null, 
$fieldName );
+                       if ( strpos( $fieldName, 'Blank value ' ) === false ) {
+                               $text .= "\t\t\t\t" . Html::element( 'th', 
null, $fieldName );
+                       }
+                       else {
+                               $text .= "\t\t\t\t" . Html::element( 'th', 
null, null );
+                       }
                }
 
                $text .=<<<END
@@ -45,7 +50,12 @@
 END;
 
                foreach ( $fieldDescriptions as $fieldName => $fieldDescription 
) {
-                       $text .= "\t\t\t\t" . Html::element( 'th', null, 
$fieldName );
+                       if ( strpos( $fieldName, 'Blank value ' ) === false ) {
+                               $text .= "\t\t\t\t" . Html::element( 'th', 
null, $fieldName );
+                       }
+                       else {
+                               $text .= "\t\t\t\t" . Html::element( 'th', 
null, null );
+                       }
                }
 
                $text .=<<<END
diff --git a/formats/CargoListFormat.php b/formats/CargoListFormat.php
index 0c634d0..95bffa1 100644
--- a/formats/CargoListFormat.php
+++ b/formats/CargoListFormat.php
@@ -43,7 +43,11 @@
                                } else {
                                        $text .= ', ';
                                }
-                               $text .= "<span 
class=\"cargoFieldName\">$fieldName:</span> $fieldValue";
+                               if ( empty( $fieldName ) || strpos( $fieldName, 
'Blank value ' ) !== false ) {
+                                       $text .= $fieldValue;
+                               } else {
+                                       $text .= "<span 
class=\"cargoFieldName\">$fieldName:</span> $fieldValue";
+                               }
                        }
                }
                if ( $startParenthesisAdded ) {
diff --git a/formats/CargoTableFormat.php b/formats/CargoTableFormat.php
index 388d06f..371b0a4 100644
--- a/formats/CargoTableFormat.php
+++ b/formats/CargoTableFormat.php
@@ -24,7 +24,9 @@
                $text = '<table class="cargoTable">';
                $text .= '<tr>';
                foreach ( array_keys( $fieldDescriptions ) as $field ) {
-                       $text .= Html::rawElement( 'th', null, $field ) . "\n";
+                       if ( strpos( $field, 'Blank value ' ) === false ) {
+                               $text .= Html::rawElement( 'th', null, $field ) 
. "\n";
+                       }
                }
                $text .= "</tr>\n";
                foreach ( $formattedValuesTable as $row ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/195036
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I32c92d3167d8bb9647c7a0ec32acdeb4df2a7c09
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Namit <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to