| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
|---|
| 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 | |
|---|
| 14 | $core->addBehavior ('adminPostFormSidebar',array('attachmentAdmin','adminPostFormSidebar')); |
|---|
| 15 | $core->addBehavior ('adminPostAfterForm',array('attachmentAdmin','adminPostAfterForm')); |
|---|
| 16 | |
|---|
| 17 | class attachmentAdmin |
|---|
| 18 | { |
|---|
| 19 | public static function adminPostFormSidebar($post) |
|---|
| 20 | { |
|---|
| 21 | if ($post !== null) |
|---|
| 22 | { |
|---|
| 23 | $core =& $GLOBALS['core']; |
|---|
| 24 | $post_media = $core->media->getPostMedia($post->post_id); |
|---|
| 25 | echo |
|---|
| 26 | '<h3 class="clear">'.__('Attachments').'</h3>'; |
|---|
| 27 | foreach ($post_media as $f) |
|---|
| 28 | { |
|---|
| 29 | $ftitle = $f->media_title; |
|---|
| 30 | if (strlen($ftitle) > 18) { |
|---|
| 31 | $ftitle = substr($ftitle,0,16).'...'; |
|---|
| 32 | } |
|---|
| 33 | echo |
|---|
| 34 | '<div class="media-item">'. |
|---|
| 35 | '<a class="media-icon" href="media_item.php?id='.$f->media_id.'">'. |
|---|
| 36 | '<img src="'.$f->media_icon.'" alt="" title="'.$f->basename.'" /></a>'. |
|---|
| 37 | '<ul>'. |
|---|
| 38 | '<li><a class="media-link" href="media_item.php?id='.$f->media_id.'"'. |
|---|
| 39 | 'title="'.$f->basename.'">'.$ftitle.'</a></li>'. |
|---|
| 40 | '<li>'.$f->media_dtstr.'</li>'. |
|---|
| 41 | '<li>'.files::size($f->size).' - '. |
|---|
| 42 | '<a href="'.$f->file_url.'">'.__('open').'</a>'.'</li>'. |
|---|
| 43 | |
|---|
| 44 | '<li class="media-action"><a class="attachment-remove" id="attachment-'.$f->media_id.'" '. |
|---|
| 45 | 'href="post_media.php?post_id='.$post->post_id.'&media_id='.$f->media_id.'&remove=1">'. |
|---|
| 46 | '<img src="images/check-off.png" alt="'.__('remove').'" /></a>'. |
|---|
| 47 | '</li>'. |
|---|
| 48 | |
|---|
| 49 | '</ul>'. |
|---|
| 50 | '</div>'; |
|---|
| 51 | } |
|---|
| 52 | unset($f); |
|---|
| 53 | |
|---|
| 54 | if (empty($post_media)) { |
|---|
| 55 | echo '<p>'.__('No attachment.').'</p>'; |
|---|
| 56 | } else { |
|---|
| 57 | } |
|---|
| 58 | echo '<p><a class="button" href="media.php?post_id='.$post->post_id.'">'.__('Add files to this entry').'</a></p>'; |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | public static function adminPostAfterForm($post) { |
|---|
| 63 | if ($post !== null) |
|---|
| 64 | { |
|---|
| 65 | $core =& $GLOBALS['core']; |
|---|
| 66 | echo |
|---|
| 67 | '<form action="post_media.php" id="attachment-remove-hide" method="post">'. |
|---|
| 68 | '<div>'.form::hidden(array('post_id'),$post->post_id). |
|---|
| 69 | form::hidden(array('media_id'),''). |
|---|
| 70 | form::hidden(array('remove'),1). |
|---|
| 71 | $core->formNonce().'</div></form>'; |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | ?> |
|---|