Explorar o código

Ticket #255 - Timeline: parse markers in description field.

AntonLV %!s(int64=8) %!d(string=hai) anos
pai
achega
4e788ddbbc

+ 11 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -390,8 +390,18 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
     /**
      * Ancillary functions
      */
-    public function getTitle($s)
+    public function getTitle($s, $mixedProfile = false)
     {
+        if($mixedProfile !== false) {
+            if(is_numeric($mixedProfile))
+                $mixedProfile = BxDolProfile::getInstanceMagic((int)$mixedProfile);
+
+            if($mixedProfile instanceof BxDolProfile)
+                $s = bx_replace_markers($s, array(
+                    'profile_name' => $mixedProfile->getDisplayName()
+                ));
+        }
+
         return strmaxtextlen($s, $this->getCharsDisplayMaxTitle(), '...');
     }
 

+ 35 - 35
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1275,20 +1275,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
     	$CNF = &$this->_oConfig->CNF;
 
-    	$iContent = (int)$aEvent['object_id'];
-		$aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
+        $iContent = (int)$aEvent['object_id'];
+        $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
         if(empty($aContent) || !is_array($aContent))
             return array();
 
-        $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description']);
+        $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
 
-		return array(
-			'entry_sample' => $CNF['T']['txt_sample_single_ext'],
-			'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
-			'entry_caption' => $sEntryCaption,
-			'entry_author' => $aContent['owner_id'],
-			'lang_key' => '_bx_timeline_ntfs_txt_object_added', //may be empty or not specified. In this case the default one from Notification module will be used.
-		);
+        return array(
+            'entry_sample' => $CNF['T']['txt_sample_single_ext'],
+            'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
+            'entry_caption' => $sEntryCaption,
+            'entry_author' => $aContent['owner_id'],
+            'lang_key' => '_bx_timeline_ntfs_txt_object_added', //may be empty or not specified. In this case the default one from Notification module will be used.
+        );
     }
 
     /**
@@ -1313,26 +1313,26 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
     	$CNF = &$this->_oConfig->CNF;
 
-    	$iContent = (int)$aEvent['object_id'];
-    	$aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
+        $iContent = (int)$aEvent['object_id'];
+        $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
         if(empty($aContent) || !is_array($aContent))
             return array();
 
-		$oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContent);
+        $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContent);
         if(!$oComment || !$oComment->isEnabled())
             return array();
 
-        $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description']);
+        $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
 
-		return array(
-			'entry_sample' => $CNF['T']['txt_sample_single'],
-			'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
-			'entry_caption' => $sEntryCaption,
-			'entry_author' => $aContent['owner_id'],
-			'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
-			'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
-			'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
-		);
+        return array(
+            'entry_sample' => $CNF['T']['txt_sample_single'],
+            'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
+            'entry_caption' => $sEntryCaption,
+            'entry_author' => $aContent['owner_id'],
+            'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
+            'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
+            'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
+        );
     }
 
     /**
@@ -1357,25 +1357,25 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
     	$CNF = &$this->_oConfig->CNF;
 
-    	$iContent = (int)$aEvent['object_id'];
-    	$aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
+        $iContent = (int)$aEvent['object_id'];
+        $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
         if(empty($aContent) || !is_array($aContent))
             return array();
 
-		$oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContent);
+        $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContent);
         if(!$oVote || !$oVote->isEnabled())
             return array();
 
-        $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description']);
+        $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
 
-		return array(
-			'entry_sample' => $CNF['T']['txt_sample_single'],
-			'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
-			'entry_caption' => $sEntryCaption,
-			'entry_author' => $aContent['owner_id'],
-			'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
-			'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
-		);
+        return array(
+            'entry_sample' => $CNF['T']['txt_sample_single'],
+            'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
+            'entry_caption' => $sEntryCaption,
+            'entry_author' => $aContent['owner_id'],
+            'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
+            'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
+        );
     }
 
     /**