RomanL 4 лет назад
Родитель
Сommit
fb04cdefd4

+ 5 - 0
inc/classes/BxDolPage.php

@@ -525,6 +525,11 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
     	return $this->_sObject;
     }
     
+    public function getObject ()
+    {
+    	return $this->_aObject;
+    }
+    
     public function getInjections()
     {
         $aResult = array();

+ 17 - 1
inc/classes/BxDolTemplate.php

@@ -832,6 +832,22 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
     {
         return $this->_sCode;
     }
+    
+    /**
+     * Get embed code.
+     *
+     * @return string embed's code.
+     */
+    function getEmbed($sContent)
+    {
+        $this->addJs(['inc/js/|embed.js']);
+        $this->addCss(['embed.css']);
+        
+        $this->setPageNameIndex (BX_PAGE_EMBED);
+        $this->setPageContent('page_main_code', '<div class="bx-embed">' . $sContent . '</div>');
+        $this->getPageCode();
+        
+    }
 
     /**
      * Get code key.
@@ -1173,7 +1189,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 ."oembed.php?url=" . urlencode($_SERVER["REQUEST_URI"]) . "&format=json\" title=\"". (isset($this->aPage['header']) ? bx_html_attribute(strip_tags($this->aPage['header'])) : '') . "\" />";
+        $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'])) : '') . "\" />";
         
         return $sRet;
     }

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

@@ -107,7 +107,8 @@ class BxBaseModGeneralModule extends BxDolModule
         if(empty($sUnitTemplate))
             $sUnitTemplate = 'unit_gallery.html';
 
-        echo $this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate);
+        $oTemplate = BxDolTemplate::getInstance();
+        $oTemplate->getEmbed($this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate));
     }
    
 	public function subactionDelete()

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

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

+ 0 - 2
page.php

@@ -31,11 +31,9 @@ BxDolPage::seoRedirect();
 
 $oPage = BxDolPage::getObjectInstanceByURI('', false, true);
 if ($oPage) {
-
     $oPage->displayPage();
 
 } else {
-
     $oTemplate = BxDolTemplate::getInstance();
     $oTemplate->displayPageNotFound();
 }

+ 7 - 0
template/css/embed.css

@@ -0,0 +1,7 @@
+body,
+.bx-embed{
+    background-color: transparent !important;
+}
+.bx-embed{
+    width:calc(100% - 2px);
+}

+ 1 - 0
template/embed.html

@@ -0,0 +1 @@
+<iframe width="100%" height="300" src="__url__" title="__title__" frameborder="0" allowfullscreen></iframe>

+ 23 - 0
template/embed_card.html

@@ -0,0 +1,23 @@
+<div class="bx-base-text-unit bx-base-text-unit-gallery bx-def-gal-unit-size flex flex-col w-full p-2 box-border">
+    <div class="bx-base-text-unit-cnt rounded ring-1 ring-gray-200 dark:ring-gray-700 overflow-hidden bg-white dark:bg-gray-800">
+        <bx_if:thumb>
+            <a href="__url__" title="__title__">
+                <div class="flex-shrink-0 m-1">
+                    <img class="h-48 w-full object-cover rounded" src="__background__" alt="">
+                </div>
+            </a>
+        </bx_if:thumb>
+        <bx_if:no_thumb>
+            <a href="__url__" title="__title__">
+                <div class="bx-def-gal-img-column flex-shrink-0 m-1">
+                    <div class="bx-base-text-unit-no-thumb flex flex-col items-center justify-center h-48 p-4 bg-gradient-to-b from-red-400 to-red-500 box-border rounded-md"></div>
+                </div>
+            </a>
+        </bx_if:no_thumb>
+        <div class="bx-base-text-unit-text p-3 md:p-4 lg:p-6 pt-2 md:pt-3 lg:pt-5 box-border">
+            <div class="bx-base-text-unit-title flex items-center text-left">
+                <a href="__url__" class="text-lg lg:text-xl font-semibold text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white">__title__</a>
+            </div>
+        </div>
+    </div>
+</div>

+ 25 - 0
template/scripts/BxBasePage.php

@@ -59,6 +59,31 @@ class BxBasePage extends BxDolPage
             'content' => _t($aBlock['help'])
         ));
     }
+    
+    public function performActionEmbed ()
+    {
+        $aCover = $this->getPageCoverImage();
+        $this->_oTemplate->getEmbed($this->_oTemplate->parseHtmlByName('embed_card.html', [
+            'title' => _t($this->_aObject['title']),
+            'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
+            'bx_if:thumb' => [
+                'condition' => $this->isPageCover() && count($aCover) > 0,
+                'content' => [
+                    'title' => _t($this->_aObject['title']),
+                    'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
+                    'background' => BxDolCover::getInstance(BxDolTemplate::getInstance())->getCoverImageUrl($aCover)
+                ],
+            ],
+            'bx_if:no_thumb' => [
+                'condition' => count($aCover) == 0 || !$this->isPageCover(),
+                'content' => [
+                    'title' => _t($this->_aObject['title']),
+                    'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
+                ]
+            ]
+        ]
+        ));
+    }
 
     /**
      * Very similar to BxBasePage::getCode