[VkBridge] Generate feed item title

This commit is contained in:
Eugene Molotov 2018-03-17 13:52:03 +05:00
parent d583b0c974
commit ca77295c80

View File

@ -73,12 +73,20 @@ class VkBridge extends BridgeAbstract
// get post link // get post link
$item['uri'] = self::URI . $post->find('a.post_link', 0)->getAttribute('href'); $item['uri'] = self::URI . $post->find('a.post_link', 0)->getAttribute('href');
$item['timestamp'] = $this->getTime($post); $item['timestamp'] = $this->getTime($post);
$item['title'] = $this->getTitle($item['content']);
$item['author'] = $pageName; $item['author'] = $pageName;
$this->items[] = $item; $this->items[] = $item;
} }
} }
private function getTitle($content)
{
preg_match('/^["\w\ \p{Cyrillic}\(\)\?#«»-]+/mu', htmlspecialchars_decode($content), $result);
if (count($result) == 0) return "untitled";
return $result[0];
}
private function getTime($post) private function getTime($post)
{ {
if ($time = $post->find('span.rel_date', 0)->getAttribute('time')) { if ($time = $post->find('span.rel_date', 0)->getAttribute('time')) {