From bd806d368349db9f28f20ac45b9b1640eecf0faa Mon Sep 17 00:00:00 2001 From: Cake Date: Tue, 23 Feb 2010 01:21:26 +0900 Subject: [PATCH] =?utf8?q?=E8=A4=87=E6=95=B0=E3=83=95=E3=82=A1=E3=82=A4?= =?utf8?q?=E3=83=AB=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89?= =?utf8?q?=E7=A6=81=E6=AD=A2=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.php | 18 +++- app/plugins/media/views/elements/medium_edit.ctp | 107 +++++++++++++++++++++++ app/views/users/edit_image.ctp | 2 +- 3 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 app/plugins/media/views/elements/medium_edit.ctp diff --git a/app/controllers/users_controller.php b/app/controllers/users_controller.php index 9382eb4..0cfef1a 100644 --- a/app/controllers/users_controller.php +++ b/app/controllers/users_controller.php @@ -49,6 +49,7 @@ class UsersController extends ModuleController { } function index() { + $this->set('is_owner', true); self::_index(); } @@ -79,7 +80,20 @@ class UsersController extends ModuleController { function edit_image() { $id = $this->AuthPlus->user("id"); + $user = $this->User->read(null, $id); + if (!empty($this->data)) { + // 重複アップロードチェック + if (!empty($user['Attachment']) && + (count($user['Attachment']) > 2 + || !isset($this->data['Attachment'][1]['delete']) + || ($this->data['Attachment'][1]['delete'] != '1') + )) { + $this->Session->setFlash(__('User is able to have the only One image.', true)); + $this->redirect(array('action'=>'edit_image')); + } + + $this->data['User']['id'] = $id; $fieldList = array( @@ -122,7 +136,7 @@ class UsersController extends ModuleController { } } - $this->data = $this->User->read(null, $id); + $this->data = $user; } function change_password() { @@ -149,6 +163,8 @@ class UsersController extends ModuleController { } function mobile_index() { + $this->set('is_owner', true); + self::_index(); } function mobile_view($id = null) { diff --git a/app/plugins/media/views/elements/medium_edit.ctp b/app/plugins/media/views/elements/medium_edit.ctp new file mode 100644 index 0000000..0804c06 --- /dev/null +++ b/app/plugins/media/views/elements/medium_edit.ctp @@ -0,0 +1,107 @@ +model(); +} + +$modelId = $form->value($form->model().'.id'); + +if (isset($this->data[$assocAlias][0]['basename'])) { + array_unshift($this->data[$assocAlias],array()); +} +?> + +
+ data[$assocAlias]) || empty($this->data[$assocAlias])): ?> + +
+ hidden($assocAlias . '.0.model', array('value' => $model)); + echo $form->hidden($assocAlias . '.0.group', array('value' => strtolower($assocAlias))); + echo $form->input($assocAlias . '.0.file', array( + 'label' => __('File', true), + 'type' => 'file', + 'error' => array( + 'error' => __('An error occured while transferring the file.', true), + 'resource' => __('The file is invalid.', true), + 'access' => __('The file cannot be processed.', true), + 'location' => __('The file cannot be transferred from or to location.', true), + 'permission' => __('Executable files cannot be uploaded.', true), + 'size' => __('The file is too large.', true), + 'pixels' => __('The file is too large.', true), + 'extension' => __('The file has the wrong extension.', true), + 'mimeType' => __('The file has the wrong MIME type.', true), + ))); + echo $form->input($assocAlias . '.0.alternative', array( + 'label' => __('Textual replacement', true), + 'value' => '', + 'error' => __('A textual replacement must be provided.', true) + )); + ?> +
+ + +
+
+ data[$assocAlias][$i]; + + echo $form->hidden($assocAlias . '.' . $i . '.id', array('value' => $item['id'])); + echo $form->hidden($assocAlias . '.' . $i . '.model', array('value' => $model)); + echo $form->hidden($assocAlias . '.' . $i . '.group', array('value' => $item['group'])); + echo $form->hidden($assocAlias . '.' . $i . '.dirname', array('value' => $item['dirname'])); + echo $form->hidden($assocAlias . '.' . $i . '.basename', array('value' => $item['basename'])); + echo $form->hidden($assocAlias . '.' . $i . '.alternative', array('value' => $item['alternative'])); + + if ($file = $upfile->file('filter/'.$previewVersion, $item, $model)) { + $url = null; // 元ファイル出力実装まで仮 + + echo $medium->embed($medium->file($previewVersion . '/', $item), array( + '$file' => $file, + 'restrict' => array('image') + )); + + $Medium = Medium::factory($file); + $size = $medium->size($file); + + if (isset($number)) { + $size = $number->toReadableSize($size); + } else { + $size .= ' Bytes'; + } + + printf('
%s (%s/%s)
', + $item['alternative'], +// $url ? $html->link($item['basename'], $url) : $item['basename'], + strtolower($Medium->name), $size); + } + + echo $form->input($assocAlias . '.' . $i . '.delete', array( + 'label' => __('Release', true), + 'type' => 'checkbox', + 'value' => 0 + )); + ?> +
+
+ +
\ No newline at end of file diff --git a/app/views/users/edit_image.ctp b/app/views/users/edit_image.ctp index 5f6d866..a861f02 100644 --- a/app/views/users/edit_image.ctp +++ b/app/views/users/edit_image.ctp @@ -9,7 +9,7 @@
element('attachments', array( + echo $this->element('medium_edit', array( 'plugin' => 'media', 'previewVersion' => 'm', )); -- 2.11.0