Просмотр исходного кода

Ticket #4888 - Market: Embed shouldn't have 'dots' menu and Buy action.

AntonLV 1 год назад
Родитель
Сommit
1ce6763941

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

@@ -380,8 +380,8 @@ class BxBaseModGeneralModule extends BxDolModule
             if($oView && $oView->isEnabled())
                 $oView->doView();
         }
-        
-        $oTemplate->getEmbed($this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate) . $sAddCode);
+
+        $oTemplate->getEmbed($this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate, ['embed' => true]) . $sAddCode);
     }
    
     public function subactionDelete()

+ 9 - 6
modules/boonex/market/classes/BxMarketTemplate.php

@@ -197,7 +197,7 @@ class BxMarketTemplate extends BxBaseModTextTemplate
     	));    	
     }
 
-    protected function getUnit ($aData, $aParams = array())
+    protected function getUnit ($aData, $aParams = [])
     {
         $bTmplVarsSectionAuthor = true;
         $bTmplVarsSectionPricing = false;
@@ -210,6 +210,8 @@ class BxMarketTemplate extends BxBaseModTextTemplate
         $oPayment = BxDolPayments::getInstance();
         $oPermalinks = BxDolPermalinks::getInstance();
 
+        $bEmbed = isset($aParams['embed']) && $aParams['embed'] === true;
+
         $iAuthorId = (int)$aData[$CNF['FIELD_AUTHOR']];
         list($sAuthorName, $sAuthorUrl, $sAuthorIcon, $sAuthorUnit, $sAuthorUnitShort) = $oModule->getUserInfo($iAuthorId);
         $sAuthorCurrencySign = $oPayment->getCurrencySign($iAuthorId);
@@ -230,8 +232,7 @@ class BxMarketTemplate extends BxBaseModTextTemplate
 
             //--- Actions
             $sActions = '';
-            $oActions = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_SNIPPET']);
-            if($oActions) {
+            if(!$bEmbed && ($oActions = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_SNIPPET'])) !== false) {
                 $oActions->setContentId($aData[$CNF['FIELD_ID']]);
                 $sActions = $oActions->getCode();
             }
@@ -348,9 +349,11 @@ class BxMarketTemplate extends BxBaseModTextTemplate
         $aTmplVarsSectionVoting = array();
         if($bTmplVarsSectionVoting) {
             $sVoting = '';
-            $oVoting = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aData[$CNF['FIELD_ID']]);
-            if($oVoting)
-                $sVoting = $oVoting->getElementBlock(array('show_counter' => false));
+            if(($oVoting = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aData[$CNF['FIELD_ID']])) !== false)
+                $sVoting = $oVoting->getElementBlock([
+                    'show_counter' => false,
+                    'read_only' => $bEmbed
+                ]);
 
             $sPricing = "";
             if((float)$aData[$CNF['FIELD_PRICE_RECURRING']] != 0) {

+ 4 - 2
template/scripts/BxBaseVoteStars.php

@@ -31,7 +31,8 @@ class BxBaseVoteStars extends BxDolVoteStars
             'show_counter' => true,
             'show_counter_empty' => false,
             'show_legend' => false,
-            'show_script' => true
+            'show_script' => true,
+            'read_only' => false
         ];
         $this->_aElementDefaultsApi = array_merge($this->_aElementDefaults, [
             'show_counter' => true,
@@ -112,6 +113,7 @@ class BxBaseVoteStars extends BxDolVoteStars
         $iMinValue = $this->getMinValue();
         $iMaxValue = $this->getMaxValue();
 
+        $bReadOnly = isset($aParams['read_only']) && (bool)$aParams['read_only'] === true;
         $bVoted = isset($aParams['is_voted']) && (bool)$aParams['is_voted'] === true;
         $bDisabled = !$isAllowedVote || ($bVoted && !$this->isUndo());
 
@@ -141,7 +143,7 @@ class BxBaseVoteStars extends BxDolVoteStars
                 'style_prefix' => $this->_sStylePrefix
             );
 
-            if($isAllowedVote)
+            if($isAllowedVote && !$bReadOnly)
                 $aTmplVarsButtons[] = array(
                     'style_prefix' => $this->_sStylePrefix,
                     'js_object' => $sJsObject,