diff --git a/rmcommon/images.php b/rmcommon/images.php index 50ac4f35..822d7500 100644 --- a/rmcommon/images.php +++ b/rmcommon/images.php @@ -169,7 +169,7 @@ function images_form($edit = 0){ xoops_cp_header(); $isupdate = false; - include RMTemplate::get()->get_template('rmc-images-upload-images.php','module','rmcommon'); + include RMTemplate::getInstance()->path('rmc-images-upload-images.php','module','rmcommon'); xoops_cp_footer(); @@ -436,8 +436,8 @@ function resize_images(){ } $sizes = $cat->getVar('sizes'); - $updir = XOOPS_UPLOAD_PATH.'/'.date('Y', $image->getVar('date')).'/'.date('m',time()); - $upurl = XOOPS_UPLOAD_URL.'/'.date('Y', $image->getVar('date')).'/'.date('m',time());; + $updir = XOOPS_UPLOAD_PATH.'/'.date('Y', $image->getVar('date')).'/'.date('m',$image->getVar('date')); + $upurl = XOOPS_UPLOAD_URL.'/'.date('Y', $image->getVar('date')).'/'.date('m',$image->getVar('date'));; $width = 0; $tfile = ''; @@ -798,23 +798,38 @@ function delete_category(){ * Update image thumbnails */ function update_thumbnails(){ - global $xoopsUser, $xoopsSecurity; - $cat = new RMImageCategory(rmc_server_var($_POST, 'category', 0)); - $imgs = rmc_server_var($_POST, 'imgs', array()); + global $xoopsUser, $xoopsSecurity, $common; + + $catId = $common->httpRequest()->post('category', 'integer', 0); + $imgs = $common->httpRequest()->post('imgs', 'array', []); + $page = $common->httpRequest()->post('page', 'integer', 1); + + if($catId <= 0){ + $common->uris()->redirect_with_message( + __('No category ID has been provided!', 'rmcommon'), 'images.php?page=' . $page, RMMSG_WARN + ); + } + + $cat = new RMImageCategory($catId); + + if($cat->isNew()){ + $common->uris()->redirect_with_message( + __('Specified category does not exists!', 'rmcommon'), 'images.php?page=' . $page, RMMSG_WARN + ); + } $ids = implode(',', $imgs); RMTemplate::getInstance()->add_jquery(true, true); - RMTemplate::get()->add_style('imgmgr.css', 'rmcommon'); - RMTemplate::get()->add_script('images.min.js', 'rmcommon'); + $common->template()->add_style('imgmgr.min.css', 'rmcommon'); + RMTemplate::getInstance()->add_script('images-manager.min.js', 'rmcommon', ['id' => 'images-manager-js', 'footer' => 1]); + RMTemplate::getInstance()->add_script('images.min.js', 'rmcommon', ['id' => 'images-js', 'footer' => 1]); xoops_cp_header(); RMFunctions::create_toolbar(); $isupdate = true; - RMTemplate::get()->add_head(""); + cuImagesManager.uploadedIds = [$ids]; + cuImagesManager.resizeImages(cuImagesManager); + });", 1); + + // Messages title + $messagesTitle = __('Resizing results', 'rmcommon'); + + // Disable upload controls + $showControls = false; - include RMTemplate::get()->get_template('rmc-images-upload-images.php','module','rmcommon'); + include RMTemplate::getInstance()->path('rmc-images-upload-images.php','module','rmcommon'); xoops_cp_footer(); diff --git a/rmcommon/js/images-manager.min.js b/rmcommon/js/images-manager.min.js index 3b4ad8e1..6f4bb0c0 100644 --- a/rmcommon/js/images-manager.min.js +++ b/rmcommon/js/images-manager.min.js @@ -1 +1 @@ -!function(e){this.CUImagesManager=function(s){this.uploadedIds=[],this.currentResizing=0,this.dropzone,this.okIcon='',this.errorIcon='',this.init=function(i,r){var n=this;Dropzone.options.imagesUploader=!1,this.dropzone=new Dropzone(s,{url:i,acceptedFiles:".png, .jpg, .gif, .jpeg, .svg",maxFileSize:r,parallelUpload:1,autoProcessQueue:!0,params:{CUTOKEN_REQUEST:e("#cu-token").val()},dictDefaultMessage:cuLanguage.dzDefault,init:function(){this.on("success",function(e,s){n.serverResponse(e,s,n)}),this.on("queuecomplete",function(){e("#files-container").slideUp(300),e("#images-resizing").slideDown(300,function(){n.resizeImages(n)})})}})},this.printMessage=function(s,i,r){var n=e("#uploading-messages > ul");e("#uploading-messages").is(":visible")||e("#uploading-messages").slideDown(200),"error"==s?n.append('
  • '+r.errorIcon+" "+i):n.append('
  • '+r.okIcon+" "+i)},this.updateProgress=function(s){var i=s.uploadedIds.length,r=1/i*100;e("#bar-indicator").animate({width:r*s.currentResizing+"%"},200),e("#bar-indicator").html(Math.round(r*s.currentResizing+1)+"%"),r*s.currentResizing>25&&e("#bar-indicator").removeClass("progress-bar-danger").addClass("progress-bar-warning"),r*s.currentResizing>65&&e("#bar-indicator").removeClass("progress-bar-warning").addClass("progress-bar-info"),this.currentResizing++},this.serverResponse=function(s,i,r){return i=JSON.parse(i),void 0!=i.token&&""!=i.token&&e("#cu-token").val(i.token),void 0==i||"error"==i.type?(r.printMessage("error",s.name+": "+i.message,r),!1):(r.printMessage("success",i.message,r),r.uploadedIds.push(i.id),!0)},this.resizeImages=function(s){var i=s.uploadedIds;if(!(i.length<=0))return void 0==i[s.currentResizing]?(e("#bar-indicator").html("100%"),e("#bar-indicator").animate({width:"100%"},200).removeClass("progress-bar-info").removeClass("active").addClass("progress-bar-success"),s.currentResizing=0,s.uploadedIds=[],e("button[data-action='upload-more']").fadeIn(300),void e(s).trigger("resizeFinished")):void s.sendResizeCommand(i[s.currentResizing],s)},this.sendResizeCommand=function(s,i){var r={action:"resize",CUTOKEN_REQUEST:e("#cu-token").val(),img:s};e.get(xoUrl+"/modules/rmcommon/images.php",r,function(s){return"error"==s.type?(i.printMessage("error",s.message,i),i.updateProgress(i),void i.resizeImages(i)):(i.printMessage("success",s.message,i),i.updateProgress(i),e("#images-resizing span.message").html(cuLanguage.resizingLegend.replace("%1",i.currentResizing).replace("%2",i.uploadedIds.length)),void i.resizeImages(i))},"json")},this.uploadMore=function(){var s=this;e("#images-resizing").slideUp(300,function(){e("#uploading-messages").slideUp(300,function(){e(this).find("ul > li").remove(),e("#files-container").slideDown(300),s.dropzone.removeAllFiles(),e("button[data-action='upload-more']").fadeOut(300)})})}}}(jQuery); +!function(e){this.CUImagesManager=function(s){this.uploadedIds=[],this.currentResizing=0,this.dropzone,this.okIcon='',this.errorIcon='',this.init=function(i,r){var n=this;Dropzone.options.imagesUploader=!1,this.dropzone=new Dropzone(s,{url:i,acceptedFiles:".png, .jpg, .gif, .jpeg, .svg",maxFileSize:r,parallelUpload:1,autoProcessQueue:!0,params:{CUTOKEN_REQUEST:e("#cu-token").val()},dictDefaultMessage:cuLanguage.dzDefault,init:function(){this.on("success",function(e,s){n.serverResponse(e,s,n)}),this.on("queuecomplete",function(){e("#files-container").slideUp(),e("#images-resizing").slideDown(function(){n.resizeImages(n)})})}})},this.printMessage=function(s,i,r){var n=e("#uploading-messages > ul");e("#uploading-messages").is(":visible")||e("#uploading-messages").slideDown(200),"error"==s?n.append('
  • '+r.errorIcon+" "+i):n.append('
  • '+r.okIcon+" "+i)},this.updateProgress=function(s){var i=s.uploadedIds.length,r=1/i*100;r>0&&0==s.currentResizing?(e("#bar-indicator").css("width","100%"),e("#bar-indicator").html("100%")):(e("#bar-indicator").css("width",r*s.currentResizing+"%"),e("#bar-indicator").html(Math.round(r*s.currentResizing+1)+"%")),r*s.currentResizing>25&&e("#bar-indicator").removeClass("progress-bar-danger").addClass("progress-bar-warning"),r*s.currentResizing>65&&e("#bar-indicator").removeClass("progress-bar-warning").addClass("progress-bar-info"),this.currentResizing++},this.serverResponse=function(s,i,r){return i=JSON.parse(i),void 0!=i.token&&""!=i.token&&e("#cu-token").val(i.token),void 0==i||"error"==i.type?(r.printMessage("error",s.name+": "+i.message,r),!1):(r.printMessage("success",i.message,r),r.uploadedIds.push(i.id),!0)},this.resizeImages=function(s){var i=s.uploadedIds;if(!(i.length<=0))return!0!==e("#images-resizing").is(":visible")&&e("#images-resizing").slideDown(function(){s.resizeImages(s)}),void 0==i[s.currentResizing]?(e("#bar-indicator").html("100%"),e("#bar-indicator").animate({width:"100%"},200).removeClass("progress-bar-info").removeClass("active").addClass("progress-bar-success"),s.currentResizing=0,s.uploadedIds=[],e("button[data-action='upload-more']").fadeIn(300),e(s).trigger("resizeFinished"),void(e("#back-images").length>0&&e("#back-images").slideDown())):void s.sendResizeCommand(i[s.currentResizing],s)},this.sendResizeCommand=function(s,i){var r={action:"resize",CUTOKEN_REQUEST:e("#cu-token").val(),img:s};e.get(xoUrl+"/modules/rmcommon/images.php",r,function(s){return"error"==s.type?(i.printMessage("error",s.message,i),i.updateProgress(i),void i.resizeImages(i)):(i.printMessage("success",s.message,i),i.updateProgress(i),e("#images-resizing span.message").html(cuLanguage.resizingLegend.replace("%1",i.currentResizing).replace("%2",i.uploadedIds.length)),void i.resizeImages(i))},"json")},this.uploadMore=function(){var s=this;e("#images-resizing").slideUp(300,function(){e("#uploading-messages").slideUp(300,function(){e(this).find("ul > li").remove(),e("#files-container").slideDown(300),s.dropzone.removeAllFiles(),e("button[data-action='upload-more']").fadeOut(300)})})}}}(jQuery); diff --git a/rmcommon/rmcommon.zip b/rmcommon/rmcommon.zip deleted file mode 100644 index 8d83de47..00000000 Binary files a/rmcommon/rmcommon.zip and /dev/null differ diff --git a/rmcommon/templates/rmc-images-upload-images.php b/rmcommon/templates/rmc-images-upload-images.php index 916123db..03c264fa 100644 --- a/rmcommon/templates/rmc-images-upload-images.php +++ b/rmcommon/templates/rmc-images-upload-images.php @@ -1,4 +1,4 @@ - +

    @@ -14,36 +14,53 @@
    -isNew()): ?> + -
    -
    +isNew()): ?> -
    -
    + +
    +
    -
    -
    - -
    +
    + +
    +
    + +
    +
    + -
    -

    -
    -
    +
    +

    +
    +
    -
    -
    + +
    + + -
    -

    -
      -
    + - + + +
    +

    + + + + + +

    +
      +
    +
    + diff --git a/rmcommon/xoops_version.php b/rmcommon/xoops_version.php index a8b17778..a3639474 100644 --- a/rmcommon/xoops_version.php +++ b/rmcommon/xoops_version.php @@ -34,7 +34,7 @@ function __($text, $d = ''){ * Information for Common Utilities */ $modversion['rmnative'] = 1; -$modversion['rmversion'] = array('major'=>2,'minor'=>3,'revision'=>39,'stage'=>0,'name'=>'Common Utilities'); +$modversion['rmversion'] = array('major'=>2,'minor'=>3,'revision'=>40,'stage'=>0,'name'=>'Common Utilities'); $modversion['rewrite'] = 1; $modversion['url'] = "http://rmcommon.com"; $modversion['author'] = "Eduardo Cortés"; diff --git a/src/js/js/images-manager.js b/src/js/js/images-manager.js index 7fe32104..fdb281d8 100644 --- a/src/js/js/images-manager.js +++ b/src/js/js/images-manager.js @@ -68,8 +68,8 @@ }); this.on('queuecomplete', function(){ - $("#files-container").slideUp(300); - $("#images-resizing").slideDown(300, function(){ + $("#files-container").slideUp(); + $("#images-resizing").slideDown(function(){ $this.resizeImages($this); }); }); @@ -108,12 +108,20 @@ var total = $this.uploadedIds.length; var percent = 1/total*100; - $("#bar-indicator").animate({ + /*$("#bar-indicator").animate({ width: percent*($this.currentResizing)+'%' - }, 200); + }, 50);*/ + + if(percent > 0 && $this.currentResizing == 0){ + $("#bar-indicator").css('width', '100%'); + $("#bar-indicator").html('100%'); + } else { + $("#bar-indicator").css('width', percent*($this.currentResizing)+'%'); + $("#bar-indicator").html(Math.round(percent*$this.currentResizing+1)+'%'); + } //$("#bar-indicator").css('width', percent*(current+1)+'%'); - $("#bar-indicator").html(Math.round(percent*$this.currentResizing+1)+'%'); + if (percent * $this.currentResizing > 25) $("#bar-indicator").removeClass('progress-bar-danger').addClass('progress-bar-warning'); @@ -161,6 +169,12 @@ if (ids.length<=0) return; + if(true !== $("#images-resizing").is(":visible")){ + $("#images-resizing").slideDown(function(){ + $this.resizeImages($this); + }); + } + if(ids[$this.currentResizing]==undefined){ $("#bar-indicator").html('100%'); $("#bar-indicator").animate({ @@ -173,9 +187,13 @@ $this.uploadedIds = []; $("button[data-action='upload-more']").fadeIn(300); $($this).trigger('resizeFinished'); + + if($("#back-images").length > 0){ + $("#back-images").slideDown(); + } + return; } - $this.sendResizeCommand(ids[$this.currentResizing], $this); }