file-upload.php 1.4 KB

123456789101112131415161718192021222324252627282930
  1. <?php if(!defined('__TYPECHO_ADMIN__')) exit; ?>
  2. <?php
  3. if (isset($post) || isset($page)) {
  4. $cid = isset($post) ? $post->cid : $page->cid;
  5. if ($cid) {
  6. \Widget\Contents\Attachment\Related::alloc(['parentId' => $cid])->to($attachment);
  7. } else {
  8. \Widget\Contents\Attachment\Unattached::alloc()->to($attachment);
  9. }
  10. }
  11. ?>
  12. <div id="upload-panel" class="p">
  13. <div class="upload-area" draggable="true"><?php _e('拖放文件到这里<br>或者 %s选择文件上传%s', '<a href="###" class="upload-file">', '</a>'); ?></div>
  14. <ul id="file-list">
  15. <?php while ($attachment->next()): ?>
  16. <li data-cid="<?php $attachment->cid(); ?>" data-url="<?php echo $attachment->attachment->url; ?>" data-image="<?php echo $attachment->attachment->isImage ? 1 : 0; ?>"><input type="hidden" name="attachment[]" value="<?php $attachment->cid(); ?>" />
  17. <a class="insert" title="<?php _e('点击插入文件'); ?>" href="###"><?php $attachment->title(); ?></a>
  18. <div class="info">
  19. <?php echo number_format(ceil($attachment->attachment->size / 1024)); ?> Kb
  20. <a class="file" target="_blank" href="<?php $options->adminUrl('media.php?cid=' . $attachment->cid); ?>" title="<?php _e('编辑'); ?>"><i class="i-edit"></i></a>
  21. <a href="###" class="delete" title="<?php _e('删除'); ?>"><i class="i-delete"></i></a>
  22. </div>
  23. </li>
  24. <?php endwhile; ?>
  25. </ul>
  26. </div>