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

Ticket #3956 - Groups: Improve meta data for Secret groups.

AntonLV 4 лет назад
Родитель
Сommit
8ecc68cde1

+ 5 - 0
inc/classes/BxDolPage.php

@@ -588,6 +588,11 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
         return $this->_aObject['submenu'];
     }
 
+    public function getMetaDescription ()
+    {
+        return $this->_aObject['meta_description'];
+    }
+
     public function getName ()
     {
     	return $this->_sObject;

+ 20 - 11
inc/classes/BxDolTemplate.php

@@ -1173,13 +1173,22 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
     {
         $sRet = '';
 
+        $oPage = BxDolPage::getObjectInstanceByURI();
+        $bPage = $oPage !== false;
+
         // general meta tags
         if (!empty($this->aPage['keywords']) && is_array($this->aPage['keywords']))
             $sRet .= '<meta name="keywords" content="' . bx_html_attribute(implode(',', $this->aPage['keywords'])) . '" />';
 
-        $bDescription = !empty($this->aPage['description']) && is_string($this->aPage['description']);
+        $sDescription = '';
+        if(!empty($this->aPage['description']) && is_string($this->aPage['description']))
+            $sDescription = $this->aPage['description'];
+        if(!$sDescription && $bPage)
+            $sDescription = $oPage->getMetaDescription();
+        $bDescription = !empty($sDescription);
+
         if ($bDescription)
-            $sRet .= '<meta name="description" content="' . bx_html_attribute($this->aPage['description']) . '" />';
+            $sRet .= '<meta name="description" content="' . bx_html_attribute($sDescription) . '" />';
 
         // location
         if (!empty($this->aPage['location']) && isset($this->aPage['location']['lat']) && isset($this->aPage['location']['lng']) && isset($this->aPage['location']['country']))
@@ -1189,22 +1198,22 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
                 <meta name="geo.region" content="' . bx_html_attribute($this->aPage['location']['country']) . '" />';
 
         // set cover image as meta[image] value
-		if (empty($this->aPage['image']) && ($oPage = BxDolPage::getObjectInstanceByURI()) !== false){
+        if (empty($this->aPage['image']) && $bPage) {
             $aCover = $oPage->getPageCoverImage();
-			if ($aCover){
-				$oCover = BxDolCover::getInstance($this);
-				$this->aPage['image'] =  $oCover->getCoverImageUrl($aCover);
-			}
-		}	
-		
-		// facebook / twitter
+            if ($aCover) {
+                $oCover = BxDolCover::getInstance($this);
+                $this->aPage['image'] =  $oCover->getCoverImageUrl($aCover);
+            }
+        }	
+
+        // facebook / twitter
         $bPageImage = !empty($this->aPage['image']);
         $sRet .= '<meta name="twitter:card" content="' . ($bPageImage ? 'summary_large_image' : 'summary') . '" />';
         if ($bPageImage)
             $sRet .= '<meta property="og:image" content="' . $this->aPage['image'] . '" />';
         $sRet .= '
 			<meta property="og:title" content="' . (isset($this->aPage['header']) ? bx_html_attribute(strip_tags($this->aPage['header'])) : '') . '" />
-			<meta property="og:description" content="' . ($bDescription ? bx_html_attribute($this->aPage['description']) : '') . '" />';
+			<meta property="og:description" content="' . ($bDescription ? bx_html_attribute($sDescription) : '') . '" />';
 
         // Smart App Banner
         if (getParam('smart_app_banner') && false === strpos($_SERVER['HTTP_USER_AGENT'], 'UNAMobileApp')) {

+ 4 - 1
modules/base/groups/classes/BxBaseModGroupsPageEntry.php

@@ -73,7 +73,10 @@ class BxBaseModGroupsPageEntry extends BxBaseModProfilePageEntry
         
         $mixedAllowView = $this->_oModule->checkAllowedView($this->_aContentInfo);
         if (!$oPrivacy->isPartiallyVisible($this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $mixedAllowView)) {
-            $this->_oTemplate->displayAccessDenied($sMsg);
+            $this->_oTemplate->displayAccessDenied([
+                'title' => $this->_oProfile->getDisplayName(),
+                'content' => $sMsg
+            ]);
             exit;
         }
         elseif ($oPrivacy->isPartiallyVisible($this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && $CNF['OBJECT_PAGE_VIEW_ENTRY'] == $this->_sObject && CHECK_ACTION_RESULT_ALLOWED !== $mixedAllowView) {