}
function index() {
+ $this->set('is_owner', true);
self::_index();
}
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(
}
}
- $this->data = $this->User->read(null, $id);
+ $this->data = $user;
}
function change_password() {
}
function mobile_index() {
+ $this->set('is_owner', true);
+
self::_index();
}
function mobile_view($id = null) {
--- /dev/null
+<?php
+/**
+ * ファイルアップロードフォーム
+ * Attachmentエレメントのカスタマイズ版
+ * ファイルアップロード済みの場合、追加アップロードフォームを表示しない
+ */
+
+// アップロード済みファイルの表示サイズ
+if (!isset($previewVersion)) {
+ $previewVersion = 'l';
+}
+
+/* Set $assocAlias and $model if you're using this element multiple times in one form */
+
+if (!isset($assocAlias)) {
+ $assocAlias = 'Attachment';
+} else {
+ $assocAlias = Inflector::singularize($assocAlias);
+}
+
+if (!isset($model)) {
+ $model = $form->model();
+}
+
+$modelId = $form->value($form->model().'.id');
+
+if (isset($this->data[$assocAlias][0]['basename'])) {
+ array_unshift($this->data[$assocAlias],array());
+}
+?>
+
+<div class="attachments element">
+ <?php if (!isset($this->data[$assocAlias]) || empty($this->data[$assocAlias])): ?>
+ <!-- New Attachment -->
+ <div class="new">
+ <?php
+ echo $form->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)
+ ));
+ ?>
+ </div>
+ <?php else: ?>
+ <!-- Existing Attachments -->
+ <div class="existing">
+ <div>
+ <?php
+ $i = 1;
+ $item = $this->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('<div class="fileOptions"><em>%s</em> (%s/%s)</div>',
+ $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
+ ));
+ ?>
+ </div>
+ </div>
+ <?php endif ?>
+</div>
\ No newline at end of file