Dotclear

source: plugins/attachments/_admin.php @ 1537:a3ac778e9132

Revision 1537:a3ac778e9132, 2.4 KB checked in by Lepeltier kévin, 12 years ago (diff)

Ticket #1406 : on encapsule new dcMedia dans des try catch pour crriger plusieurs bug.

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

Sites map