Przeglądaj źródła

#1339 Embeds for all content types - fix

RomanL 4 lat temu
rodzic
commit
f9c59bdfe9

+ 5 - 1
em.php

@@ -9,7 +9,11 @@
 require_once('./inc/header.inc.php');
 
 $aEmbedData = BxDolPage::getEmbedData(bx_get('url'));
-    
+if(empty($aEmbedData)){
+    header('HTTP/1.0 404 Not Found');
+    header('Status: 404 Not Found');
+    exit();
+}    
 $aResult = [
     'version' => '1.0',
     'type' => 'rich',

+ 7 - 3
inc/classes/BxDolPage.php

@@ -495,22 +495,26 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
         $aParams = [];
         
         $aUrl = bx_get_base_url($sUrl);
+        if (!isset($aUrl[1]['i'])){
+            return [];
+        }
+            
         $sUri = $aUrl[1]['i'];
         unset($aUrl[1]['i']);
         $aParams = $aUrl[1];
-        
+
         $sAuthorName = $sAuthorUrl = $sThumb = '';
         if (isset($aParams['id'])){
             $sContentInfoObject = BxDolPageQuery::getContentInfoObjectNameByURI($sUri);
             $oContentInfo = BxDolContentInfo::getObjectInstance($sContentInfoObject);
-            
+
             $sTitle = $oContentInfo->getContentTitle($aParams['id']);
             $iAuthor = $oContentInfo->getContentAuthor($aParams['id']);
             $sAuthorName = BxDolProfile::getInstance()->getDisplayName($iAuthor);
             $sAuthorUrl = BxDolProfile::getInstance()->getUrl($iAuthor);
             $sThumb = $oContentInfo->getContentThumb($aParams['id']);
             $sHtml = $oContentInfo->getContentEmbed($aParams['id']);
-            
+
         }
         else{
             $oPage = BxDolPage::getObjectInstanceByURI($sUri, false, true);

+ 4 - 5
inc/classes/BxDolTemplate.php

@@ -841,12 +841,11 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      */
     function getEmbed($sContent)
     {
+        header('Content-Security-Policy: frame-ancestors ' . getParam('sys_csp_frame_ancestors')) ;
         if ($sContent == ''){
-            header('HTTP/1.0 404 Not Found');
-            header('Status: 404 Not Found');
-            exit();
+            $this->displayPageNotFound('', BX_PAGE_EMBED);
+            exit;
         }
-        header('Content-Security-Policy: frame-ancestors ' . getParam('sys_csp_frame_ancestors')) ;
         
         $this->addJs(['inc/js/|embed.js']);
         $this->addCss(['embed.css']);
@@ -1195,7 +1194,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         
         if (!empty($this->aPage['rss']) && !empty($this->aPage['rss']['url']))
             $sRet .= '<link rel="alternate" type="application/rss+xml" title="' . bx_html_attribute($this->aPage['rss']['title'], BX_ESCAPE_STR_QUOTE) . '" href="' . $this->aPage['rss']['url'] . '" />';
-
+        
         $sRet .= "<link rel=\"alternate\" type=\"application/json+oembed\" href=\"" . BX_DOL_URL_ROOT ."em.php?url=" . urlencode($_SERVER["REQUEST_URI"]) . "&format=json\" title=\"". (isset($this->aPage['header']) ? bx_html_attribute(strip_tags($this->aPage['header'])) : '') . "\" />";
         
         $sRet .= "<link rel=\"canonical\" href=\"" . BX_DOL_URL_ROOT . substr($_SERVER["REQUEST_URI"], 1) . "\" />";

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

@@ -104,7 +104,7 @@ class BxBaseModGeneralModule extends BxDolModule
         
         $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
         if(empty($aContentInfo))
-            $oTemplate->displayPageNotFound();
+            $oTemplate->getEmbed(false);
 
         if(empty($sUnitTemplate))
             $sUnitTemplate = 'unit_gallery.html';

+ 1 - 0
modules/base/profile/template/embed.html

@@ -0,0 +1 @@
+<iframe width="300" height="230" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 1 - 0
modules/boonex/ads/template/embed.html

@@ -0,0 +1 @@
+<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 1 - 1
modules/boonex/albums/classes/BxAlbumsModule.php

@@ -48,7 +48,7 @@ class BxAlbumsModule extends BxBaseModTextModule
         
         $aContentInfo = $this->_oDb->getMediaInfoById($iContentId);
         if(empty($aContentInfo))
-            $oTemplate->displayPageNotFound();
+            $oTemplate->getEmbed(false);
 
         if(empty($sUnitTemplate))
             $sUnitTemplate = 'unit_media_gallery.html';

+ 1 - 0
modules/boonex/albums/template/embed.html

@@ -0,0 +1 @@
+<iframe width="300" height="330" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 1 - 0
modules/boonex/files/template/embed.html

@@ -0,0 +1 @@
+<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 1 - 0
modules/boonex/market/template/embed.html

@@ -0,0 +1 @@
+<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>

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

@@ -0,0 +1 @@
+<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 1 - 0
modules/boonex/videos/template/embed.html

@@ -0,0 +1 @@
+<iframe width="560" height="315" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 2 - 7
modules/boonex/videos/template/unit_gallery_embed.html

@@ -2,7 +2,7 @@
     <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" >
+                <div class="bx-def-round-corners bx-def-font-middle" >
                     __entry_video__
                 </div>
             </a>
@@ -15,11 +15,6 @@
                 </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/embed.html

@@ -1 +1 @@
-<iframe width="300" height="300" src="__url__" frameborder="0" allowfullscreen></iframe>
+<iframe width="300" height="260" src="__url__" frameborder="0" allowfullscreen></iframe>