From 03ffddc76a1e8fe0f8b049759fba6bbc3de99f89 Mon Sep 17 00:00:00 2001 From: Lexa M Date: Fri, 24 Feb 2017 15:39:21 +0700 Subject: [PATCH 0001/1311] Ethplorer export as CSV. --- css/ethplorer.css | 5 +++++ index.php | 2 +- service/lib/ethplorer.php | 28 ++++++++++++++++++++++++++++ service/service.php | 10 ++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/css/ethplorer.css b/css/ethplorer.css index 1c66f74d..6b16ff21 100644 --- a/css/ethplorer.css +++ b/css/ethplorer.css @@ -467,6 +467,11 @@ a.dashed { margin-bottom: 20px; } +.export-csv { + float: right; + padding-right: 16px; +} + #address-chainy-tx .table tr td:nth-child(4){ white-space: nowrap; } diff --git a/index.php b/index.php index fff9dab0..4c769db5 100644 --- a/index.php +++ b/index.php @@ -481,7 +481,7 @@
- * all dates are displayed for timezone + * all dates are displayed for timezone
diff --git a/service/lib/ethplorer.php b/service/lib/ethplorer.php index ccf6c2a5..9ec11e2f 100644 --- a/service/lib/ethplorer.php +++ b/service/lib/ethplorer.php @@ -850,6 +850,34 @@ public function getAddressOperations($address, $limit = 10, $offset = FALSE){ return $result; } + /** + * Returns data of transfers made by specified address for downloading in CSV format. + * + * @param string $address Address + * @return array + */ + public function getAddressOperationsCSV($address){ + $limit = 1000; + + $cache = 'address_operations_csv-' . $address . '-' . $limit; + $result = $this->oCache->get($cache, false, true, 24 * 3600); + if(FALSE === $result){ + $cr = "\r\n"; + $spl = ";"; + $result = 'date;txhash;from;to;token-name;token-address;value' . $cr; + $operations = $this->getAddressOperations($address, $limit); + foreach($operations as $record){ + $date = date("Y-m-d H:i:s", $record['timestamp']); + $hash = $record['transactionHash']; + $from = isset($record['from']) ? $record['from'] : ''; + $to = isset($record['to']) ? $record['to'] : ''; + $value = $record['value']; + $result .= $date . $spl . $hash . $spl . $from . $spl . $to . $spl . $value . $cr; + } + } + return $result; + } + /** * Returns top tokens list. * diff --git a/service/service.php b/service/service.php index 432a7c78..5bb5fb5e 100644 --- a/service/service.php +++ b/service/service.php @@ -22,12 +22,22 @@ $data = isset($_GET["data"]) ? $_GET["data"] : false; $page = isset($_GET["page"]) ? $_GET["page"] : false; $refresh = isset($_GET["refresh"]) ? $_GET["refresh"] : false; +$csv = isset($_GET["csv"]) ? $_GET["csv"] : false; $search = isset($_GET["search"]) ? $_GET["search"] : false; // Allow cross-domain ajax requests header('Access-Control-Allow-Origin: *'); +// Download as CSV +if($csv){ + if((false !== $data) && $es->isValidAddress($data)){ + $result = $es->getAddressOperationsCSV($data); + echo $result; + } + die; +} + $pageSize = 10; // Parse page data From a6eb4348031d1893bec367191f3506ab952d9709 Mon Sep 17 00:00:00 2001 From: Lexa M Date: Fri, 24 Feb 2017 15:53:11 +0700 Subject: [PATCH 0002/1311] Debug removed. --- api/widget.js | 1 - 1 file changed, 1 deletion(-) diff --git a/api/widget.js b/api/widget.js index 5daaf76d..2ed00719 100644 --- a/api/widget.js +++ b/api/widget.js @@ -124,7 +124,6 @@ ethplorerWidget = { var popupContent = $("#" + popupId).html(); $("#" + popupId).html(popupContent.replace(/(\n)/gm, "
")); $("#" + popupId).dialog('open'); - console.log(widgetCode); }, parseTemplate: function(template, data){ var res = template; From 3a526cbaa8ce6fb146c1eaa9cffa7b17241ff4cb Mon Sep 17 00:00:00 2001 From: Lexa M Date: Fri, 24 Feb 2017 17:48:38 +0700 Subject: [PATCH 0003/1311] Ethplorer CSV export . --- service/lib/ethplorer.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/service/lib/ethplorer.php b/service/lib/ethplorer.php index 9d156344..4e81ea49 100644 --- a/service/lib/ethplorer.php +++ b/service/lib/ethplorer.php @@ -851,12 +851,13 @@ public function getAddressOperations($address, $limit = 10, $offset = FALSE){ } /** - * Returns data of transfers made by specified address for downloading in CSV format. + * Returns data of operations made by specified address for downloading in CSV format. * * @param string $address Address + * @param string $type Operations type * @return array */ - public function getAddressOperationsCSV($address){ + public function getAddressOperationsCSV($address, $type = 'transfer'){ $limit = 1000; $cache = 'address_operations_csv-' . $address . '-' . $limit; @@ -865,14 +866,27 @@ public function getAddressOperationsCSV($address){ $cr = "\r\n"; $spl = ";"; $result = 'date;txhash;from;to;token-name;token-address;value' . $cr; - $operations = $this->getAddressOperations($address, $limit); + + $options = array( + 'address' => $address, + 'type' => $type, + 'limit' => $limit + ); + $operations = $this->getLastTransfers($options); + //return json_encode($operations); foreach($operations as $record){ $date = date("Y-m-d H:i:s", $record['timestamp']); $hash = $record['transactionHash']; $from = isset($record['from']) ? $record['from'] : ''; $to = isset($record['to']) ? $record['to'] : ''; + $tokenName = ''; + $tokenAddress = ''; + if(isset($record['token'])){ + $tokenName = isset($record['token']['name']) ? $record['token']['name'] : ''; + $tokenAddress = isset($record['token']['address']) ? $record['token']['address'] : ''; + } $value = $record['value']; - $result .= $date . $spl . $hash . $spl . $from . $spl . $to . $spl . $value . $cr; + $result .= $date . $spl . $hash . $spl . $from . $spl . $to . $spl . $tokenName . $spl . $tokenAddress . $spl . $value . $cr; } } return $result; From 014a5c145f774fd732a2c6cab3cd8c39981de037 Mon Sep 17 00:00:00 2001 From: Lexa M Date: Fri, 24 Feb 2017 20:17:45 +0700 Subject: [PATCH 0004/1311] Ethplorer CSV export. --- index.php | 5 +++-- js/ethplorer.js | 2 +- service/lib/ethplorer.php | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 4c769db5..2aa03171 100644 --- a/index.php +++ b/index.php @@ -48,6 +48,7 @@ die(); } } +$csvExport = '';//' Export as CSV'; ?> @@ -481,7 +482,7 @@
- * all dates are displayed for timezone + * all dates are displayed for timezone
@@ -517,7 +518,7 @@
- * all dates are displayed for timezone + * all dates are displayed for timezone