[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')); |
---|
[1617] | 17 | $core->addBehavior ('adminPageFormItems',array('attachmentAdmin','adminPostFormItems')); |
---|
| 18 | $core->addBehavior ('adminPageAfterForm',array('attachmentAdmin','adminPostAfterForm')); |
---|
| 19 | $core->addBehavior('adminPageHeaders',array('attachmentAdmin','postHeaders')); |
---|
[407] | 20 | |
---|
| 21 | class attachmentAdmin |
---|
| 22 | { |
---|
[1392] | 23 | public static function postHeaders() |
---|
| 24 | { |
---|
| 25 | return |
---|
| 26 | '<script type="text/javascript" src="index.php?pf=attachments/js/post.js"></script>'; |
---|
| 27 | } |
---|
[1398] | 28 | public static function adminPostFormItems($main,$sidebar,$post) |
---|
[407] | 29 | { |
---|
| 30 | if ($post !== null) |
---|
| 31 | { |
---|
| 32 | $core =& $GLOBALS['core']; |
---|
| 33 | $post_media = $core->media->getPostMedia($post->post_id); |
---|
[1501] | 34 | $nb_media = count($post_media); |
---|
| 35 | $title = !$nb_media ? __('Attachments') : sprintf(__('Attachments (%d)'),$nb_media); |
---|
| 36 | $item = '<h5 class="clear s-attachments">'.$title.'</h5>'; |
---|
[407] | 37 | foreach ($post_media as $f) |
---|
| 38 | { |
---|
| 39 | $ftitle = $f->media_title; |
---|
| 40 | if (strlen($ftitle) > 18) { |
---|
| 41 | $ftitle = substr($ftitle,0,16).'...'; |
---|
| 42 | } |
---|
[1392] | 43 | $item .= |
---|
| 44 | '<div class="media-item s-attachments">'. |
---|
[407] | 45 | '<a class="media-icon" href="media_item.php?id='.$f->media_id.'">'. |
---|
| 46 | '<img src="'.$f->media_icon.'" alt="" title="'.$f->basename.'" /></a>'. |
---|
| 47 | '<ul>'. |
---|
[1467] | 48 | '<li><a class="media-link" href="media_item.php?id='.$f->media_id.'" '. |
---|
[407] | 49 | 'title="'.$f->basename.'">'.$ftitle.'</a></li>'. |
---|
| 50 | '<li>'.$f->media_dtstr.'</li>'. |
---|
| 51 | '<li>'.files::size($f->size).' - '. |
---|
| 52 | '<a href="'.$f->file_url.'">'.__('open').'</a>'.'</li>'. |
---|
| 53 | |
---|
| 54 | '<li class="media-action"><a class="attachment-remove" id="attachment-'.$f->media_id.'" '. |
---|
| 55 | 'href="post_media.php?post_id='.$post->post_id.'&media_id='.$f->media_id.'&remove=1">'. |
---|
| 56 | '<img src="images/check-off.png" alt="'.__('remove').'" /></a>'. |
---|
| 57 | '</li>'. |
---|
| 58 | |
---|
| 59 | '</ul>'. |
---|
| 60 | '</div>'; |
---|
| 61 | } |
---|
| 62 | unset($f); |
---|
| 63 | |
---|
| 64 | if (empty($post_media)) { |
---|
[1392] | 65 | $item .= '<p class="form-note s-attachments">'.__('No attachment.').'</p>'; |
---|
| 66 | } |
---|
| 67 | $item .= '<p class="s-attachments"><a class="button" href="media.php?post_id='.$post->post_id.'">'.__('Add files to this entry').'</a></p>'; |
---|
[1398] | 68 | $sidebar['metas-box']['items']['attachments']= $item; |
---|
[407] | 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
[416] | 72 | public static function adminPostAfterForm($post) { |
---|
[407] | 73 | if ($post !== null) |
---|
| 74 | { |
---|
| 75 | $core =& $GLOBALS['core']; |
---|
| 76 | echo |
---|
| 77 | '<form action="post_media.php" id="attachment-remove-hide" method="post">'. |
---|
| 78 | '<div>'.form::hidden(array('post_id'),$post->post_id). |
---|
| 79 | form::hidden(array('media_id'),''). |
---|
| 80 | form::hidden(array('remove'),1). |
---|
| 81 | $core->formNonce().'</div></form>'; |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | ?> |
---|