From 9599f921a502581b48656f70e66b7399a2c3c0f3 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 5 Aug 2017 22:24:48 +0200 Subject: [PATCH] [DanbooruBridge] Allow descendant classes to override tag collection Add protected function 'getTags' that receives the current element and returns a string containing all tags. References #560 --- bridges/DanbooruBridge.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bridges/DanbooruBridge.php b/bridges/DanbooruBridge.php index f2cddf4..36b8c08 100644 --- a/bridges/DanbooruBridge.php +++ b/bridges/DanbooruBridge.php @@ -23,6 +23,7 @@ class DanbooruBridge extends BridgeAbstract { const PATHTODATA = 'article'; const IDATTRIBUTE = 'data-id'; + const TAGATTRIBUTE = 'alt'; protected function getFullURI(){ return $this->getURI() @@ -30,6 +31,10 @@ class DanbooruBridge extends BridgeAbstract { . '&tags=' . urlencode($this->getInput('t')); } + protected function getTags($element){ + return $element->find('img', 0)->getAttribute(static::TAGATTRIBUTE); + } + protected function getItemFromElement($element){ // Fix links defaultLinkTo($element, $this->getURI()); @@ -39,7 +44,7 @@ class DanbooruBridge extends BridgeAbstract { $item['postid'] = (int)preg_replace("/[^0-9]/", '', $element->getAttribute(static::IDATTRIBUTE)); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; - $item['tags'] = $element->find('img', 0)->getAttribute('alt'); + $item['tags'] = $this->getTags($element); $item['title'] = $this->getName() . ' | ' . $item['postid']; $item['content'] = '