Parcourir la source

#4148 Build-in API support (common changes, entryText)

roman.lesnikov@gmail.com il y a 3 ans
Parent
commit
4205849b2c

+ 2 - 2
modules/base/general/classes/BxBaseModGeneralFormsEntryHelper.php

@@ -148,7 +148,7 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
             $sMsgCnt = $sMsg;
         
         if ($sMsgCnt)
-            return bx_api_rv([['id' => 1, 'type' => 'msg', 'data' => $sMsgCnt]], MsgBox($sMsgCnt));
+            return bx_is_api() ? [['id' => 1, 'type' => 'msg', 'data' => $sMsgCnt]] : MsgBox($sMsgCnt);
 
         $oForm = $this->getObjectFormView();
         if (!$oForm)
@@ -161,7 +161,7 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         else
             $s = $this->_oModule->_oTemplate->entryText($aContentInfo);
         
-        return bx_api_rv([['id' => 1, 'type' => 'entry', 'data' => $s]], $s);
+        return bx_is_api() ? [['id' => 1, 'type' => 'entry', 'data' => $s]] : $s;
     }
 
     public function addData ($iProfile, $aValues, $sDisplay = false)

+ 7 - 3
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -2761,7 +2761,7 @@ class BxBaseModGeneralModule extends BxDolModule
     public function _serviceBrowse ($sMode, $aParams = false, $iDesignBox = BX_DB_PADDING_DEF, $bDisplayEmptyMsg = false, $bAjaxPaginate = true, $sClassSearchResult = 'SearchResult')
     {
         if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse()))
-            return bx_api_rv([['id' => 1, 'type' => 'msg', 'data' => $sMsg]], MsgBox($sMsg));
+            return bx_is_api() ? [['id' => 1, 'type' => 'msg', 'data' => $sMsg]] : MsgBox($sMsg);
 
         bx_import($sClassSearchResult, $this->_aModule);
         $sClass = $this->_aModule['class_prefix'] . $sClassSearchResult;
@@ -2778,7 +2778,7 @@ class BxBaseModGeneralModule extends BxDolModule
             return '';
 
         if ($s = $o->processing())
-            return bx_api_rv([['id' => 1, 'type' => 'browse', 'data' => $s]], $s);
+            return bx_is_api() ? [['id' => 1, 'type' => 'browse', 'data' => $s]] : $s;
         else
             return '';
     }
@@ -3457,7 +3457,11 @@ class BxBaseModGeneralModule extends BxDolModule
         if (!$oCmts || !$oCmts->isEnabled())
             return false;
 
-        return bx_api_rv([['id' => 1, 'type' => 'browse', 'data' => $oCmts->getCommentsBlockAPI(array(), array('in_designbox' => false, 'show_empty' => false))]], $oCmts->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => false)));
+        
+        if (bx_is_api())
+            return [['id' => 1, 'type' => 'browse', 'data' => $oCmts->getCommentsBlockAPI(array(), array('in_designbox' => false, 'show_empty' => false))]];
+
+        return $oCmts->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => false));
     }
 
     protected function _getFields($iContentId)

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

@@ -226,7 +226,7 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
         if (empty($aVars['entry_text']))
             return false;
         
-        return bx_api_rv($aVars, $this->parseHtmlByName($sTemplateName, $aVars));
+        return bx_is_api() ? $aVars : $this->parseHtmlByName($sTemplateName, $aVars);
     }
 
     public function entryLocation ($iContentId)

+ 1 - 1
modules/boonex/contact/classes/BxContactModule.php

@@ -123,7 +123,7 @@ class BxContactModule extends BxDolModule
             }
         }
 
-        if (defined('BX_API'))
+        if (bx_is_api())
             return [
                 ['id' => 1, 'type' => 'form', 'data' => $oForm->getCodeAPI(), 'request' => ['url' => '/api.php?r=bx_contact/get_block_form', 'immutable' => true]],
                 ['id' => 2, 'type' => 'msg', 'data' => $sResult],