393 lines
18 KiB
HTML
Executable File
393 lines
18 KiB
HTML
Executable File
<div id="filemanager" class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
<h4 class="modal-title">文件管理器</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="row">
|
|
<div class="col-sm-5">
|
|
<a href="<?php echo $parent; ?>" data-toggle="tooltip" title="上一级" id="button-parent" class="btn btn-info"><i class="glyphicon glyphicon-level-up"></i></a>
|
|
<a href="<?php echo $refresh; ?>" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-info"><i class="glyphicon glyphicon-refresh"></i></a>
|
|
<a href="<?php echo $webuploader; ?>" data-toggle="tooltip" title="上传文件" id="button-webuploader" class="btn btn-info"><i class="glyphicon glyphicon-cloud-upload"></i></a>
|
|
<button type="button" data-toggle="tooltip" title="直接上传" id="button-upload" class="btn btn-primary"><i class="glyphicon glyphicon-upload"></i></button>
|
|
<button type="button" data-toggle="tooltip" title="新目录" id="button-folder" class="btn btn-info"><i class="glyphicon glyphicon-folder-close"></i></button>
|
|
<button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i></button>
|
|
<button type="button" data-toggle="tooltip" title="重命名" id="button-rename" class="btn btn-danger"><i class="glyphicon glyphicon-transfer"></i></button>
|
|
</div>
|
|
<div class="col-sm-7">
|
|
<div class="input-group">
|
|
<input type="text" name="search" value="<?php echo $filter_name; ?>" placeholder="检索中....." class="form-control">
|
|
<span class="input-group-btn">
|
|
<button type="button" data-toggle="tooltip" title="检索" id="button-search" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<?php foreach (array_chunk($images, 4) as $image4) { ?>
|
|
<div class="row">
|
|
<?php foreach ($image4 as $image) { ?>
|
|
<div class="col-sm-3 col-xs-6 text-center">
|
|
<?php switch($image['type']):
|
|
case 'directory':?>
|
|
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="directory" style="vertical-align: middle;"><i class="fa fa-fw fa-folder fa-5x"></i></a></div>
|
|
<label>
|
|
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
|
<?php echo $image['name']; ?>
|
|
</label>
|
|
<?php break;
|
|
case 'image':?>
|
|
<a href="<?php echo $image['href']; ?>" class="thumbnail"><img src="<?php echo $image['thumb']; ?>" alt="<?php echo $image['name']; ?>" title="<?php echo $image['name']; ?>" /></a>
|
|
<label>
|
|
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
|
<?php echo $image['name']; ?>
|
|
</label>
|
|
<?php break;
|
|
case 'text':?>
|
|
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file-text fa-5x"></i></a></div>
|
|
<label>
|
|
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
|
<?php echo $image['name']; ?>
|
|
</label>
|
|
<?php break;
|
|
case 'archive':?>
|
|
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file-archive-o fa-5x"></i></a></div>
|
|
<label>
|
|
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
|
<?php echo $image['name']; ?>
|
|
</label>
|
|
<?php break;
|
|
case 'video':?>
|
|
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file-video-o fa-5x"></i></a></div>
|
|
<label>
|
|
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
|
<?php echo $image['name']; ?>
|
|
</label>
|
|
<?php break;
|
|
default:?>
|
|
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file fa-5x"></i></a></div>
|
|
<label>
|
|
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
|
<?php echo $image['name']; ?>
|
|
</label>
|
|
<?php endswitch;?>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
<br />
|
|
<?php } ?>
|
|
</div>
|
|
<div class="modal-footer"><?php echo $pagination; ?></div>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var check_value = [];
|
|
$('#modal-image a.thumbnail').on('click', function(e) {
|
|
e.preventDefault();
|
|
var target = "<?php echo $target; ?>";
|
|
var thumb = "<?php echo $thumb; ?>";
|
|
var callback = "<?php echo $func;?>";
|
|
|
|
if (callback != "undefined") {
|
|
var fileurl_tmp = $(this).find('img').attr('src');
|
|
eval('window.parent.' + callback + '(fileurl_tmp,target,thumb);');
|
|
$('#modal-image').modal('hide');
|
|
return;
|
|
}
|
|
|
|
if (thumb) {
|
|
if (thumb.indexOf('thumb-image') != -1)
|
|
{
|
|
$.each($('input:checkbox:checked'),function() {
|
|
if(!$.isNumeric($(this).val())){
|
|
check_value.push($(this).val());
|
|
}
|
|
|
|
});
|
|
|
|
console.log(check_value);
|
|
// 修改附加图
|
|
var len = check_value.length;
|
|
var arr_tmp = [];
|
|
if (len > 1)
|
|
{
|
|
var tmp_obj = $.extend(true, {}, $('#' + thumb));
|
|
for (var i=0; i<len; i++)
|
|
{
|
|
// console.log(image_row);
|
|
var _id = 'thumb-image' + image_row;
|
|
|
|
tmp_obj.attr('id', _id);
|
|
tmp_obj.children('img').attr('src', check_value[i]);
|
|
var this_html = tmp_obj.prop("outerHTML");
|
|
tmp_obj.parent().append(this_html);
|
|
arr_tmp.push(check_value[i]);
|
|
image_row++;
|
|
}
|
|
|
|
arr_product_img.push(arr_tmp);
|
|
tmp_obj.remove();
|
|
|
|
// console.log(arr_product_img);
|
|
$("#albums").children('.image_111').remove();
|
|
for (var j=0; j<arr_product_img.length; j++)
|
|
{
|
|
for (var k=0; k<arr_product_img[j].length; k++)
|
|
{
|
|
var tmp_html = '<input type="hidden" class="image_111" name="arr_product_img[' + j + '][]" value="' + arr_product_img[j][k] + '">';
|
|
$("#albums").append(tmp_html);
|
|
}
|
|
}
|
|
|
|
console.log(arr_product_img);
|
|
}
|
|
else
|
|
{
|
|
arr_tmp.push($(this).find('img').attr('src'));
|
|
arr_product_img.push(arr_tmp);
|
|
$("#albums").children('.image_111').remove();
|
|
for (var j=0; j<arr_product_img.length; j++)
|
|
{
|
|
for (var k=0; k<arr_product_img[j].length; k++)
|
|
{
|
|
var tmp_html = '<input type="hidden" class="image_111" name="arr_product_img[' + j + '][]" value="' + arr_product_img[j][k] + '">';
|
|
$("#albums").append(tmp_html);
|
|
}
|
|
}
|
|
|
|
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
|
console.log(2);
|
|
console.log(arr_product_img);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
|
}
|
|
|
|
}
|
|
if (target) {
|
|
$('#' + target).val($(this).parent().find('input').val());
|
|
}
|
|
$('#modal-image').modal('hide');
|
|
});
|
|
$('#modal-image a.iconfile').on('click', function(e) {
|
|
e.preventDefault();
|
|
var target = "<?php echo $target; ?>";
|
|
var thumb = "<?php echo $thumb; ?>";
|
|
var callback = "<?php echo $func;?>";
|
|
if (callback != "undefined") {
|
|
var fileurl_tmp = $(this).parent().parent().find('input').val();
|
|
eval('window.parent.' + callback + '(fileurl_tmp,target,thumb);');
|
|
$('#modal-image').modal('hide');
|
|
return;
|
|
}
|
|
// if (thumb) {
|
|
// $('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
|
// }
|
|
if (target) {
|
|
//console.log($(this).parent().parent().find('input').val());
|
|
$('#' + target).val($(this).parent().parent().find('input').val());
|
|
}
|
|
$('#modal-image').modal('hide');
|
|
});
|
|
$('#modal-image a.directory').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-image').load($(this).attr('href'));
|
|
});
|
|
$('#modal-image .pagination a').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-image').load($(this).attr('href'));
|
|
});
|
|
$('#button-parent').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-image').load($(this).attr('href'));
|
|
});
|
|
$('#button-refresh').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-image').load($(this).attr('href'));
|
|
});
|
|
$('#button-webuploader').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-image').load($(this).attr('href'));
|
|
});
|
|
$('#modal-image input[name=\'search\']').on('keydown', function(e) {
|
|
if (e.which == 13) {
|
|
$('#button-search').trigger('click');
|
|
}
|
|
});
|
|
$('#button-search').on('click', function(e) {
|
|
var url = '<?php echo url("/admin/webuploader/show",array_filter(["target"=>$target,"thumb"=>$thumb,"type"=>$type,"func"=>$func,"num"=>$num,"directory"=>$directory])); ?>';
|
|
var filter_name = $('#modal-image input[name=\'search\']').val();
|
|
if (filter_name) {
|
|
url += '&filter_name=' + encodeURIComponent(filter_name);
|
|
}
|
|
$('#modal-image').load(url);
|
|
});
|
|
</script>
|
|
<script type="text/javascript">
|
|
$('#button-upload').on('click', function() {
|
|
$('#form-upload').remove();
|
|
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file[]" value="" multiple="multiple"/></form>');
|
|
$('#form-upload input[name=\'file[]\']').trigger('click');
|
|
if (typeof timer != 'undefined') {
|
|
clearInterval(timer);
|
|
}
|
|
timer = setInterval(function() {
|
|
if ($('#form-upload input[name=\'file[]\']').val() != '') {
|
|
clearInterval(timer);
|
|
$.ajax({
|
|
url: '<?php echo url("/admin/webuploader/upload",["directory"=>$directory,"type"=>$type]); ?>',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: new FormData($('#form-upload')[0]),
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function() {
|
|
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-hourglass"></i>');
|
|
$('#button-upload').prop('disabled', true);
|
|
},
|
|
complete: function() {
|
|
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-upload"></i>');
|
|
$('#button-upload').prop('disabled', false);
|
|
},
|
|
success: function(json) {
|
|
if (json['error']) {
|
|
alert(json['error']);
|
|
}
|
|
if (json['success']) {
|
|
alert(json['success']);
|
|
$('#button-refresh').trigger('click');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
}, 500);
|
|
});
|
|
|
|
$('#button-folder').popover({
|
|
html: true,
|
|
placement: 'bottom',
|
|
trigger: 'click',
|
|
title: '文件夹名称',
|
|
content: function() {
|
|
var html = '<div class="input-group">';
|
|
html += ' <input type="text" name="folder" value="" placeholder="文件夹名称,仅支持字母数字下划线" class="form-control">';
|
|
html += ' <span class="input-group-btn"><button type="button" title="新目录" id="button-create" class="btn btn-primary"><i class="glyphicon glyphicon-plus-sign"></i></button></span>';
|
|
html += '</div>';
|
|
return html;
|
|
}
|
|
});
|
|
|
|
$('#button-folder').on('shown.bs.popover', function() {
|
|
$('#button-create').on('click', function() {
|
|
$.ajax({
|
|
url: '<?php echo url("/admin/webuploader/folder",["directory"=>$directory]); ?>',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()),
|
|
beforeSend: function() {
|
|
$('#button-create').prop('disabled', true);
|
|
},
|
|
complete: function() {
|
|
$('#button-create').prop('disabled', false);
|
|
},
|
|
success: function(json) {
|
|
if (json['error']) {
|
|
alert(json['error']);
|
|
}
|
|
if (json['success']) {
|
|
alert(json['success']);
|
|
$('#button-refresh').trigger('click');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
$('#button-rename').popover({
|
|
html: true,
|
|
placement: 'bottom',
|
|
trigger: 'click',
|
|
title: '文件名称',
|
|
content: function() {
|
|
var html = '<div class="input-group">';
|
|
html += ' <input type="text" name="filenewname" value="" placeholder="文件名称,仅支持字母数字下划线" class="form-control">';
|
|
html += ' <span class="input-group-btn"><button type="button" title="文件名" id="button-newname" class="btn btn-primary"><i class="glyphicon glyphicon-check"></i></button></span>';
|
|
html += '</div>';
|
|
return html;
|
|
}
|
|
});
|
|
$('#button-rename').on('shown.bs.popover', function() {
|
|
$('#button-newname').on('click', function() {
|
|
//console.log($('input[name^=\'path\']:checked').val());
|
|
var path = $('input[name^=\'path\']:checked').val();
|
|
var filenewname = $('input[name=\'filenewname\']').val();
|
|
if (path && /^[a-zA-Z0-9_-]+$/.test(filenewname)) {
|
|
$.ajax({
|
|
url: '<?php echo url("/admin/webuploader/rename",["directory"=>$directory]); ?>',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: {filenewname: encodeURIComponent(filenewname), path: encodeURIComponent(path)},
|
|
beforeSend: function() {
|
|
$('#button-newname').prop('disabled', true);
|
|
},
|
|
complete: function() {
|
|
$('#button-newname').prop('disabled', false);
|
|
},
|
|
success: function(json) {
|
|
if (json['error']) {
|
|
alert(json['error']);
|
|
}
|
|
if (json['success']) {
|
|
alert(json['success']);
|
|
$('#button-refresh').trigger('click');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
|
}
|
|
});
|
|
} else {
|
|
alert('未选择文件或文件名为不是由字母数字下划线组成');
|
|
}
|
|
});
|
|
});
|
|
$('#modal-image #button-delete').on('click', function(e) {
|
|
if (confirm('确定删除吗?')) {
|
|
$.ajax({
|
|
url: '<?php echo url("/admin/webuploader/delete",["directory"=>$directory]); ?>',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: $('input[name^=\'path\']:checked'),
|
|
beforeSend: function() {
|
|
$('#button-delete').prop('disabled', true);
|
|
},
|
|
complete: function() {
|
|
$('#button-delete').prop('disabled', false);
|
|
},
|
|
success: function(json) {
|
|
if (json['error']) {
|
|
alert(json['error']);
|
|
}
|
|
if (json['success']) {
|
|
alert(json['success']);
|
|
$('#button-refresh').trigger('click');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|