[AskfmBridge] code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-28 11:52:41 +02:00
parent ff5ac1659f
commit efb6ad9ff2

View file

@ -15,13 +15,12 @@ class AskfmBridge extends BridgeAbstract{
);
public function collectData(){
$html = '';
$html = $this->getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Requested username can\'t be found.');
foreach($html->find('div.streamItem-answer') as $element) {
$item = array();
$item['uri'] = 'http://ask.fm'.$element->find('a.streamItemsAge',0)->href;
$item['uri'] = $this->uri.$element->find('a.streamItemsAge',0)->href;
$question = trim($element->find('h1.streamItemContent-question',0)->innertext);
$item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES));
$answer = trim($element->find('p.streamItemContent-answer',0)->innertext);
@ -36,7 +35,7 @@ class AskfmBridge extends BridgeAbstract{
}
$content = '<p>' . $question . '</p><p>' . $answer . '</p><p>' . $visual . '</p>';
// Fix relative links without breaking // scheme used by YouTube stuff
$content = preg_replace('#href="\/(?!\/)#', 'href="http://ask.fm/',$content);
$content = preg_replace('#href="\/(?!\/)#', 'href="'.$this->uri,$content);
$item['content'] = $content;
$this->items[] = $item;
}