Ver Fonte

#4148 - Build-in API support (pics)

roman.lesnikov@gmail.com há 3 anos atrás
pai
commit
c0bebd9f43

+ 5 - 0
inc/classes/BxDolContentInfo.php

@@ -261,6 +261,11 @@ class BxDolContentInfo extends BxDolFactory implements iBxDolFactoryObject
     {
         return $this->_call('get_thumb', $iContentId);
     }
+    
+    public function getContentCover ($iContentId)
+    {
+        return $this->_call('get_cover', $iContentId);
+    }
 
     public function getContentLink ($iContentId)
     {

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

@@ -211,23 +211,6 @@ class BxBaseModGeneralSearchResult extends BxTemplSearchResult
         return parent::displayResultBlock();
     }
 
-    function decodeData ($a)
-    {
-        $oContentInfo = $this->getContentInfoObject();
-        $CNF = $this->oModule->_oConfig->CNF;
-        
-        foreach ($a as $i => $r) {
-            if (isset($r['author']))
-                $a[$i]['author_data'] = BxDolProfile::getData($r[$CNF['FIELD_AUTHOR']]);
-
-            $a[$i]['url'] = $this->decodeDataUrl($oContentInfo, $r);
-            $a[$i]['image'] = $oContentInfo->getContentThumb($r['id']);
-            $a[$i]['summary_plain'] = $this->decodeDataSummaryPlain($oContentInfo, $r);
-        }
-
-        return $a;
-    }
-
     function decodeDataUrl ($oContentInfo, $r)
     {
         return bx_relative_url($oContentInfo->getContentLink($r['id']));

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

@@ -139,6 +139,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
     public function serviceGetThumb ($iContentId, $sTranscoder = '') 
     {
         $CNF = &$this->_oConfig->CNF;
+        
+        if(bx_is_api()){
+            $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+            return bx_api_get_image($CNF['OBJECT_STORAGE'], $aContentInfo[$CNF['FIELD_PICTURE']]);
+        }
 
         if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_THUMB']))
             $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'];
@@ -146,6 +151,22 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         $mixedResult = $this->_getFieldValueThumb('FIELD_PICTURE', $iContentId, $sTranscoder);
         return $mixedResult !== false ? $mixedResult : '';
     }
+    
+    public function serviceGetCover ($iContentId, $sTranscoder = '') 
+    {
+        $CNF = &$this->_oConfig->CNF;
+        
+        if(bx_is_api()){
+            $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+            return bx_api_get_image($CNF['OBJECT_STORAGE'], $aContentInfo[$CNF['FIELD_COVER']]);
+        }
+
+        if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_COVER']))
+            $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_COVER'];
+
+        $mixedResult = $this->_getFieldValueThumb('FIELD_COVER', $iContentId, $sTranscoder);
+        return $mixedResult !== false ? $mixedResult : '';
+    }
 
     public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
     {

+ 18 - 0
modules/base/profile/classes/BxBaseModProfileSearchResult.php

@@ -233,6 +233,24 @@ class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
 
         return true;
     }
+    
+    function decodeData ($a)
+    {
+        $oContentInfo = $this->getContentInfoObject();
+        $CNF = $this->oModule->_oConfig->CNF;
+        
+        foreach ($a as $i => $r) {
+            if (isset($r['author']))
+                $a[$i]['author_data'] = BxDolProfile::getData($r[$CNF['FIELD_AUTHOR']]);
+
+            $a[$i]['url'] = $this->decodeDataUrl($oContentInfo, $r);
+            $a[$i]['image'] = $oContentInfo->getContentThumb($r['id']);
+            $a[$i]['cover'] = $oContentInfo->getContentCover($r['id']);
+            $a[$i]['summary_plain'] = $this->decodeDataSummaryPlain($oContentInfo, $r);
+        }
+
+        return $a;
+    }
 	
 	function getItemPerPageInShowCase ()
     {

+ 17 - 0
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -236,6 +236,23 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
 
         return true;
     }
+    
+    function decodeData ($a)
+    {
+        $oContentInfo = $this->getContentInfoObject();
+        $CNF = $this->oModule->_oConfig->CNF;
+        
+        foreach ($a as $i => $r) {
+            if (isset($r['author']))
+                $a[$i]['author_data'] = BxDolProfile::getData($r[$CNF['FIELD_AUTHOR']]);
+
+            $a[$i]['url'] = $this->decodeDataUrl($oContentInfo, $r);
+            $a[$i]['image'] = $oContentInfo->getContentThumb($r['id']);
+            $a[$i]['summary_plain'] = $this->decodeDataSummaryPlain($oContentInfo, $r);
+        }
+
+        return $a;
+    }
 
     function _getPseud ()
     {

+ 1 - 0
modules/boonex/channels/install/sql/install.sql

@@ -48,6 +48,7 @@ CREATE TABLE `bx_cnl_pics` (
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,

+ 1 - 0
modules/boonex/events/install/sql/install.sql

@@ -64,6 +64,7 @@ CREATE TABLE `bx_events_pics` (
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,

+ 1 - 0
modules/boonex/groups/install/sql/install.sql

@@ -44,6 +44,7 @@ CREATE TABLE `bx_groups_pics` (
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,

+ 1 - 0
modules/boonex/organizations/install/sql/install.sql

@@ -44,6 +44,7 @@ CREATE TABLE IF NOT EXISTS `bx_organizations_pics` (
   `file_name` varchar(255) NOT NULL,
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `size` bigint(20) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,

+ 1 - 0
modules/boonex/persons/install/sql/install.sql

@@ -44,6 +44,7 @@ CREATE TABLE IF NOT EXISTS `bx_persons_pictures` (
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,

+ 1 - 0
modules/boonex/spaces/install/sql/install.sql

@@ -46,6 +46,7 @@ CREATE TABLE `bx_spaces_pics` (
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,