OSDN Git Service

UP済み画像の編集表示を微修正
[trpgtools-onweb/cake-frame.git] / app / plugins / media / views / elements / medium_edit.ctp
1 <?php
2 /**
3  * ファイルアップロードフォーム
4  * Attachmentエレメントのカスタマイズ版
5  * ファイルアップロード済みの場合、追加アップロードフォームを表示しない
6  */
7
8 // アップロード済みファイルの表示サイズ
9 if (!isset($previewVersion)) {
10         $previewVersion = 'l';
11 }
12
13 /* Set $assocAlias and $model if you're using this element multiple times in one form */
14
15 if (!isset($assocAlias)) {
16         $assocAlias = 'Attachment';
17 } else {
18         $assocAlias = Inflector::singularize($assocAlias);
19 }
20
21 if (!isset($model)) {
22         $model = $form->model();
23 }
24
25 $modelId = $form->value($form->model().'.id');
26
27 if (isset($this->data[$assocAlias][0]['basename'])) {
28         array_unshift($this->data[$assocAlias], array());
29 }
30
31 if (!isset($label)) {
32         $label = __('File', true);
33 }
34
35 ?>
36 <div class="attachments element input">
37 <?php if (!isset($this->data[$assocAlias][1]['id']) || isset($this->data[$assocAlias][0]['file'])): ?>
38 <!-- New Attachment -->
39 <div class="new">
40 <?php
41         echo $form->hidden($assocAlias . '.0.model', array('value' => $model));
42         echo $form->hidden($assocAlias . '.0.group', array('value' => strtolower($assocAlias)));
43         echo $form->input($assocAlias . '.0.file', array(
44                 'label' => $label,
45                 'type'  => 'file',
46         ));
47 if (!isset($noCaption) || $noCaption !== true) {
48         echo $form->input($assocAlias . '.0.alternative', array(
49                 'label' => $label." ".__('Caption', true),
50                 'value' => '',
51         ));
52 }
53 ?>
54 </div>
55 <?php else: ?>
56 <!-- Existing Attachments -->
57 <div class="existing">
58 <div>
59 <?php
60         $i = 1;
61         $item = $this->data[$assocAlias][$i];
62
63         echo $html->tag('label', $label);
64
65         echo $form->hidden($assocAlias . '.' . $i . '.id', array('value' => $item['id']));
66
67         $file = $upfile->file(
68                 $previewVersion, 
69                 CorePlus::get_value($this->data, $assocAlias.'.'.$i),
70                 array(
71                         'model_name' => $model, 
72                         'mime_type' => 'original',
73                         'nodata' => 'image',
74                 )
75         );
76
77         echo $upfile->embed(
78                 $file,
79                 array(
80                         'alt' => CorePlus::get_value($user, 'User.name'),
81                         'class' => 'shadow',
82                         'id' => 'HomeUserImage',
83                         'restrict' => array('image')
84                 )
85         );
86
87         // ファイル情報出力
88         echo $upfile->fileInfo($file, $item);
89
90         // caption
91 if (!isset($noCaption) || $noCaption !== true) {
92         echo $form->input($assocAlias . '.' . $i . '.alternative', array(
93                 'label' => $label." ".__('Caption', true),
94                 'value' => $item['alternative'],
95         ));
96 }
97
98         // Release
99         if (isset($item['delete']) && $item['delete'] == 1) {
100                 $checked = 'checked';
101         } else {
102                 $checked = null;
103         }
104         echo $form->input($assocAlias . '.' . $i . '.delete', array(
105                 'label' => __('Release', true),
106                 'type' => 'checkbox',
107                 'value' => 0,
108                 'checked' => $checked,
109         ));
110 ?>
111 </div>
112 </div>
113 <?php endif ?>
114 </div>