4 * Attachmentエレメントのカスタマイズ版
5 * ファイルアップロード済みの場合、追加アップロードフォームを表示しない
9 if (!isset($previewVersion)) {
10 $previewVersion = 'l';
13 /* Set $assocAlias and $model if you're using this element multiple times in one form */
15 if (!isset($assocAlias)) {
16 $assocAlias = 'Attachment';
18 $assocAlias = Inflector::singularize($assocAlias);
22 $model = $form->model();
25 $modelId = $form->value($form->model().'.id');
27 if (isset($this->data[$assocAlias][0]['basename'])) {
28 array_unshift($this->data[$assocAlias], array());
32 $label = __('File', true);
36 <div class="attachments element input">
37 <?php if (!isset($this->data[$assocAlias][1]['id']) || isset($this->data[$assocAlias][0]['file'])): ?>
38 <!-- New Attachment -->
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(
47 if (!isset($noCaption) || $noCaption !== true) {
48 echo $form->input($assocAlias . '.0.alternative', array(
49 'label' => $label." ".__('Caption', true),
56 <!-- Existing Attachments -->
57 <div class="existing">
61 $item = $this->data[$assocAlias][$i];
63 echo $html->tag('label', $label);
65 echo $form->hidden($assocAlias . '.' . $i . '.id', array('value' => $item['id']));
67 $file = $upfile->file(
69 CorePlus::get_value($this->data, $assocAlias.'.'.$i),
71 'model_name' => $model,
72 'mime_type' => 'original',
80 'alt' => CorePlus::get_value($user, 'User.name'),
82 'id' => 'HomeUserImage',
83 'restrict' => array('image')
88 echo $upfile->fileInfo($file, $item);
91 if (!isset($noCaption) || $noCaption !== true) {
92 echo $form->input($assocAlias . '.' . $i . '.alternative', array(
93 'label' => $label." ".__('Caption', true),
94 'value' => $item['alternative'],
99 if (isset($item['delete']) && $item['delete'] == 1) {
100 $checked = 'checked';
104 echo $form->input($assocAlias . '.' . $i . '.delete', array(
105 'label' => __('Release', true),
106 'type' => 'checkbox',
108 'checked' => $checked,