[Mangareader] Fix coding styles

This commit is contained in:
logmanoriginal 2016-09-03 20:10:36 +02:00
parent 4c96aab832
commit 6c51eaa4d7

View file

@ -1,94 +1,94 @@
<?php <?php
class MangareaderBridge extends BridgeAbstract{ class MangareaderBridge extends BridgeAbstract {
const MAINTAINER = "logmanoriginal"; const MAINTAINER = "logmanoriginal";
const NAME = "Mangareader Bridge"; const NAME = "Mangareader Bridge";
const URI = "http://www.mangareader.net/"; const URI = "http://www.mangareader.net/";
const DESCRIPTION = "Returns the latest updates, popular mangas or manga updates (new chapters)"; const DESCRIPTION = "Returns the latest updates, popular mangas or manga updates (new chapters)";
const PARAMETERS = array( const PARAMETERS = array(
'Get latest updates' => array(), 'Get latest updates' => array(),
'Get popular mangas' => array( 'Get popular mangas' => array(
'category'=>array( 'category' => array(
'name'=>'Category', 'name' => 'Category',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'values'=>array( 'values' => array(
'All'=>'all', 'All' => 'all',
'Action'=>'action', 'Action' => 'action',
'Adventure'=>'adventure', 'Adventure' => 'adventure',
'Comedy'=>'comedy', 'Comedy' => 'comedy',
'Demons'=>'demons', 'Demons' => 'demons',
'Drama'=>'drama', 'Drama' => 'drama',
'Ecchi'=>'ecchi', 'Ecchi' => 'ecchi',
'Fantasy'=>'fantasy', 'Fantasy' => 'fantasy',
'Gender Bender'=>'gender-bender', 'Gender Bender' => 'gender-bender',
'Harem'=>'harem', 'Harem' => 'harem',
'Historical'=>'historical', 'Historical' => 'historical',
'Horror'=>'horror', 'Horror' => 'horror',
'Josei'=>'josei', 'Josei' => 'josei',
'Magic'=>'magic', 'Magic' => 'magic',
'Martial Arts'=>'martial-arts', 'Martial Arts' => 'martial-arts',
'Mature'=>'mature', 'Mature' => 'mature',
'Mecha'=>'mecha', 'Mecha' => 'mecha',
'Military'=>'military', 'Military' => 'military',
'Mystery'=>'mystery', 'Mystery' => 'mystery',
'One Shot'=>'one-shot', 'One Shot' => 'one-shot',
'Psychological'=>'psychological', 'Psychological' => 'psychological',
'Romance'=>'romance', 'Romance' => 'romance',
'School Life'=>'school-life', 'School Life' => 'school-life',
'Sci-Fi'=>'sci-fi', 'Sci-Fi' => 'sci-fi',
'Seinen'=>'seinen', 'Seinen' => 'seinen',
'Shoujo'=>'shoujo', 'Shoujo' => 'shoujo',
'Shoujoai'=>'shoujoai', 'Shoujoai' => 'shoujoai',
'Shounen'=>'shounen', 'Shounen' => 'shounen',
'Shounenai'=>'shounenai', 'Shounenai' => 'shounenai',
'Slice of Life'=>'slice-of-life', 'Slice of Life' => 'slice-of-life',
'Smut'=>'smut', 'Smut' => 'smut',
'Sports'=>'sports', 'Sports' => 'sports',
'Super Power'=>'super-power', 'Super Power' => 'super-power',
'Supernatural'=>'supernatural', 'Supernatural' => 'supernatural',
'Tragedy'=>'tragedy', 'Tragedy' => 'tragedy',
'Vampire'=>'vampire', 'Vampire' => 'vampire',
'Yaoi'=>'yaoi', 'Yaoi' => 'yaoi',
'Yuri'=>'yuri' 'Yuri' => 'yuri'
), ),
'exampleValue'=>'All', 'exampleValue' => 'All',
'title'=>'Select your category' 'title' => 'Select your category'
) )
), ),
'Get manga updates' => array( 'Get manga updates' => array(
'path'=>array( 'path' => array(
'name'=>'Path', 'name' => 'Path',
'required'=>true, 'required' => true,
'pattern'=>'[a-zA-Z0-9-_]*', 'pattern' => '[a-zA-Z0-9-_]*',
'exampleValue'=>'bleach, umi-no-kishidan', 'exampleValue' => 'bleach, umi-no-kishidan',
'title'=>'URL part of desired manga' 'title' => 'URL part of desired manga'
), ),
'limit'=>array( 'limit' => array(
'name'=>'Limit', 'name' => 'Limit',
'type'=>'number', 'type' => 'number',
'defaultValue'=>10, 'defaultValue' => 10,
'title'=>'Number of items to return [-1 returns all]' 'title' => 'Number of items to return [-1 returns all]'
) )
) )
); );
private $request=''; private $request = '';
public function collectData(){ public function collectData(){
// We'll use the DOM parser for this as it makes navigation easier // We'll use the DOM parser for this as it makes navigation easier
$html = $this->getContents($this->getURI()); $html = $this->getContents($this->getURI());
if(!$html){ if(!$html){
$this->returnClientError('Could not receive data for ' . $path . '!'); $this->returnClientError('Could not receive data for ' . $path . '!');
} }
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$doc = new DomDocument; $doc = new DomDocument;
@$doc->loadHTML($html); @$doc->loadHTML($html);
libxml_clear_errors(); libxml_clear_errors();
// Navigate via XPath // Navigate via XPath
$xpath = new DomXPath($doc); $xpath = new DomXPath($doc);
$this->request = ''; $this->request = '';
switch($this->queriedContext){ switch($this->queriedContext){
@ -107,7 +107,7 @@ class MangareaderBridge extends BridgeAbstract{
if (isset($manga) && $chapters->length >= 1){ if (isset($manga) && $chapters->length >= 1){
$item = array(); $item = array();
$item['uri'] = self::URI. htmlspecialchars($manga->getAttribute('href')); $item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href'));
$item['title'] = htmlspecialchars($manga->nodeValue); $item['title'] = htmlspecialchars($manga->nodeValue);
// Add each chapter to the feed // Add each chapter to the feed
@ -117,7 +117,7 @@ class MangareaderBridge extends BridgeAbstract{
if($item['content'] <> ""){ if($item['content'] <> ""){
$item['content'] .= "<br>"; $item['content'] .= "<br>";
} }
$item['content'] .= "<a href='" .self::URI. htmlspecialchars($chapter->getAttribute('href')) . "'>" . htmlspecialchars($chapter->nodeValue) . "</a>"; $item['content'] .= "<a href='" . self::URI . htmlspecialchars($chapter->getAttribute('href')) . "'>" . htmlspecialchars($chapter->nodeValue) . "</a>";
} }
$this->items[] = $item; $this->items[] = $item;
@ -176,14 +176,14 @@ class MangareaderBridge extends BridgeAbstract{
break; break;
} }
// Return some dummy-data if no content available // Return some dummy-data if no content available
if(empty($this->items)){ if(empty($this->items)){
$item = array(); $item = array();
$item['content'] = "<p>No updates available</p>"; $item['content'] = "<p>No updates available</p>";
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getURI(){ public function getURI(){
switch($this->queriedContext){ switch($this->queriedContext){
@ -204,12 +204,12 @@ class MangareaderBridge extends BridgeAbstract{
} }
public function getName(){ public function getName(){
return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge'; return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
} }
public function getCacheDuration(){ public function getCacheDuration(){
return 10800; // 3 hours return 10800; // 3 hours
} }
} }
?> ?>