Yaron Koren has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/394394 )
Change subject: Added table structure to top of "View table"
......................................................................
Added table structure to top of "View table"
Change-Id: I49be8abd7dff3d196e4e625cb3f3d3565f92bc02
---
M i18n/en.json
M i18n/qqq.json
M specials/CargoTables.php
3 files changed, 26 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo
refs/changes/94/394394/2
diff --git a/i18n/en.json b/i18n/en.json
index 4474f0e..fc0baff 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -75,6 +75,8 @@
"cargo-cargotables-declaredby": "Declared by $1",
"cargo-cargotables-attachedby": "attached by $1",
"cargo-cargotables-tablenotfound": "Table \"$1\" not found in Cargo
database.",
+ "cargo-cargotables-tablestructure": "Table structure:",
+ "cargo-cargotables-listof": "List of $1",
"cargo-cargotables-totalrows": "This table has '''$1'''
{{PLURAL:$1|row|rows}} altogether.",
"cargo-cargotables-totalrowsshort": "$1 {{PLURAL:$1|row|rows}}",
"cargo-cargotables-switch": "Switch to using this table.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 97fbe99..791d773 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -81,6 +81,8 @@
"cargo-cargotables-declaredby": "Parameters:\n* $1 - template name",
"cargo-cargotables-attachedby": "Parameters:\n* $1 - template name",
"cargo-cargotables-tablenotfound": "An error message.
({{doc-cargo}})\n\nParameters:\n* $1 - table name.",
+ "cargo-cargotables-tablestructure": "A header for a list of fields",
+ "cargo-cargotables-listof": "An informational message",
"cargo-cargotables-totalrows": "Parameters:\n* $1 - number of rows in a
database table.",
"cargo-cargotables-totalrowsshort": "Parameters:\n* $1 - number of rows
in a database table.",
"cargo-cargotables-switch": "The text of a link to a subpage of
[[Special:SwitchCargoTable]].",
diff --git a/specials/CargoTables.php b/specials/CargoTables.php
index 16b8c79..117200a 100644
--- a/specials/CargoTables.php
+++ b/specials/CargoTables.php
@@ -81,7 +81,26 @@
);
$out->setSubtitle( '< '. $mainPageLink );
- // First, display a count.
+ $tableSchemas = CargoUtils::getTableSchemas( array( $tableName
) );
+ $fieldDescriptions =
$tableSchemas[$tableName]->mFieldDescriptions;
+
+ // Display the table structure.
+ $structureDesc = '<p>' . $this->msg(
'cargo-cargotables-tablestructure' )->parse() . '</p>';
+ $structureDesc .= '<ul>';
+ foreach ( $fieldDescriptions as $fieldName => $fieldDescription
) {
+ $fieldDesc = '<strong>' . $fieldName . '</strong> - ';
+ $typeDesc = '<tt>' . $fieldDescription->mType . '</tt>';
+ if ( $fieldDescription->mIsList ) {
+ $fieldDesc .= $this->msg(
'cargo-cargotables-listof', $typeDesc )->parse();
+ } else {
+ $fieldDesc .= $typeDesc;
+ }
+ $structureDesc .= Html::rawElement( 'li', null,
$fieldDesc ) . "\n";
+ }
+ $structureDesc .= '</ul>';
+ $out->addHTML( $structureDesc );
+
+ // Then, display a count.
try {
$res = $cdb->select( $tableName, 'COUNT(*) AS total' );
} catch ( Exception $e ) {
@@ -92,15 +111,15 @@
$row = $cdb->fetchRow( $res );
$out->addWikiText( $this->msg( 'cargo-cargotables-totalrows'
)->numParams( intval($row['total']) )->text() . "\n" );
+ // Then, show the actual table, via a query.
$sqlQuery = new CargoSQLQuery();
$sqlQuery->mTablesStr = $tableName;
$sqlQuery->mAliasedTableNames = array( $tableName => $tableName
);
- $tableSchemas = CargoUtils::getTableSchemas( array( $tableName
) );
$sqlQuery->mTableSchemas = $tableSchemas;
$aliasedFieldNames = array( $this->msg( 'nstab-main' )->parse()
=> '_pageName' );
- foreach ( $tableSchemas[$tableName]->mFieldDescriptions as
$fieldName => $fieldDescription ) {
+ foreach ( $fieldDescriptions as $fieldName => $fieldDescription
) {
// Skip "hidden" fields.
if ( array_key_exists( 'hidden', $fieldDescription ) ) {
continue;
--
To view, visit https://gerrit.wikimedia.org/r/394394
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I49be8abd7dff3d196e4e625cb3f3d3565f92bc02
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits