[VkBridge] Converting hashtags to categories (#755)

* [VkBridge] Converting hashtags to categories
This commit is contained in:
Eugene Molotov 2018-07-22 19:43:00 +05:00 committed by Teromene
parent bae7a5879f
commit 43bb17f995

View file

@ -228,6 +228,19 @@ class VkBridge extends BridgeAbstract
$item = array();
$item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '<br><img>');
$item['content'] .= $content_suffix;
$item['categories'] = array();
// get post hashtags
foreach($post->find('a') as $a) {
$href = $a->getAttribute('href');
$prefix = '/feed?section=search&q=%23';
$innertext = $a->innertext;
if ($href && substr($href, 0, strlen($prefix)) === $prefix) {
$item['categories'][] = urldecode(substr($href, strlen($prefix)));
} else if (substr($innertext, 0, 1) == '#') {
$item['categories'][] = $innertext;
}
}
// get post link
$post_link = $post->find('a.post_link', 0)->getAttribute('href');