Explorar el Código

Merge branch 'master' of https://github.com/unaio/una

roman.lesnikov@gmail.com hace 3 años
padre
commit
a97b14294d

+ 10 - 1
inc/classes/BxDolProfile.php

@@ -292,7 +292,16 @@ class BxDolProfile extends BxDolFactory implements iBxDolProfile
         $aInfo = $this->getInfo($iProfileId);
         return BxDolService::call($aInfo['type'], 'profile_unit', array($aInfo['content_id'], $aParams));
     }
-    
+
+    /**
+     * Get profile unit for API calls
+     */
+    public function getUnitAPI($iProfileId = 0, $aParams = array())
+    {
+        $aInfo = $this->getInfo($iProfileId);
+        return BxDolService::call($aInfo['type'], 'profile_unit_api', array($aInfo['content_id'], $aParams));
+    }
+
     /**
      * Get badges
      */

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

@@ -98,7 +98,7 @@ class BxBaseModGeneralCmtsSearchResult extends BxBaseModGeneralSearchResult
             if(isset($r['author']))
                 $a[$i]['author_data'] = BxDolProfile::getData($r['author']);
 
-            $a[$i]['url'] = $this->decodeDataUrl($oContentInfo, $r);
+            $a[$i]['url'] = bx_api_get_relative_url($oContentInfo->getContentLink($r['id']));
         }
 
         return $a;

+ 0 - 17
modules/base/general/classes/BxBaseModGeneralSearchResult.php

@@ -212,23 +212,6 @@ class BxBaseModGeneralSearchResult extends BxTemplSearchResult
 
         return parent::displayResultBlock();
     }
-
-    function decodeDataUrl ($oContentInfo, $r)
-    {
-        $sLink = $oContentInfo->getContentLink($r['id']);
-        if(bx_is_api())
-            $sLink = bx_api_get_relative_url($sLink);
-
-        return $sLink;
-    }
-
-    function decodeDataSummaryPlain ($oContentInfo, $r)
-    {
-        $CNF = $this->oModule->_oConfig->CNF;
-        $sSummary = $this->oModule->_oTemplate->getText($r);
-        return isset($CNF['PARAM_CHARS_SUMMARY_PLAIN']) && $CNF['PARAM_CHARS_SUMMARY_PLAIN'] ? BxTemplFunctions::getInstance()->getStringWithLimitedLength(strip_tags($sSummary), (int)getParam($CNF['PARAM_CHARS_SUMMARY_PLAIN'])) : '';
-    }
-
 }
 
 /** @} */

+ 13 - 0
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -108,6 +108,8 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             'BrowseActiveProfiles' => '',
             'BrowseTopProfiles' => '',
             'BrowseOnlineProfiles' => '',
+            'BrowseConnections' => '',
+            'BrowseConnectionsEverywhere' => '',
             'BrowseByAcl' => '',
         ));
     }
@@ -417,6 +419,17 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         return $this->_oTemplate->unit($aContentInfo, $bCheckPrivateContent, array($sTemplate, $sTemplateSize, $aTemplateVars));
     }
 
+    public function serviceProfileUnitApi ($iContentId, $aParams = array())
+    {
+        $mixedContent = $this->_getContent($iContentId);
+        if($mixedContent === false)
+            return false;
+
+        list($iContentId, $aContentInfo) = $mixedContent;
+
+        return $this->_oTemplate->unitAPI($aContentInfo);
+    }
+
     public function serviceHasImage ($iContentId)
     {
         $CNF = &$this->_oConfig->CNF;

+ 20 - 7
modules/base/profile/classes/BxBaseModProfileSearchResult.php

@@ -124,8 +124,11 @@ class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
         $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
         $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
 
-        if($this->bConnectionsEverywhere)
+        if($this->bConnectionsEverywhere) {
+            $this->aCurrent['ownFields'] = ['id', 'account_id', 'type', 'content_id'];
+            
             unset($this->aCurrent['restriction']['perofileType'], $this->aCurrent['join']['profile']);
+        }
 
         return true;
     }
@@ -244,6 +247,15 @@ class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
     {
         $CNF = $this->oModule->_oConfig->CNF;
 
+        if($this->bConnectionsEverywhere) {
+            $aResult = [];
+            foreach ($a as $index => $aItem) 
+                if(($oProfile = BxDolProfile::getInstance($aItem['id'])) !== false)
+                    $aResult[] = $oProfile->getUnitAPI();
+
+            return $aResult;
+        }
+
         $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
         $bPrivacy = $oPrivacy !== false;
 
@@ -253,26 +265,27 @@ class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
         $oContentInfo = $this->getContentInfoObject();
 
         foreach ($a as $i => $r) {
-            $a[$i] = array_merge($a[$i], [
-                'url' => $this->decodeDataUrl($oContentInfo, $r),
+            $aAddon = [
+                'url' => bx_api_get_relative_url($oContentInfo->getContentLink($r['id'])),
                 'image' => $oContentInfo->getContentThumb($r['id']),
                 'cover' => $oContentInfo->getContentCover($r['id']),
-                'summary_plain' => $this->decodeDataSummaryPlain($oContentInfo, $r)
-            ]);
+            ];
 
             if($bMetaMenu) {
                 $bPublic = !$bPrivacy || $oPrivacy->check($r[$CNF['FIELD_ID']]) || $oPrivacy->isPartiallyVisible($r[$CNF['FIELD_ALLOW_VIEW_TO']]);
 
                 $oMetaMenu->setContentId($r['id']);
                 $oMetaMenu->setContentPublic($bPublic);
-                $a[$i]['meta'] = $oMetaMenu->getCodeAPI();
+                $aAddon['meta'] = $oMetaMenu->getCodeAPI();
             }
+
+            $a[$i] = array_merge($r, $aAddon);
         }
 
         return $a;
     }
 	
-	function getItemPerPageInShowCase ()
+    function getItemPerPageInShowCase ()
     {
         $iPerPageInShowCase = parent::getItemPerPageInShowCase();
         $CNF = &$this->oModule->_oConfig->CNF;

+ 30 - 0
modules/base/profile/classes/BxBaseModProfileTemplate.php

@@ -94,6 +94,36 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
         return $this->parseHtmlByName($sTemplate, $aVars);
     }
 
+    public function unitAPI($aData)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $iContentId = (int)$aData[$CNF['FIELD_ID']];
+
+        // get profile's url
+        $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId));
+
+        $aAddon  = [
+            'url' => bx_api_get_relative_url($sUrl),
+            'image' => bx_api_get_image($CNF['OBJECT_STORAGE'], $aData[$CNF['FIELD_PICTURE']]),
+            'cover' => bx_api_get_image($CNF['OBJECT_STORAGE'], $aData[$CNF['FIELD_COVER']])
+        ];
+
+        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
+        $bPrivacy = $oPrivacy !== false;
+
+        $sKey = 'OBJECT_MENU_SNIPPET_META';
+        if(!empty($CNF[$sKey]) && ($oMetaMenu = BxDolMenu::getObjectInstance($CNF[$sKey], $this)) !== false) {
+            $bPublic = !$bPrivacy || $oPrivacy->check($iContentId) || $oPrivacy->isPartiallyVisible($aData[$CNF['FIELD_ALLOW_VIEW_TO']]);
+
+            $oMetaMenu->setContentId($iContentId);
+            $oMetaMenu->setContentPublic($bPublic);
+            $aAddon['meta'] = $oMetaMenu->getCodeAPI();
+        }
+
+        return array_merge($aData, $aAddon);
+    }
+
     function unitVars ($aData, $isCheckPrivateContent = true, $mixedTemplate = false, $aParams = array())
     {
         $CNF = &$this->_oConfig->CNF;

+ 14 - 2
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -241,21 +241,33 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
     {
         $CNF = &$this->oModule->_oConfig->CNF;
 
+        $oMetaMenu = null;
         $bMetaMenu = false;
+
         /**
          * Disabled for now, because Author is used only.
         $oMetaMenu = !empty($CNF['OBJECT_MENU_SNIPPET_META']) ? BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SNIPPET_META'], $this->oModule->_oTemplate) : false;
         $bMetaMenu = $oMetaMenu !== false;
          */
 
+        $oFunctions = BxTemplFunctions::getInstance();
         $oContentInfo = $this->getContentInfoObject();
+        
+        $bSummaryPlain = isset($CNF['PARAM_CHARS_SUMMARY_PLAIN']) && $CNF['PARAM_CHARS_SUMMARY_PLAIN'];
+        $iSummaryPlain = $bSummaryPlain ? (int)getParam($CNF['PARAM_CHARS_SUMMARY_PLAIN']) : 0;
 
         foreach ($a as $i => $r) {
+            $sSummary = '';
+            if($bSummaryPlain) {
+                $sSummary = $this->oModule->_oTemplate->getText($r);
+                $sSummary = $oFunctions->getStringWithLimitedLength(strip_tags($sSummary), $iSummaryPlain);
+            }
+
             $a[$i] = array_merge($a[$i], [
                 'author_data' => isset($r['author']) ? BxDolProfile::getData($r[$CNF['FIELD_AUTHOR']]) : '',
-                'url' => $this->decodeDataUrl($oContentInfo, $r),
+                'url' => bx_api_get_relative_url($oContentInfo->getContentLink($r['id'])),
                 'image' => $oContentInfo->getContentThumb($r['id']),
-                'summary_plain' => $this->decodeDataSummaryPlain($oContentInfo, $r)
+                'summary_plain' => $sSummary
             ]);
 
             if($bMetaMenu) {