From 990719d6146f501b9c0f2cc5a2f3a865a23801de Mon Sep 17 00:00:00 2001 From: somini Date: Mon, 29 Jul 2019 11:12:55 +0100 Subject: [PATCH] [FabriceBellard]: New Bridge (#1220) * [FabriceBellard]: New Bridge --- bridges/FabriceBellardBridge.php | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bridges/FabriceBellardBridge.php diff --git a/bridges/FabriceBellardBridge.php b/bridges/FabriceBellardBridge.php new file mode 100644 index 00000000..2c24b5ea --- /dev/null +++ b/bridges/FabriceBellardBridge.php @@ -0,0 +1,36 @@ +find('p') as $obj) { + $item = array(); + + $html = defaultLinkTo($html, $this->getURI()); + + $links = $obj->find('a'); + if (count($links) > 0) { + $link_uri = $links[0]->href; + } else { + $link_uri = $this->getURI(); + } + + /* try to make sure the link is valid */ + if ($link_uri[-1] !== '/' && strpos($link_uri, '/') === false) { + $link_uri = $link_uri . '/'; + } + + $item['title'] = strip_tags($obj->innertext); + $item['uri'] = $link_uri; + $item['content'] = $obj->innertext; + + $this->items[] = $item; + } + } +}