Skip to content

Commit

Permalink
unacms#1339 Embeds for all content types - fix
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlesnikov committed Jan 18, 2022
1 parent ac9d85a commit f9c59bd
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 19 deletions.
6 changes: 5 additions & 1 deletion em.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 7 additions & 3 deletions inc/classes/BxDolPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,22 +495,26 @@ static public function getEmbedData ($sUrl)
$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);
Expand Down
9 changes: 4 additions & 5 deletions inc/classes/BxDolTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,11 @@ function getCode()
*/
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']);
Expand Down Expand Up @@ -1195,7 +1194,7 @@ function getMetaInfo()

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) . "\" />";
Expand Down
2 changes: 1 addition & 1 deletion modules/base/general/classes/BxBaseModGeneralModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function actionEmbed($iContentId, $sUnitTemplate = '')

$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
if(empty($aContentInfo))
$oTemplate->displayPageNotFound();
$oTemplate->getEmbed(false);

if(empty($sUnitTemplate))
$sUnitTemplate = 'unit_gallery.html';
Expand Down
1 change: 1 addition & 0 deletions modules/base/profile/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="300" height="230" src="__url__" frameborder="0" allowfullscreen></iframe>
1 change: 1 addition & 0 deletions modules/boonex/ads/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>
2 changes: 1 addition & 1 deletion modules/boonex/albums/classes/BxAlbumsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function actionEmbedMedia($iContentId)

$aContentInfo = $this->_oDb->getMediaInfoById($iContentId);
if(empty($aContentInfo))
$oTemplate->displayPageNotFound();
$oTemplate->getEmbed(false);

if(empty($sUnitTemplate))
$sUnitTemplate = 'unit_media_gallery.html';
Expand Down
1 change: 1 addition & 0 deletions modules/boonex/albums/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="300" height="330" src="__url__" frameborder="0" allowfullscreen></iframe>
1 change: 1 addition & 0 deletions modules/boonex/files/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>
1 change: 1 addition & 0 deletions modules/boonex/market/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>
1 change: 1 addition & 0 deletions modules/boonex/polls/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="300" height="270" src="__url__" frameborder="0" allowfullscreen></iframe>
1 change: 1 addition & 0 deletions modules/boonex/videos/template/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="560" height="315" src="__url__" frameborder="0" allowfullscreen></iframe>
9 changes: 2 additions & 7 deletions modules/boonex/videos/template/unit_gallery_embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
2 changes: 1 addition & 1 deletion template/embed.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<iframe width="300" height="300" src="__url__" frameborder="0" allowfullscreen></iframe>
<iframe width="300" height="260" src="__url__" frameborder="0" allowfullscreen></iframe>

0 comments on commit f9c59bd

Please sign in to comment.