Parcourir la source

#3445 Add Files to Timeline form like in Posts

RomanL il y a 5 ans
Parent
commit
4de5fdc058

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

@@ -97,6 +97,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'FIELD_LINK' => 'link',
             'FIELD_PHOTO' => 'photo',
             'FIELD_VIDEO' => 'video',
+            'FIELD_FILE' => 'file',
             'FIELD_STATUS' => 'status',
             'FIELD_STICKED' => 'sticked',
             'FIELD_DATE' => 'date',
@@ -115,6 +116,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             // objects
             'OBJECT_STORAGE' => $this->_sName . '_photos',
             'OBJECT_STORAGE_VIDEOS' => $this->_sName . '_videos',
+            'OBJECT_STORAGE_FILES' => $this->_sName . '_files',
             'OBJECT_IMAGES_TRANSCODER_PREVIEW' => $this->_sName . '_photos_preview',
             'OBJECT_VIDEOS_TRANSCODERS' => array(
                 'poster' => 'bx_timeline_videos_poster', 
@@ -126,6 +128,8 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'OBJECT_UPLOADER_VIDEO_SIMPLE' => $this->_sName . '_simple_video',
             'OBJECT_UPLOADER_VIDEO_HTML5' => $this->_sName . '_html5_video',
             'OBJECT_UPLOADER_VIDEO_RECORD' => $this->_sName . '_record_video',
+            'OBJECT_UPLOADER_FILE_HTML5' => $this->_sName . '_html5_file',
+            'OBJECT_UPLOADER_FILE_SIMPLE' => $this->_sName . '_simple_file',
             'OBJECT_GRID_ADMINISTRATION' => $this->_sName . '_administration',
             'OBJECT_GRID_MUTE' => $this->_sName . '_mute',
             'OBJECT_MENU_ENTRY_ATTACHMENTS' => $this->_sName . '_menu_post_attachments',
@@ -193,6 +197,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
 
             'storage_photos' => $this->CNF['OBJECT_STORAGE'],
             'storage_videos' => $this->CNF['OBJECT_STORAGE_VIDEOS'],
+            'storage_files' => $this->CNF['OBJECT_STORAGE_FILES'],
             'transcoder_photos_preview' => $this->CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'],
             'transcoder_photos_view' => $this->_sName . '_photos_view',
             'transcoder_photos_medium' => $this->_sName . '_photos_medium',
@@ -230,6 +235,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
 
         $this->_aPhotoUploaders = array($this->CNF['OBJECT_UPLOADER_PHOTO_SIMPLE']);
         $this->_aVideoUploaders = array($this->CNF['OBJECT_UPLOADER_VIDEO_SIMPLE']);
+        $this->_aFilesUploaders = array($this->CNF['OBJECT_UPLOADER_FILE_SIMPLE']);
 
         $this->_aItemToUploader = array(
             'add-photo-simple' => $this->CNF['OBJECT_UPLOADER_PHOTO_SIMPLE'],
@@ -237,6 +243,8 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'add-video-simple' => $this->CNF['OBJECT_UPLOADER_VIDEO_SIMPLE'],
             'add-video-html5' => $this->CNF['OBJECT_UPLOADER_VIDEO_HTML5'],
             'add-video-record' => $this->CNF['OBJECT_UPLOADER_VIDEO_RECORD'],
+            'add-file-simple' => $this->CNF['OBJECT_UPLOADER_FILE_SIMPLE'],
+            'add-file-html5' => $this->CNF['OBJECT_UPLOADER_FILE_HTML5'],
         );
 
         $this->_bJsMode = false;
@@ -551,6 +559,9 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             case 'video':
                 $aResult = $this->_aVideoUploaders;
                 break;
+            case 'file':
+                $aResult = $this->_aFilesUploaders;
+                break;
         }
 
         return $aResult;

+ 4 - 2
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -37,11 +37,13 @@ class BxTimelineDb extends BxBaseModNotificationsDb
 
         $this->_aTablesMedia = array(
             $CNF['FIELD_PHOTO'] => $this->_sPrefix . 'photos',
-            $CNF['FIELD_VIDEO'] => $this->_sPrefix . 'videos' 
+            $CNF['FIELD_VIDEO'] => $this->_sPrefix . 'videos',
+			$CNF['FIELD_FILE'] => $this->_sPrefix . 'files' 
         );
         $this->_aTablesMedia2Events = array(
             $CNF['FIELD_PHOTO'] => $this->_sPrefix . 'photos2events',
-            $CNF['FIELD_VIDEO'] => $this->_sPrefix . 'videos2events'
+            $CNF['FIELD_VIDEO'] => $this->_sPrefix . 'videos2events',
+			$CNF['FIELD_FILE'] => $this->_sPrefix . 'files2events'
         );
     }
 

+ 36 - 6
modules/boonex/timeline/classes/BxTimelineFormPost.php

@@ -64,9 +64,19 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
                 $this->aInputs[$CNF['FIELD_VIDEO']]['content_id'] = $iValueId;
             }
 
-            $this->aInputs[$CNF['FIELD_VIDEO']]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName($this->_sGhostTemplate, $this->_getVideoGhostTmplVars($aContentInfo));
+            $this->aInputs[$CNF['FIELD_VIDEO']]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName($this->_sGhostTemplate, $this->_getGhostTmplVars($CNF['FIELD_VIDEO'], $aContentInfo));
         }
+		
+		if(isset($CNF['FIELD_FILE']) && isset($this->aInputs[$CNF['FIELD_FILE']])) {
+            $aContentInfo = false;
+            if($bValueId) {
+                $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($iValueId);
+                $this->aInputs[$CNF['FIELD_FILE']]['content_id'] = $iValueId;
+            }
 
+            $this->aInputs[$CNF['FIELD_FILE']]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName($this->_sGhostTemplate, $this->_getGhostTmplVars($CNF['FIELD_FILE'], $aContentInfo));
+        }
+	
         if($this->aParams['display'] == $this->_oModule->_oConfig->getObject('form_display_post_edit') && isset($CNF['FIELD_PUBLISHED']) && isset($this->aInputs[$CNF['FIELD_PUBLISHED']]))
             if(isset($aValues[$CNF['FIELD_STATUS']]) && in_array($aValues[$CNF['FIELD_STATUS']], array(BX_TIMELINE_STATUS_ACTIVE, BX_TIMELINE_STATUS_HIDDEN)))
                 unset($this->aInputs[$CNF['FIELD_PUBLISHED']]);
@@ -217,6 +227,28 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
             $this->aInputs[$CNF['FIELD_VIDEO']]['content_id'] = 0;
             $this->aInputs[$CNF['FIELD_VIDEO']]['ghost_template'] = '';
         }
+        
+        if(isset($this->aInputs[$CNF['FIELD_FILE']])) {
+            $sStorage = $this->_oModule->_oConfig->getObject('storage_files');
+            $sUploadersId = genRndPwd(8, false);
+            $aUploaders = !empty($this->aInputs[$CNF['FIELD_FILE']]['value']) ? unserialize($this->aInputs[$CNF['FIELD_FILE']]['value']) : $this->_oModule->_oConfig->getUploaders($CNF['FIELD_FILE']);
+          
+            foreach($aUploaders as $sUploader){
+                $this->_aUploadersInfo[$sUploader] = array(
+                    'id' => $sUploadersId, 
+                    'js_object' => BxDolUploader::getObjectInstance($sUploader, $sStorage, $sUploadersId)->getNameJsInstanceUploader()
+                );
+            }
+            
+            $this->aInputs[$CNF['FIELD_FILE']]['storage_object'] = $sStorage;
+            $this->aInputs[$CNF['FIELD_FILE']]['images_transcoder'] = '';
+            $this->aInputs[$CNF['FIELD_FILE']]['uploaders_id'] = $sUploadersId;
+            $this->aInputs[$CNF['FIELD_FILE']]['uploaders'] = $aUploaders;
+            $this->aInputs[$CNF['FIELD_FILE']]['upload_buttons_titles'] = array('Simple' => 'file');
+            $this->aInputs[$CNF['FIELD_FILE']]['multiple'] = true;
+            $this->aInputs[$CNF['FIELD_FILE']]['content_id'] = 0;
+            $this->aInputs[$CNF['FIELD_FILE']]['ghost_template'] = '';
+        }
 
         if (isset($this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']) && isset($this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]))
             $this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]['manual_input'] = false;
@@ -340,13 +372,11 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
         ));
     }
 
-    protected function _getVideoGhostTmplVars($aContentInfo = array())
+    protected function _getGhostTmplVars($sName, $aContentInfo = array())
     {
-    	$CNF = &$this->_oModule->_oConfig->CNF;
-
     	return array (
-            'name' => $this->aInputs[$CNF['FIELD_VIDEO']]['name'],
-            'content_id' => (int)$this->aInputs[$CNF['FIELD_VIDEO']]['content_id'],
+            'name' => $this->aInputs[$sName]['name'],
+            'content_id' => (int)$this->aInputs[$sName]['content_id'],
         );
     }
 }

+ 44 - 6
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -2797,15 +2797,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
             $aVideoIds = $oForm->getCleanValue($CNF['FIELD_VIDEO']);
             $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
+			
+			//--- Process Files ---//
+			$aFileIds = $oForm->getCleanValue($CNF['FIELD_FILE']);
+            $bFileIds = !empty($aFileIds) && is_array($aFileIds);
+			
 
-            if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds) {
+            if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds && !$bFileIds) {
                 $oForm->aInputs['text']['error'] =  _t('_bx_timeline_txt_err_empty_post');
                 $oForm->setValid(false);
 
             	return $this->_prepareResponse(array('form' => $oForm->getCode($bDynamicMode), 'form_id' => $oForm->id), $bAjaxMode);
             }
 
-            $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oConfig->getTitleDefault($bLinkIds, $bPhotoIds, $bVideoIds);
+            $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oConfig->getTitleDefault($bLinkIds, $bPhotoIds, $bVideoIds);//RLTODO
             $sDescription = _t('_bx_timeline_txt_user_added_sample', '{profile_name}', _t('_bx_timeline_txt_sample_with_article'));
 
             /**
@@ -2848,6 +2853,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 //--- Process Media ---//
                 $this->_saveMedia($CNF['FIELD_PHOTO'], $iId, $aPhotoIds, $iUserId, true);
                 $this->_saveMedia($CNF['FIELD_VIDEO'], $iId, $aVideoIds, $iUserId, true);
+				$this->_saveMedia($CNF['FIELD_FILE'], $iId, $aFileIds, $iUserId, true);
+				
 
                 $this->onPost($iId);
 
@@ -2962,8 +2969,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
             $aVideoIds = $oForm->getCleanValue($CNF['FIELD_VIDEO']);
             $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
+			
+			$aFileIds = $oForm->getCleanValue($CNF['FIELD_FILE']);
+            $bFileIds = !empty($aFileIds) && is_array($aFileIds);
 
-            if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds) {
+            if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds && !$bFileIds) {
                 $oForm->aInputs['text']['error'] =  _t('_bx_timeline_txt_err_empty_post');
                 $oForm->setValid(false);
 
@@ -2986,6 +2996,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             //--- Process Media ---//
             $this->_saveMedia($CNF['FIELD_PHOTO'], $iId, $aPhotoIds, $iUserId);
             $this->_saveMedia($CNF['FIELD_VIDEO'], $iId, $aVideoIds, $iUserId);
+			$this->_saveMedia($CNF['FIELD_FILE'], $iId, $aFileIds, $iUserId);
 
             $this->getCacheItemObject()->removeAllByPrefix($this->_oConfig->getPrefix('cache_item') . $iId);
             $this->_oDb->deleteCache(array('event_id' => $iId));
@@ -3686,7 +3697,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     	if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_POST) {
             $this->_deleteMedia($CNF['FIELD_PHOTO'], $aEvent[$CNF['FIELD_ID']]);
             $this->_deleteMedia($CNF['FIELD_VIDEO'], $aEvent[$CNF['FIELD_ID']]);
-
+			$this->_deleteMedia($CNF['FIELD_FILE'], $aEvent[$CNF['FIELD_ID']]);
             $this->_deleteLinks($aEvent[$CNF['FIELD_ID']]);
     	}
 
@@ -3929,6 +3940,34 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return $aResult;
     }
+	
+	public function getEventFiles($iEventId)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $aFiles = $this->_oDb->getMedia($CNF['FIELD_FILE'], $iEventId);
+		
+        if(empty($aFiles) || !is_array($aFiles))
+            return array();
+
+        $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_files'));
+		
+        $aResult = array();
+        foreach($aFiles as $iFileId) {
+            $sFileUrl = $oStorage->getFileUrlById($iFileId);
+            $aFileFile = $oStorage->getFile($iFileId);
+
+            $aResult[$iFileId] = array(
+                'id' => $iFileId,
+                'src' => $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFileFile['file_name'])),
+                'src_medium' => '',
+                'src_orig' => '',
+                'url' => $sFileUrl
+            );
+        }
+
+        return $aResult;
+    }
 
     /**
      * Protected Methods 
@@ -4097,7 +4136,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             'videos' => array(),
             'videos_attach' => $this->getEventVideos($iId),
             'files' => array(),
-            'files_attach' => array()
+            'files_attach' => $this->getEventFiles($iId)
         );
     }
 
@@ -4243,7 +4282,6 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             $iProfileId = $this->_iProfileId;
 
         $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
-
         $aGhostFiles = $oStorage->getGhosts ($iProfileId, !$isAssociateWithContent ? $iContentId : 0, true, $this->_isModerator());
         if(empty($aGhostFiles) || !is_array($aGhostFiles))
             return;

+ 11 - 7
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -1990,7 +1990,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             $sAttachmentsLayout = BX_TIMELINE_ML_GALLERY;
 
         $iAttachmentsTotal = 0;
-        $aTmplVarsImages = $aTmplVarsVideos = $aTmplVarsAttachments = array();
+        $aTmplVarsImages = $aTmplVarsVideos = $aTmplVarsFiles = $aTmplVarsAttachments = array();
 
         //--- Process Photos ---//
         $bImages = !empty($aContent['images']) && is_array($aContent['images']);
@@ -2003,7 +2003,6 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                     'bx_repeat:items' => $aImages['items']
                 );
         }
-
         $bImagesAttach = !empty($aContent['images_attach']) && is_array($aContent['images_attach']);
         if($bImagesAttach) {
             $aImagesAttach = $this->_getTmplVarsImages($aContent['images_attach'], array('layout' => $sAttachmentsLayout, 'first' => empty($aTmplVarsAttachments)), $aEvent, $aBrowseParams);
@@ -2045,7 +2044,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 $aTmplVarsAttachments = array_merge($aTmplVarsAttachments, $aVideosAttach['items']);
             }
         }
-
+ 
         //--- Process Files ---//
         $bFiles = !empty($aContent['files']) && is_array($aContent['files']);
         if($bFiles) {
@@ -2058,16 +2057,16 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 );
         }
 
-        $bFilesAttach = !empty($aContent['files_attach']) && is_array($aContent['files_attach']);
+		$bFilesAttach = !empty($aContent['files_attach']) && is_array($aContent['files_attach']);
         if($bFilesAttach) {
             $aFilesAttach = $this->_getTmplVarsFiles($aContent['files_attach'], $aEvent, $aBrowseParams);
-            if(!empty($aFilesAttach)) {
+			if(!empty($aFilesAttach)) {
                 $iAttachmentsTotal += $aFilesAttach['total'];
                 $aTmplVarsAttachments = array_merge($aTmplVarsAttachments, $aFilesAttach['items']);
             }
         }
-
-        /*
+		
+		/*
          *  Process collected attachments in case of Showcase layout.
          */
         $iAttachmentsShow = 4;
@@ -2123,6 +2122,10 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'bx_if:show_videos' => array(
                 'condition' => !empty($aTmplVarsVideos),
                 'content' => $aTmplVarsVideos
+            ),
+			 'bx_if:show_files' => array(
+                'condition' => !empty($aTmplVarsFiles),
+                'content' => $aTmplVarsFiles
             ),
             'bx_if:show_attachments' => array(
                 'condition' => !empty($aTmplVarsAttachments),
@@ -2587,6 +2590,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 $aResult['content']['links'] = $oModule->getEventLinks($aEvent['id']);
                 $aResult['content']['images_attach'] = $oModule->getEventImages($aEvent['id']);
                 $aResult['content']['videos_attach'] = $oModule->getEventVideos($aEvent['id']);
+				$aResult['content']['files_attach'] = $oModule->getEventFiles($aEvent['id']);
                 break;
 
             case BX_TIMELINE_PARSE_TYPE_REPOST:

+ 8 - 1
modules/boonex/timeline/install/langs/en.xml

@@ -68,6 +68,8 @@
     <string name="_bx_timeline_form_post_input_link_err_delete"><![CDATA[Cannot remove the link. Please report.]]></string>
     <string name="_bx_timeline_form_post_input_sys_photo"><![CDATA[Photo]]></string>
     <string name="_bx_timeline_form_post_input_photo"><![CDATA[]]></string>
+    <string name="_bx_timeline_form_post_input_sys_files"><![CDATA[File]]></string>
+    <string name="_bx_timeline_form_post_input_files"><![CDATA[]]></string>
     <string name="_bx_timeline_form_post_input_photo_alt"><![CDATA[Add Photo]]></string>
     <string name="_bx_timeline_form_post_input_sys_video"><![CDATA[Video]]></string>
     <string name="_bx_timeline_form_post_input_video"><![CDATA[]]></string>
@@ -238,7 +240,12 @@
     <string name="_bx_timeline_menu_item_title_add_photo"><![CDATA[Add Photo]]></string>
     <string name="_bx_timeline_menu_item_title_system_add_video_simple"><![CDATA[Add Video (Simple)]]></string>
     <string name="_bx_timeline_menu_item_title_system_add_video_html5"><![CDATA[Add Video (HTML5)]]></string>
-    <string name="_bx_timeline_menu_item_title_add_video"><![CDATA[Add Video]]></string>
+
+    <string name="_bx_timeline_menu_item_title_add_file"><![CDATA[Add File]]></string>
+    <string name="_bx_timeline_menu_item_title_system_add_file_simple"><![CDATA[Add File (Simple)]]></string>
+    <string name="_bx_timeline_menu_item_title_system_add_file_html5"><![CDATA[Add File (HTML5)]]></string>
+
+  <string name="_bx_timeline_menu_item_title_add_video"><![CDATA[Add Video]]></string>
     <string name="_bx_timeline_menu_item_title_system_add_video_record"><![CDATA[Record Video]]></string>
     <string name="_bx_timeline_menu_item_title_add_video_record"><![CDATA[Record Video]]></string>
     <string name="_bx_timeline_menu_item_title_system_timeline"><![CDATA[Timeline]]></string>

+ 3 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -218,7 +218,9 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-photo-html5', '_bx_timeline_menu_item_title_system_add_photo_html5', '_bx_timeline_menu_item_title_add_photo', 'javascript:void(0)', 'javascript:{js_object_add_photo_html5}.showUploaderForm();', '_self', 'camera', '', '', 2147483647, 1, 0, 1, 3),
 ('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-video-simple', '_bx_timeline_menu_item_title_system_add_video_simple', '_bx_timeline_menu_item_title_add_video', 'javascript:void(0)', 'javascript:{js_object_add_video_simple}.showUploaderForm();', '_self', 'video', '', '', 2147483647, 0, 0, 1, 4),
 ('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-video-html5', '_bx_timeline_menu_item_title_system_add_video_html5', '_bx_timeline_menu_item_title_add_video', 'javascript:void(0)', 'javascript:{js_object_add_video_html5}.showUploaderForm();', '_self', 'video', '', '', 2147483647, 1, 0, 1, 5),
-('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-video-record', '_bx_timeline_menu_item_title_system_add_video_record', '_bx_timeline_menu_item_title_add_video_record', 'javascript:void(0)', 'javascript:{js_object_add_video_record}.showUploaderForm();', '_self', 'fas circle', '', '', 2147483647, 1, 0, 1, 6);
+('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-video-record', '_bx_timeline_menu_item_title_system_add_video_record', '_bx_timeline_menu_item_title_add_video_record', 'javascript:void(0)', 'javascript:{js_object_add_video_record}.showUploaderForm();', '_self', 'fas circle', '', '', 2147483647, 1, 0, 1, 6),
+('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-file-simple', '_bx_timeline_menu_item_title_system_add_file_simple', '_bx_timeline_menu_item_title_add_file', 'javascript:void(0)', 'javascript:{js_object_add_file_simple}.showUploaderForm();', '_self', 'file', '', '', 2147483647, 0, 0, 1, 7),
+('bx_timeline_menu_post_attachments', 'bx_timeline', 'add-file-html5', '_bx_timeline_menu_item_title_system_add_file_html5', '_bx_timeline_menu_item_title_add_file', 'javascript:void(0)', 'javascript:{js_object_add_file_html5}.showUploaderForm();', '_self', 'file', '', '', 2147483647, 1, 0, 1, 8);
 
 -- MENU: add to "add content" menu
 SET @iAddMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_add_content_links' AND `active` = 1 ORDER BY `order` DESC LIMIT 1);

+ 41 - 8
modules/boonex/timeline/install/sql/install.sql

@@ -165,6 +165,30 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_videos2events` (
   UNIQUE KEY `media` (`event_id`, `media_id`)
 );
 
+CREATE TABLE IF NOT EXISTS `bx_timeline_files` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `profile_id` int(10) unsigned NOT NULL,
+  `remote_id` varchar(128) NOT NULL,
+  `path` varchar(255) NOT NULL,
+  `file_name` varchar(255) NOT NULL,
+  `mime_type` varchar(128) NOT NULL,
+  `ext` varchar(32) NOT NULL,
+  `size` bigint(20) NOT NULL,
+  `added` int(11) NOT NULL,
+  `modified` int(11) NOT NULL,
+  `private` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `remote_id` (`remote_id`)
+);
+
+CREATE TABLE IF NOT EXISTS `bx_timeline_files2events` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `event_id` int(11) NOT NULL DEFAULT '0',
+  `media_id` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `media` (`event_id`, `media_id`)
+);
+
 -- TABLES: LINKS
 CREATE TABLE IF NOT EXISTS `bx_timeline_links` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -349,14 +373,18 @@ INSERT INTO `sys_objects_uploader` (`object`, `active`, `override_class_name`, `
 ('bx_timeline_simple_video', 1, 'BxTimelineUploaderSimpleAttach', 'modules/boonex/timeline/classes/BxTimelineUploaderSimpleAttach.php'),
 ('bx_timeline_html5_photo', 1, 'BxTimelineUploaderHTML5Attach', 'modules/boonex/timeline/classes/BxTimelineUploaderHTML5Attach.php'),
 ('bx_timeline_html5_video', 1, 'BxTimelineUploaderHTML5Attach', 'modules/boonex/timeline/classes/BxTimelineUploaderHTML5Attach.php'),
-('bx_timeline_record_video', 1, 'BxTimelineUploaderRecordVideoAttach', 'modules/boonex/timeline/classes/BxTimelineUploaderRecordVideoAttach.php');
+('bx_timeline_record_video', 1, 'BxTimelineUploaderRecordVideoAttach', 'modules/boonex/timeline/classes/BxTimelineUploaderRecordVideoAttach.php'),
+('bx_timeline_simple_file', 1, 'BxTimelineUploaderSimpleAttach', 'modules/boonex/timeline/classes/BxTimelineUploaderSimpleAttach.php'),
+('bx_timeline_html5_file', 1, 'BxTimelineUploaderHTML5Attach', 'modules/boonex/timeline/classes/BxTimelineUploaderHTML5Attach.php');
 
 INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `cache_control`, `levels`, `table_files`, `ext_mode`, `ext_allow`, `ext_deny`, `quota_size`, `current_size`, `quota_number`, `current_number`, `max_file_size`, `ts`) VALUES
 ('bx_timeline_photos', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_photos', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0),
 ('bx_timeline_photos_processed', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_photos_processed', 'allow-deny', 'jpg,jpeg,jpe,gif,png', '', 0, 0, 0, 0, 0, 0),
 
 ('bx_timeline_videos', @sStorageEngine, 'a:1:{s:6:"fields";a:1:{s:10:"dimensions";s:17:"getFileDimensions";}}', 360, 2592000, 3, 'bx_timeline_videos', 'allow-deny', 'avi,flv,mpg,mpeg,wmv,mp4,m4v,mov,qt,divx,xvid,3gp,3g2,webm,mkv,ogv,ogg,rm,rmvb,asf,drc', '', 0, 0, 0, 0, 0, 0),
-('bx_timeline_videos_processed', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_videos_processed', 'allow-deny', 'jpg,jpeg,jpe,gif,png,avi,flv,mpg,mpeg,wmv,mp4,m4v,mov,qt,divx,xvid,3gp,3g2,webm,mkv,ogv,ogg,rm,rmvb,asf,drc', '', 0, 0, 0, 0, 0, 0);
+('bx_timeline_videos_processed', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_videos_processed', 'allow-deny', 'jpg,jpeg,jpe,gif,png,avi,flv,mpg,mpeg,wmv,mp4,m4v,mov,qt,divx,xvid,3gp,3g2,webm,mkv,ogv,ogg,rm,rmvb,asf,drc', '', 0, 0, 0, 0, 0, 0),
+
+('bx_timeline_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_timeline_files', 'deny-allow', '', 'jpg,jpeg,jpe,gif,png,action,apk,app,bat,bin,cmd,com,command,cpl,csh,exe,gadget,inf,ins,inx,ipa,isu,job,jse,ksh,lnk,msc,msi,msp,mst,osx,out,paf,pif,prg,ps1,reg,rgs,run,sct,shb,shs,u3p,vb,vbe,vbs,vbscript,workflow,ws,wsf', 0, 0, 0, 0, 0, 0);
 
 INSERT INTO `sys_objects_transcoder` (`object`, `storage_object`, `source_type`, `source_params`, `private`, `atime_tracking`, `atime_pruning`, `ts`, `override_class_name`, `override_class_file`) VALUES
 ('bx_timeline_photos_preview', 'bx_timeline_photos_processed', 'Storage', 'a:1:{s:6:"object";s:18:"bx_timeline_photos";}', 'no', '1', '2592000', '0', '', ''),
@@ -405,6 +433,7 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
 ('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:2:{s:24:"bx_timeline_simple_photo";s:26:"_sys_uploader_simple_title";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),
 ('bx_timeline_post', @sName, 'video', 'a:2:{i:0;s:23:"bx_timeline_html5_video";i:1;s:24:"bx_timeline_record_video";}', 'a:3:{s:24:"bx_timeline_simple_video";s:26:"_sys_uploader_simple_title";s:23:"bx_timeline_html5_video";s:25:"_sys_uploader_html5_title";s:24:"bx_timeline_record_video";s:32:"_sys_uploader_record_video_title";}', 0, 'files', '_bx_timeline_form_post_input_sys_video', '_bx_timeline_form_post_input_video', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_timeline_post', @sName, 'file', 'a:1:{i:0;s:22:"bx_timeline_html5_file";}', 'a:2:{s:23:"bx_timeline_simple_file";s:26:"_sys_uploader_simple_title";s:22:"bx_timeline_html5_file";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_timeline_form_post_input_sys_files', '_bx_timeline_form_post_input_files', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'attachments', '', '', 0, 'custom', '_bx_timeline_form_post_input_sys_attachments', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'controls', '', 'tlb_do_submit,tlb_do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 ('bx_timeline_post', @sName, 'tlb_do_submit', '_bx_timeline_form_post_input_do_submit', '', 0, 'submit', '_bx_timeline_form_post_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
@@ -422,7 +451,8 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 ('bx_timeline_post_add', 'link', 2147483647, 1, 8),
 ('bx_timeline_post_add', 'photo', 2147483647, 1, 9),
 ('bx_timeline_post_add', 'video', 2147483647, 1, 10),
-('bx_timeline_post_add', 'tlb_do_submit', 2147483647, 1, 11),
+('bx_timeline_post_add', 'file', 2147483647, 1, 11),
+('bx_timeline_post_add', 'tlb_do_submit', 2147483647, 1, 12),
 
 ('bx_timeline_post_add_public', 'type', 2147483647, 1, 0),
 ('bx_timeline_post_add_public', 'action', 2147483647, 1, 1),
@@ -435,7 +465,8 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 ('bx_timeline_post_add_public', 'link', 2147483647, 1, 8),
 ('bx_timeline_post_add_public', 'photo', 2147483647, 1, 9),
 ('bx_timeline_post_add_public', 'video', 2147483647, 1, 10),
-('bx_timeline_post_add_public', 'tlb_do_submit', 2147483647, 1, 11),
+('bx_timeline_post_add_public', 'file', 2147483647, 1, 11),
+('bx_timeline_post_add_public', 'tlb_do_submit', 2147483647, 1, 12),
 
 ('bx_timeline_post_add_profile', 'type', 2147483647, 1, 0),
 ('bx_timeline_post_add_profile', 'action', 2147483647, 1, 1),
@@ -448,7 +479,8 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 ('bx_timeline_post_add_profile', 'link', 2147483647, 1, 8),
 ('bx_timeline_post_add_profile', 'photo', 2147483647, 1, 9),
 ('bx_timeline_post_add_profile', 'video', 2147483647, 1, 10),
-('bx_timeline_post_add_profile', 'tlb_do_submit', 2147483647, 1, 11),
+('bx_timeline_post_add_profile', 'file', 2147483647, 1, 11),
+('bx_timeline_post_add_profile', 'tlb_do_submit', 2147483647, 1, 12),
 
 ('bx_timeline_post_edit', 'type', 2147483647, 1, 1),
 ('bx_timeline_post_edit', 'action', 2147483647, 1, 2),
@@ -460,9 +492,10 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 ('bx_timeline_post_edit', 'link', 2147483647, 1, 8),
 ('bx_timeline_post_edit', 'photo', 2147483647, 1, 9),
 ('bx_timeline_post_edit', 'video', 2147483647, 1, 10),
-('bx_timeline_post_edit', 'controls', 2147483647, 1, 11),
-('bx_timeline_post_edit', 'tlb_do_submit', 2147483647, 1, 12),
-('bx_timeline_post_edit', 'tlb_do_cancel', 2147483647, 1, 13);
+('bx_timeline_post_edit', 'file', 2147483647, 1, 11),
+('bx_timeline_post_edit', 'controls', 2147483647, 1, 12),
+('bx_timeline_post_edit', 'tlb_do_submit', 2147483647, 1, 13),
+('bx_timeline_post_edit', 'tlb_do_cancel', 2147483647, 1, 14);
 
 -- Forms -> Attach link
 INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES

+ 2 - 0
modules/boonex/timeline/install/sql/uninstall.sql

@@ -8,6 +8,8 @@ DROP TABLE IF EXISTS `bx_timeline_photos`, `bx_timeline_photos_processed`, `bx_t
 
 DROP TABLE IF EXISTS `bx_timeline_videos`, `bx_timeline_videos_processed`, `bx_timeline_videos2events`;
 
+DROP TABLE IF EXISTS `bx_timeline_files`, `bx_timeline_files2events`;
+
 DROP TABLE IF EXISTS `bx_timeline_links`, `bx_timeline_links2events`;
 
 DROP TABLE IF EXISTS `bx_timeline_reposts_track`;

+ 7 - 0
modules/boonex/timeline/template/type_post.html

@@ -12,6 +12,13 @@
         </bx_repeat:items>
     </div>
 </bx_if:show_videos>
+<bx_if:show_files>
+    <div class="__style_prefix__-item-images __style_prefix__-ii-main __style_prefix__-ii-__display__ bx-def-margin-top">
+        <bx_repeat:items>
+            <div class="__style_prefix__-item-image">__item__</div>
+        </bx_repeat:items>
+    </div>
+</bx_if:show_files>
 <div class="__style_prefix__-item-text bx-def-margin-lefttopright">
     <bx_if:show_title>
         <div class="__style_prefix__-title bx-def-margin-sec-bottom bx-def-font-h3">__title__</div>