' . $item['genre'] . '
' . $item['chaptercount'] . '
'; - $this->items[] = $item; - } + $this->request = substr($pagetitle, 0, strrpos($pagetitle, " -")); + $this->get_popular_mangas($xpath); break; - case 'Get manga updates': $limit = $this->getInput('limit'); if(empty($limit)){ - $limit = MANGAREADER_LIMIT; + $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 . "]"; - } - - $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); - array_unshift($this->items, $item); - } + $this->get_manga_updates($xpath, $limit); break; } - // Return some dummy-data if no content available - if(empty($this->items)){ - $item = array(); - $item['content'] = "No updates available
"; + // Return some dummy-data if no content available + if(empty($this->items)){ + $item = array(); + $item['content'] = "No updates available
"; - $this->items[] = $item; - } - } + $this->items[] = $item; + } + } + + private function get_latest_updates($xpath){ + // Query each item (consists of Manga + chapters) + $nodes = $xpath->query("//*[@id='latestchapters']/table//td"); + + foreach ($nodes as $node){ + // Query the manga + $manga = $xpath->query("a[@class='chapter']", $node)->item(0); + + // Collect the chapters for each Manga + $chapters = $xpath->query("a[@class='chaptersrec']", $node); + + if (isset($manga) && $chapters->length >= 1){ + $item = array(); + $item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href')); + $item['title'] = htmlspecialchars($manga->nodeValue); + + // Add each chapter to the feed + $item['content'] = ""; + + foreach ($chapters as $chapter){ + if($item['content'] <> ""){ + $item['content'] .= "{$item['genre']}
+{$item['chaptercount']}
+EOD; + $this->items[] = $item; + } + } + + private function get_manga_updates($xpath, $limit){ + $query = "(.//*[@id='listing']//tr)[position() > 1]"; + + if($limit !== -1){ + $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); + array_unshift($this->items, $item); + } + } public function getURI(){ switch($this->queriedContext){ @@ -205,12 +243,12 @@ class MangareaderBridge extends BridgeAbstract{ } - public function getName(){ - return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge'; - } + public function getName(){ + return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge'; + } - public function getCacheDuration(){ - return 10800; // 3 hours - } + public function getCacheDuration(){ + return 10800; // 3 hours + } } ?>