Browse Source

#24 - Minor fixes and improvements.

AntonLV 12 năm trước cách đây
mục cha
commit
c746309faf

+ 4 - 22
modules/base/notifications/classes/BxBaseModNotificationsDb.php

@@ -107,36 +107,18 @@ class BxBaseModNotificationsDb extends BxDolModuleDb
 
     public function deleteModuleEvents($aData)
     {
-    	foreach($aData['handlers'] as $aHandler) {
-    		//Delete system events.
+		//Delete system events.
+    	foreach($aData['handlers'] as $aHandler)
             $this->deleteEvent(array('type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-
-            //Delete shared events.
-    		$aEvents = $this->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-			foreach($aEvents as $aEvent) {
-				$aContent = unserialize($aEvent['content']);
-				if(isset($aContent['type']) && $aContent['type'] == $aHandler['alert_unit'] && isset($aContent['action']) && $aContent['action'] == $aHandler['alert_action'])
-					$this->deleteEvent(array('id' => (int)$aEvent['id']));
-			}
-    	}
     }
 
 	public function activateModuleEvents($aData, $bActivate = true)
     {
     	$iActivate = $bActivate ? 1 : 0;
 
-    	foreach($aData['handlers'] as $aHandler) {
-    		//Activate (deactivate) system events.
+    	//Activate (deactivate) system events.
+    	foreach($aData['handlers'] as $aHandler)    		
             $this->updateEvent(array('active' => $iActivate), array('type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-
-			//Activate (deactivate) shared events.
-			$aEvents = $this->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-			foreach($aEvents as $aEvent) {
-				$aContent = unserialize($aEvent['content']);
-				if(isset($aContent['type']) && $aContent['type'] == $aHandler['alert_unit'] && isset($aContent['action']) && $aContent['action'] == $aHandler['alert_action'])
-					$this->updateEvent(array('active' => $iActivate), array('id' => (int)$aEvent['id']));
-			}
-    	}
     }
 
     public function getHandlers($aParams = array())

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

@@ -142,7 +142,6 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         $this->_aPregPatterns = array(
             "meta_title" => "/<title>(.*)<\/title>/",
             "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
-            "url" => "/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*\.)+(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|[a-z]{2})|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&amp;]*)?)?(#[a-z][a-z0-9_]*)?/"
         );
 
     }

+ 34 - 0
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -36,6 +36,40 @@ class BxTimelineDb extends BxBaseModNotificationsDb
         );
     }
 
+    public function deleteModuleEvents($aData)
+    {
+    	foreach($aData['handlers'] as $aHandler) {
+    		//Delete system events.
+            $this->deleteEvent(array('type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
+
+            //Delete shared events.
+    		$aEvents = $this->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
+			foreach($aEvents as $aEvent) {
+				$aContent = unserialize($aEvent['content']);
+				if(isset($aContent['type']) && $aContent['type'] == $aHandler['alert_unit'] && isset($aContent['action']) && $aContent['action'] == $aHandler['alert_action'])
+					$this->deleteEvent(array('id' => (int)$aEvent['id']));
+			}
+    	}
+    }
+
+	public function activateModuleEvents($aData, $bActivate = true)
+    {
+    	$iActivate = $bActivate ? 1 : 0;
+
+    	foreach($aData['handlers'] as $aHandler) {
+    		//Activate (deactivate) system events.
+            $this->updateEvent(array('active' => $iActivate), array('type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
+
+			//Activate (deactivate) shared events.
+			$aEvents = $this->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
+			foreach($aEvents as $aEvent) {
+				$aContent = unserialize($aEvent['content']);
+				if(isset($aContent['type']) && $aContent['type'] == $aHandler['alert_unit'] && isset($aContent['action']) && $aContent['action'] == $aHandler['alert_action'])
+					$this->updateEvent(array('active' => $iActivate), array('id' => (int)$aEvent['id']));
+			}
+    	}
+    }
+
     public function getMaxDuration($aParams)
     {
         $aParams['browse'] = 'last';

+ 8 - 26
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -596,6 +596,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sStylePrefix = $this->_oConfig->getPrefix('style');
         $sJsObject = $this->_oConfig->getJsObject('view');
 
+        $bBrowseItem = isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_ITEM;
+
         //--- Process Text ---//
         $sUrl = isset($aContent['url']) ? bx_html_attribute($aContent['url']) : '';
         $sTitle = $sTitleAttr = '';
@@ -614,15 +616,15 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 'content' => $sTitle
             ));
 
-        $sText = isset($aContent['text']) ? strip_tags($aContent['text'], '<p><br>') : '';
+        $sText = isset($aContent['text']) ? strip_tags($aContent['text'], $bBrowseItem ? '<br><p>' : '') : '';
         $sTextMore = '';
 
         $iMaxLength = $this->_oConfig->getCharsDisplayMax();
-        if(strlen($sText) > $iMaxLength) {
+        if(!$bBrowseItem && strlen($sText) > $iMaxLength) {
             $iLength = strpos($sText, ' ', $iMaxLength);
 
-            $sTextMore = trim(substr($sText, $iLength));
-            $sText = trim(substr($sText, 0, $iLength));
+            $sTextMore = nl2br(trim(substr($sText, $iLength)));
+            $sText = nl2br(trim(substr($sText, 0, $iLength)));
         }
 
         $sText = $this->_prepareTextForOutput($sText, $aEvent['id']);
@@ -659,8 +661,6 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         //--- Process Photos ---//
         $aTmplVarsImages = array();
         if(!empty($aContent['images'])) {
-            $bBrowseItem = isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_ITEM;
-
             foreach($aContent['images'] as $aImage) {
                 $sImage = '';
                 if(!empty($aImage['src']))
@@ -930,26 +930,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
     protected function _prepareTextForOutput($s, $iEventId = 0)
     {
-    	$oTemplate = &$this;
-
-        $sPattern = $this->_oConfig->getPregPattern('url');
-        $bAddNofollow = $this->_oDb->getParam('sys_add_nofollow') == 'on';
-
-        $s = bx_process_output($s, BX_DATA_TEXT_MULTILINE);
-        $s = preg_replace_callback($sPattern, function($aMatches) use($oTemplate, $bAddNofollow) {
-        	$aLinkAttrs = array(
-        		array('key' => 'target', 'value' => '_blank')
-        	);
-	        if($bAddNofollow && strncmp(BX_DOL_URL_ROOT, $aMatches[0], strlen(BX_DOL_URL_ROOT)) != 0)
-	        	$aLinkAttrs[] = array('key' => 'rel', 'value' => 'nofollow');
-
-        	return $oTemplate->parsePageByName('bx_a.html', array(
-        		'href' => (empty($aMatches[1]) ? 'http://' : '') . $aMatches[0],
-        		'title' => $aMatches[0],
-        		'bx_repeat:attrs' => $aLinkAttrs,
-        		'content' => $aMatches[0],
-        	));
-        }, $s);
+    	$s = bx_process_output($s, BX_DATA_HTML);
+        $s = bx_convert_links($s);
 
         bx_import('BxDolMetatags');
         $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));