Просмотр исходного кода

Ticket #258 - Market module: Core changes.

AntonLV 10 лет назад
Родитель
Сommit
756d8f47e7

+ 5 - 0
inc/classes/BxDolStorage.php

@@ -295,6 +295,11 @@ abstract class BxDolStorage extends BxDol implements iBxDolFactoryObject
         return true;
     }
 
+    public function getObject()
+    {
+    	return $this->_aObject['object'];
+    }
+
     /**
      * Get error code from the last occured error
      * @return error code

+ 2 - 1
inc/classes/BxDolUploader.php

@@ -49,7 +49,7 @@
  * 1. Pass template as string - just plain string with HTML, for example:
  *
  * @code
- * <div id="bx-uploader-file-{file_id}" class="bx-uploader-ghost">
+ * <div id="bx-uploader-file-{storage_object}-{file_id}" class="bx-uploader-ghost">
  *     <div style="border:2px dotted green; padding:10px; margin-bottom:10px;">
  *         <input type="hidden" name="f[]" value="{file_id}" />
  *         {file_name} <br />
@@ -332,6 +332,7 @@ abstract class BxDolUploader extends BxDol
                 $sFileIcon = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFile['file_name']));
 
             $aVars = array (
+            	'storage_object' => $this->_sStorageObject,
                 'file_id' => $aFile['id'],
                 'file_name' => $aFile['file_name'],
                 'file_title' => $oStorage->getFileTitle($aFile['file_name']),

+ 16 - 11
inc/js/classes/BxDolUploader.js

@@ -34,7 +34,7 @@ BxDolUploaderSimple.prototype.init = function (sUploaderObject, sStorageObject,
 
     this._sFormContainerId = 'bx-form-input-files-' + sUniqId + '-form-cont';
 
-    this._sTemplateGhost = options.template_ghost ? options.template_ghost : '<div id="bx-uploader-file-{file_id}"><input type="hidden" name="f[]" value="{file_id}" />{file_name} (<a href="javascript:void(0);" onclick="{js_instance_name}.deleteGhost(\'{file_id}\')">delete</a>)</div>';
+    this._sTemplateGhost = options.template_ghost ? options.template_ghost : '<div id="' + this._getFileContainerId('{file_id}') + '"><input type="hidden" name="f[]" value="{file_id}" />{file_name} (<a href="javascript:void(0);" onclick="{js_instance_name}.deleteGhost(\'{file_id}\')">delete</a>)</div>';
     this._sTemplateError = options.template_error_msg ? options.template_error_msg : '<div>{error}</div>' ;
     this._sTemplateErrorGhosts = options.template_error_ghosts ? options.template_error_ghosts : this._sTemplateError;
 
@@ -138,7 +138,8 @@ BxDolUploaderSimple.prototype.restoreGhosts = function () {
 
         if ('object' === typeof(aData)) {
             $.each(aData, function(iFileId, oVars) {
-                if ($('#bx-uploader-file-' + iFileId).length > 0)
+            	var oFileContainer = $('#' + $this._getFileContainerId(iFileId));
+                if (oFileContainer.length > 0)
                     return;
                 var sHTML;
                 if (typeof $this._sTemplateGhost == 'object')
@@ -150,30 +151,30 @@ BxDolUploaderSimple.prototype.restoreGhosts = function () {
                 
                 $('#' + $this._sResultContainerId).prepend(sHTML);
 
-                $('#bx-uploader-file-' + iFileId + ' .bx-uploader-ghost-preview img').hide().fadeIn(1000);
-
+                oFileContainer.find('.bx-uploader-ghost-preview img').hide().fadeIn(1000);
             });
         }
     });
-}
+};
 
 BxDolUploaderSimple.prototype.deleteGhost = function (iFileId) {
     var sUrl = this._getUrlWithStandardParams() + '&a=delete&id=' + iFileId;
     var $this = this;
 
-    bx_loading('bx-uploader-file-' + iFileId, true);
+    var sFileContainerId = $this._getFileContainerId(iFileId);
+    bx_loading(sFileContainerId, true);
 
     $.post(sUrl, function (sMsg) {
-        bx_loading('bx-uploader-file-' + iFileId, false);
+        bx_loading(sFileContainerId, false);
         if ('ok' == sMsg) {
-            $('#bx-uploader-file-' + iFileId).slideUp('slow', function () {
-                $('#bx-uploader-file-' + iFileId).remove();
+            $('#' + sFileContainerId).slideUp('slow', function () {
+                $(this).remove();
             });
         } else {
             $('#' + this._sResultContainerId).prepend($this._sTemplateErrorGhosts.replace('{error}', sMsg));
         }        
     });
-}
+};
 
 BxDolUploaderSimple.prototype._showError = function (s, bAppend) {
     if (s == undefined || !s.length)
@@ -183,7 +184,11 @@ BxDolUploaderSimple.prototype._showError = function (s, bAppend) {
     else
         $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).prepend(this._sTemplateError.replace('{error}', s));
     this._isErrorShown = true;
-}
+};
+
+BxDolUploaderSimple.prototype._getFileContainerId = function (iFileId) {
+	return 'bx-uploader-file-' + this._sStorageObject + '-' + iFileId;
+};
 
 BxDolUploaderSimple.prototype._getUrlWithStandardParams = function () {
     return sUrlRoot + 'storage_uploader.php?uo=' + this._sUploaderObject + '&so=' + this._sStorageObject + '&uid=' + this._sUniqId;

+ 7 - 6
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -175,12 +175,16 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
 
     function entryAttachments ($aData)
     {
-    	return $this->getAttachments($oModule->_oConfig->CNF['OBJECT_STORAGE'], $aData);
+    	return $this->parseHtmlByName('attachments.html', array(
+            'bx_repeat:attachments' => $this->getAttachments($oModule->_oConfig->CNF['OBJECT_STORAGE'], $aData),
+        ));
     }
 
 	function entryAttachmentsByStorage ($sStorage, $aData)
     {
-    	return $this->getAttachments($sStorage, $aData);
+    	return $this->parseHtmlByName('attachments.html', array(
+            'bx_repeat:attachments' => $this->getAttachments($sStorage, $aData),
+        ));
     }
 
     function entryAllActions ($sActionsEntity, $sActionsSocial)
@@ -267,10 +271,7 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
             );
         }
 
-        $aVars = array(
-            'bx_repeat:attachments' => $aGhostFiles,
-        );
-        return $this->parseHtmlByName('attachments.html', $aVars);
+        return $aGhostFiles;
     }
 }
 

+ 2 - 2
modules/base/text/template/form_ghost_template.html

@@ -1,4 +1,4 @@
-<div id="bx-uploader-file-{file_id}" class="bx-uploader-ghost bx-def-margin-sec-top bx-clearfix">
+<div id="bx-uploader-file-{storage_object}-{file_id}" class="bx-uploader-ghost bx-def-margin-sec-top bx-clearfix">
     <input type="hidden" name="__name__" value="{file_id}" />
     <div class="bx-base-text-icon-wrapper bx-def-margin-sec-right">
         <img src="{file_icon}" class="bx-def-round-corners bx-base-text-icon bx-base-text-icon-{file_id}" />
@@ -26,7 +26,7 @@
     if ('object' == typeof(tinymce))
         $('#bx-base-text-intert-to-post-link-{file_id}').show();
 
-    $('#bx-uploader-file-{file_id} .bx-base-text-use-as-thumb input[value="__thumb_id__"]').attr('checked', true);
+    $('#bx-uploader-file-{storage_object}-{file_id} .bx-base-text-use-as-thumb input[value="__thumb_id__"]').attr('checked', true);
 
     // disable images drag&drop, because resized images address can be reset after some time
     $(".bx-base-text-icon-{file_id}").bind('dragstart', function(){

+ 1 - 1
modules/boonex/albums/classes/BxAlbumsFormEntry.php

@@ -65,7 +65,7 @@ class BxAlbumsFormEntry extends BxBaseModTextFormEntry
         }
     }
 
-    function _deleteFile ($iFileId)
+    function _deleteFile ($iFileId, $sStorage = '')
     {
         if (!($bRet = parent::_deleteFile ($iFileId)))
             return false;

+ 2 - 2
modules/boonex/albums/template/form_ghost_template.html

@@ -1,4 +1,4 @@
-<div id="bx-uploader-file-{file_id}" class="bx-uploader-ghost bx-def-margin-sec-top bx-clearfix">
+<div id="bx-uploader-file-{storage_object}-{file_id}" class="bx-uploader-ghost bx-def-margin-sec-top bx-clearfix">
     <input type="hidden" name="__name__[]" value="{file_id}" />
     <div class="bx-base-text-icon-wrapper bx-def-margin-sec-right">
         <img src="{file_icon}" class="bx-def-round-corners bx-base-text-icon bx-base-text-icon-{file_id}" />
@@ -20,5 +20,5 @@
     </span>
 </div>
 <script>
-    $('#bx-uploader-file-{file_id} .bx-base-text-use-as-thumb input[value="__thumb_id__"]').attr('checked', true);
+    $('#bx-uploader-file-{storage_object}-{file_id} .bx-base-text-use-as-thumb input[value="__thumb_id__"]').attr('checked', true);
 </script>

+ 1 - 1
modules/boonex/timeline/template/uploader_nfw.html

@@ -1,4 +1,4 @@
-<div id="bx-uploader-file-{file_id}" class="bx-tl-uploader-file bx-def-margin-sec-top bx-def-margin-sec-left-auto">
+<div id="bx-uploader-file-{storage_object}-{file_id}" class="bx-tl-uploader-file bx-def-margin-sec-top bx-def-margin-sec-left-auto">
     <div class="bx-tl-uploader-file-preview bx-def-round-corners">
     	<img src="<bx_image_url:spacer.gif />" style="background-image:url({file_icon})" />
     </div>

+ 1 - 1
template/comments_uploader_nfw.html

@@ -1,4 +1,4 @@
-<div id="bx-uploader-file-{file_id}" class="cmts-uploader-file bx-def-margin-sec-top bx-def-margin-sec-left-auto">
+<div id="bx-uploader-file-{storage_object}-{file_id}" class="cmts-uploader-file bx-def-margin-sec-top bx-def-margin-sec-left-auto">
     <div class="cmts-uploader-file-preview bx-def-round-corners">
     	<img src="<bx_image_url:spacer.gif />" style="background-image:url({file_icon})" />
     </div>

+ 1 - 1
template/uploader_nested_form_wrapper.html

@@ -1,4 +1,4 @@
-<div id="bx-uploader-file-{file_id}" class="bx-uploader-ghost">
+<div id="bx-uploader-file-{storage_object}-{file_id}" class="bx-uploader-ghost">
     <div class="bx-uploader-ghost-preview bx-def-padding-right bx-def-padding-top">
         <img src="{file_icon}" class="bx-def-border" />
     </div>