[MediaWiki-commits] [Gerrit] Added comment to viewxls message - change (mediawiki...Cargo)

2015-04-02 Thread AdSvS (Code Review)
AdSvS has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/201423

Change subject: Added comment to viewxls message
..

Added comment to viewxls message

Change-Id: I8df361552a2570699d332079da42e322d71513a3
---
M i18n/qqq.json
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/23/201423/1

diff --git a/i18n/qqq.json b/i18n/qqq.json
index 089969a..d6a5c42 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -40,6 +40,7 @@
cargo-drilldown-novalues: This is an informational message on 
[[Special:Drildown]].,
cargo-drilldown-toomanyvalues: This is an informational message on 
[[Special:Drildown]].,
cargo-viewcsv: The text of a link.,
+   cargo-viewxls: The text of a link.,
cargo-viewjson: The text of a link.,
cargo-purgecache: The name of a tab; the \cache\ is the MediaWiki 
page cache.,
specialpages-group-cargo: Used for name of Special Page group

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8df361552a2570699d332079da42e322d71513a3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: AdSvS a...@wikibase.nl

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


[MediaWiki-commits] [Gerrit] Added Excel export format - change (mediawiki...Cargo)

2015-04-01 Thread AdSvS (Code Review)
AdSvS has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/201211

Change subject: Added Excel export format
..

Added Excel export format

Change-Id: I0b053d5ef0decbf0b3b70a5e50c8780a8eb06e41
---
M Cargo.php
M CargoQueryDisplayer.php
A formats/CargoExcelFormat.php
M i18n/en.json
M i18n/nl.json
M specials/CargoExport.php
6 files changed, 73 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/11/201211/1

diff --git a/Cargo.php b/Cargo.php
index 7f36145..73944e5 100644
--- a/Cargo.php
+++ b/Cargo.php
@@ -100,6 +100,7 @@
 $wgAutoloadClasses['CargoTreeFormatTree'] = $dir . 
'/formats/CargoTreeFormat.php';
 $wgAutoloadClasses['CargoEmbeddedFormat'] = $dir . 
'/formats/CargoEmbeddedFormat.php';
 $wgAutoloadClasses['CargoCSVFormat'] = $dir . '/formats/CargoCSVFormat.php';
+$wgAutoloadClasses['CargoExcelFormat'] = $dir . 
'/formats/CargoExcelFormat.php';
 $wgAutoloadClasses['CargoJSONFormat'] = $dir . '/formats/CargoJSONFormat.php';
 $wgAutoloadClasses['CargoTableFormat'] = $dir . 
'/formats/CargoTableFormat.php';
 $wgAutoloadClasses['CargoDynamicTableFormat'] = $dir . 
'/formats/CargoDynamicTableFormat.php';
diff --git a/CargoQueryDisplayer.php b/CargoQueryDisplayer.php
index d5d5fa0..460dd8e 100644
--- a/CargoQueryDisplayer.php
+++ b/CargoQueryDisplayer.php
@@ -35,6 +35,7 @@
'template' = 'CargoTemplateFormat',
'embedded' = 'CargoEmbeddedFormat',
'csv' = 'CargoCSVFormat',
+   'excel' = 'CargoExcelFormat',
'json' = 'CargoJSONFormat',
'outline' = 'CargoOutlineFormat',
'tree' = 'CargoTreeFormat',
diff --git a/formats/CargoExcelFormat.php b/formats/CargoExcelFormat.php
new file mode 100644
index 000..16064d3
--- /dev/null
+++ b/formats/CargoExcelFormat.php
@@ -0,0 +1,40 @@
+?php
+/**
+ * @author Yaron Koren
+ * @ingroup Cargo
+ */
+
+class CargoExcelFormat extends CargoDeferredFormat {
+
+   function allowedParameters() {
+   return array( 'filename' );
+   }
+
+   /**
+*
+* @param array $sqlQueries
+* @param array $displayParams Unused
+* @param array $querySpecificParams Unused
+* @return string
+*/
+   function queryAndDisplay( $sqlQueries, $displayParams, 
$querySpecificParams = null ) {
+   $ce = SpecialPage::getTitleFor( 'CargoExport' );
+   $queryParams = $this-sqlQueriesToQueryParams( $sqlQueries );
+   $queryParams['format'] = 'excel';
+   if ( array_key_exists( 'filename', $displayParams ) ) {
+   $queryParams['filename'] = $displayParams['filename'];
+   }
+   if ( array_key_exists( 'link text', $displayParams ) ) {
+   $linkText = $displayParams['link text'];
+   } else {
+   $linkText = wfMessage( 'results.xls' )-text();
+   }
+   $linkAttrs = array(
+   'href' = $ce-getFullURL( $queryParams ),
+   );
+   $text = Html::rawElement( 'a', $linkAttrs, $linkText );
+
+   return $text;
+   }
+
+}
diff --git a/i18n/en.json b/i18n/en.json
index 308664e..b7c0fc8 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -38,6 +38,7 @@
cargo-drilldown-novalues: There are no values for this filter,
cargo-drilldown-toomanyvalues: Too many values; not displaying.,
cargo-viewcsv: View CSV,
+   cargo-viewxls: View XLS,
cargo-viewjson: View JSON,
cargo-purgecache: Purge cache,
specialpages-group-cargo: Cargo,
diff --git a/i18n/nl.json b/i18n/nl.json
index 8758974..5451e5b 100644
--- a/i18n/nl.json
+++ b/i18n/nl.json
@@ -9,5 +9,6 @@
cargo-pagevalues-tablevalues: \$1\ waarden,
cargo-drilldown-or: of,
cargo-viewcsv: CSV bekijken,
+   cargo-viewxls: XLS bekijken,
cargo-viewjson: JSON bekijken
 }
diff --git a/specials/CargoExport.php b/specials/CargoExport.php
index 43aa0de..5356553 100644
--- a/specials/CargoExport.php
+++ b/specials/CargoExport.php
@@ -56,6 +56,12 @@
$filename = 'results.csv';
}
$this-displayCSVData( $sqlQueries, $delimiter, 
$filename );
+   } elseif ( $format == 'excel' ) {
+   $filename = $req-getVal( 'filename' );
+   if ( $filename == '' ) {
+   $filename = 'results.xls';
+   }
+   $this-displayExcelData( $sqlQueries, $filename );
} elseif ( $format == 'json' ) {
$this-displayJSONData( $sqlQueries );
}
@@ -247,6 +253,29 @@
fclose( $out );
   

[MediaWiki-commits] [Gerrit] Added the Excel export format. - change (mediawiki...Cargo)

2015-03-26 Thread AdSvS (Code Review)
AdSvS has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/199859

Change subject: Added the Excel export format.
..

Added the Excel export format.

Change-Id: Ic3d0d21398eaac9c70de8d21606a3d17ca59cd1a
---
M Cargo.php
M CargoQueryDisplayer.php
A formats/CargoExcelFormat.php
M specials/CargoExport.php
4 files changed, 68 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/59/199859/1

diff --git a/Cargo.php b/Cargo.php
index 7f36145..73944e5 100644
--- a/Cargo.php
+++ b/Cargo.php
@@ -100,6 +100,7 @@
 $wgAutoloadClasses['CargoTreeFormatTree'] = $dir . 
'/formats/CargoTreeFormat.php';
 $wgAutoloadClasses['CargoEmbeddedFormat'] = $dir . 
'/formats/CargoEmbeddedFormat.php';
 $wgAutoloadClasses['CargoCSVFormat'] = $dir . '/formats/CargoCSVFormat.php';
+$wgAutoloadClasses['CargoExcelFormat'] = $dir . 
'/formats/CargoExcelFormat.php';
 $wgAutoloadClasses['CargoJSONFormat'] = $dir . '/formats/CargoJSONFormat.php';
 $wgAutoloadClasses['CargoTableFormat'] = $dir . 
'/formats/CargoTableFormat.php';
 $wgAutoloadClasses['CargoDynamicTableFormat'] = $dir . 
'/formats/CargoDynamicTableFormat.php';
diff --git a/CargoQueryDisplayer.php b/CargoQueryDisplayer.php
index d5d5fa0..460dd8e 100644
--- a/CargoQueryDisplayer.php
+++ b/CargoQueryDisplayer.php
@@ -35,6 +35,7 @@
'template' = 'CargoTemplateFormat',
'embedded' = 'CargoEmbeddedFormat',
'csv' = 'CargoCSVFormat',
+   'excel' = 'CargoExcelFormat',
'json' = 'CargoJSONFormat',
'outline' = 'CargoOutlineFormat',
'tree' = 'CargoTreeFormat',
diff --git a/formats/CargoExcelFormat.php b/formats/CargoExcelFormat.php
new file mode 100644
index 000..f3b97af
--- /dev/null
+++ b/formats/CargoExcelFormat.php
@@ -0,0 +1,40 @@
+?php
+/**
+ * @author Yaron Koren
+ * @ingroup Cargo
+ */
+
+class CargoExcelFormat extends CargoDeferredFormat {
+
+   function allowedParameters() {
+   return array( 'filename' );
+   }
+
+   /**
+*
+* @param array $sqlQueries
+* @param array $displayParams Unused
+* @param array $querySpecificParams Unused
+* @return string
+*/
+   function queryAndDisplay( $sqlQueries, $displayParams, 
$querySpecificParams = null ) {
+   $ce = SpecialPage::getTitleFor( 'CargoExport' );
+   $queryParams = $this-sqlQueriesToQueryParams( $sqlQueries );
+   $queryParams['format'] = 'excel';
+   if ( array_key_exists( 'filename', $displayParams ) ) {
+   $queryParams['filename'] = $displayParams['filename'];
+   }
+   if ( array_key_exists( 'link text', $displayParams ) ) {
+   $linkText = $displayParams['link text'];
+   } else {
+   $linkText = wfMessage( 'cargo-viewcsv' )-text();
+   }
+   $linkAttrs = array(
+   'href' = $ce-getFullURL( $queryParams ),
+   );
+   $text = Html::rawElement( 'a', $linkAttrs, $linkText );
+
+   return $text;
+   }
+
+}
diff --git a/specials/CargoExport.php b/specials/CargoExport.php
index 08ab751..67034c1 100644
--- a/specials/CargoExport.php
+++ b/specials/CargoExport.php
@@ -56,6 +56,12 @@
$filename = 'results.csv';
}
$this-displayCSVData( $sqlQueries, $delimiter, 
$filename );
+   } elseif ( $format == 'excel' ) {
+   $filename = $req-getVal( 'filename' );
+   if ( $filename == '' ) {
+   $filename = 'results.xls';
+   }
+   $this-displayExcelData( $sqlQueries, $filename );
} elseif ( $format == 'json' ) {
$this-displayJSONData( $sqlQueries );
}
@@ -226,8 +232,9 @@
}
 
function displayCSVData( $sqlQueries, $delimiter, $filename ) {
-   header( Content-Type: text/csv );
+   header( Content-Type: text/csv;charset=UTF-8 );
header( Content-Disposition: attachment; filename=$filename );
+   header( Content-Transfer-Encoding: quoted-printable );
 
// We'll only use the first query, if there's more than one.
$sqlQuery = $sqlQueries[0];
@@ -240,7 +247,25 @@
}
fclose( $out );
}
+   
+   function displayExcelData( $sqlQueries, $filename ) {
+   
+   // We'll only use the first query, if there's more than one.
+   $sqlQuery = $sqlQueries[0];
+   $queryResults = $sqlQuery-run();
+   
+   

[MediaWiki-commits] [Gerrit] Start (mandatory) and name parameters added to calendar format - change (mediawiki...Cargo)

2015-03-16 Thread AdSvS (Code Review)
AdSvS has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/197015

Change subject: Start (mandatory) and name parameters added to calendar format
..

Start (mandatory) and name parameters added to calendar format

Change-Id: Ic674602d9fac991b8b75419dda8453bca19bf931
---
M specials/CargoExport.php
1 file changed, 23 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/15/197015/1

diff --git a/specials/CargoExport.php b/specials/CargoExport.php
index fc32a39..08ab751 100644
--- a/specials/CargoExport.php
+++ b/specials/CargoExport.php
@@ -61,47 +61,52 @@
}
}
 
+   /**
+* Calendar format
+* These fields are used for display in calendar
+*  start - represents the start of the event; can be Date 
or Datetime (mandatory)
+*  name - sets the name to be displayed in the calendar 
(default is the title of the page)
+*  color - sets the color in which to show the names of 
events; useful within #compound_query (default is set by the FullCalendar 
library)
+* These parameters concern the calendar as a whole:
+*  width - sets the width of the calendar (default is 100%)
+*  start date - sets the date at which to display the 
calendar (default is the current date)
+*/
function displayCalendarData( $sqlQueries ) {
$req = $this-getRequest();
 
$colorArray = $req-getArray( 'color' );
-
+   // The url will have a start and end parameter
+   // generated by the FullCalendar
$startDate = $req-getVal( 'start' );
$endDate = $req-getVal( 'end' );
 
$displayedArray = array();
foreach ( $sqlQueries as $i = $sqlQuery ) {
-   $dateFields = array();
-   foreach( $sqlQuery-mFieldDescriptions as $field = 
$description ) {
-   if ( $description-mType == 'Date' || 
$description-mType == 'Datetime' ) {
-   $dateFields[] = $field;
-   }
-   }
 
$where = $sqlQuery-mWhereStr;
if ( $where != '' ) {
$where .=  AND ;
}
-   $where .= (;
-   foreach ( $dateFields as $j = $dateField ) {
-   if ( $j  0 ) {
-   $where .=  OR ;
-   }
-   $where .= ($dateField = '$startDate' AND 
$dateField = '$endDate');
-   }
-   $where .= );
+   // Retrieve only those pages that are 'in scope'
+   $where .= (date = '$startDate' AND date = 
'$endDate');
+   
$sqlQuery-mWhereStr = $where;
-
+   
$queryResults = $sqlQuery-run();
 
foreach ( $queryResults as $queryResult ) {
+   if ( $queryResult['name'] == '' ) {
+   $eventTitle = reset($queryResult);
+   } else {
+   $eventTitle = $queryResult['name'];
+   }
$title = Title::newFromText( 
$queryResult['_pageName'] );
$displayedArray[] = array(
// Get first field for the title - not
// necessarily the page name.
-   'title' = reset( $queryResult ),
+   'title' = $eventTitle,
'url' = $title-getLocalURL(),
-   'start' = $queryResult[$dateFields[0]],
+   'start' = $queryResult['start'],
'color' = $colorArray[$i]
);
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic674602d9fac991b8b75419dda8453bca19bf931
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: AdSvS a...@wikibase.nl

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


[MediaWiki-commits] [Gerrit] Additional params 'filename' and 'link text' - change (mediawiki...Cargo)

2015-03-11 Thread AdSvS (Code Review)
AdSvS has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/195893

Change subject: Additional params 'filename' and 'link text'
..

Additional params 'filename' and 'link text'

Support has been added for two additional parameters. Filename sets the
name of the file to be downloaded, instead of 'results.csv'. Link text
sets the text of the text shown on the page, instead of the
'cargo-viewcsv' message ('View CSV' in English).

Change-Id: If85be4133c294e71767b58340b6907a829181bbb
---
M formats/CargoCSVFormat.php
M specials/CargoExport.php
2 files changed, 27 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/93/195893/1

diff --git a/formats/CargoCSVFormat.php b/formats/CargoCSVFormat.php
index 90e4a48..beab6be 100644
--- a/formats/CargoCSVFormat.php
+++ b/formats/CargoCSVFormat.php
@@ -24,13 +24,20 @@
if ( array_key_exists( 'delimiter', $displayParams ) ) {
$queryParams['delimiter'] = $displayParams['delimiter'];
}
-
+   if ( array_key_exists( 'filename', $displayParams ) ) {
+   $queryParams['filename'] = $displayParams['filename'];
+   }
+   if ( array_key_exists( 'link text', $displayParams ) ) {
+   $linktext = $displayParams['link text'];
+   } else { 
+   $linktext = wfMessage( 'cargo-viewcsv' )-text();
+   }
$linkAttrs = array(
'href' = $ce-getFullURL( $queryParams ),
);
-   $text = Html::rawElement( 'a', $linkAttrs, wfMessage( 
'cargo-viewcsv' )-text() );
+   $text = Html::rawElement( 'a', $linkAttrs, $linktext );
 
-   return $text;
+   return $text; 
}
 
 }
diff --git a/specials/CargoExport.php b/specials/CargoExport.php
index 9295289..034e8f5 100644
--- a/specials/CargoExport.php
+++ b/specials/CargoExport.php
@@ -51,7 +51,12 @@
} elseif ( $delimiter == '\t' ) {
$delimiter = \t;
}
-   $this-displayCSVData( $sqlQueries, $delimiter );
+   $filename = $req-getVal( 'filename' );
+   if ( $filename == '' ) {
+   $filename = 'results.csv';
+   }
+   $default = $req-getVal( 'default' );
+   $this-displayCSVData( $sqlQueries, $delimiter, 
$filename, $default );
} elseif ( $format == 'json' ) {
$this-displayJSONData( $sqlQueries );
}
@@ -216,13 +221,22 @@
print json_encode( $displayedArray, JSON_NUMERIC_CHECK | 
JSON_HEX_TAG );
}
 
-   function displayCSVData( $sqlQueries, $delimiter ) {
+   function displayCSVData( $sqlQueries, $delimiter, $filename, $default ) 
{
+   $attachmenttext = Content-Disposition: attachment; filename=;
+   $attachmenttext .= $filename;
header( Content-Type: text/csv );
-   header( Content-Disposition: attachment; filename=results.csv 
);
+   header( $attachmenttext );
 
// We'll only use the first query, if there's more than one.
$sqlQuery = $sqlQueries[0];
$queryResults = $sqlQuery-run();
+   if ( count( $queryResults ) == 0 ) {
+   if ( $default == '' ) {
+   return 'em' . wfMessage( 'table_pager_empty' 
)-text() . '/em'; //default
+   } else {
+   return $default;
+   }
+   }
$out = fopen('php://output', 'w');
// Display header row.
fputcsv( $out, array_keys( reset( $queryResults ) ), $delimiter 
);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If85be4133c294e71767b58340b6907a829181bbb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: AdSvS a...@wikibase.nl

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