<?php
/**
 * The buildform view file of file module of ZDOO.
 *
 * @copyright   Copyright 2009-2018 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Chunsheng Wang <chunsheng@cnezsoft.com>
 * @package     file
 * @version     $Id: buildform.html.php 4029 2016-08-26 06:50:41Z liugang $
 * @link        http://www.zdoo.com
 */
?>
<?php if(commonModel::hasPriv('file', 'upload')):?>
<?php if(!$writable):?>
<div class='text-danger text-left'> <?php echo $this->lang->file->errorUnwritable;?> </div>
<?php else:?>
<?php $maxUploadSize = strtoupper(ini_get('upload_max_filesize'));?>
<?php js::set('uid', $uid);?>
<?php js::set('uploaderID', $uploaderID);?>
<style>
.uploader-files, .file-list {min-height: 0 !important; margin-bottom: 0 !important;} 
.uploader {margin-bottom: 0 !important;}
</style>
<div id="<?php echo $uploaderID;?>" class="uploader">
  <div class="uploader-message text-center">
    <div class="content"></div>
    <button type="button" class="close">×</button>
  </div>
  <div class="uploader-files file-list file-list-grid"></div>
  <div>
    <div class="uploader-status pull-right text-muted"></div>
    <button type="button" class="btn btn-link file-input-btn uploader-btn-browse"><i class="icon icon-plus"></i> <?php echo $lang->file->addFile;?></button> <small class="muted"><?php echo sprintf($lang->file->maxUploadSize, $maxUploadSize);?></small>
  </div>
  <input type='hidden' name='<?php echo $uidName;?>' value='<?php echo $uid;?>'>
</div>
<?php $jsRoot = $this->config->webRoot . "js/";?>
<?php /* Import css and js for uploader. */?>
<?php css::import($jsRoot . 'uploader/min.css');?>
<?php js::import($jsRoot  . 'uploader/min.js');?>
<script>
var uploaderID = '#' + v.uploaderID;
$(uploaderID).uploader({
    autoUpload: true,
    chunk_size: 0,
    url: createLink('file', 'ajaxUpload', 'uid=' + v.uid + '&editor=0&name=file'),
    deleteActionOnDone(file){
        $.post(createLink('file', 'deleteMultiple', 'uuid=' + file.id));
        return true;
    },
    statusCreator:() => ''
});
</script>
<?php endif;?>
<?php endif;?>
