Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/gwtdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __construct()
);
$this->_downloaded = array();
$this->_skipped = array();
$this->_filter = "WEB";
}

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -404,4 +425,4 @@ private function IsISO8601($str)
date('d', $stamp), date('Y', $stamp))) ? true : false;
}
}
?>
?>