diff --git a/src/gwtdata.php b/src/gwtdata.php index cf12938..fa72cc8 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. @@ -287,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); } @@ -404,4 +425,4 @@ private function IsISO8601($str) date('d', $stamp), date('Y', $stamp))) ? true : false; } } -?> \ No newline at end of file +?>