Parcourir la source

#1970 - Hashtag autosuggestion for existing (or popular) hashtags

RomanL il y a 4 ans
Parent
commit
8624044ae2
1 fichiers modifiés avec 21 ajouts et 21 suppressions
  1. 21 21
      inc/classes/BxDolSearchExtended.php

+ 21 - 21
inc/classes/BxDolSearchExtended.php

@@ -106,38 +106,38 @@ class BxDolSearchExtended extends BxDolFactory implements iBxDolFactoryObject
 
     static public function actionGetAuthors()
     {
-        $aResult = BxDolService::call('system', 'profiles_search', array(bx_get('term')), 'TemplServiceProfiles');
-        foreach ($aResult as &$aItem) {
-            $aItem['symbol'] = bx_get('symbol');
-        }
-        
-        return $aResult;
+        self::getMention("@");
     }
     
     static public function actionGetHashtags()
     {
-        $aResult = [];
-        if (bx_get('term')){
-            $aData = BxDolMetatags::getMetatagsDataByTerm('keywords', 'keyword', bx_get('term'));
-            foreach ($aData as $aItem) {
-                $aResult[] = ['label' => $aItem['meta'], 'value' => $aItem['id'], 'url' => $aItem['url'], 'symbol' => bx_get('symbol')];
-            }
-        }
-        
-        return $aResult;
+        self::getMention("#");
     }
     
     static public function actionGetMention()
+    {
+        self::getMention(bx_get('symbol'));
+    }
+    
+    static function getMention($sSymbol)
     {
         $a = bx_get_base_url_inline();
         $aResult = [];
         
-        if(bx_get('symbol') == '@')
-            $aResult = self::actionGetAuthors();
-        
-        if(bx_get('symbol') == '#')
-            $aResult = self::actionGetHashtags();
-        
+        if($sSymbol == '@'){
+            $aResult = BxDolService::call('system', 'profiles_search', array(bx_get('term')), 'TemplServiceProfiles');
+            foreach ($aResult as &$aItem) {
+                $aItem['symbol'] = bx_get('symbol');
+            }
+        }
+
+        if($sSymbol == '#'){
+            $aData = BxDolMetatags::getMetatagsDataByTerm('keywords', 'keyword', bx_get('term'));
+            foreach ($aData as $aItem) {
+                $aResult[] = ['label' => $aItem['meta'], 'value' => $aItem['id'], 'url' => $aItem['url'], 'symbol' => bx_get('symbol')];
+            }
+        }
+
         bx_alert('search', 'get_mention', 0, 0, array('params' => $a[1], 'override_result' => &$aResult));
         
         header('Content-Type:text/javascript; charset=utf-8');