Anton 1 неделя назад
Родитель
Сommit
7f2bf994aa

+ 2 - 0
inc/classes/BxDolConnection.php

@@ -131,6 +131,8 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
 {
     protected $_oQuery;
 
+    protected $_bIsApi;
+
     protected $_sObject;
     protected $_aObject;
     protected $_iInitiator;

+ 4 - 4
inc/classes/BxDolObject.php

@@ -23,7 +23,7 @@ class BxDolObject extends BxDolFactory implements iBxDolReplaceable
     protected $_oTemplate = null;
     protected $_oQuery = null;
 
-    protected $_bApi = false;
+    protected $_bIsApi = false;
 
     protected $_iId = 0; ///< item id the action to be performed with
     protected $_sSystem = ''; ///< current system name
@@ -42,7 +42,7 @@ class BxDolObject extends BxDolFactory implements iBxDolReplaceable
     {
         parent::__construct();
 
-        $this->_bApi = bx_is_api();
+        $this->_bIsApi = bx_is_api();
 
         $aSystems = $this->getSystems();
         if(!isset($aSystems[$sSystem]))
@@ -251,7 +251,7 @@ class BxDolObject extends BxDolFactory implements iBxDolReplaceable
 
     public function getElementAPI($aParams = [])
     {
-        if(!$this->_bApi)
+        if(!$this->_bIsApi)
             return;
 
         //TODO: Implement for Objects like Views, Votes, etc.
@@ -265,7 +265,7 @@ class BxDolObject extends BxDolFactory implements iBxDolReplaceable
 
     public function getCounterAPI($aParams = [])
     {
-        if(!$this->_bApi)
+        if(!$this->_bIsApi)
             return;
 
         //TODO: Implement for Objects like Views, Votes, etc.

+ 2 - 2
inc/classes/BxDolVoteReactions.php

@@ -78,7 +78,7 @@ class BxDolVoteReactions extends BxTemplVote
 
         if(!empty($sDefault)) {
             $aDefault = $this->_aDataList[$sDefault];
-            if(((!$this->_bQuickMode && !$this->_bSingleMode) || $this->_bApi) && isset($aDefault['default'])) {
+            if(((!$this->_bQuickMode && !$this->_bSingleMode) || $this->_bIsApi) && isset($aDefault['default'])) {
                 if(is_array($aDefault['default']))
                     $aDefault = array_merge ($aDefault, $aDefault['default']);
                 else
@@ -254,7 +254,7 @@ class BxDolVoteReactions extends BxTemplVote
         $iCount = (int)$aVote['count_' . $sReaction];
         $aResult = [
             'code' => 0,
-            'reaction' => $this->_bApi ? $aReactions[$sSwitchTo]['name'] : $sReaction,
+            'reaction' => $this->_bIsApi ? $aReactions[$sSwitchTo]['name'] : $sReaction,
             'rate' => $aVote['rate_' . $sReaction],
             'count' => $iCount,
             'countf' => $iCount > 0 ? $this->_getCounterLabel($iCount, array('reaction' => $sReaction)) : '',

+ 6 - 6
modules/boonex/tasks/classes/BxTasksTime.php

@@ -189,7 +189,7 @@ class BxTasksTime extends BxTemplReport
     {
         $mixedResult = parent::_getDoReport($aParams);
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             $mixedResult['is_do_auto'] = $this->_iDoAuto($aParams);
 
         return $mixedResult;
@@ -200,16 +200,16 @@ class BxTasksTime extends BxTemplReport
         $iAuthorId = $this->_getAuthorId();
         $iAuthorNip = bx_get_ip_hash($this->_getAuthorIp());
 
-        $iObjectId = ($sKey = 'object_id') && $this->_bApi ? $this->_iId : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
+        $iObjectId = ($sKey = 'object_id') && $this->_bIsApi ? $this->_iId : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
 
         if(!$this->isAllowedReport(true))
             return ['code' => 2, 'message' => $this->msgErrAllowedReport()];
 
-        $iVh = ($sKey = 'value_h') && $this->_bApi ? $aParams[$sKey] : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
-        $iVm = ($sKey = 'value_m') && $this->_bApi ? $aParams[$sKey] : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
+        $iVh = ($sKey = 'value_h') && $this->_bIsApi ? $aParams[$sKey] : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
+        $iVm = ($sKey = 'value_m') && $this->_bIsApi ? $aParams[$sKey] : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
         $iValue = $this->_oModule->_oConfig->timeA2I([$iVh, $iVm]);
 
-        $sText = ($sKey = 'text') && $this->_bApi ? $aParams[$sKey] : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
+        $sText = ($sKey = 'text') && $this->_bIsApi ? $aParams[$sKey] : ($aParams[$sKey] ?? $oForm->getCleanValue($sKey));
         $sText = bx_process_input($sText);
 
         $iId = (int)$oForm->insert(['object_id' => $iObjectId, 'author_id' => $iAuthorId, 'author_nip' => $iAuthorNip, 'value' => $iValue,  'text' => $sText,  'date' => time()]);
@@ -232,7 +232,7 @@ class BxTasksTime extends BxTemplReport
                 if($aTimer && ($iContentId = $aTimer['content_id'] ?? 0) && ($iProfileId = $aTimer['profile_id'] ?? 0)) {
                     $this->_oModule->serviceProcessTimer('clear', $iContentId, $iProfileId);
 
-                    if(!$this->_bApi)
+                    if(!$this->_bIsApi)
                         $aResult = array_merge($aResult, [
                             'label_title' => _t('_bx_tasks_txt_timer_log'),
                             'eval' => $aResult['eval'] . '; ' . $this->_oModule->_oConfig->getJsObject('timer'). '.reload(this, ' . $iContentId . ', ' . $iProfileId . ');'

+ 1 - 3
template/scripts/BxBaseConnection.php

@@ -15,8 +15,6 @@ class BxBaseConnection extends BxDolConnection
     protected $_oTemplate;
     protected $_oFunctions;
 
-    protected $_bApi = false; // NOSONAR php:S116, the same field as BxDolObject::$_bApi
-
     protected $_sStylePrefix;
     protected $_sJsObjName;
 
@@ -211,7 +209,7 @@ class BxBaseConnection extends BxDolConnection
 
     public function getElementAPI($iContent, $iInitiator = false, $aParams = [])
     {
-        if(!($this->_bApi = bx_is_api()))
+        if(!($this->_bIsApi = bx_is_api()))
             return;
 
         if(!$iInitiator && (!($iInitiator = bx_get_logged_profile_id()) || $iInitiator == $iContent))

+ 2 - 2
template/scripts/BxBaseFavorite.php

@@ -179,7 +179,7 @@ class BxBaseFavorite extends BxDolFavorite
 
     public function getElementAPI($aParams = [])
     {
-        if(!($this->_bApi = bx_is_api()))
+        if(!($this->_bIsApi = bx_is_api()))
             return;
 
         if(!$this->isEnabled())
@@ -253,7 +253,7 @@ class BxBaseFavorite extends BxDolFavorite
         if($bDisabled)
             $sClass .= $bShowDoFavoriteAsButton || $bShowDoFavoriteAsButtonSmall ? ' bx-btn-disabled' : 'bx-favorite-disabled';
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $this->isUndo(),
                 'is_favorited' => $bFavorited,

+ 2 - 2
template/scripts/BxBaseFeature.php

@@ -124,7 +124,7 @@ class BxBaseFeature extends BxDolFeature
 
     public function getElementAPI($aParams = [])
     {
-        if(!($this->_bApi = bx_is_api()))
+        if(!($this->_bIsApi = bx_is_api()))
             return;
 
         if(!$this->isEnabled())
@@ -173,7 +173,7 @@ class BxBaseFeature extends BxDolFeature
         if($bDisabled)
             $sClass .= $bShowDoFeatureAsButton || $bShowDoFeatureAsButtonSmall ? ' bx-btn-disabled' : 'bx-feature-disabled';
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $this->isUndo(),
                 'is_featured' => $bFeatured,

+ 8 - 8
template/scripts/BxBaseReport.php

@@ -52,7 +52,7 @@ class BxBaseReport extends BxDolReport
             'show_counter' => true,
             'show_counter_only' => true
         );
-        if($this->_bApi) {
+        if($this->_bIsApi) {
             $aTypes = BxDolFormQuery::getDataItems($this->_sTypesPreList);
 
             $this->_aElementDefaultsApi = array_merge($this->_aElementDefaults, [
@@ -119,10 +119,10 @@ class BxBaseReport extends BxDolReport
 
         $oForm = $this->_getFormObject();
         $oForm->initChecker();
-        if($oForm->isSubmittedAndValid() || ($this->_bApi && !empty($aParams) && is_array($aParams)))
+        if($oForm->isSubmittedAndValid() || ($this->_bIsApi && !empty($aParams) && is_array($aParams)))
             return $this->_report($bPerformed, $aParams, $oForm);
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'code' => 0,
                 'api' => bx_api_get_block('form', $oForm->getCodeAPI(), [
@@ -268,7 +268,7 @@ class BxBaseReport extends BxDolReport
 
     public function getElementAPI($aParams = [])
     {
-        if(!$this->_bApi)
+        if(!$this->_bIsApi)
             return;
         
         if(!$this->isEnabled())
@@ -375,17 +375,17 @@ class BxBaseReport extends BxDolReport
         $iAuthorId = $this->_getAuthorId();
         $iAuthorNip = bx_get_ip_hash($this->_getAuthorIp());
 
-        $iObjectId = $this->_bApi ? $this->_iId : $oForm->getCleanValue('object_id');
+        $iObjectId = $this->_bIsApi ? $this->_iId : $oForm->getCleanValue('object_id');
         $iObjectAuthorId = $this->_oQuery->getObjectAuthorId($iObjectId);
 
         if(!$this->isAllowedReport(true))
             return ['code' => 2, 'message' => $this->msgErrAllowedReport()];
 
-        $sType = $this->_bApi ? $aParams['type'] : $oForm->getCleanValue('type');
+        $sType = $this->_bIsApi ? $aParams['type'] : $oForm->getCleanValue('type');
         if(!in_array($sType, $this->_aTypes)) 
             return ['code' => 5, 'message' => _t('_report_err_wrong_type')];
 
-        $sText = $this->_bApi ? $aParams['text'] : $oForm->getCleanValue('text');
+        $sText = $this->_bIsApi ? $aParams['text'] : $oForm->getCleanValue('text');
         $sText = bx_process_input($sText, BX_DATA_TEXT_MULTILINE);
 
         $iId = (int)$oForm->insert(['object_id' => $iObjectId, 'author_id' => $iAuthorId, 'author_nip' => $iAuthorNip, 'type' => $sType, 'text' => $sText,  'date' => time()]);
@@ -496,7 +496,7 @@ class BxBaseReport extends BxDolReport
 
         $sTitle = call_user_func_array('_t', $this->_getTitleDoReport($bReported, $aParams));
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $this->isUndo(),
                 'is_reported' => $bReported,

+ 2 - 2
template/scripts/BxBaseScore.php

@@ -387,7 +387,7 @@ class BxBaseScore extends BxDolScore
 
     public function getElementAPI($aParams = [])
     {
-        if(!($this->_bApi = bx_is_api()))
+        if(!($this->_bIsApi = bx_is_api()))
             return;
 
         if(!$this->isEnabled())
@@ -449,7 +449,7 @@ class BxBaseScore extends BxDolScore
         if($bDisabled)
             $sClass .= $bShowDoVoteAsButton || $bShowDoVoteAsButtonSmall ? ' bx-btn-disabled' : 'bx-score-disabled';
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $bUndo,
                 'is_voted' => $bVoted,

+ 2 - 2
template/scripts/BxBaseVote.php

@@ -176,7 +176,7 @@ class BxBaseVote extends BxDolVote
     
     public function getElementAPI($aParams = [])
     {
-        if(!($this->_bApi = bx_is_api()))
+        if(!($this->_bIsApi = bx_is_api()))
             return;
 
         if(!$this->isEnabled())
@@ -331,7 +331,7 @@ class BxBaseVote extends BxDolVote
 
     protected function _getDoVote($aParams = array(), $isAllowedVote = true)
     {
-        return $this->_bApi ? [] : '';
+        return $this->_bIsApi ? [] : '';
     }
 
     protected function _getCounterLabel($iCount, $aParams = array())

+ 1 - 1
template/scripts/BxBaseVoteLikes.php

@@ -109,7 +109,7 @@ class BxBaseVoteLikes extends BxDolVoteLikes
         if($bDisabled)
             $sClass .= $bShowDoVoteAsButton || $bShowDoVoteAsButtonSmall ? ' bx-btn-disabled' : 'bx-vote-disabled';
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $this->isUndo(),
                 'is_voted' => $bVoted,

+ 1 - 1
template/scripts/BxBaseVoteReactions.php

@@ -430,7 +430,7 @@ class BxBaseVoteReactions extends BxDolVoteReactions
         else
             $sClass .= $bShowDoVoteAsButton || $bShowDoVoteAsButtonSmall ? ' bx-btn-disabled' : ' ' . $this->_sStylePrefix . '-disabled';
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $bUndo,
                 'is_voted' => $bVoted,

+ 1 - 1
template/scripts/BxBaseVoteStars.php

@@ -117,7 +117,7 @@ class BxBaseVoteStars extends BxDolVoteStars
         $bVoted = isset($aParams['is_voted']) && (bool)$aParams['is_voted'] === true;
         $bDisabled = !$isAllowedVote || ($bVoted && !$this->isUndo());
 
-        if($this->_bApi)
+        if($this->_bIsApi)
             return [
                 'is_undo' => $this->isUndo(),
                 'is_voted' => $bVoted,

+ 1 - 1
tests/units/template/scripts/BxBaseConnectionTest.php

@@ -41,7 +41,7 @@ class BxBaseConnectionTest extends BxDolTestCase
 
         $this->assertSame([], $aErrors);
         // A class name, not the object: ReflectionClass of an object also sees dynamic properties.
-        $this->assertTrue((new ReflectionClass(get_class($o)))->hasProperty('_bApi'));
+        $this->assertTrue((new ReflectionClass(get_class($o)))->hasProperty('_bIsApi'));
     }
 
     static public function providerForConnectionObjects()