[JapanExpoBridge] code simplification + use checkbox instead of list
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
f13f44a682
commit
df80500c51
1 changed files with 19 additions and 24 deletions
|
@ -7,12 +7,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||||
public $description = 'Returns most recent entries from Japan Expo actualités.';
|
public $description = 'Returns most recent entries from Japan Expo actualités.';
|
||||||
public $parameters = array( array(
|
public $parameters = array( array(
|
||||||
'mode'=>array(
|
'mode'=>array(
|
||||||
'name'=>'Mode',
|
'name'=>'Show full contents',
|
||||||
'type'=>'list',
|
'type'=>'checkbox',
|
||||||
'values'=>array(
|
|
||||||
'Titles only'=>'light',
|
|
||||||
'Full Contents'=>'full'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -46,9 +42,9 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$link = 'http://www.japan-expo-paris.com/fr/actualites';
|
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||||
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request JapanExpo: '.$link);
|
or $this->returnServerError('Could not request JapanExpo: '.$this->uri);
|
||||||
$fullcontent = (!empty($this->getInput('mode')) && $this->getInput('mode') == 'full');
|
$fullcontent = $this->getInput('mode');
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
foreach ($html->find('a._tile2') as $element) {
|
foreach ($html->find('a._tile2') as $element) {
|
||||||
|
@ -60,7 +56,9 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||||
$thumbnail = trim($img_search_result[1], "'");
|
$thumbnail = trim($img_search_result[1], "'");
|
||||||
|
|
||||||
if ($fullcontent) {
|
if ($fullcontent) {
|
||||||
if ($count < 5) {
|
if ($count >= 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if($this->get_cached_time($url) <= strtotime('-24 hours'))
|
if($this->get_cached_time($url) <= strtotime('-24 hours'))
|
||||||
$this->remove_from_cache($url);
|
$this->remove_from_cache($url);
|
||||||
|
|
||||||
|
@ -73,9 +71,6 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||||
$article = $article_html->find('div.content', 0)->innertext;
|
$article = $article_html->find('div.content', 0)->innertext;
|
||||||
$article = preg_replace_callback('/<img [^>]+ style="[^\(]+\(\'([^\']+)\'[^>]+>/i', $convert_article_images, $article);
|
$article = preg_replace_callback('/<img [^>]+ style="[^\(]+\(\'([^\']+)\'[^>]+>/i', $convert_article_images, $article);
|
||||||
$content = $headings.$article;
|
$content = $headings.$article;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$date_text = $element->find('span.date', 0)->plaintext;
|
$date_text = $element->find('span.date', 0)->plaintext;
|
||||||
$timestamp = french_pubdate_to_timestamp($date_text);
|
$timestamp = french_pubdate_to_timestamp($date_text);
|
||||||
|
|
Loading…
Reference in a new issue