forked from blallo/rss-bridge
[UnsplashBridge] code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
351e1e9a6a
commit
0262162bc3
1 changed files with 12 additions and 12 deletions
|
@ -9,32 +9,32 @@ class UnsplashBridge extends BridgeAbstract {
|
||||||
public $parameters = array( array(
|
public $parameters = array( array(
|
||||||
'm'=>array(
|
'm'=>array(
|
||||||
'name'=>'Max number of photos',
|
'name'=>'Max number of photos',
|
||||||
'type'=>'number'
|
'type'=>'number',
|
||||||
|
'defaultValue'=>20
|
||||||
),
|
),
|
||||||
'w'=>array(
|
'w'=>array(
|
||||||
'name'=>'Width',
|
'name'=>'Width',
|
||||||
'exampleValue'=>'1920, 1680, …'
|
'exampleValue'=>'1920, 1680, …',
|
||||||
|
'defaultValue'=>'1920'
|
||||||
),
|
),
|
||||||
'q'=>array(
|
'q'=>array(
|
||||||
'name'=>'JPEG quality',
|
'name'=>'JPEG quality',
|
||||||
'type'=>'number'
|
'type'=>'number',
|
||||||
|
'defaultValue'=>75
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = '';
|
$width = $this->getInput('w') ;
|
||||||
$baseUri = 'http://unsplash.com';
|
|
||||||
|
|
||||||
$width = $this->getInput('w') ?: '1920'; // Default width
|
|
||||||
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
$max = $this->getInput('m') ?: 20;
|
$max = $this->getInput('m');
|
||||||
$quality = $this->getInput('q') ?: 75;
|
$quality = $this->getInput('q');
|
||||||
$lastpage = 1;
|
$lastpage = 1;
|
||||||
|
|
||||||
for ($page = 1; $page <= $lastpage; $page++) {
|
for ($page = 1; $page <= $lastpage; $page++) {
|
||||||
$link = $baseUri.'/grid?page='.$page;
|
$link = $this->uri.'/grid?page='.$page;
|
||||||
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.');
|
$html = $this->getSimpleHTMLDOM($link)
|
||||||
|
or $this->returnServerError('No results for this query.');
|
||||||
|
|
||||||
if ($page === 1) {
|
if ($page === 1) {
|
||||||
preg_match('/=(\d+)$/', $html->find('.pagination > a[!class]', -1)->href, $matches);
|
preg_match('/=(\d+)$/', $html->find('.pagination > a[!class]', -1)->href, $matches);
|
||||||
|
|
Loading…
Reference in a new issue