[XenForoBridge] Fix broken bridge
This commit is contained in:
parent
28d46b6721
commit
ade09b2aad
1 changed files with 14 additions and 10 deletions
|
@ -118,7 +118,7 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
// Notice: The DOM structure changes depending on the XenForo version used
|
// Notice: The DOM structure changes depending on the XenForo version used
|
||||||
if($mainContent = $html->find('div.mainContent', 0)) {
|
if($mainContent = $html->find('div.mainContent', 0)) {
|
||||||
$this->version = self::XENFORO_VERSION_1;
|
$this->version = self::XENFORO_VERSION_1;
|
||||||
} elseif ($mainContent = $html->find('div[class="p-body"]', 0)) {
|
} elseif ($mainContent = $html->find('div[class~="p-body"]', 0)) {
|
||||||
$this->version = self::XENFORO_VERSION_2;
|
$this->version = self::XENFORO_VERSION_2;
|
||||||
} else {
|
} else {
|
||||||
returnServerError('This forum is currently not supported!');
|
returnServerError('This forum is currently not supported!');
|
||||||
|
@ -140,7 +140,7 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
|
|
||||||
case self::XENFORO_VERSION_2:
|
case self::XENFORO_VERSION_2:
|
||||||
|
|
||||||
$titleBar = $mainContent->find('div[class="p-title"] h1', 0)
|
$titleBar = $mainContent->find('div[class~="p-title"] h1', 0)
|
||||||
or returnServerError('Error finding title bar!');
|
or returnServerError('Error finding title bar!');
|
||||||
|
|
||||||
$this->title = $titleBar->plaintext;
|
$this->title = $titleBar->plaintext;
|
||||||
|
@ -255,7 +255,7 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
|
|
||||||
$lang = $html->find('html', 0)->lang;
|
$lang = $html->find('html', 0)->lang;
|
||||||
|
|
||||||
$messageList = $html->find('div[class="block-body"] article')
|
$messageList = $html->find('div[class~="block-body"] article')
|
||||||
or returnServerError('Error finding message list!');
|
or returnServerError('Error finding message list!');
|
||||||
|
|
||||||
foreach($messageList as $post) {
|
foreach($messageList as $post) {
|
||||||
|
@ -268,13 +268,17 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
|
|
||||||
$item['uri'] = $url . '#' . $post->getAttribute('id');
|
$item['uri'] = $url . '#' . $post->getAttribute('id');
|
||||||
|
|
||||||
$title = $post->find('div[class="message-content"] article', 0)->plaintext;
|
$title = $post->find('div[class~="message-content"] article', 0)->plaintext;
|
||||||
$end = strpos($title, ' ', 70);
|
$end = strpos($title, ' ', 70);
|
||||||
$item['title'] = substr($title, 0, $end);
|
$item['title'] = substr($title, 0, $end);
|
||||||
|
|
||||||
$item['timestamp'] = $this->fixDate($post->find('time', 0)->title, $lang);
|
if ($post->find('time[datetime]', 0)) {
|
||||||
|
$item['timestamp'] = $post->find('time[datetime]', 0)->datetime;
|
||||||
|
} else {
|
||||||
|
$item['timestamp'] = $this->fixDate($post->find('time', 0)->title, $lang);
|
||||||
|
}
|
||||||
$item['author'] = $post->getAttribute('data-author');
|
$item['author'] = $post->getAttribute('data-author');
|
||||||
$item['content'] = $post->find('div[class="message-content"] article', 0);
|
$item['content'] = $post->find('div[class~="message-content"] article', 0);
|
||||||
|
|
||||||
// Bridge specific properties
|
// Bridge specific properties
|
||||||
$item['id'] = $post->getAttribute('id');
|
$item['id'] = $post->getAttribute('id');
|
||||||
|
@ -305,7 +309,7 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
// Load at least the last page
|
// Load at least the last page
|
||||||
do {
|
do {
|
||||||
|
|
||||||
$pageurl = $hosturl . str_replace($sentinel, $lastpage, $baseurl);
|
$pageurl = str_replace($sentinel, $lastpage, $baseurl);
|
||||||
|
|
||||||
// We can optimize performance by caching all but the last page
|
// We can optimize performance by caching all but the last page
|
||||||
if($page != $lastpage) {
|
if($page != $lastpage) {
|
||||||
|
@ -353,7 +357,7 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
// Load at least the last page
|
// Load at least the last page
|
||||||
do {
|
do {
|
||||||
|
|
||||||
$pageurl = $hosturl . str_replace($sentinel, $lastpage, $baseurl);
|
$pageurl = str_replace($sentinel, $lastpage, $baseurl);
|
||||||
|
|
||||||
// We can optimize performance by caching all but the last page
|
// We can optimize performance by caching all but the last page
|
||||||
if($page != $lastpage) {
|
if($page != $lastpage) {
|
||||||
|
@ -364,9 +368,9 @@ class XenForoBridge extends BridgeAbstract {
|
||||||
or returnServerError('Error loading contents from ' . $pageurl . '!');
|
or returnServerError('Error loading contents from ' . $pageurl . '!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = defaultLinkTo($html, $this->hosturl);
|
$html = defaultLinkTo($html, $hosturl);
|
||||||
|
|
||||||
$this->extractThreadPostsV2($html, $this->pageurl);
|
$this->extractThreadPostsV2($html, $pageurl);
|
||||||
|
|
||||||
$page--;
|
$page--;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue