Browse Source

Ticket #268 - Custom HTML5 uploader for System Settings.

AntonLV 10 years ago
parent
commit
f9d7b0e5cd

+ 2 - 1
install/sql/system.sql

@@ -2113,7 +2113,8 @@ CREATE TABLE IF NOT EXISTS `sys_objects_uploader` (
 INSERT INTO `sys_objects_uploader` (`object`, `active`, `override_class_name`, `override_class_file`) VALUES
 ('sys_simple', 1, 'BxTemplUploaderSimple', ''),
 ('sys_html5', 1, 'BxTemplUploaderHTML5', ''),
-('sys_cmts_simple', 1, 'BxTemplCmtsUploaderSimple', '');
+('sys_cmts_simple', 1, 'BxTemplCmtsUploaderSimple', ''),
+('sys_settings_html5', 1, 'BxTemplStudioSettingsUploaderHTML5', '');
 
 
 -- --------------------------------------------------------

+ 19 - 0
modules/boonex/air/data/template/studio/scripts/BxTemplStudioSettingsUploaderHTML5.php

@@ -0,0 +1,19 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentView Trident Studio Representation classes
+ * @ingroup     TridentStudio
+ * @{
+ */
+
+class BxTemplStudioSettingsUploaderHTML5 extends BxBaseStudioSettingsUploaderHTML5
+{
+    function __construct ($aObject, $sStorageObject, $sUniqId, $oTemplate)
+    {
+        parent::__construct($aObject, $sStorageObject, $sUniqId, $oTemplate);
+    }
+}
+
+/** @} */

+ 19 - 0
modules/boonex/ocean/data/template/studio/scripts/BxTemplStudioSettingsUploaderHTML5.php

@@ -0,0 +1,19 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentView Trident Studio Representation classes
+ * @ingroup     TridentStudio
+ * @{
+ */
+
+class BxTemplStudioSettingsUploaderHTML5 extends BxBaseStudioSettingsUploaderHTML5
+{
+    function __construct ($aObject, $sStorageObject, $sUniqId, $oTemplate)
+    {
+        parent::__construct($aObject, $sStorageObject, $sUniqId, $oTemplate);
+    }
+}
+
+/** @} */

+ 19 - 0
modules/boonex/uni/data/template/studio/scripts/BxTemplStudioSettingsUploaderHTML5.php

@@ -0,0 +1,19 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentView Trident Studio Representation classes
+ * @ingroup     TridentStudio
+ * @{
+ */
+
+class BxTemplStudioSettingsUploaderHTML5 extends BxBaseStudioSettingsUploaderHTML5
+{
+    function __construct ($aObject, $sStorageObject, $sUniqId, $oTemplate)
+    {
+        parent::__construct($aObject, $sStorageObject, $sUniqId, $oTemplate);
+    }
+}
+
+/** @} */

+ 2 - 3
studio/classes/BxDolStudioSettings.php

@@ -141,11 +141,9 @@ class BxDolStudioSettings extends BxTemplStudioPage
 		        if(!$oStorage)
 					break;
 
-    			$iProfileId = bx_get_logged_profile_id();
     			foreach($aIds as $iId) {
+    				$oStorage->updateGhostsContentId($iId, false, $aOption['id']);
     				$mixedValue = $iId;
-
-    				$oStorage->updateGhostsContentId($iId, $iProfileId, $aOption['id']);
     			}
     			break;
 
@@ -155,6 +153,7 @@ class BxDolStudioSettings extends BxTemplStudioPage
 
     	return $mixedValue;
     }
+
     protected function getProcessedValue($aOption, $mixedValue)
     {
         if(is_array($mixedValue))

+ 1 - 1
studio/template/scripts/BxBaseStudioSettings.php

@@ -249,7 +249,7 @@ class BxBaseStudioSettings extends BxDolStudioSettings
                     'name' => $aItem['name'],
 					'storage_object' => $this->sStorage,
  					'images_transcoder' => $this->sTranscoder,
- 					'uploaders' => array('sys_html5'),
+ 					'uploaders' => array('sys_settings_html5'),
                 	'upload_buttons_titles' => array('HTML5' => _t('_sys_uploader_button_name_single')),
 					'multiple' => false,
  					'content_id' => $aItem['id'],

+ 38 - 0
studio/template/scripts/BxBaseStudioSettingsUploaderHTML5.php

@@ -0,0 +1,38 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    TridentStudio Trident Studio
+ * @{
+ */
+
+/**
+ * Upload files using AJAX uploader with multiple files selection support (without flash),
+ * it works in Firefox and WebKit(Safari, Chrome) browsers only, but has fallback for other browsers (IE, Opera).
+ * @see BxDolUploader
+ */
+class BxBaseStudioSettingsUploaderHTML5 extends BxTemplUploaderHTML5
+{
+    function __construct ($aObject, $sStorageObject, $sUniqId, $oTemplate)
+    {
+        parent::__construct($aObject, $sStorageObject, $sUniqId, $oTemplate);
+    }
+
+    public function getGhosts($iProfileId, $sFormat, $sImagesTranscoder = false, $iContentId = false)
+    {
+    	return parent::getGhosts(0, $sFormat, $sImagesTranscoder, $iContentId);
+    }
+
+    public function handleUploads ($iProfileId, $mixedFiles, $isMultiple = true, $iContentId = false, $bPrivate = true)
+    {
+    	parent::handleUploads(0, $mixedFiles, $isMultiple, $iContentId, $bPrivate);
+    }
+
+    public function deleteGhost($iFileId, $iProfileId)
+    {
+    	return parent::deleteGhost($iFileId, 0);
+    }
+}
+
+/** @} */

+ 0 - 2
template/scripts/BxBaseUploaderHTML5.php

@@ -72,8 +72,6 @@ class BxBaseUploaderHTML5 extends BxDolUploader
     {
         $oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject);
 
-        $iProfileId = bx_get_logged_profile_id();
-
         if (!$isMultiple)
             $this->cleanupGhostsForProfile($iProfileId, $iContentId);