Browse Source

#1339 Embeds for all content types - fix

RomanL 4 years ago
parent
commit
79c55b1b00

+ 10 - 1
inc/classes/BxDolTemplate.php

@@ -626,6 +626,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             'location' => array(),
             'description'  => '',
             'robots' => '',
+            'base' => ['href' =>  BX_DOL_URL_ROOT],
             'css_name' => array(),
             'css_compiled' => array(),
             'css_system' => array(),
@@ -840,11 +841,16 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      */
     function getEmbed($sContent)
     {
+        if ($sContent == ''){
+            header('HTTP/1.0 404 Not Found');
+            header('Status: 404 Not Found');
+            exit();
+        }
         header('Content-Security-Policy: frame-ancestors ' . getParam('sys_csp_frame_ancestors')) ;
         
         $this->addJs(['inc/js/|embed.js']);
         $this->addCss(['embed.css']);
-        
+        $this->aPage['base']['target'] = '_blank';
         $this->setPageNameIndex (BX_PAGE_EMBED);
         $this->setPageContent('page_main_code', '<div class="bx-embed">' . $sContent . '</div>');
         $this->getPageCode();
@@ -1685,6 +1691,9 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             case 'included_js':
                 $sRet = json_encode($this->getIncludedUrls('js_compiled'));
                 break;
+            case 'base':
+                $sRet = bx_convert_array2attrs($this->aPage['base']);
+                break;
             default:
                 $sRet = ($sTemplAdd = BxTemplFunctions::getInstance()->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : $aKeyWrappers['left'] . $sKey . $aKeyWrappers['right'];
         }

+ 4 - 3
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -98,16 +98,17 @@ class BxBaseModGeneralModule extends BxDolModule
         $this->$sMethodName();
     }
     
-    public function actionEmbed($iContentId)
+    public function actionEmbed($iContentId, $sUnitTemplate = '')
     {
+        $oTemplate = BxDolTemplate::getInstance();
+        
         $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
         if(empty($aContentInfo))
-            return '';
+            $oTemplate->displayPageNotFound();
 
         if(empty($sUnitTemplate))
             $sUnitTemplate = 'unit_gallery.html';
 
-        $oTemplate = BxDolTemplate::getInstance();
         $oTemplate->getEmbed($this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate));
     }
    

+ 5 - 0
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -88,6 +88,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         header('Content-Type: application/json; charset=utf-8');
         echo json_encode($aEntries);
     }
+    
+    public function actionEmbed($iContentId, $sUnitTemplate = '')
+    {
+        return parent::actionEmbed($iContentId, 'unit_with_cover.html');
+    }
 
     // ====== SERVICE METHODS
 

+ 8 - 2
modules/boonex/albums/classes/BxAlbumsModule.php

@@ -36,17 +36,23 @@ class BxAlbumsModule extends BxBaseModTextModule
             'BrowseFavoriteMedia' => '',
         ));
     }
+    
+    public function actionEmbed($iContentId, $sUnitTemplate = '')
+    {
+        return $this->_oTemplate->getJsCode('main') . parent::actionEmbed($iContentId);
+    }
 
     public function actionEmbedMedia($iContentId)
     {
+        $oTemplate = BxDolTemplate::getInstance();
+        
         $aContentInfo = $this->_oDb->getMediaInfoById($iContentId);
         if(empty($aContentInfo))
-            return '';
+            $oTemplate->displayPageNotFound();
 
         if(empty($sUnitTemplate))
             $sUnitTemplate = 'unit_media_gallery.html';
 
-        $oTemplate = BxDolTemplate::getInstance();
         $oTemplate->getEmbed($this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate));
     }
     

+ 10 - 1
modules/boonex/albums/template/unit_gallery.html

@@ -12,4 +12,13 @@
             </div>
         </div>
     </div>
-</div>
+</div>
+<script>
+    $('.bx-albums-unit-images').flickity({
+        cellSelector: '.bx-albums-unit-image',
+        cellAlign: 'left',
+        imagesLoaded: true,
+        wrapAround: true,
+        pageDots: false
+    });
+</script>

+ 5 - 0
modules/boonex/videos/classes/BxVideosModule.php

@@ -24,6 +24,11 @@ class BxVideosModule extends BxBaseModTextModule
         $aRes = $this->parseEmbedLink($sCode);
         if ($aRes) echo $aRes['embed'];
     }
+    
+    public function actionEmbed($iContentId, $sUnitTemplate = '')
+    {
+        return parent::actionEmbed($iContentId, 'unit_gallery_embed.html');
+    }
 
     public function parseEmbedLink($sLink) {
         $aEmbedProviders = $this->_oDb->getEmbedProviders();

+ 5 - 4
modules/boonex/videos/classes/BxVideosTemplate.php

@@ -37,7 +37,7 @@ class BxVideosTemplate extends BxBaseModTextTemplate
         ));
     }
 
-    public function entryVideo ($aContentInfo, $mixedContext = false)
+    public function entryVideo ($aContentInfo, $mixedContext = false, $aAttrs = false, $sStyles = false)
     {
         $aTmplVars = array(
             'video_title' => bx_process_output($aContentInfo['title']),
@@ -53,7 +53,7 @@ class BxVideosTemplate extends BxBaseModTextTemplate
             }
         }
 
-        $mixedVideo = $this->getVideo($aContentInfo);
+        $mixedVideo = $this->getVideo($aContentInfo, $aAttrs, $sStyles);
         if($mixedVideo !== false)
             $aTmplVars = array_merge($aTmplVars, array(
                 'video_poster_url' => $mixedVideo['poster_url'],
@@ -80,7 +80,7 @@ class BxVideosTemplate extends BxBaseModTextTemplate
     	return $sVotes; 
     }
 
-    public function getVideo($aContentInfo)
+    public function getVideo($aContentInfo, $aAttrs = false, $sStyles = false)
     {
         $CNF = &$this->getModule()->_oConfig->CNF;
 
@@ -132,7 +132,7 @@ class BxVideosTemplate extends BxBaseModTextTemplate
             'player' => BxTemplFunctions::getInstance()->videoPlayer(
                 $sPoster, 
                 $aTranscodersVideo['mp4']->getFileUrl($iFile), 
-                $sVideoUrlHd, false, 'max-height:' . $CNF['OBJECT_VIDEO_TRANSCODER_HEIGHT']
+                $sVideoUrlHd, $aAttrs, $sStyles ? $sStyles : 'max-height:' . $CNF['OBJECT_VIDEO_TRANSCODER_HEIGHT']
             )
         );
     }
@@ -178,6 +178,7 @@ class BxVideosTemplate extends BxBaseModTextTemplate
                 'duration' => _t_format_duration($aData[$CNF['FIELD_DURATION']]),
             ]
         ];
+        $aUnit['bx_if:thumb']['content']['entry_video'] = $this->entryVideo($aData, false, ['muted' => 'muted', 'autoplay' => 'autoplay'], 'height:100%');
 
         return $aUnit;
     }

+ 25 - 0
modules/boonex/videos/template/unit_gallery_embed.html

@@ -0,0 +1,25 @@
+<div class="__class__ bx-base-text-unit bx-base-text-unit-gallery bx-def-gal-unit-size bx-def-padding-sec bx-def-margin-sec-bottom">
+    <div class="bx-base-text-unit-cnt bx-def-box bx-def-round-corners bx-def-color-bg-box bx-def-box-sizing">
+        <bx_if:thumb>
+            <a href="__content_url__" title="__summary_attr__">
+                <div class="bx-base-text-unit-thumb bx-def-gal-div-size bx-def-round-corners bx-def-font-middle" >
+                    __entry_video__
+                </div>
+            </a>
+        </bx_if:thumb>
+        <bx_if:no_thumb>
+            <div class="bx-def-gal-img-column">
+                <div class="bx-base-text-unit-no-thumb bx-def-gal-div-size bx-def-font-middle bx-def-font-grayed bx-def-padding bx-def-box-sizing">
+                    __summary_plain__
+                    <div class="bx-base-text-unit-strecher">__strecher__</div>
+                </div>
+            </div>
+        </bx_if:no_thumb>
+        <div class="bx-base-text-unit-text bx-def-padding-leftright bx-def-padding-sec-topbottom bx-def-font-align-center bx-def-box-sizing">
+            <h2><a href="__content_url__">__title__</a></h2>
+            <div class="bx-base-text-unit-info bx-def-font-small">
+                <bx_if:meta><div class="bx-base-general-unit-meta">__meta__</div></bx_if:meta>
+            </div>
+        </div>
+    </div>
+</div>  

+ 1 - 1
template/_header.html

@@ -6,7 +6,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=__page_charset__" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
     <title>__page_header__</title>
-    <base href="<bx_url_root />" />
+    <base__base__ />
 
     __meta_info__
     __page_robots__

+ 3 - 0
template/css/embed.css

@@ -4,4 +4,7 @@ body,
 }
 .bx-embed{
     width:calc(100% - 2px);
+}
+.bx-embed .bx-base-pofile-unit-with-cover{
+    display: block;
 }

+ 1 - 1
template/page_2.html

@@ -6,7 +6,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=__page_charset__" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
     <title>__page_header__</title>
-    <base href="<bx_url_root />" />
+    <base__base__ />
 
     __meta_info__
     __page_robots__

+ 1 - 1
template/page_22.html

@@ -6,7 +6,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=__page_charset__" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
     <title>__page_header__</title>
-    <base href="<bx_url_root />" />
+    <base__base__ />
 
     __meta_info__
     __page_robots__