[407] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[407] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 13 | |
---|
[1398] | 14 | $core->addBehavior ('adminPostFormItems',array('attachmentAdmin','adminPostFormItems')); |
---|
[416] | 15 | $core->addBehavior ('adminPostAfterForm',array('attachmentAdmin','adminPostAfterForm')); |
---|
[1392] | 16 | $core->addBehavior('adminPostHeaders',array('attachmentAdmin','postHeaders')); |
---|
[407] | 17 | |
---|
| 18 | class attachmentAdmin |
---|
| 19 | { |
---|
[1392] | 20 | public static function postHeaders() |
---|
| 21 | { |
---|
| 22 | return |
---|
| 23 | '<script type="text/javascript" src="index.php?pf=attachments/js/post.js"></script>'; |
---|
| 24 | } |
---|
[1398] | 25 | public static function adminPostFormItems($main,$sidebar,$post) |
---|
[407] | 26 | { |
---|
| 27 | if ($post !== null) |
---|
| 28 | { |
---|
| 29 | $core =& $GLOBALS['core']; |
---|
| 30 | $post_media = $core->media->getPostMedia($post->post_id); |
---|
[1392] | 31 | $item = '<h5 class="clear s-attachments">'.__('Attachments').'</h5>'; |
---|
[407] | 32 | foreach ($post_media as $f) |
---|
| 33 | { |
---|
| 34 | $ftitle = $f->media_title; |
---|
| 35 | if (strlen($ftitle) > 18) { |
---|
| 36 | $ftitle = substr($ftitle,0,16).'...'; |
---|
| 37 | } |
---|
[1392] | 38 | $item .= |
---|
| 39 | '<div class="media-item s-attachments">'. |
---|
[407] | 40 | '<a class="media-icon" href="media_item.php?id='.$f->media_id.'">'. |
---|
| 41 | '<img src="'.$f->media_icon.'" alt="" title="'.$f->basename.'" /></a>'. |
---|
| 42 | '<ul>'. |
---|
[1467] | 43 | '<li><a class="media-link" href="media_item.php?id='.$f->media_id.'" '. |
---|
[407] | 44 | 'title="'.$f->basename.'">'.$ftitle.'</a></li>'. |
---|
| 45 | '<li>'.$f->media_dtstr.'</li>'. |
---|
| 46 | '<li>'.files::size($f->size).' - '. |
---|
| 47 | '<a href="'.$f->file_url.'">'.__('open').'</a>'.'</li>'. |
---|
| 48 | |
---|
| 49 | '<li class="media-action"><a class="attachment-remove" id="attachment-'.$f->media_id.'" '. |
---|
| 50 | 'href="post_media.php?post_id='.$post->post_id.'&media_id='.$f->media_id.'&remove=1">'. |
---|
| 51 | '<img src="images/check-off.png" alt="'.__('remove').'" /></a>'. |
---|
| 52 | '</li>'. |
---|
| 53 | |
---|
| 54 | '</ul>'. |
---|
| 55 | '</div>'; |
---|
| 56 | } |
---|
| 57 | unset($f); |
---|
| 58 | |
---|
| 59 | if (empty($post_media)) { |
---|
[1392] | 60 | $item .= '<p class="form-note s-attachments">'.__('No attachment.').'</p>'; |
---|
| 61 | } |
---|
| 62 | $item .= '<p class="s-attachments"><a class="button" href="media.php?post_id='.$post->post_id.'">'.__('Add files to this entry').'</a></p>'; |
---|
[1398] | 63 | $sidebar['metas-box']['items']['attachments']= $item; |
---|
[407] | 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
[416] | 67 | public static function adminPostAfterForm($post) { |
---|
[407] | 68 | if ($post !== null) |
---|
| 69 | { |
---|
| 70 | $core =& $GLOBALS['core']; |
---|
| 71 | echo |
---|
| 72 | '<form action="post_media.php" id="attachment-remove-hide" method="post">'. |
---|
| 73 | '<div>'.form::hidden(array('post_id'),$post->post_id). |
---|
| 74 | form::hidden(array('media_id'),''). |
---|
| 75 | form::hidden(array('remove'),1). |
---|
| 76 | $core->formNonce().'</div></form>'; |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | ?> |
---|