Prechádzať zdrojové kódy

Ticket #1172 - Basic changes

AntonLV 8 rokov pred
rodič
commit
1203873635

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

@@ -715,7 +715,7 @@ class BxBaseModGeneralModule extends BxDolModule
             'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
         	'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
         	'sample_wo_article' => $CNF['T']['txt_sample_single'],
-    	    'sample_action' => isset($CNF['T']['txt_sample_single_action']) ? $CNF['T']['txt_sample_single_action'] : '',
+    	    'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
             'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
             'content' => $this->_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams), //a string to display or array to parse default template before displaying.
             'date' => $aContentInfo[$CNF['FIELD_ADDED']],
@@ -1110,7 +1110,7 @@ class BxBaseModGeneralModule extends BxDolModule
     	return array(
     		'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
     		'sample_wo_article' => $CNF['T']['txt_sample_single'],
-    	    'sample_action' => isset($CNF['T']['txt_sample_single_action']) ? $CNF['T']['txt_sample_single_action'] : '',
+    	    'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
 			'url' => $sUrl,
 			'title' => isset($CNF['FIELD_TITLE']) && isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : 
 			(isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...') : ''),

+ 8 - 0
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -421,6 +421,14 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 		);
     }
 
+    /**
+     * Data for Timeline module
+     */
+    public function serviceGetTimelineData()
+    {
+        return BxBaseModGeneralModule::serviceGetTimelineData();
+    }
+
     /**
      * Entry post for Timeline module
      */

+ 18 - 1
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -174,8 +174,25 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
 
     protected function _associalFileWithContent($oStorage, $iFileId, $iProfileId, $iContentId, $sPictureField = '')
     {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
         $oStorage->updateGhostsContentId ($iFileId, $iProfileId, $iContentId, $this->_isAdmin($iContentId));
-        $this->_oModule->_oDb->updateContentPictureById($iContentId, 0/*$iProfileId*/, $iFileId, $sPictureField);
+
+        $bResult = (int)$this->_oModule->_oDb->updateContentPictureById($iContentId, 0/*$iProfileId*/, $iFileId, $sPictureField) > 0;
+        if($bResult) {
+            $sModule = $this->_oModule->getName();
+            switch($sPictureField) {
+                case $CNF['FIELD_PICTURE']:
+                    bx_alert($sModule, 'profile_picture_changed', $iContentId, $iProfileId, array('file' => $iFileId));
+                    bx_alert('profile', 'picture_changed', $iProfileId, $iProfileId, array('file' => $iFileId, 'content' => $iContentId, 'module' => $sModule));
+                    break;
+
+                case $CNF['FIELD_COVER']:
+                    bx_alert($sModule, 'profile_cover_changed', $iContentId, $iProfileId, array('file' => $iFileId));
+                    bx_alert('profile', 'cover_changed', $iProfileId, $iProfileId, array('file' => $iFileId, 'content' => $iContentId, 'module' => $sModule));
+                    break;
+            }
+        }
     }
 
     protected function _getProfilePhotoGhostTmplVars($sField, $aContentInfo = array())

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

@@ -567,6 +567,135 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 		);
     }
 
+	/**
+     * Data for Timeline module
+     */
+    public function serviceGetTimelineData()
+    {
+        $CNF = &$this->_oConfig->CNF;
+        $sModule = $this->_aModule['name'];
+
+        $aAlerts = array();
+        $aHandlers = array();
+        if(!empty($CNF['FIELD_PICTURE'])) {
+            $aAlerts[] = array('unit' => $sModule, 'action' => 'profile_picture_changed');
+            $aHandlers[] = array('group' => $sModule . '_profile_picture', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'profile_picture_changed', 'module_name' => $sModule, 'module_method' => 'get_timeline_profile_picture', 'module_class' => 'Module',  'groupable' => 0, 'group_by' => '');
+        }
+
+        if(!empty($CNF['FIELD_COVER'])) {
+            $aAlerts[] = array('unit' => $sModule, 'action' => 'profile_cover_changed');
+            $aHandlers[] = array('group' => $sModule . '_profile_cover', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'profile_cover_changed', 'module_name' => $sModule, 'module_method' => 'get_timeline_profile_cover', 'module_class' => 'Module',  'groupable' => 0, 'group_by' => '');
+        }
+
+    	$aResult = array();
+        if(!empty($aAlerts) && !empty($aHandlers))
+            $aResult = array(
+            	'handlers' => $aHandlers,
+            	'alerts' => $aAlerts
+            );
+
+        return $aResult;
+    }
+
+	/**
+     * Entry post for Timeline module
+     */
+    public function serviceGetTimelineProfilePicture($aEvent, $aBrowseParams = array())
+    {
+        return $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, array(
+         	'fld_image' => 'FIELD_PICTURE',
+    		'trans' => array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_AVATAR'),
+    		'trans_orig' => array('OBJECT_IMAGES_TRANSCODER_PICTURE', 'OBJECT_IMAGES_TRANSCODER_GALLERY'),
+            'txt_ss' => 'txt_sample_pp_single',
+            'txt_sswa' => 'txt_sample_pp_single_with_article',
+            'txt_sa' => 'txt_sample_pi_action',
+            'txt_sau' => 'txt_sample_pi_action_user'
+        ));
+    }
+
+    public function serviceGetTimelineProfileCover($aEvent, $aBrowseParams = array())
+    {
+        return $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, array(
+         	'fld_image' => 'FIELD_COVER',
+    		'trans' => array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_COVER_THUMB'),
+    		'trans_orig' => array('OBJECT_IMAGES_TRANSCODER_COVER', 'OBJECT_IMAGES_TRANSCODER_GALLERY'),
+            'txt_ss' => 'txt_sample_pc_single',
+            'txt_sswa' => 'txt_sample_pc_single_with_article',
+            'txt_sa' => 'txt_sample_pi_action',
+            'txt_sau' => 'txt_sample_pi_action_user'
+        ));
+    }
+    
+    protected function _serviceGetTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams)
+    {
+        $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
+        if(empty($aContentInfo) || !is_array($aContentInfo))
+            return '';
+
+        $CNF = &$this->_oConfig->CNF;
+
+        list($sUserName) = $this->getUserInfo($aContentInfo['profile_id']);
+
+        $sSample = isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']];
+
+        //--- Title & Description
+        $sTitle = !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '';
+        if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TEXT']]))
+            $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
+
+        $sDescription = _t($CNF['T'][$aBuildParams['txt_sau']], $sUserName, _t($sSample));
+
+        return array(
+            'owner_id' => $aContentInfo['profile_id'],
+            'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
+        	'sample' => $sSample,
+        	'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
+    	    'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
+            'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
+            'content' => $this->_getContentForTimelineProfileImage($aEvent, $aContentInfo, $aBrowseParams, $aBuildParams), //a string to display or array to parse default template before displaying.
+            'date' => $aContentInfo[$CNF['FIELD_ADDED']],
+            'views' => '',
+            'votes' => '',
+            'reports' => '',
+            'comments' => '',
+            'title' => $sTitle, //may be empty.
+            'description' => $sDescription //may be empty.
+        );
+    }
+
+    protected function _getContentForTimelineProfileImage($aEvent, $aContentInfo, $aBrowseParams, $aBuildParams)
+    {
+    	$CNF = &$this->_oConfig->CNF;
+
+    	$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+
+    	//--- Image(s)
+    	$aImages = array();
+        if(isset($CNF[$aBuildParams['fld_image']]) && isset($aContentInfo[$CNF[$aBuildParams['fld_image']]]) && $aContentInfo[$CNF[$aBuildParams['fld_image']]]) {
+            $sImage = $this->_oConfig->getImageUrl($aContentInfo[$CNF[$aBuildParams['fld_image']]], $aBuildParams['trans']);
+            $sImageOrig = $this->_oConfig->getImageUrl($aContentInfo[$CNF[$aBuildParams['fld_image']]], $aBuildParams['trans_orig']);
+            if(!empty($sImage)) {
+                if(empty($sImageOrig))
+                    $sImageOrig = $sImage;
+
+                $aImages = array(
+                    array('url' => $sUrl, 'src' => $sImage, 'src_orig' => $sImageOrig),
+                );
+            }
+        }
+
+    	return array(
+    		'sample' => isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']],
+    		'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
+    	    'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
+			'url' => $sUrl,
+			'title' =>  '',
+			'text' => '',
+			'images' => $aImages,
+            'videos' => array()
+		);
+    }
+
     public function serviceGetConnectionButtonsTitles($iProfileId, $sConnectionsObject = 'sys_profiles_friends')
     {
         if (!isLogged())

+ 22 - 13
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -1261,14 +1261,17 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     protected function _getSystemData(&$aEvent, $aBrowseParams = array())
     {
         $mixedResult = $this->_oConfig->getSystemData($aEvent, $aBrowseParams);
-		if($mixedResult !== false)
-			return $mixedResult;
-
-		$sMethod = 'display' . bx_gen_method_name($aEvent['type'] . '_' . $aEvent['action']);
-		if(!method_exists($this, $sMethod))
-        	return '';
+		if($mixedResult === false) {
+    		$sMethod = 'display' . bx_gen_method_name($aEvent['type'] . '_' . $aEvent['action']);
+    		if(method_exists($this, $sMethod))
+    		    $mixedResult = $this->$sMethod($aEvent);
+		}
+		
+		if($mixedResult === false)
+            return '';
 
-		return $this->$sMethod($aEvent);
+        $this->_preparetDataActions($aEvent, $mixedResult);
+		return $mixedResult;
     }
 
     protected function _getCommonData(&$aEvent, $aBrowseParams = array())
@@ -1390,8 +1393,16 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 break;
         }
 
+        $this->_preparetDataActions($aEvent, $aResult);
+        return $aResult;
+    }
+
+    protected function _preparetDataActions(&$aEvent, &$aResult)
+    {
+        $oModule = $this->getModule();
+
         $sSystem = $this->_oConfig->getObject('view');
-        if($oModule->getViewObject($sSystem, $aEvent['id']) !== false)
+        if(empty($aResult['views']) && $oModule->getViewObject($sSystem, $aEvent['id']) !== false)
             $aResult['views'] = array(
                 'system' => $sSystem,
                 'object_id' => $aEvent['id'],
@@ -1399,7 +1410,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             );
 
         $sSystem = $this->_oConfig->getObject('vote');
-        if($oModule->getVoteObject($sSystem, $aEvent['id']) !== false)
+        if(empty($aResult['votes']) && $oModule->getVoteObject($sSystem, $aEvent['id']) !== false)
             $aResult['votes'] = array(
                 'system' => $sSystem,
                 'object_id' => $aEvent['id'],
@@ -1407,7 +1418,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             );
 
 		$sSystem = $this->_oConfig->getObject('report');
-        if($oModule->getReportObject($sSystem, $aEvent['id']) !== false)
+        if(empty($aResult['reports']) && $oModule->getReportObject($sSystem, $aEvent['id']) !== false)
             $aResult['reports'] = array(
                 'system' => $sSystem,
                 'object_id' => $aEvent['id'],
@@ -1415,14 +1426,12 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             );
 
         $sSystem = $this->_oConfig->getObject('comment');
-        if($oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
+        if(empty($aResult['comments']) && $oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
             $aResult['comments'] = array(
                 'system' => $sSystem,
                 'object_id' => $aEvent['id'],
                 'count' => $aEvent['comments']
             );
-
-        return $aResult;
     }
 
     protected function _prepareTextForOutput($s, $iEventId = 0)