Skip to content

Commit

Permalink
#4148 Build-in API support (common changes, entryText)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlesnikov committed Jan 17, 2023
1 parent 5628ae6 commit 4205849
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function viewDataEntry ($iContentId)
$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)
Expand All @@ -161,7 +161,7 @@ public function viewDataEntry ($iContentId)
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)
Expand Down
10 changes: 7 additions & 3 deletions modules/base/general/classes/BxBaseModGeneralModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,7 @@ protected function _serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAc
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;
Expand All @@ -2778,7 +2778,7 @@ public function _serviceBrowse ($sMode, $aParams = false, $iDesignBox = BX_DB_PA
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 '';
}
Expand Down Expand Up @@ -3457,7 +3457,11 @@ protected function _entityComments ($sObject, $iId = 0)
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)
Expand Down
2 changes: 1 addition & 1 deletion modules/base/general/classes/BxBaseModGeneralTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function entryText ($aData, $sTemplateName = 'entry-text.html')
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)
Expand Down
2 changes: 1 addition & 1 deletion modules/boonex/contact/classes/BxContactModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function serviceGetBlockForm()
}
}

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],
Expand Down

0 comments on commit 4205849

Please sign in to comment.