Przeglądaj źródła

Ticket #4469 - Timeline: Add Labels field support.

AntonLV 3 lat temu
rodzic
commit
83de3d901e

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

@@ -122,6 +122,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'FIELD_CONTROLS' => 'controls',
             'FIELD_LOCATION' => 'location',
             'FIELD_LOCATION_PREFIX' => 'location',
+            'FIELD_LABELS' => 'labels',
             'FIELDS_DELAYED_PROCESSING' => 'video', // can be array of fields or comma separated string of field names
 
             // page URIs

+ 29 - 12
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -3690,10 +3690,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 $this->_oDb->updateEvent(['content' => serialize($aContent), 'source' => $sSource], ['id' => $iId]);
 
                 //--- Process Meta ---//
-            	$oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
-            	if($bText)
-                    $oMetatags->metaAdd($iId, $sText);
-                $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
+                $this->_processMetas($iId, $sText);
 
                 //--- Process Link ---//
                 if($bLinkIds)
@@ -3857,10 +3854,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
             $this->isAllowedEdit($aEvent, true);
 
-            $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
-            if($bText)
-                $oMetatags->metaAdd($iId, $sText);
-            $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
+            //--- Process Meta ---//
+            $this->_processMetas($iId, $sText);
 
             //--- Process Link ---//
             if($bLinkIds)
@@ -4708,10 +4703,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
             $aContent = unserialize($aEvent['content']);
 
-            $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
-            if(!empty($aContent['text']))
-                $oMetatags->metaAdd($aEvent[$CNF['FIELD_ID']], $aContent['text']);
-            $oMetatags->locationsAddFromForm($aEvent[$CNF['FIELD_ID']], $CNF['FIELD_LOCATION_PREFIX']);
+            $this->_processMetas($aEvent[$CNF['FIELD_ID']], $aContent['text']);
         }
 
         //--- Rebuild cache table.
@@ -5439,6 +5431,31 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         $this->_oDb->deleteLinks($iId);
     }
 
+    protected function _processMetas($iId, $sText)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
+
+        if(!empty($sText)) {
+            $oMetatags->metaAdd($iId, $sText);
+
+            $aEvent = $this->_oDb->getEvents(['browse' => 'id', 'value' => $iId]);
+            if($oMetatags->keywordsIsEnabled() && !empty($aEvent[$CNF['FIELD_LABELS']])) {
+                $aLabels = unserialize($aEvent[$CNF['FIELD_LABELS']]);
+                if(!empty($aLabels) && is_array($aLabels))
+                    foreach ($aLabels as $sLabel) {
+                        if(!preg_match("/(\pL[\pL\pN_]+)/u", $sLabel)) 
+                            continue;
+
+                        $oMetatags->keywordsAddOne($iId, $sLabel, false);
+                    }
+            }
+        }
+
+        $oMetatags->locationsAddFromForm($iId, $CNF['FIELD_LOCATION_PREFIX']);
+    }
+
     protected function _saveMedia($sType, $iContentId, $aItemIds, $iProfileId = 0, $isAssociateWithContent = false)
     {
         if(empty($iContentId))

+ 3 - 0
modules/boonex/timeline/install/sql/install.sql

@@ -15,6 +15,7 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_events` (
   `source` varchar(32) NOT NULL default '',
   `title` varchar(255) NOT NULL,
   `description` text NOT NULL,
+  `labels` text NOT NULL,
   `location` text NOT NULL,
   `views` int(11) unsigned NOT NULL default '0',
   `rate` float NOT NULL default '0',
@@ -56,6 +57,7 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_events_slice` (
   `source` varchar(32) NOT NULL default '',
   `title` varchar(255) NOT NULL,
   `description` text NOT NULL,
+  `labels` text NOT NULL,
   `location` text NOT NULL,
   `views` int(11) unsigned NOT NULL default '0',
   `rate` float NOT NULL default '0',
@@ -536,6 +538,7 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
 ('bx_timeline_post', @sName, 'published', '', '', 0, 'datetime', '_bx_timeline_form_post_input_sys_date_published', '_bx_timeline_form_post_input_date_published', '_bx_timeline_form_post_input_date_published_info', 0, 0, 0, '', '', '', '', '', '', 'DateTimeTs', '', 1, 0),
 ('bx_timeline_post', @sName, 'object_cf', '1', '#!sys_content_filter', 0, 'select', '_sys_form_entry_input_sys_cf', '_sys_form_entry_input_cf', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
 ('bx_timeline_post', @sName, 'object_privacy_view', '', '', 0, 'custom', '_bx_timeline_form_post_input_sys_object_privacy_view', '_bx_timeline_form_post_input_object_privacy_view', '', 1, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_timeline_post', @sName, 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'location', '', '', 0, 'location', '_sys_form_input_sys_location', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'link', '', '', 0, 'custom', '_bx_timeline_form_post_input_sys_link', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'photo', 'a:1:{i:0;s:23:"bx_timeline_html5_photo";}', 'a:1:{s:23:"bx_timeline_html5_photo";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_timeline_form_post_input_sys_photo', '_bx_timeline_form_post_input_photo', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),