[core] store parameters values in BridgeAbstract::parameters

This way, any BridgeAbstract method can now have access to these values,
no only collectData

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-25 01:24:53 +02:00
parent dea37c8e34
commit 117031bf0f
131 changed files with 548 additions and 411 deletions

View file

@ -20,23 +20,24 @@ class GiphyBridge extends BridgeAbstract{
}
public function collectData(array $param){
public function collectData(){
$param=$this->parameters[$this->queriedContext];
$html = '';
$base_url = 'http://giphy.com';
if (isset($param['s'])) { /* keyword search mode */
$html = $this->getSimpleHTMLDOM($base_url.'/search/'.urlencode($param['s'].'/')) or $this->returnServerError('No results for this query.');
if (isset($param['s']['value'])) { /* keyword search mode */
$html = $this->getSimpleHTMLDOM($base_url.'/search/'.urlencode($param['s']['value'].'/')) or $this->returnServerError('No results for this query.');
}
else {
$this->returnClientError('You must specify a search worf (?s=...).');
}
$max = GIPHY_LIMIT;
if (isset($param['n'])) {
$max = (integer) $param['n'];
if (isset($param['n']['value'])) {
$max = (integer) $param['n']['value'];
}
$limit = 0;
$kw = urlencode($param['s']);
$kw = urlencode($param['s']['value']);
foreach($html->find('div.hoverable-gif') as $entry) {
if($limit < $max) {
$node = $entry->first_child();