From 0262162bc3acf4e5a9805007952778d8072eb78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Mon, 29 Aug 2016 23:39:29 +0200 Subject: [PATCH] [UnsplashBridge] code simplification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/UnsplashBridge.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bridges/UnsplashBridge.php b/bridges/UnsplashBridge.php index d12d3782..24ffefe8 100644 --- a/bridges/UnsplashBridge.php +++ b/bridges/UnsplashBridge.php @@ -9,32 +9,32 @@ class UnsplashBridge extends BridgeAbstract { public $parameters = array( array( 'm'=>array( 'name'=>'Max number of photos', - 'type'=>'number' + 'type'=>'number', + 'defaultValue'=>20 ), 'w'=>array( 'name'=>'Width', - 'exampleValue'=>'1920, 1680, …' + 'exampleValue'=>'1920, 1680, …', + 'defaultValue'=>'1920' ), 'q'=>array( 'name'=>'JPEG quality', - 'type'=>'number' + 'type'=>'number', + 'defaultValue'=>75 ) )); public function collectData(){ - $html = ''; - $baseUri = 'http://unsplash.com'; - - $width = $this->getInput('w') ?: '1920'; // Default width - + $width = $this->getInput('w') ; $num = 0; - $max = $this->getInput('m') ?: 20; - $quality = $this->getInput('q') ?: 75; + $max = $this->getInput('m'); + $quality = $this->getInput('q'); $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { - $link = $baseUri.'/grid?page='.$page; - $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); + $link = $this->uri.'/grid?page='.$page; + $html = $this->getSimpleHTMLDOM($link) + or $this->returnServerError('No results for this query.'); if ($page === 1) { preg_match('/=(\d+)$/', $html->find('.pagination > a[!class]', -1)->href, $matches);