Parcourir la source

Ticket #2246 - Point 3.

AntonLV il y a 7 ans
Parent
commit
39f01aa2c5

+ 13 - 27
modules/base/text/classes/BxBaseModTextModule.php

@@ -534,37 +534,23 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
 
 
         $CNF = &$this->_oConfig->CNF;
         $CNF = &$this->_oConfig->CNF;
 
 
-        $iProfile = bx_get_logged_profile_id();
         $bDynamic = isset($aBrowseParams['dynamic_mode']) && (bool)$aBrowseParams['dynamic_mode'] === true;
         $bDynamic = isset($aBrowseParams['dynamic_mode']) && (bool)$aBrowseParams['dynamic_mode'] === true;
 
 
-        $sPolls = '';
         $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
         $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
         if(!empty($aPolls) && is_array($aPolls)) {
         if(!empty($aPolls) && is_array($aPolls)) {
-            foreach($aPolls as $aPoll) {
-                $sPoll = $this->_oTemplate->getPollItem($aPoll, $iProfile, array(
-                    'dynamic' => $bDynamic,
-                    'switch_menu' => false
-                ));
-                if(empty($sPoll))
-                    continue;
-
-                $sPolls .= $sPoll;
-            }
-
-            if(!empty($sPolls)) {
-                $sInclude = '';
-                $sInclude .= $this->_oTemplate->addJs(array('polls.js'), $bDynamic);
-                $sInclude .= $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
-
-                $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->getJsCode('poll') . $this->_oTemplate->parseHtmlByName('poll_items_showcase.html', array(
-                    'js_object' => $this->_oConfig->getJsObject('poll'),
-                    'html_id' => $this->_oConfig->getHtmlIds('polls_showcase') . $aEvent['id'],
-                    'polls' => $sPolls
-                ));
-
-                if((!empty($aResult['videos']) && is_array($aResult['videos'])) || (!empty($aResult['videos_attach']) && is_array($aResult['videos_attach'])))
-                    $aResult['_cache'] = false;
-            }
+            $sInclude = $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
+
+            $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('poll_items_embed.html', array(
+                'embed_url' => BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'embed_polls/', array(
+                    'id' => (int)$aContentInfo[$CNF['FIELD_ID']],
+                    'param_switch_menu' => 0,
+                    'param_showcase' => 1
+                ))
+            ));
+/*
+            if((!empty($aResult['videos']) && is_array($aResult['videos'])) || (!empty($aResult['videos_attach']) && is_array($aResult['videos_attach'])))
+                $aResult['_cache'] = false;
+ */
         }
         }
 
 
         return $aResult;
         return $aResult;

+ 14 - 1
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -307,7 +307,9 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         if(empty($aContentInfo) || !is_array($aContentInfo))
         if(empty($aContentInfo) || !is_array($aContentInfo))
             return;
             return;
 
 
-        $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
+        $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
+
+        $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => $iContentId));
         if(empty($aPolls) || !is_array($aPolls))
         if(empty($aPolls) || !is_array($aPolls))
             return;
             return;
 
 
@@ -315,6 +317,17 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         foreach($aPolls as $aPoll)
         foreach($aPolls as $aPoll)
             $sContent .= $this->getPollItem($aPoll, 0, $aParams);
             $sContent .= $this->getPollItem($aPoll, 0, $aParams);
 
 
+        if(!empty($sContent) && isset($aParams['showcase']) && (bool)$aParams['showcase'] === true) {
+            $this->addJs(array('flickity/flickity.pkgd.min.js'));
+            $this->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flickity/|flickity.css');
+
+            $sContent = $this->parseHtmlByName('poll_items_showcase.html', array(
+                'js_object' => $this->_oConfig->getJsObject('poll'),
+                'html_id' => $this->_oConfig->getHtmlIds('polls_showcase') . $iContentId,
+                'polls' => $sContent
+            ));
+        }
+
         $sHeader = '';
         $sHeader = '';
         if(!empty($sContent)) {
         if(!empty($sContent)) {
             $sHeader = strmaxtextlen($aContentInfo[$CNF['FIELD_TITLE']], 32, '...');
             $sHeader = strmaxtextlen($aContentInfo[$CNF['FIELD_TITLE']], 32, '...');

+ 1 - 1
modules/base/text/template/css/polls.css

@@ -186,7 +186,7 @@ div.bx-base-text-pr-graph .bx-base-text-prg-text {
 
 
 /*--- Poll item embed ---*/
 /*--- Poll item embed ---*/
 .bx-base-text-poll-embed {
 .bx-base-text-poll-embed {
-    width: 560px;
+    width: 100%;
     height: 315px;
     height: 315px;
 }
 }
 
 

+ 1 - 1
modules/boonex/posts/js/polls.js

@@ -105,7 +105,7 @@ BxPostsPolls.prototype.embedPoll = function(oLink, iId)
     var sEmbedUrl = this._sActionsUrl + 'embed_poll/' + iId;
     var sEmbedUrl = this._sActionsUrl + 'embed_poll/' + iId;
     var sHtmlId = 'bx-base-general-poll-' + iId;
     var sHtmlId = 'bx-base-general-poll-' + iId;
 
 
-    bx_editor_insert_html (this._sEditorId, sHtmlId, '<iframe class="bx-base-text-poll-embed" src="' + sEmbedUrl + '" frameborder="0" allow="autoplay; picture-in-picture" allowfullscreen></iframe>');
+    bx_editor_insert_html (this._sEditorId, sHtmlId, '<iframe class="bx-base-text-poll-embed" src="' + sEmbedUrl + '" frameborder="0"></iframe>');
 };
 };
 
 
 BxPostsPolls.prototype.deletePoll = function(oLink, iId)
 BxPostsPolls.prototype.deletePoll = function(oLink, iId)