リビジョン dd7691f4
app/Model/Image.php | ||
---|---|---|
1 |
<?php |
|
2 |
App::uses('AppModel', 'Model'); |
|
3 |
/** |
|
4 |
* Image Model |
|
5 |
* |
|
6 |
*/ |
|
7 |
class Image extends AppModel { |
|
8 |
|
|
9 |
/** |
|
10 |
* Validation rules |
|
11 |
* |
|
12 |
* @var array |
|
13 |
*/ |
|
14 |
public $validate = array( |
|
15 |
'name' => array( |
|
16 |
'notBlank' => array( |
|
17 |
'rule' => array('notBlank'), |
|
18 |
//'message' => 'Your custom message here', |
|
19 |
//'allowEmpty' => false, |
|
20 |
//'required' => false, |
|
21 |
//'last' => false, // Stop validation after this rule |
|
22 |
//'on' => 'create', // Limit validation to 'create' or 'update' operations |
|
23 |
), |
|
24 |
), |
|
25 |
); |
|
26 |
|
|
27 |
public $actsAs = array( |
|
28 |
'UploadPack.Upload' => array( |
|
29 |
'image' => array( //☆ここでは、"_file_name"を除いたカラム名を書く |
|
30 |
'quality' => 95, //☆画質指定、デフォルトでは75 |
|
31 |
'path' => ':webroot/upload/:model/:id/:hash.:extension', |
|
32 |
'styles' => array( |
|
33 |
'thumb' => '85x85' //☆リサイズしたいサイズを書く |
|
34 |
) |
|
35 |
) |
|
36 |
), |
|
37 |
'Search.Searchable' |
|
38 |
); |
|
39 |
|
|
40 |
public $filterArgs = array( |
|
41 |
'name' => array('type' => 'query', 'method' => 'orConditions'), |
|
42 |
'status' => array('type' => 'value'), |
|
43 |
); |
|
44 |
|
|
45 |
public function orConditions( $data = array() ) { |
|
46 |
$filter = $data['name']; |
|
47 |
$cond = array( |
|
48 |
'OR' => array( |
|
49 |
$this->alias . '.name LIKE' => '%' . $filter . '%', |
|
50 |
), |
|
51 |
); |
|
52 |
return $cond; |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
} |
app/View/Images/add.ctp | ||
---|---|---|
1 |
<div class="form"> |
|
2 |
<?php echo $this->Form->create('Image',array('type'=>'file')); ?> |
|
3 |
<fieldset> |
|
4 |
<legend><?php echo __('Add Image'); ?></legend> |
|
5 |
<?php echo $this->Form->input('name'); ?> |
|
6 |
<?php echo $this->Form->input('image',array('type'=>'file','label'=>'画像')); ?> |
|
7 |
</fieldset> |
|
8 |
<?php echo $this->Form->end(__('Submit')); ?> |
|
9 |
</div> |
|
10 |
<?php echo $this->element('admin_action');?> |
|
11 |
<div class="actions"> |
|
12 |
<h3><?php echo __('Actions'); ?></h3> |
|
13 |
<ul> |
|
14 |
|
|
15 |
<li><?php echo $this->Html->link(__('List Images'), array('action' => 'index')); ?></li> |
|
16 |
</ul> |
|
17 |
</div> |
app/View/Images/edit.ctp | ||
---|---|---|
1 |
<div class="images form"> |
|
2 |
<?php //echo $this->Form->create('Image'); ?> |
|
3 |
<?php echo $this->Form->create('Image',array('type'=>'file')); ?> |
|
4 |
<fieldset> |
|
5 |
<legend><?php echo __('Edit Image'); ?></legend> |
|
6 |
<?php |
|
7 |
echo $this->Form->input('id'); |
|
8 |
echo $this->Form->input('name'); |
|
9 |
echo $this->Form->input('image_file_name'); |
|
10 |
echo $this->Form->input('image',array('type'=>'file','label'=>'画像')); |
|
11 |
echo $this->Form->input('status', array( |
|
12 |
'type' => 'select', |
|
13 |
'options' => array('1' => 'Active', '0' => 'Expire') |
|
14 |
)); |
|
15 |
?> |
|
16 |
</fieldset> |
|
17 |
<?php echo $this->Form->end(__('Submit')); ?> |
|
18 |
</div> |
|
19 |
<?php echo $this->element('admin_action'); ?> |
|
20 |
<div class="actions"> |
|
21 |
<h3><?php echo __('Actions'); ?></h3> |
|
22 |
<ul> |
|
23 |
|
|
24 |
<li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('Image.id')), array('confirm' => __('Are you sure you want to delete # %s?', $this->Form->value('Image.id')))); ?></li> |
|
25 |
<li><?php echo $this->Html->link(__('List Images'), array('action' => 'index')); ?></li> |
|
26 |
</ul> |
|
27 |
</div> |
app/View/Images/index.ctp | ||
---|---|---|
1 |
<script type="text/javascript"> |
|
2 |
// When the document is ready set up our sortable with it's inherant function(s) |
|
3 |
$(document).ready(function() { |
|
4 |
$("#sortable tbody").sortable({ |
|
5 |
update : function () { |
|
6 |
var order = $('#sortable tbody').sortable('toArray'); |
|
7 |
$.post("/images/ajax_sort_change/",{ |
|
8 |
id:order |
|
9 |
},function(data){ |
|
10 |
}); |
|
11 |
} |
|
12 |
}); |
|
13 |
}); |
|
14 |
</script> |
|
15 |
|
|
16 |
<div class="images index"> |
|
17 |
<h2><?php echo __('Images'); ?></h2> |
|
18 |
|
|
19 |
<div class="section form_search"> |
|
20 |
<?php echo $this->Form->create('Image', array( |
|
21 |
'novalidate' => true, |
|
22 |
'inputDefaults' => array( |
|
23 |
'div' => 'form-group', |
|
24 |
'wrapInput' => false, |
|
25 |
'class' => 'form-control' |
|
26 |
), |
|
27 |
'div' =>false, |
|
28 |
'class' => 'well well-sm', |
|
29 |
'url' => array_merge(array( |
|
30 |
'action' => 'index'), |
|
31 |
$this->params['pass']) )); ?> |
|
32 |
<fieldset> |
|
33 |
<legend>検索</legend> |
|
34 |
<?php echo $this->Form->input('name', array( |
|
35 |
'legend' => false, |
|
36 |
'placeholder' => '例)kkk', |
|
37 |
'label' => '名前' |
|
38 |
) |
|
39 |
); ?> |
|
40 |
<?php echo $this->Form->input('type', array( |
|
41 |
'label'=>'ステータス', |
|
42 |
'legend' => false, |
|
43 |
'type'=>'select', |
|
44 |
'options'=>array( |
|
45 |
'0' => 'expire', '1' => 'active' ,'2'=>'削除済み' |
|
46 |
), |
|
47 |
'empty'=>'選択してください')); ?> |
|
48 |
<?php echo $this->Form->submit('検索', array('div' => false,'class' => 'btn btn-danger')); ?> |
|
49 |
<?php echo $this->Form->end(); ?> |
|
50 |
</fieldset> |
|
51 |
</div> |
|
52 |
|
|
53 |
<?php echo $this->Paginator->counter(array('format' => __('全{:count}件中 {:start}-{:end}件を表示'))); ?> |
|
54 |
|
|
55 |
|
|
56 |
<table id="sortable" cellpadding="0" cellspacing="0" class="table table-striped"> |
|
57 |
<thead> |
|
58 |
<tr> |
|
59 |
<th><?php echo $this->Paginator->sort('id'); ?></th> |
|
60 |
<th><?php echo $this->Paginator->sort('name'); ?></th> |
|
61 |
<th><?php echo $this->Paginator->sort('image_file_name'); ?></th> |
|
62 |
<th><?php echo $this->Paginator->sort('status'); ?></th> |
|
63 |
<th><?php echo $this->Paginator->sort('created'); ?></th> |
|
64 |
<th><?php echo $this->Paginator->sort('updated'); ?></th> |
|
65 |
<th class="actions"><?php echo __('Actions'); ?></th> |
|
66 |
</tr> |
|
67 |
</thead> |
|
68 |
<tbody> |
|
69 |
<?php foreach ($images as $image): ?> |
|
70 |
<tr id="<?php echo $image['Image']['id']?>"> |
|
71 |
<td><span class="glyphicon glyphicon-list"></span></td> |
|
72 |
<td><?php echo h($image['Image']['name']); ?> </td> |
|
73 |
<td><?php echo h($image['Image']['image_file_name']); ?> <?php echo $this->upload->uploadImage($image, 'Image.image', array('style' => 'thumb')); ?></td> |
|
74 |
<td><?php echo h($image['Image']['status']); ?> </td> |
|
75 |
<td><?php echo h($image['Image']['created']); ?> </td> |
|
76 |
<td><?php echo h($image['Image']['updated']); ?> </td> |
|
77 |
<td class="actions"> |
|
78 |
<?php echo $this->Html->link(__('View'), array('action' => 'view', $image['Image']['id']),array('class'=>'btn btn-primary')); ?> |
|
79 |
<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $image['Image']['id']),array('class'=>'btn btn-primary')); ?> |
|
80 |
<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $image['Image']['id']),array('class'=>'btn btn-primary','confirm' => __('削除しますか?', $image['Image']['id']))); ?> |
|
81 |
<?php echo $this->Form->postLink(__('抹消'), array('action' => 'compdelete', $image['Image']['id']),array('class'=>'btn btn-danger-outline','confirm' => __('完全に抹消されます。よろしいすか?', $image['Image']['id']))); ?> |
|
82 |
</td> |
|
83 |
</tr> |
|
84 |
<?php endforeach; ?> |
|
85 |
</tbody> |
|
86 |
</table> |
|
87 |
<p> |
|
88 |
<?php |
|
89 |
echo $this->Paginator->counter(array( |
|
90 |
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') |
|
91 |
)); |
|
92 |
?> </p> |
|
93 |
<div class="paging"> |
|
94 |
<nav> |
|
95 |
<ul class="pager"> |
|
96 |
<?php |
|
97 |
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled')); |
|
98 |
echo $this->Paginator->numbers(array('separator' => '')); |
|
99 |
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled')); |
|
100 |
?> |
|
101 |
</ul> |
|
102 |
</nav> |
|
103 |
</div> |
|
104 |
</div> |
|
105 |
<!-- <div class="actions"> |
|
106 |
<h3><?php echo __('Actions'); ?></h3> |
|
107 |
<ul> |
|
108 |
<li><?php echo $this->Html->link(__('New Image'), array('action' => 'add'),array('class'=>'btn btn-warning')); ?></li> |
|
109 |
</ul> |
|
110 |
</div>--> |
app/View/Images/view.ctp | ||
---|---|---|
1 |
<div class="images view"> |
|
2 |
<h2><?php echo __('Image'); ?></h2> |
|
3 |
<dl> |
|
4 |
<dt><?php echo __('Id'); ?></dt> |
|
5 |
<dd> |
|
6 |
<?php echo h($image['Image']['id']); ?> |
|
7 |
|
|
8 |
</dd> |
|
9 |
<dt><?php echo __('Name'); ?></dt> |
|
10 |
<dd> |
|
11 |
<?php echo h($image['Image']['name']); ?> |
|
12 |
|
|
13 |
</dd> |
|
14 |
<dt><?php echo __('Image File Name'); ?></dt> |
|
15 |
<dd> |
|
16 |
<?php echo h($image['Image']['image_file_name']); ?> |
|
17 |
|
|
18 |
</dd> |
|
19 |
<dt><?php echo __('Status'); ?></dt> |
|
20 |
<dd> |
|
21 |
<?php echo h($image['Image']['status']); ?> |
|
22 |
|
|
23 |
</dd> |
|
24 |
<dt><?php echo __('Created'); ?></dt> |
|
25 |
<dd> |
|
26 |
<?php echo h($image['Image']['created']); ?> |
|
27 |
|
|
28 |
</dd> |
|
29 |
<dt><?php echo __('Updated'); ?></dt> |
|
30 |
<dd> |
|
31 |
<?php echo h($image['Image']['updated']); ?> |
|
32 |
|
|
33 |
</dd> |
|
34 |
</dl> |
|
35 |
</div> |
|
36 |
<div class="actions"> |
|
37 |
<h3><?php echo __('Actions'); ?></h3> |
|
38 |
<ul> |
|
39 |
<li><?php echo $this->Html->link(__('Edit Image'), array('action' => 'edit', $image['Image']['id'])); ?> </li> |
|
40 |
<li><?php echo $this->Form->postLink(__('Delete Image'), array('action' => 'delete', $image['Image']['id']), array('confirm' => __('Are you sure you want to delete # %s?', $image['Image']['id']))); ?> </li> |
|
41 |
<li><?php echo $this->Html->link(__('List Images'), array('action' => 'index')); ?> </li> |
|
42 |
<li><?php echo $this->Html->link(__('New Image'), array('action' => 'add')); ?> </li> |
|
43 |
</ul> |
|
44 |
</div> |
他の形式にエクスポート: Unified diff