Przeglądaj źródła

Ticket #2375 - Point №3

AntonLV 7 lat temu
rodzic
commit
6f5ce5cbf4

+ 7 - 1
modules/boonex/polls/classes/BxPollsConfig.php

@@ -107,9 +107,15 @@ class BxPollsConfig extends BxBaseModTextConfig
             'OBJECT_MENU_SNIPPET_META' => 'bx_polls_snippet_meta', // menu for snippet meta info
             'OBJECT_MENU_MANAGE_TOOLS' => 'bx_polls_menu_manage_tools', //manage menu in content administration tools
             'OBJECT_GRID_ADMINISTRATION' => 'bx_polls_administration',
-        	'OBJECT_GRID_COMMON' => 'bx_polls_common',
+            'OBJECT_GRID_COMMON' => 'bx_polls_common',
             'OBJECT_UPLOADERS' => array('sys_simple', 'sys_html5'),
 
+            // styles
+            'STYLES_POLLS_EMBED_CLASS' => 'body.bx-page-iframe.bx-def-color-bg-page',
+            'STYLES_POLLS_EMBED_CONTENT' => array(
+                'background-color' => 'transparent'
+            ),
+
             // menu items which visibility depends on custom visibility checking
             'MENU_ITEM_TO_METHOD' => array (
                 'bx_polls_my' => array (

+ 20 - 3
modules/boonex/polls/classes/BxPollsModule.php

@@ -46,6 +46,20 @@ class BxPollsModule extends BxBaseModTextModule
         ));
     }
 
+    public function actionEmbedEntry($iId = 0)
+    {
+        list($iContentId, $aContentInfo) = $this->_getContent($iId);
+        if($iContentId === false)
+            return;
+
+        $aParams = bx_get_with_prefix('param');
+        array_walk($aParams, function(&$sValue) {
+            $sValue = bx_process_input($sValue);
+        });
+
+        $this->_oTemplate->embedEntry($aContentInfo, $aParams);
+    }
+
 
     /**
      * SERVICE METHODS
@@ -207,15 +221,18 @@ class BxPollsModule extends BxBaseModTextModule
         $bDynamic = isset($aBrowseParams['dynamic_mode']) && $aBrowseParams['dynamic_mode'] === true;
 
         $sInclude = '';
-        $sInclude .= $this->_oTemplate->addJs(array('entry.js'), $bDynamic);
-        $sInclude .= $this->_oTemplate->addCss(array('entry.css'), $bDynamic);
+        $sInclude .= $this->_oTemplate->addCss(array('main.css'), $bDynamic);
 
         $aBlock = $this->_oTemplate->{$this->_oDb->isPerformed($aContentInfo[$CNF['FIELD_ID']], bx_get_logged_profile_id()) ? 'entryResults' : 'entrySubentries'}($aContentInfo, $bDynamic);
 
         $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
         $aResult['title'] = $this->_oConfig->getTitle($aContentInfo);
         $aResult['text'] = '';
-        $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->getJsCode('entry') . $aBlock['content'];
+        $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('unit_embed.html', array(
+            'embed_url' => BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'embed_entry/', array(
+                'id' => (int)$aContentInfo[$CNF['FIELD_ID']]
+            ))
+        ));
 
         return $aResult;
     }

+ 22 - 0
modules/boonex/polls/classes/BxPollsTemplate.php

@@ -23,6 +23,28 @@ class BxPollsTemplate extends BxBaseModTextTemplate
         parent::__construct($oConfig, $oDb);
     }
 
+    public function embedEntry($mixedContentInfo, $aParams = array())
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+
+        $aContentInfo = is_array($mixedContentInfo) ? $mixedContentInfo : $this->_oDb->getContentInfoById((int)$mixedContentInfo);
+        if(empty($aContentInfo) || !is_array($aContentInfo))
+            return;
+
+        $aBlock = $this->{$this->_oDb->isPerformed((int)$aContentInfo[$CNF['FIELD_ID']], bx_get_logged_profile_id()) ? 'entryResults' : 'entrySubentries'}($aContentInfo);
+
+        $this->addJs(array('entry.js'));
+        $this->addCss(array('entry.css'));
+
+        $oTemplate = BxDolTemplate::getInstance();
+        $oTemplate->addCssStyle($CNF['STYLES_POLLS_EMBED_CLASS'], $CNF['STYLES_POLLS_EMBED_CONTENT']);
+        $oTemplate->setPageNameIndex(BX_PAGE_EMBED);
+        $oTemplate->setPageHeader(strmaxtextlen($this->_oConfig->getTitle($aContentInfo), 32, '...'));
+        $oTemplate->setPageContent('page_main_code', $this->getJsCode('entry') . $aBlock['content']);
+        $oTemplate->getPageCode();
+        exit;
+    }
+
     public function getJsCode($sType, $aParams = array(), $bWrap = true)
     {
         $aParams = array_merge(array(

+ 8 - 0
modules/boonex/polls/template/css/entry.css

@@ -1,3 +1,11 @@
+/*--- Embed ---*/
+.bx-page-iframe .bx-polls-content {
+    width: 100vw;
+    height: 100vh;
+    overflow-x: hidden;
+    overflow-y: auto;
+}
+
 /*--- Text and Subentries ---*/
 .bx-polls-entity-actions {
     position: relative;

+ 7 - 0
modules/boonex/polls/template/css/main.css

@@ -1 +1,8 @@
 @import url(../../../../base/text/template/css/main.css);
+
+
+/*--- Unit embed ---*/
+.bx-polls-embed {
+    width: 100%;
+    height: 200px;
+}

+ 1 - 0
modules/boonex/polls/template/unit_embed.html

@@ -0,0 +1 @@
+<iframe class="bx-polls-embed" src="__embed_url__" frameborder="0"></iframe>