[WhydBridge] fix getName() + code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-30 00:07:22 +02:00
parent 014d016a51
commit 23bb5c5dfb

View file

@ -13,6 +13,8 @@ class WhydBridge extends BridgeAbstract{
) )
)); ));
private $userName='';
public function collectData(){ public function collectData(){
$html = ''; $html = '';
if (strlen(preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))) == 24){ if (strlen(preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))) == 24){
@ -34,7 +36,7 @@ class WhydBridge extends BridgeAbstract{
} }
} }
} }
$this->name = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext; $this->userName = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext;
for($i = 0; $i < 10; $i++) { for($i = 0; $i < 10; $i++) {
$track = $html->find('div.post', $i); $track = $html->find('div.post', $i);
@ -42,13 +44,13 @@ class WhydBridge extends BridgeAbstract{
$item['author'] = $track->find('h2', 0)->plaintext; $item['author'] = $track->find('h2', 0)->plaintext;
$item['title'] = $track->find('h2', 0)->plaintext; $item['title'] = $track->find('h2', 0)->plaintext;
$item['content'] = $track->find('a.thumb',0) . '<br/>' . $track->find('h2', 0)->plaintext; $item['content'] = $track->find('a.thumb',0) . '<br/>' . $track->find('h2', 0)->plaintext;
$item['id'] = 'http://www.whyd.com' . $track->find('a.no-ajaxy',0)->getAttribute('href'); $item['id'] = $this->uri . $track->find('a.no-ajaxy',0)->getAttribute('href');
$item['uri'] = 'http://www.whyd.com' . $track->find('a.no-ajaxy',0)->getAttribute('href'); $item['uri'] = $this->uri . $track->find('a.no-ajaxy',0)->getAttribute('href');
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getName(){ public function getName(){
return (!empty($this->name) ? $this->name .' - ' : '') .'Whyd Bridge'; return (!empty($this->userName) ? $this->userName .' - ' : '') .'Whyd Bridge';
} }
public function getCacheDuration(){ public function getCacheDuration(){