From 4854657905a27a07e16738dcc3e0d65a74fe243e Mon Sep 17 00:00:00 2001 From: Ariel Souza Date: Mon, 17 Feb 2014 17:36:58 -0300 Subject: [PATCH 1/2] Filter Method Query filter added. --- src/gwtdata.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gwtdata.php b/src/gwtdata.php index cf12938..dba1e17 100644 --- a/src/gwtdata.php +++ b/src/gwtdata.php @@ -54,6 +54,7 @@ public function __construct() ); $this->_downloaded = array(); $this->_skipped = array(); + $this->_filter = "WEB"; } /** @@ -88,6 +89,26 @@ public function SetTables($arr) } } else { throw new Exception("Invalid argument given."); } } + + /** + * Sets filter that will be use on query. + * + * @param $filter String Valid string values are: + * "ALL", "WEB", "MOBILE", "IMAGE", + * "VIDEO". + */ + public function SetFilter($filter) + { + if(!empty($filter) && is_string($filter)) { + $valid = array("ALL","WEB","MOBILE","IMAGE", + "VIDEO"); + $this->_filter = array(); + if(in_array($filter, $valid)) + { + $this->_filter = $filter; + } else { throw new Exception("Invalid argument given."); } + } else { throw new Exception("Invalid argument given."); } + } /** * Sets daterange for download data. @@ -404,4 +425,4 @@ private function IsISO8601($str) date('d', $stamp), date('Y', $stamp))) ? true : false; } } -?> \ No newline at end of file +?> From 58d8cdb99178aee2734fa2d79f90d043a12a4135 Mon Sep 17 00:00:00 2001 From: Ariel Souza Date: Wed, 19 Feb 2014 09:03:05 -0300 Subject: [PATCH 2/2] Update gwtdata.php --- src/gwtdata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gwtdata.php b/src/gwtdata.php index dba1e17..fa72cc8 100644 --- a/src/gwtdata.php +++ b/src/gwtdata.php @@ -308,7 +308,7 @@ public function DownloadCSV($site, $savepath=".") } else { $finalName = "$savepath/$table-$filename.csv"; - $finalUrl = $downloadUrls[$table] ."&prop=ALL&db=%s&de=%s&more=true"; + $finalUrl = $downloadUrls[$table] ."&prop=" . $this->_filter . "&db=%s&de=%s&more=true"; $finalUrl = sprintf($finalUrl, $this->_daterange[0], $this->_daterange[1]); self::SaveData($finalUrl,$finalName); }