Просмотр исходного кода

#2137 Video Attachments preview in Posts module

Alex Trofimov 7 лет назад
Родитель
Сommit
2c74477668

+ 14 - 12
inc/classes/BxDolTemplate.php

@@ -36,6 +36,7 @@ define('BX_DOL_PAGE_WIDTH', '1024px');
  */
  */
 define('BX_PAGE_DEFAULT', 0); ///< default, regular page
 define('BX_PAGE_DEFAULT', 0); ///< default, regular page
 define('BX_PAGE_CLEAR', 2); ///< clear page, without any headers and footers
 define('BX_PAGE_CLEAR', 2); ///< clear page, without any headers and footers
+define('BX_PAGE_EMBED', 2); ///< page used for embeds
 define('BX_PAGE_POPUP', 44); ///< popup page, without any headers and footers
 define('BX_PAGE_POPUP', 44); ///< popup page, without any headers and footers
 define('BX_PAGE_TRANSITION', 150); ///< transition page with redirect to display some msg, like 'please wait', without headers footers
 define('BX_PAGE_TRANSITION', 150); ///< transition page with redirect to display some msg, like 'please wait', without headers footers
 
 
@@ -2692,41 +2693,42 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      * Functions to display pages with errors, messages and so on.
      * Functions to display pages with errors, messages and so on.
      *
      *
      */
      */
-    function displayAccessDenied ($sMsg = '')
+    function displayAccessDenied ($sMsg = '', $iPage = BX_PAGE_DEFAULT)
     {
     {
         bx_import('BxDolLanguages');
         bx_import('BxDolLanguages');
         header("HTTP/1.0 403 Forbidden");
         header("HTTP/1.0 403 Forbidden");
-        $this->displayMsg($sMsg ? $sMsg : _t('_Access denied'));
+        $this->displayMsg($sMsg ? $sMsg : _t('_Access denied'), false, $iPage);
     }
     }
-    function displayNoData ($sMsg = '')
+    function displayNoData ($sMsg = '', $iPage = BX_PAGE_DEFAULT)
     {
     {
         bx_import('BxDolLanguages');
         bx_import('BxDolLanguages');
         header("HTTP/1.0 204 No Content");
         header("HTTP/1.0 204 No Content");
-        $this->displayMsg($sMsg ? $sMsg : _t('_Empty'));
+        $this->displayMsg($sMsg ? $sMsg : _t('_Empty'), false, $iPage);
     }
     }
-    function displayErrorOccured ($sMsg = '')
+    function displayErrorOccured ($sMsg = '', $iPage = BX_PAGE_DEFAULT)
     {
     {
         bx_import('BxDolLanguages');
         bx_import('BxDolLanguages');
         header("HTTP/1.0 500 Internal Server Error");
         header("HTTP/1.0 500 Internal Server Error");
-        $this->displayMsg($sMsg ? $sMsg : _t('_error occured'));
+        $this->displayMsg($sMsg ? $sMsg : _t('_error occured'), false, $iPage);
     }
     }
-    function displayPageNotFound ($sMsg = '')
+    function displayPageNotFound ($sMsg = '', $iPage = BX_PAGE_DEFAULT)
     {
     {
         bx_import('BxDolLanguages');
         bx_import('BxDolLanguages');
         header("HTTP/1.0 404 Not Found");
         header("HTTP/1.0 404 Not Found");
-        $this->displayMsg($sMsg ? $sMsg : _t('_sys_request_page_not_found_cpt'));
+        $this->displayMsg($sMsg ? $sMsg : _t('_sys_request_page_not_found_cpt'), false, $iPage);
     }
     }
-    function displayMsg ($s, $bTranslate = false)
+    function displayMsg ($s, $bTranslate = false, $iPage = BX_PAGE_DEFAULT)
     {
     {
         $sTitle = $bTranslate ? _t($s) : $s;
         $sTitle = $bTranslate ? _t($s) : $s;
         $oTemplate = BxDolTemplate::getInstance();
         $oTemplate = BxDolTemplate::getInstance();
-        $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
+        $oTemplate->setPageNameIndex ($iPage);
         $oTemplate->setPageHeader (_t('_Error'));
         $oTemplate->setPageHeader (_t('_Error'));
-        $oTemplate->setPageContent ('page_main_code', DesignBoxContent(_t('_Error'), MsgBox($sTitle), BX_DB_PADDING_DEF));
+        $s = BX_PAGE_DEFAULT == $iPage ? DesignBoxContent(_t('_Error'), MsgBox($sTitle), BX_DB_PADDING_DEF) : MsgBox($sTitle);
+        $oTemplate->setPageContent ('page_main_code', $s);
         $oTemplate->getPageCode();
         $oTemplate->getPageCode();
         exit;
         exit;
     }
     }
-
+    
     /**
     /**
      * * * * Static methods for work with template injections * * *
      * * * * Static methods for work with template injections * * *
      *
      *

+ 9 - 4
inc/js/editor.tinymce.js

@@ -6,8 +6,8 @@
  * @{
  * @{
  */
  */
 
 
-function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
-
+function bx_editor_insert_html (sEditorId, sImgId, sHtml) {
+    
     var eEditor = 'object' == typeof(tinymce) ? tinymce.get(sEditorId) : undefined;
     var eEditor = 'object' == typeof(tinymce) ? tinymce.get(sEditorId) : undefined;
     if ('undefined' == typeof(eEditor))
     if ('undefined' == typeof(eEditor))
         return;
         return;
@@ -15,10 +15,15 @@ function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
     if (eEditor.dom && eEditor.dom.doc && eEditor.dom.doc.getElementById(sImgId))
     if (eEditor.dom && eEditor.dom.doc && eEditor.dom.doc.getElementById(sImgId))
         return;
         return;
 
 
+    eEditor.execCommand('mceInsertContent', false, sHtml);
+}
+
+function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
+
     if ('undefined' == typeof(sClasses))
     if ('undefined' == typeof(sClasses))
         sClasses = '';
         sClasses = '';
-
-    eEditor.execCommand('mceInsertContent', false, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />');
+    
+    bx_editor_insert_html(sEditorId, sImgId, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />')
 }
 }
 
 
 function bx_editor_on_init (sEditorId)
 function bx_editor_on_init (sEditorId)

+ 1 - 1
inc/utils.inc.php

@@ -544,7 +544,7 @@ function clear_xss($val)
             $oConfig->set('HTML.Nofollow', 'true');
             $oConfig->set('HTML.Nofollow', 'true');
         }
         }
 
 
-        $oConfig->set('Filter.Custom', array (new HTMLPurifier_Filter_YouTube(), new HTMLPurifier_Filter_YoutubeIframe(), new HTMLPurifier_Filter_AddBxLinksClass()));
+        $oConfig->set('Filter.Custom', array (new HTMLPurifier_Filter_YouTube(), new HTMLPurifier_Filter_YoutubeIframe(), new HTMLPurifier_Filter_AddBxLinksClass(), new HTMLPurifier_Filter_LocalIframe()));
 
 
 	    $oConfig->set('HTML.DefinitionID', 'html5-definitions');
 	    $oConfig->set('HTML.DefinitionID', 'html5-definitions');
 		$oConfig->set('HTML.DefinitionRev', 1);
 		$oConfig->set('HTML.DefinitionRev', 1);

+ 72 - 0
modules/base/general/classes/BxBaseModGeneralTemplate.php

@@ -320,6 +320,78 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
         return $aAttachmnts;
         return $aAttachmnts;
     }
     }
 
 
+    public function embedVideo($iFileId)
+    {
+        // general checks
+        $oPlayer = BxDolPlayer::getObjectInstance();
+        $CNF = $this->getModule()->_oConfig->CNF;
+        $sStorage = isset($CNF['OBJECT_STORAGE_VIDEOS']) ? $CNF['OBJECT_STORAGE_VIDEOS'] : false;
+        if (!$oPlayer || !$sStorage || !($oStorage = BxDolStorage::getObjectInstance($sStorage))) {
+            $this->displayErrorOccured('', BX_PAGE_EMBED);
+            exit;
+        }
+
+        // privacy check
+        $aGhost = $oStorage->getGhost($iFileId);
+        $aContentInfo = $aGhost && $aGhost['content_id'] ? $this->getModule()->_oDb->getContentInfoById($aGhost['content_id']) : false;
+        if (!$aGhost || ($aGhost['content_id'] && !$aContentInfo)) {
+            $this->displayPageNotFound('', BX_PAGE_EMBED);
+            exit;
+        }
+            
+        if (!$aGhost['content_id']) {
+            // if file is not associated with content yet, then only admin and owner can view it
+            if (!isAdmin() && CHECK_ACTION_RESULT_ALLOWED !== $this->getModule()->checkAllowedEditAnyEntry() && $aGhost['profile_id'] != bx_get_logged_profile_id()) {
+                $this->displayAccessDenied('', BX_PAGE_EMBED);
+                exit;
+            }
+        }
+        else {
+            // if file is associated with content, then check entry privacy
+            if (CHECK_ACTION_RESULT_ALLOWED !== $this->getModule()->checkAllowedView($aContentInfo)) {
+                $this->displayAccessDenied('', BX_PAGE_EMBED);
+                exit;
+            }
+        }
+
+        // get file info
+        if (!($a = $oStorage->getFile($iFileId))) {
+            $this->displayPageNotFound('', BX_PAGE_EMBED);
+            exit;
+        }
+
+        // check if file is really video
+        $aTranscodersVideo = $this->getAttachmentsVideoTranscoders($sStorage);        
+        if (!$aTranscodersVideo || (0 !== strncmp('video/', $a['mime_type'], 6)) || !$aTranscodersVideo['poster']->isMimeTypeSupported($a['mime_type'])) {
+            $this->displayErrorOccured('', BX_PAGE_EMBED);
+            exit;
+        }
+
+        // check HD video version
+        $sVideoUrlHd = '';
+        $sVideoUrl = $oStorage->getFileUrlById($a['id']);
+        $aVideoSize = $aTranscodersVideo['mp4_hd']->getVideoSize($sVideoUrl);
+        if (!empty($aVideoSize) && is_array($aVideoSize) && (int)$aVideoSize['h'] >= 720)
+            $sVideoUrlHd = $aTranscodersVideo['mp4_hd']->getFileUrl($a['id']);
+
+        // generate player code
+        $sCode = $oPlayer->getCodeVideo (BX_PLAYER_EMBED, array(
+            'poster' => $aTranscodersVideo['poster']->getFileUrl($a['id']),
+            'mp4' => array(
+                'sd' => $aTranscodersVideo['mp4']->getFileUrl($a['id']), 
+                'hd' => $sVideoUrlHd
+            ),
+        ));
+
+        // display page
+        $oTemplate = BxDolTemplate::getInstance();
+        $oTemplate->setPageNameIndex (BX_PAGE_EMBED);
+        $oTemplate->setPageHeader ($a['file_name']);
+        $oTemplate->setPageContent ('page_main_code', $sCode);
+        $oTemplate->getPageCode();
+        exit;
+    }
+
     public function addCssJs()
     public function addCssJs()
     {
     {
         $this->addCss('main.css');
         $this->addCss('main.css');

+ 10 - 2
modules/base/general/js/forms.js

@@ -33,8 +33,16 @@ function bx_base_general_delete_ghost (iFileId, sFileUrl, sFileIcon, aEditors, o
     oUploaderInstance.deleteGhost(iFileId);
     oUploaderInstance.deleteGhost(iFileId);
 }
 }
 
 
-function bx_base_general_insert_to_post (iFileId, sFileUrl, sEditorId) {
-    bx_editor_insert_img (sEditorId, 'bx-base-general-img-' + iFileId, sFileUrl, 'bx-base-general-img');
+function bx_base_general_insert_to_post (iFileId, sFileUrl, sEditorId, sMimeType, sEmbedBaseUrl) {
+    if ('undefined' !== typeof(sMimeType) && sMimeType.startsWith('video/') && 'undefined' !== typeof(sEmbedBaseUrl))
+        bx_base_general_insert_video_embed (sEditorId, 'bx-base-general-img-' + iFileId, sEmbedBaseUrl + iFileId, 'bx-base-general-img');
+    else
+        bx_editor_insert_img (sEditorId, 'bx-base-general-img-' + iFileId, sFileUrl, 'bx-base-general-img');
+}
+
+function bx_base_general_insert_video_embed (sEditorId, sHtmlId, sEmbedUrl, sClass)
+{    
+    bx_editor_insert_html (sEditorId, sHtmlId, '<iframe width="560" height="315" src="' + sEmbedUrl + '" frameborder="0" allow="autoplay; picture-in-picture" allowfullscreen></iframe>');
 }
 }
 
 
 /** @} */
 /** @} */

+ 2 - 1
modules/base/text/classes/BxBaseModTextFormEntry.php

@@ -117,7 +117,8 @@ class BxBaseModTextFormEntry extends BxBaseModGeneralFormEntry
     	return array (
     	return array (
             'name' => $this->aInputs[$CNF['FIELD_VIDEO']]['name'],
             'name' => $this->aInputs[$CNF['FIELD_VIDEO']]['name'],
             'content_id' => (int)$this->aInputs[$CNF['FIELD_VIDEO']]['content_id'],
             'content_id' => (int)$this->aInputs[$CNF['FIELD_VIDEO']]['content_id'],
-            'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : ''
+            'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : '',
+            'embed_url' => BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'file_embed_video/',
     	);
     	);
     }
     }
 
 

+ 5 - 9
modules/base/text/classes/BxBaseModTextModule.php

@@ -64,6 +64,10 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
         echoJson($this->getPollForm());
         echoJson($this->getPollForm());
     }
     }
 
 
+    public function actionFileEmbedVideo($iFileId)
+    {
+        $this->_oTemplate->embedVideo($iFileId);
+    }
 
 
     // ====== SERVICE METHODS
     // ====== SERVICE METHODS
     public function serviceGetBlockPollAnswers($iPollId, $bForceDisplay = false)
     public function serviceGetBlockPollAnswers($iPollId, $bForceDisplay = false)
@@ -222,15 +226,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
 
 
     public function serviceEntityBreadcrumb ($iContentId = 0)
     public function serviceEntityBreadcrumb ($iContentId = 0)
     {
     {
-    	if (!$iContentId)
-            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if (!$iContentId)
-            return false;
-        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
-        if (!$aContentInfo)
-            return false;
-
-		return $this->_oTemplate->entryBreadcrumb($aContentInfo);
+        return $this->_serviceTemplateFunc ('entryBreadcrumb', $iContentId);
     }
     }
 
 
     /**
     /**

+ 8 - 3
modules/boonex/froala/js/editor.js

@@ -8,15 +8,20 @@
  * @{
  * @{
  */
  */
 
 
-function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) 
+function bx_editor_insert_html (sEditorId, sImgId, sHtml) 
 {
 {
     if (typeof $('#' + sEditorId).froalaEditor !== 'function')
     if (typeof $('#' + sEditorId).froalaEditor !== 'function')
         return;
         return;
-    
+
+    $('#' + sEditorId).froalaEditor('html.insert', sHtml, false);
+}
+
+function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) 
+{   
     if ('undefined' == typeof(sClasses))
     if ('undefined' == typeof(sClasses))
         sClasses = '';
         sClasses = '';
 
 
-    $('#' + sEditorId).froalaEditor('html.insert', '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />', false);
+    bx_editor_insert_html(sEditorId, sImgId, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />');
 }
 }
 
 
 function bx_editor_remove_img (aEditorIds, aMarkers) 
 function bx_editor_remove_img (aEditorIds, aMarkers) 

+ 1 - 1
modules/boonex/plyr/classes/BxPlyrPlayer.php

@@ -136,7 +136,7 @@ class BxPlyrPlayer extends BxDolPlayer
         // plyr initialization
         // plyr initialization
         $sFormat = getParam('sys_player_default_format');
         $sFormat = getParam('sys_player_default_format');
         $aOptions = array_merge(array(
         $aOptions = array_merge(array(
-            'debug' => true,
+            // 'debug' => true,
             'quality' => array('default' => $this->_aSizes[$sFormat]),
             'quality' => array('default' => $this->_aSizes[$sFormat]),
         ), $this->_aConfCustom);
         ), $this->_aConfCustom);
         $sInitEditor = "
         $sInitEditor = "

+ 0 - 3
modules/boonex/posts/template/form_ghost_template_file.html

@@ -6,9 +6,6 @@
     <span class="bx-base-general-uploader-ghost">
     <span class="bx-base-general-uploader-ghost">
         <b><bx_text:_sys_txt_form_entry_input_picture_pic_url /></b><br />
         <b><bx_text:_sys_txt_form_entry_input_picture_pic_url /></b><br />
         <input class="bx-def-font-inputs bx-form-input-text bx-def-margin-sec-bottom" type="text" value="{file_url}" readonly="1" /> <br />
         <input class="bx-def-font-inputs bx-form-input-text bx-def-margin-sec-bottom" type="text" value="{file_url}" readonly="1" /> <br />
-        <span id="bx-base-general-intert-to-post-link-{file_id}" style="display:none;">
-            <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="bx_base_general_insert_to_post('{file_id}', '{file_url}', '__editor_id__');"><bx_text:_sys_txt_form_entry_input_picture_insert /></a>
-        </span>
         <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="bx_base_general_delete_ghost('{file_id}', '{file_url}', '{file_icon}', ['__editor_id__'], {js_instance_name});"><bx_text:_sys_txt_form_entry_input_picture_delete /></a>
         <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="bx_base_general_delete_ghost('{file_id}', '{file_url}', '{file_icon}', ['__editor_id__'], {js_instance_name});"><bx_text:_sys_txt_form_entry_input_picture_delete /></a>
     </span>
     </span>
 </div>
 </div>

+ 5 - 0
modules/boonex/posts/template/form_ghost_template_video.html

@@ -6,10 +6,15 @@
     <span class="bx-base-general-uploader-ghost">
     <span class="bx-base-general-uploader-ghost">
         <b><bx_text:_sys_txt_form_entry_input_picture_pic_url /></b><br />
         <b><bx_text:_sys_txt_form_entry_input_picture_pic_url /></b><br />
         <input class="bx-def-font-inputs bx-form-input-text bx-def-margin-sec-bottom" type="text" value="{file_url}" readonly="1" /> <br />
         <input class="bx-def-font-inputs bx-form-input-text bx-def-margin-sec-bottom" type="text" value="{file_url}" readonly="1" /> <br />
+        <span id="bx-base-general-intert-to-post-link-{file_id}" style="display:none;">
+            <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="bx_base_general_insert_to_post('{file_id}', '{file_url}', '__editor_id__', '{file_type}', '__embed_url__');"><bx_text:_sys_txt_form_entry_input_picture_insert /></a>
+        </span>
         <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="bx_base_general_delete_ghost('{file_id}', '{file_url}', '{file_icon}', ['__editor_id__'], {js_instance_name});"><bx_text:_sys_txt_form_entry_input_picture_delete /></a>
         <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="bx_base_general_delete_ghost('{file_id}', '{file_url}', '{file_icon}', ['__editor_id__'], {js_instance_name});"><bx_text:_sys_txt_form_entry_input_picture_delete /></a>
     </span>
     </span>
 </div>
 </div>
 <script>
 <script>
+    $('#bx-base-general-intert-to-post-link-{file_id}').show();
+
     // disable images drag&drop, because resized images address can be reset after some time
     // disable images drag&drop, because resized images address can be reset after some time
     $(".bx-base-general-icon-{file_id}").bind('dragstart', function(){
     $(".bx-base-general-icon-{file_id}").bind('dragstart', function(){
         return false; 
         return false; 

+ 45 - 0
plugins/htmlpurifier/standalone/HTMLPurifier/Filter/LocalIframe.php

@@ -0,0 +1,45 @@
+<?php
+
+class HTMLPurifier_Filter_LocalIframe extends HTMLPurifier_Filter
+{
+    public $name = 'LocalIframe';
+
+    public function preFilter($sHtml, $config, $context)
+    {
+        if (strstr($sHtml, '<iframe')) {
+            $sHtml = str_ireplace("</iframe>", "", $sHtml);
+            if (preg_match_all("/<iframe(.*?)>/si", $sHtml, $aResult)) {
+                foreach ($aResult[1] as $key => $sItem) {
+                    preg_match('/width="([0-9]+)"/', $sItem, $width);
+                    $iWidth = $width[1];
+                    preg_match('/height="([0-9]+)"/', $sItem, $height);
+                    $iHeight = $height[1];
+                    $sDolUrl = preg_quote(BX_DOL_URL_ROOT);
+                    $sIframeUrl = '';
+echoDbgLog($sItem);
+                    if (preg_match("#({$sDolUrl}[a-zA-Z0-9_=\-\?\&\/]+)#", $sItem, $aMatches))
+                        $sIframeUrl = $aMatches[1];
+                    if (preg_match("#src=\"(((?!//)(?![a-z]+://)(?![a-z]+://))[a-zA-Z0-9_=\-\?\&\/]+)#", $sItem, $aMatches))
+                        $sIframeUrl = $aMatches[1];
+echoDbgLog($sIframeUrl);
+                    if ($sIframeUrl)
+                        $sHtml = str_replace($aResult[0][$key], '<img class="LocalIframe" width="' . $iWidth . '" height="' . $iHeight . '" src="' . $sIframeUrl . '">', $sHtml);                    
+                }
+            }
+        }
+        return $sHtml;
+    }
+
+    public function postFilter($sHtml, $config, $context)
+    {
+        $sPostRegex = '#<img class="LocalIframe" ([^>]+)>#';
+        $sHtml = preg_replace_callback($sPostRegex, array($this, 'postFilterCallback'), $sHtml);
+        return $sHtml;
+    }
+
+    protected function postFilterCallback($aMatches)
+    {
+        return '<iframe frameborder="0" allowfullscreen ' . $aMatches[1] . '></iframe>';
+    }
+}
+

+ 6 - 5
plugins/htmlpurifier/standalone/HTMLPurifier/Filter/YoutubeIframe.php

@@ -6,7 +6,7 @@ class HTMLPurifier_Filter_YoutubeIframe extends HTMLPurifier_Filter
 
 
     public function preFilter($html, $config, $context)
     public function preFilter($html, $config, $context)
     {
     {
-        if (strstr($html, '<iframe')) {
+        if (strstr($html, '<iframe') && (strstr($html, 'youtube.com') || strstr($html, 'youtu.be') || strstr($html, 'youtube-nocookie.com'))) {
             $html = str_ireplace("</iframe>", "", $html);
             $html = str_ireplace("</iframe>", "", $html);
             if (preg_match_all("/<iframe(.*?)>/si", $html, $result)) {
             if (preg_match_all("/<iframe(.*?)>/si", $html, $result)) {
                 foreach ($result[1] as $key => $item) {
                 foreach ($result[1] as $key => $item) {
@@ -14,10 +14,11 @@ class HTMLPurifier_Filter_YoutubeIframe extends HTMLPurifier_Filter
                     $width = $width[1];
                     $width = $width[1];
                     preg_match('/height="([0-9]+)"/', $item, $height);
                     preg_match('/height="([0-9]+)"/', $item, $height);
                     $height = $height[1];
                     $height = $height[1];
-                    preg_match('/((\/\/www\.youtube\.com\/embed\/)|(\/\/www\.youtube-nocookie\.com\/embed\/)|(\/\/www.youtube.com\/v\/))([a-zA-Z0-9_-]+)/', $item, $id);
-                    $id = $id[5];
-                    $sProto = 0 == strncmp('https', BX_DOL_URL_ROOT, 5) ? 'https' : 'http';
-                    $html = str_replace($result[0][$key], '<img class="YouTubeIframe" width="' . $width . '" height="' . $height . '" src="' . $sProto . '://www.youtube-nocookie.com/embed/' . $id . '?rel=0">', $html);
+                    if (preg_match('/((\/\/www\.youtube\.com\/embed\/)|(\/\/www\.youtube-nocookie\.com\/embed\/)|(\/\/www.youtube.com\/v\/))([a-zA-Z0-9_-]+)/', $item, $id)) {
+                        $id = $id[5];
+                        $sProto = 0 == strncmp('https', BX_DOL_URL_ROOT, 5) ? 'https' : 'http';
+                        $html = str_replace($result[0][$key], '<img class="YouTubeIframe" width="' . $width . '" height="' . $height . '" src="' . $sProto . '://www.youtube-nocookie.com/embed/' . $id . '?rel=0">', $html);
+                    }
                 }
                 }
             }
             }
         }
         }

+ 2 - 2
studio/classes/BxDolStudioTemplate.php

@@ -149,7 +149,7 @@ class BxDolStudioTemplate extends BxDolTemplate implements iBxDolSingleton
         return $this->parseHtmlByName('breadcrumb.html', array('bx_repeat:items' => $aItems));
         return $this->parseHtmlByName('breadcrumb.html', array('bx_repeat:items' => $aItems));
     }
     }
 
 
-    function displayMsg ($s, $bTranslate = false)
+    function displayMsg ($s, $bTranslate = false, $iPage = BX_PAGE_DEFAULT)
     {
     {
         $sTitle = $bTranslate ? _t($s) : $s;
         $sTitle = $bTranslate ? _t($s) : $s;
 
 
@@ -158,7 +158,7 @@ class BxDolStudioTemplate extends BxDolTemplate implements iBxDolSingleton
             'content' => $sContent
             'content' => $sContent
         ));
         ));
 
 
-        $this->setPageNameIndex(BX_PAGE_DEFAULT);
+        $this->setPageNameIndex($iPage);
         $this->setPageHeader($sTitle);
         $this->setPageHeader($sTitle);
         $this->setPageContent('page_main_code', $sContent);
         $this->setPageContent('page_main_code', $sContent);
         $this->getPageCode();
         $this->getPageCode();