248 lines
12 KiB
HTML
Executable File
248 lines
12 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>
|
|
<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"><!--
|
|
$("#modal-temp a.iconfile").on('click', function(e) {
|
|
var $element = $(this);
|
|
var $popover = $element.data('bs.popover'); // element has bs popover?
|
|
e.preventDefault();
|
|
// destroy all image popovers
|
|
$('#modal-temp a.iconfile').popover('destroy');
|
|
// remove flickering (do not re-add popover when clicking for removal)
|
|
if ($popover) {
|
|
return;
|
|
}
|
|
$element.popover({
|
|
html: true,
|
|
placement: 'auto top',
|
|
trigger: 'manual',
|
|
content: function() {
|
|
return '<button type="button" id="button-selectfile" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-ok"></i></button> <button type="button" id="button-editfile" class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-edit"></i></button>';
|
|
}
|
|
});
|
|
$element.popover('show');
|
|
$('#button-editfile').on('click', function() {
|
|
var $button = $(this);
|
|
var $icon = $button.find('> i');
|
|
$('#modal-file-content').remove();
|
|
$.ajax({
|
|
url: "<?php echo url('/admin/tool/showcontent');?>",
|
|
data: {filename: encodeURIComponent($element.parent().next().find('input[name^=\'path\']').val())},
|
|
dataType: 'html',
|
|
beforeSend: function() {
|
|
$button.prop('disabled', true);
|
|
if ($icon.length) {
|
|
$icon.attr('class', 'glyphicon glyphicon-hourglass');
|
|
}
|
|
},
|
|
complete: function() {
|
|
$button.prop('disabled', false);
|
|
if ($icon.length) {
|
|
$icon.attr('class', 'glyphicon glyphicon-edit');
|
|
}
|
|
},
|
|
success: function(html) {
|
|
$('body').append('<div id="modal-file-content" class="modal fade">' + html + '</div>');
|
|
$('#modal-file-content').modal({show: true, backdrop: false, keyboard: false});
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
|
}
|
|
});
|
|
$element.popover('destroy');
|
|
});
|
|
$('#button-selectfile').on('click', function() {
|
|
var target = "<?php echo $target; ?>";
|
|
var thumb = "<?php echo $thumb; ?>";
|
|
var callback = "<?php echo $func;?>";
|
|
if (callback != "undefined") {
|
|
var fileurl_tmp = $element.parent().next().find('input').val();
|
|
eval('window.parent.' + callback + '(fileurl_tmp,target);');
|
|
$('#modal-temp').modal('hide');
|
|
return;
|
|
}
|
|
if (target) {
|
|
//console.log($(this).parent().parent().find('input').val());
|
|
$('#' + target).val($element.parent().next().find('input').val());
|
|
}
|
|
$element.popover('destroy');
|
|
$('#modal-temp').modal('hide');
|
|
});
|
|
});
|
|
$('#modal-temp 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-temp').modal('hide');
|
|
return;
|
|
}
|
|
if (thumb) {
|
|
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
|
}
|
|
if (target) {
|
|
$('#' + target).val($(this).parent().find('input').val());
|
|
}
|
|
$('#modal-temp').modal('hide');
|
|
});
|
|
$('#modal-temp a.directory').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-temp').load($(this).attr('href'));
|
|
});
|
|
$('#modal-temp .pagination a').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-temp').load($(this).attr('href'));
|
|
});
|
|
$('#button-parent').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-temp').load($(this).attr('href'));
|
|
});
|
|
$('#button-refresh').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#modal-temp').load($(this).attr('href'));
|
|
});
|
|
$('#modal-temp 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/tool/show",array_filter(["target"=>$target,"thumb"=>$thumb,"type"=>$type,"func"=>$func,"num"=>$num,"directory"=>$directory])); ?>';
|
|
var filter_name = $('#modal-temp input[name=\'search\']').val();
|
|
if (filter_name) {
|
|
url += '&filter_name=' + encodeURIComponent(filter_name);
|
|
}
|
|
$('#modal-temp').load(url);
|
|
});
|
|
//--></script>
|
|
<script type="text/javascript"><!--
|
|
$('#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/tool/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('未选择文件或文件名为不是由字母数字下划线组成');
|
|
}
|
|
});
|
|
});
|
|
//--></script>
|