Quellcode durchsuchen

Ticket #4148 - Build-in API support: Comments page & category

roman.lesnikov@gmail.com vor 3 Jahren
Ursprung
Commit
911f289eeb

+ 1 - 0
inc/classes/BxDolCmts.php

@@ -2275,6 +2275,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
             $aData = $this->getCommentSimple($iCmtId);
             $aData = array_merge($aData, [
                 'author_data' => BxDolProfile::getData($aData['cmt_author_id']),
+                'cmt_url' => '/' . $this->getViewUrl($aData['cmt_id'], false),
                 'menu_actions' => $oMenuActions->getCodeAPI(),
                 'menu_manage' => $oMenuManage->getCodeAPI(),
             ]);

+ 15 - 0
modules/boonex/forum/classes/BxForumModule.php

@@ -16,6 +16,21 @@ class BxForumModule extends BxBaseModTextModule
         parent::__construct($aModule);
     }
 
+    public function decodeDataApi ($aData, $bExtended = false)
+    {
+        $CNF = $this->_oConfig->CNF;
+        
+        $aResult = parent::decodeDataApi($aData, $bExtended);
+        
+        $oCategory = BxDolCategory::getObjectInstance($CNF['OBJECT_CATEGORY']);
+        if(!$oCategory)
+            return false;
+
+        $aResult['category'] = $oCategory->getCategoryTitle($aData[$CNF['FIELD_CATEGORY']]);
+
+        return $aResult;
+    }
+    
     public function sortParticipants ($aParticipants, $iProfileIdLastComment, $iProfileIdAuthor, $iProfileIdCurrent = 0)
     {
         if (!$iProfileIdCurrent)

+ 12 - 2
template/scripts/BxBaseCategory.php

@@ -119,13 +119,23 @@ class BxBaseCategory extends BxDolCategory
             if (!$bDisplayEmptyCats && !$iNum)
                 continue;
             
-            $aVars['bx_repeat:cats'][] = array(
+            $sIcon = '';
+            if($this->_aObject['module']){
+                $oModule = BxDolModule::getInstance($this->_aObject['module']);
+                $CNF = $oModule->_oConfig->CNF;
+                if (isset($CNF['OBJECT_GRID_CATEGORIES'])){
+                    $aCategoryData = $this->_oModule->_oDb->getCategories(['type' => 'by_category', 'category' => $sValue]);
+                    $sIcon =  $aCategoryData['icon'];
+                }
+            }
+            
+            $aVars['bx_repeat:cats'][] = [
                 'url' => $mProfileContextId ? $this->getCategoryUrl($sValue, array_merge($aParams, ['context_id' => $mProfileContextId])) : $this->getCategoryUrl($sValue, $aParams),
                 'name' => $sName,
                 'value' => $sValue,
                 'num' => $iNum,
                 'selected_class' => $sValue == bx_get('category') ? 'bx-category-list-item-selected' : '',
-            );
+            ];
         }
         
         if(bx_is_api()) {

+ 28 - 0
template/scripts/BxBaseCmtsServices.php

@@ -29,6 +29,24 @@ class BxBaseCmtsServices extends BxDol
 
         return $oCmts->serviceGetAuthor((int)$aCmt['cmt_id']);
     }
+    
+    public function serviceGetAuthorBlock()
+    {
+        if(bx_is_api()){
+            $iCommentId = bx_process_input(bx_get('cmt_id'), BX_DATA_INT);
+            $sSystem =  bx_process_input(bx_get('sys'));
+            $iObjectId = bx_process_input(bx_get('id'), BX_DATA_INT);
+            
+            $oCmts = BxDolCmts::getObjectInstance($sSystem, $iObjectId, true);
+            $aCmt = $oCmts->getCommentRow($iCommentId);
+
+            return [bx_api_get_block('entity_author', [
+                'author_data' => BxDolProfile::getData($aCmt['cmt_author_id']),
+                'entry_date' => $aCmt['cmt_time'],
+                'menu_manage' => []
+            ])];
+        }
+    }
 
     public function serviceGetInfo($iCmtUniqId, $bSearchableFieldsOnly = true)
     {
@@ -45,6 +63,16 @@ class BxBaseCmtsServices extends BxDol
 
     public function serviceGetBlockView($sSystem = '', $iObjectId = 0, $iCommentId = 0)
     {
+        if (bx_is_api()){
+            $aParams['comment_id'] = bx_process_input(bx_get('cmt_id'), BX_DATA_INT);
+            $aParams['module'] =  bx_process_input(bx_get('sys'));
+            $aParams['object_id'] = bx_process_input(bx_get('id'), BX_DATA_INT);
+
+            $aRv = $this->serviceGetDataApi($aParams);
+            $aRv['browse']['data']['total_count'] = 0;
+            return [$aRv];
+        }
+        
         if(empty($sSystem) && ($sSystem = bx_get('sys')) !== false)
             $sSystem = bx_process_input($sSystem);
 

+ 6 - 6
template/scripts/BxBaseServicePages.php

@@ -47,6 +47,11 @@ class BxBaseServicePages extends BxDol
             $mixed = BxDolPage::getObjectInstanceByURI();
         }
         else{
+            if(!empty($sParams)) {
+                $aParams = json_decode($sParams, true);
+                if(!empty($aParams) && is_array($aParams))
+                    $_GET = array_merge($_GET, $aParams);
+            }
             $mixed = BxDolPage::getPageBySeoLink($sRequest);
         }
        
@@ -55,12 +60,7 @@ class BxBaseServicePages extends BxDol
             $aRes = ['redirect' => $sUrl];
         }
         elseif (($oPage = $mixed) && is_object($oPage)) {
-			if(!empty($sParams)) {
-                $aParams = json_decode($sParams, true);
-                if(!empty($aParams) && is_array($aParams))
-                    $_GET = array_merge($_GET, $aParams);
-            }
-
+			
             $aBlocks = [];
             if(!empty($sBlocks))
                 $aBlocks = explode(',', $sBlocks);