From 43bb17f995726ad9aee71aaa2b9bad0655b94e96 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Sun, 22 Jul 2018 19:43:00 +0500 Subject: [PATCH] [VkBridge] Converting hashtags to categories (#755) * [VkBridge] Converting hashtags to categories --- bridges/VkBridge.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php index 70c0db41..dc520147 100644 --- a/bridges/VkBridge.php +++ b/bridges/VkBridge.php @@ -228,6 +228,19 @@ class VkBridge extends BridgeAbstract $item = array(); $item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '
'); $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');