From f9a8f166858e7127a50841610e1748e92b4e91de Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 3 Sep 2016 20:23:18 +0200 Subject: [PATCH] [Mangareader] Reduce line lengths --- bridges/MangareaderBridge.php | 61 +++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php index 551c2ab1..e4ad472b 100644 --- a/bridges/MangareaderBridge.php +++ b/bridges/MangareaderBridge.php @@ -117,7 +117,13 @@ class MangareaderBridge extends BridgeAbstract { if($item['content'] <> ""){ $item['content'] .= "
"; } - $item['content'] .= "" . htmlspecialchars($chapter->nodeValue) . ""; + $item['content'] .= + "" + . htmlspecialchars($chapter->nodeValue) + . ""; } $this->items[] = $item; @@ -127,7 +133,9 @@ class MangareaderBridge extends BridgeAbstract { case 'Get popular mangas': $pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue; - $this->request = substr($pagetitle, 0, strrpos($pagetitle, " -")); // "Popular mangas for ..." + + // Find manga name within "Popular mangas for ..." + $this->request = substr($pagetitle, 0, strrpos($pagetitle, " -")); // Query all mangas $mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']"); @@ -136,16 +144,32 @@ class MangareaderBridge extends BridgeAbstract { // The thumbnail is encrypted in a css-style... // format: "background-image:url('')" - $mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)->item(0)->getAttribute('style'); + $mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga) + ->item(0) + ->getAttribute('style'); $thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24); $item = array(); - $item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->nodeValue); - $item['uri'] = self::URI . $xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->getAttribute('href'); - $item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)->item(0)->nodeValue); - $item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)->item(0)->nodeValue; - $item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)->item(0)->nodeValue); - $item['content'] = '' . $item['title'] . '

' . $item['genre'] . '

' . $item['chaptercount'] . '

'; + $item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga) + ->item(0) + ->nodeValue); + $item['uri'] = self::URI . $xpath->query(".//*[@class='manga_name']//a", $manga) + ->item(0) + ->getAttribute('href'); + $item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga) + ->item(0) + ->nodeValue); + $item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga) + ->item(0) + ->nodeValue; + $item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga) + ->item(0) + ->nodeValue); + $item['content'] = <<{$item['title']} +

{$item['genre']}

+

{$item['chaptercount']}

+EOD; $this->items[] = $item; } break; @@ -156,21 +180,30 @@ class MangareaderBridge extends BridgeAbstract { $limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue']; } - $this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")->item(0)->nodeValue; + $this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']") + ->item(0) + ->nodeValue; $query = "(.//*[@id='listing']//tr)[position() > 1]"; if($limit !== -1){ - $query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - " . $limit . "]"; + $query = + "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]"; } $chapters = $xpath->query($query); foreach ($chapters as $chapter){ $item = array(); - $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)->item(0)->nodeValue); - $item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter)->item(0)->getAttribute('href'); - $item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)->item(0)->nodeValue); + $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter) + ->item(0) + ->nodeValue); + $item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter) + ->item(0) + ->getAttribute('href'); + $item['timestamp'] = strtotime($xpath->query("td[2]", $chapter) + ->item(0) + ->nodeValue); array_unshift($this->items, $item); } break;