Skip to content

Commit

Permalink
Fixed #83
Browse files Browse the repository at this point in the history
  • Loading branch information
bitcero committed Aug 14, 2016
1 parent 989c128 commit 7b4c4c5
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 43 deletions.
50 changes: 36 additions & 14 deletions rmcommon/images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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 = '';

Expand Down Expand Up @@ -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("<script type='text/javascript'>
\$(document).ready(function(){
ids = [$ids];
RMTemplate::getInstance()->add_inline_script("\$(document).ready(function(){
total = ".count($imgs).";
\$('#resizer-bar').show('slow');
\$('#resizer-bar').effect('highlight',{},1000);
Expand All @@ -824,10 +839,17 @@ function update_thumbnails(){
url = '".RMCURL."/images.php';
params = '".TextCleaner::getInstance()->encrypt($xoopsUser->uid().'|'.RMCURL.'/images.php'.'|'.$xoopsSecurity->createToken(), true)."';
resize_image(params);
});</script>");
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();

Expand Down
2 changes: 1 addition & 1 deletion rmcommon/js/images-manager.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed rmcommon/rmcommon.zip
Binary file not shown.
59 changes: 38 additions & 21 deletions rmcommon/templates/rmc-images-upload-images.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php if(!$isupdate): ?>
<?php if(false == $isupdate): ?>
<h1 class="cu-section-title"><?php _e('Upload Images','rmcommon'); ?></h1>
<div class="select-image-category">
<form name="frmcat" method="get" action="images.php" class="form-inline">
Expand All @@ -14,36 +14,53 @@
<input type="hidden" name="action" value="new" />
</form>
</div>
<?php if (!$cat->isNew()): ?>
<?php endif; ?>

<div id="upload-controls">
<div id="upload-errors">
<?php if (false == $cat->isNew()): ?>

</div>
</div>
<?php if($showControls): ?>
<div id="upload-controls">
<div id="upload-errors">

<div id="files-container">
<form class="dropzone" id="images-uploader">
<input type="hidden" name="category" value="<?php echo $cat->id(); ?>">
</form>
</div>
</div>

<div id="files-container">
<form class="dropzone" id="images-uploader">
<input type="hidden" name="category" value="<?php echo $cat->id(); ?>">
</form>
</div>
<?php endif; ?>

<div id="images-resizing">
<h4><?php _e('Resizing images', 'rmcommon'); ?></h4>
<div class="progress">
<div id="bar-indicator" class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;">
<div id="images-resizing">
<h4><?php _e('Resizing images', 'rmcommon'); ?></h4>
<div class="progress">
<div id="bar-indicator" class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;">

</div>
</div>
<span class="message"></span>
</div>
<span class="message"></span>
</div>

<?php if($isupdate): ?>

<div id="uploading-messages">
<h4><?php _e('Uploading messages', 'rmcommon'); ?></h4>
<ul>
</ul>
<div id="back-images" class="text-center" style="margin: 15px 0; display: none;">
<a href="images.php?category=<?php echo $cat->id(); ?>&amp;page=<?php echo $page; ?>" class="btn btn-success"><?php _e('Back to images', 'rmcommon'); ?></a>
</div>

<?php endif; ?>
<?php endif; ?>

<div id="uploading-messages">
<h4>
<?php if(isset($messagesTitle)): ?>
<?php echo $messagesTitle; ?>
<?php else: ?>
<?php _e('Uploading messages', 'rmcommon'); ?>
<?php endif; ?>
</h4>
<ul>
</ul>
</div>

<?php endif; ?>

2 changes: 1 addition & 1 deletion rmcommon/xoops_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
30 changes: 24 additions & 6 deletions src/js/js/images-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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({
Expand All @@ -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);

}
Expand Down

0 comments on commit 7b4c4c5

Please sign in to comment.