[FlickrTagBridge] fix + code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
e139372255
commit
445f3336c0
1 changed files with 18 additions and 15 deletions
|
@ -8,32 +8,35 @@ class FlickrTagBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public $parameters = array(
|
public $parameters = array(
|
||||||
'By keyword' => array(
|
'By keyword' => array(
|
||||||
'q'=>array('name'=>'keyword')
|
'q'=>array(
|
||||||
|
'name'=>'keyword',
|
||||||
|
'required'=>true
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
'By username' => array(
|
'By username' => array(
|
||||||
'u'=>array('name'=>'Username')
|
'u'=>array(
|
||||||
|
'name'=>'Username',
|
||||||
|
'required'=>true
|
||||||
|
)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = $this->getSimpleHTMLDOM('http://www.flickr.com/search/?q=vendee&s=rec') or $this->returnServerError('Could not request Flickr.');
|
switch($this->queriedContext){
|
||||||
if ($this->getInput('q')) { /* keyword search mode */
|
case 'By keyword':
|
||||||
$this->request = $this->getInput('q');
|
$html = $this->getSimpleHTMLDOM($this->uri.'search/?q='.urlencode($this->getInput('q')).'&s=rec')
|
||||||
$html = $this->getSimpleHTMLDOM('http://www.flickr.com/search/?q='.urlencode($this->request).'&s=rec') or $this->returnServerError('No results for this query.');
|
or $this->returnServerError('No results for this query.');
|
||||||
}
|
break;
|
||||||
elseif ($this->getInput('u')) { /* user timeline mode */
|
case 'by username':
|
||||||
$this->request = $this->getInput('u');
|
$html = $this->getSimpleHTMLDOM($this->uri.'photos/'.urlencode($this->getInput('u')).'/')
|
||||||
$html = $this->getSimpleHTMLDOM('http://www.flickr.com/photos/'.urlencode($this->request).'/') or $this->returnServerError('Requested username can\'t be found.');
|
or $this->returnServerError('Requested username can\'t be found.');
|
||||||
}
|
break;
|
||||||
|
|
||||||
else {
|
|
||||||
$this->returnClientError('You must specify a keyword or a Flickr username.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($html->find('span.photo_container') as $element) {
|
foreach($html->find('span.photo_container') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = 'http://flickr.com'.$element->find('a',0)->href;
|
$item['uri'] = $this->uri.$element->find('a',0)->href;
|
||||||
$thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src');
|
$thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src');
|
||||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; // FIXME: Filter javascript ?
|
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; // FIXME: Filter javascript ?
|
||||||
$item['title'] = $element->find('a',0)->title;
|
$item['title'] = $element->find('a',0)->title;
|
||||||
|
|
Loading…
Reference in a new issue