1
0
Эх сурвалжийг харах

#4148 - Build-in API support (units)

roman.lesnikov@gmail.com 3 жил өмнө
parent
commit
74236b5227

+ 11 - 2
inc/classes/BxDolSearch.php

@@ -495,10 +495,19 @@ class BxDolSearchResult implements iBxDolReplaceable
 
     function processingAPI () 
     {
+        $sUnitType = 'content';
+        if(method_exists($this->oModule, 'serviceActAsProfile') && $this->oModule->serviceActAsProfile())
+             $sUnitType = 'profile';
+        if(method_exists($this->oModule, 'serviceIsGroupProfile') && $this->oModule->serviceIsGroupProfile())
+             $sUnitType = 'context';
+
+        $sUnit =  'list';
+        if ($this->sUnitViewDefault == 'showcase' || $this->sUnitViewDefault == 'gallery')
+            $sUnit = 'card';
+        
         return [
-            'list' => 'general',
             'module' => $this->oModule->getName(),
-            'unit' => $this->sUnitViewDefault,
+            'unit' => 'general-' . $sUnitType . '-' . $sUnit,
             'data' => $this->decodeData($this->getSearchData()),
             'paginate' => [
                 'num' => $this->aCurrent['paginate']['num'],

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -3498,7 +3498,7 @@ class BxBaseModGeneralModule extends BxDolModule
                 $aForm['id'] = 2;
             }
             else
-                $aForm = ['id' => 2, 'type' => 'form', 'data' => $aForm->getCodeAPI(), 'request' => ['url' => '/api.php?r=' . $this->_aModule['name'] . '/entity_comments', 'immutable' => true]];
+                $aForm = ['id' => 2, 'type' => 'form', 'name' => 'comment', 'data' => $aForm->getCodeAPI(), 'request' => ['url' => '/api.php?r=' . $this->_aModule['name'] . '/entity_comments', 'immutable' => true]];
             
             
             return [

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -4901,7 +4901,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $this->_iOwnerId = $aParams['owner_id'];
 
-        return bx_is_api() ? [['id' => 1, 'type' => 'browse', 'data' => ['list' => 'feed', 'data' => $this->_oTemplate->getViewBlock($aParams)]]] : ['content' => $this->_oTemplate->getViewBlock($aParams)];
+        return bx_is_api() ? [['id' => 1, 'type' => 'browse', 'data' => ['unit' => 'feed', 'data' => $this->_oTemplate->getViewBlock($aParams)]]] : ['content' => $this->_oTemplate->getViewBlock($aParams)];
     }
 
     protected function _getBlockPost($iProfileId, $aParams = array())

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -210,7 +210,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sTitle = _t('_bx_timeline_page_block_title_views_' . $aParams['view']);
 
         if (bx_is_api())
-            return [['id' => 1, 'type' => 'browse', 'data' => ['list' => 'feed', 'data' => $this->getViewBlock($aParams)]]];
+            return [['id' => 1, 'type' => 'browse', 'data' => ['unit' => 'feed', 'data' => $this->getViewBlock($aParams)]]];
         
         return [
             'content' => $this->parseHtmlByName('block_views.html', [

+ 1 - 1
template/scripts/BxBaseCmts.php

@@ -146,7 +146,7 @@ class BxBaseCmts extends BxDolCmts
         $aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp[($aBp['init_view'] != -1 ? 'init' : 'per') . '_view']);
 
         return [
-            'list' => 'comments',
+            'unit' => 'comments',
             'data' => $this->decodeData($aCmts),
         ];
     }