jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/395805 )

Change subject: New query param, 'max display chars'
......................................................................


New query param, 'max display chars'

Change-Id: Ib7cb0d8bfae7c1fbbb3fff2869580137470708aa
---
M includes/CargoQueryDisplayer.php
M specials/CargoTables.php
2 files changed, 14 insertions(+), 15 deletions(-)

Approvals:
  Yaron Koren: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/CargoQueryDisplayer.php b/includes/CargoQueryDisplayer.php
index 7ca23ab..b5e384d 100644
--- a/includes/CargoQueryDisplayer.php
+++ b/includes/CargoQueryDisplayer.php
@@ -155,6 +155,14 @@
                                } else {
                                        $text = self::formatFieldValue( $value, 
$fieldType, $fieldDescription, $this->mParser );
                                }
+
+                               if ( array_key_exists( 'max display chars', 
$this->mDisplayParams ) && ( $fieldType == 'Text' || $fieldType == 'Wikitext' ) 
) {
+                                       $maxDisplayChars = 
$this->mDisplayParams['max display chars'];
+                                       if ( strlen( $text ) > $maxDisplayChars 
&& strlen( strip_tags( $text ) ) > $maxDisplayChars ) {
+                                               $text = '<span 
class="cargoMinimizedText">' . $text . '</span>';
+                                       }
+                               }
+
                                if ( $text != '' ) {
                                        
$formattedQueryResults[$rowNum][$fieldName] = $text;
                                }
diff --git a/specials/CargoTables.php b/specials/CargoTables.php
index 5ad69ac..9fef7fd 100644
--- a/specials/CargoTables.php
+++ b/specials/CargoTables.php
@@ -176,22 +176,13 @@
 
                $queryResults = $sqlQuery->run();
 
-               $queryDisplayer = CargoQueryDisplayer::newFromSQLQuery( 
$sqlQuery );
-               $formattedQueryResults = 
$queryDisplayer->getFormattedQueryResults( $queryResults );
-
-               // Modify values to minimize cells that have more than a
-               // certain number of characters, to make the table more
-               // readable.
-               $maxChars = 300;
-               foreach ( $formattedQueryResults as $rowNum => $row ) {
-                       foreach ( $row as $colNum => $value ) {
-                               if ( strlen( $value ) > $maxChars && strlen( 
strip_tags( $value ) ) > $maxChars ) {
-                                       
$formattedQueryResults[$rowNum][$colNum] = '<span class="cargoMinimizedText">' 
. $value . '</span>';
-                               }
-                       }
-               }
-
                $displayParams = array();
+               $displayParams['max display chars'] = 300;
+
+
+               $queryDisplayer = CargoQueryDisplayer::newFromSQLQuery( 
$sqlQuery );
+               $queryDisplayer->mDisplayParams = $displayParams;
+               $formattedQueryResults = 
$queryDisplayer->getFormattedQueryResults( $queryResults );
 
                $tableFormat = new CargoTableFormat( $this->getOutput() );
                $text = $tableFormat->display( $queryResults, 
$formattedQueryResults,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib7cb0d8bfae7c1fbbb3fff2869580137470708aa
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <yaro...@gmail.com>
Gerrit-Reviewer: Yaron Koren <yaro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to