[core] extract BridgeAbstract methods to make them functions

- returnError, returnServerError, returnClientError ,debugMessage are
  moved to lib/error.php

- getContents, getSimpleHTMLDOM, getSimpleHTMLDOMCached are moved to
  lib/contents.php

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-09-25 23:22:33 +02:00
parent ad534444fa
commit f1fb95b257
111 changed files with 485 additions and 477 deletions

View file

@ -19,19 +19,19 @@ class WhydBridge extends BridgeAbstract{
$html = '';
if (strlen(preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))) == 24){
// is input the userid ?
$html = $this->getSimpleHTMLDOM(
$html = getSimpleHTMLDOM(
self::URI.'u/'.preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))
) or $this->returnServerError('No results for this query.');
) or returnServerError('No results for this query.');
} else { // input may be the username
$html = $this->getSimpleHTMLDOM(
$html = getSimpleHTMLDOM(
self::URI.'search?q='.urlencode($this->getInput('u'))
) or $this->returnServerError('No results for this query.');
) or returnServerError('No results for this query.');
for ($j = 0; $j < 5; $j++) {
if (strtolower($html->find('div.user', $j)->find('a',0)->plaintext) == strtolower($this->getInput('u'))) {
$html = $this->getSimpleHTMLDOM(
$html = getSimpleHTMLDOM(
self::URI . $html->find('div.user', $j)->find('a', 0)->getAttribute('href')
) or $this->returnServerError('No results for this query');
) or returnServerError('No results for this query');
break;
}
}