OSDN Git Service

添付ファイルがない場合の処理
authorCake <cake_67@users.sourceforge.jp>
Tue, 2 Mar 2010 05:08:36 +0000 (14:08 +0900)
committerCake <cake_67@users.sourceforge.jp>
Tue, 2 Mar 2010 05:08:36 +0000 (14:08 +0900)
app/plugins/media/views/elements/medium_edit.ctp
app/plugins/media/views/helpers/upfile.php
app/views/elements/home.ctp
app/views/systems/admin_index.ctp
app/views/systems/admin_view.ctp
app/views/systems/index.ctp
app/views/systems/view.ctp
app/views/users/admin_view.ctp

index d92088d..9f5433a 100644 (file)
@@ -62,24 +62,23 @@ if (!isset($label)) {
 
        $file = $upfile->file(
                'filter/'.$previewVersion, 
-               $this->data[$assocAlias], 
-               $i, 
+               CorePlus::get_value($this->data, $assocAlias.'.'.$i),
                array(
                        'model_name' => $model, 
                        'mime_type' => 'original',
                        'nodata' => 'image',
                )
        );
-       if (!empty($file)) {
+
        echo $medium->embed(
                $file,
                array(
-                       'alt' => $user['User']['name'],
+                       'alt' => CorePlus::get_value($user, 'User.name'),
                        'class' => 'shadow',
-               'restrict' => array('image')
+                       'id' => 'HomeUserImage',
+                       'restrict' => array('image')
                )
        );
-       }
 
        // ファイル情報出力
        echo $upfile->fileInfo($file, $item);
index d9d7fc0..2662819 100644 (file)
@@ -20,8 +20,8 @@ class UpfileHelper extends MediumHelper {
                $args = func_get_args();
 
                // ファイル指定がない場合
-               if (!isset($args[1]) || !isset($args[1][$args[2]])) {
-                       if (isset($args[3]['nodata']) && !empty($args[3]['nodata'])) {
+               if (empty($args[1])) {
+                       if (isset($args[2]['nodata']) && !empty($args[2]['nodata'])) {
                                $data = array(
                                        'id' => 0,
                                        'model' => NULL,
@@ -33,7 +33,7 @@ class UpfileHelper extends MediumHelper {
                                        'alternative' => '',
                                );
 
-                               if ($args[3]['nodata'] == 'image') {
+                               if ($args[2]['nodata'] == 'image') {
                                        $data['dirname'] = 'transfer/img';
                                        $data['basename'] = 'noimage.png';
                                        $data['alternative'] = 'No Image';
@@ -44,7 +44,7 @@ class UpfileHelper extends MediumHelper {
                                return NULL;
                        }
                } else {
-                       $data = $args[1][$args[2]];
+                       $data = $args[1];
                }
 
                // ファイルがある場合、ファイルパスを返す
@@ -54,12 +54,12 @@ class UpfileHelper extends MediumHelper {
                // $pathがfilter/* 指定でファイルがない場合、作成
                } elseif (substr($path, 0, 7) == 'filter/') {
                        require_once(APP.'plugins'.DS.'media'.DS.'libs'.DS.'upfile.php');
-                       $make_result = Upfile::make_version($path, $data['dirname']. DS. $data['basename'], $args[3]);
+                       $make_result = Upfile::make_version($path, $data['dirname']. DS. $data['basename'], $args[2]);
 
                        // cacheを削除して$file読み込み
                        if ($make_result === true) {
                                parent::__destruct();
-                               return self::file($path, $args[1], $args[2], $args[3]);
+                               return self::file($path, $args[1], $args[2]);
                        }
                }
 
index 538aaa4..5df547c 100644 (file)
@@ -20,8 +20,7 @@
 
        $file = $upfile->file(
                'filter/m', 
-               $target_user['Attachment'], 
-               0, 
+               CorePlus::get_value($target_user, 'Attachment.0'),
                array(
                        'model_name' => 'User', 
                        'mime_type' => 'original',
@@ -33,7 +32,7 @@
                $file,
                array(
                        'url' => $url,
-                       'alt' => $target_user['User']['name'],
+                       'alt' => CorePlus::get_value($user, 'User.name'),
                        'class' => 'shadow',
                        'id' => 'HomeUserImage',
                        'restrict' => array('image')
index 40960b4..0108a1f 100644 (file)
@@ -31,8 +31,7 @@ foreach ($systems as $system):
 <?php
        $file = $upfile->file(
                'filter/xxs', 
-               $system['Attachment'], 
-               0, 
+               CorePlus::get_value($system, 'Attachment.0'),
                array(
                        'model_name' => 'System', 
                        'mime_type' => 'original',
index e429aa7..b2e40b1 100644 (file)
@@ -17,8 +17,7 @@
 
        $file = $upfile->file(
                'filter/s', 
-               $system['Attachment'], 
-               0, 
+               CorePlus::get_value($system, 'Attachment.0'),
                array(
                        'model_name' => 'System', 
                        'mime_type' => 'original',
index 925e8a4..129adbd 100644 (file)
@@ -25,8 +25,7 @@ echo $paginator->counter(array(
 <?php
        $file = $upfile->file(
                'filter/xs', 
-               $system['Attachment'], 
-               0, 
+               CorePlus::get_value($system, 'Attachment.0'),
                array(
                        'model_name' => 'System', 
                        'mime_type' => 'original',
index 238fb76..a201325 100644 (file)
@@ -16,8 +16,7 @@
 
        $file = $upfile->file(
                'filter/s', 
-               $system['Attachment'], 
-               0, 
+               CorePlus::get_value($system, 'Attachment.0'),
                array(
                        'model_name' => 'System', 
                        'mime_type' => 'original',
@@ -28,7 +27,7 @@
                $file,
                array(
                        'linkTo' => $url,
-                       'alt' => $system['Attachment'][0]['alternative'],
+                       'alt' => CorePlus::get_value($system, 'Attachment.0.alternative'),
                        'restrict' => array('image'),
                        'htmlAttributes' => array(
                                'target' => '_blank',
index 27d6bd3..df69f0f 100644 (file)
 <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Image'); ?></dt>
 <dd<?php if ($i++ % 2 == 0) echo $class;?>>
 <?php
-       if (isset($target_user['Attachment'][0])) {
-               $img_name = isset($target_user['Attachment'][0]['alternative']) ? $target_user['Attachment'][0]['alternative'] : $target_user['Attachment'][0]['basename']; 
+       $file = $upfile->file(
+               'filter/m', 
+               CorePlus::get_value($target_user, 'Attachment.0'),
+               array(
+                       'model_name' => 'User', 
+                       'mime_type' => 'original',
+                       'nodata' => 'image',
+               )
+       );
 
-               echo $medium->embed($medium->file('filter/s', $target_user['Attachment'][0]));
-
-       } else {
-               echo "&nbsp;";
-       }
+       echo $medium->embed(
+               $file,
+               array(
+                       'alt' => CorePlus::get_value($user, 'User.name'),
+                       'class' => 'shadow',
+                       'id' => 'HomeUserImage',
+                       'restrict' => array('image')
+               )
+       );
 ?>
 </dd>
 <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>