commit 29186d1b02e600bbd04a6d29a6d758856a13c612
Author: spyder1211 <soichiro.yano.g@gmail.com>
Date:   Mon Feb 8 16:03:24 2016 +0900

    delete Image MVC

diff --git a/app/Controller/ImagesController.php b/app/Controller/ImagesController.php
deleted file mode 100644
index 0a74434..0000000
--- a/app/Controller/ImagesController.php
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-App::uses('AppController', 'Controller');
-/**
- * Images Controller
- *
- * @property Image $Image
- * @property PaginatorComponent $Paginator
- */
-
-
-
-
-class ImagesController extends AppController {
-
-	//$usesの指定は最初大文字！！！
-	public $uses = array('Image');
-	//public $helpers = array('UploadPack.Upload');	
-	public $layout = 'image_bootstrap3';
-	
-//	public function isAuthorized($user) {
-//		// 登録済ユーザーは投稿できる
-//		if ($this->action === 'add') {
-//			return true;
-//		}
-//
-//		// 投稿のオーナーは編集や削除ができる
-//		if (in_array($this->action, array('edit', 'delete'))) {
-//			$postId = (int) $this->request->params['pass'][0];
-//			if ($this->Post->isOwnedBy($postId, $user['id'])) {
-//				return true;
-//			}
-//		}
-//
-//		return parent::isAuthorized($user);
-//	}	
-	
-/**
- * Components
- *
- * @var array
- */
-	//public $components = array('Flash');
-	public $components = array('Search.Prg');
-	public $presetVars = true;
-
-/**
- * index method
- *
- * @return void
- */
-	public function index() {
-		$this->Image->recursive = 0;
-		$this->Prg->commonProcess();
-		$this->paginate = array(
-					'conditions' => $this->Image->parseCriteria($this->passedArgs),
-						);
-		//並び替え 以下のURLになる/images/index/sort:sort_order/direction:asc
-		$this->Paginator->settings['order'] = 'Image.sort_order asc';
-		//	$this->set('posts', $this->paginate());
-		$this->set('images', $this->Paginator->paginate());
-	
-	}
-
-/**
- * view method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
-	public function view($id = null) {
-		if (!$this->Image->exists($id)) {
-			throw new NotFoundException(__('Invalid image'));
-		}
-		$options = array('conditions' => array('Image.' . $this->Image->primaryKey => $id));
-		$this->set('image', $this->Image->find('first', $options));
-	}
-
-/**
- * add method
- *
- * @return void
- */
-	public function add() {
-		if ($this->request->is('post')) {
-			$this->Image->create();
-			//sort_orderにデータ数プラス１の番号を振る
-			$count = $this->Image->find('count');
-			$count = $count + 1;
-			$this->request->data['Image']['sort_order'] = $count;
-						
-			if ($this->Image->save($this->request->data)) {
-				$this->Flash->success(__('The image has been saved.'));
-				return $this->redirect(array('action' => 'index'));
-			} else {
-				$this->Flash->error(__('The image could not be saved. Please, try again.'));
-			}
-		}
-	}
-
-/**
- * edit method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
-	public function edit($id = null) {
-		if (!$this->Image->exists($id)) {
-			throw new NotFoundException(__('Invalid image'));
-		}
-		if ($this->request->is(array('post', 'put'))) {
-			if ($this->Image->save($this->request->data)) {
-				$this->Flash->success(__('The image has been saved.'));
-				return $this->redirect(array('action' => 'index'));
-			} else {
-				$this->Flash->error(__('The image could not be saved. Please, try again.'));
-			}
-		} else {
-			$options = array('conditions' => array('Image.' . $this->Image->primaryKey => $id));
-			$this->request->data = $this->Image->find('first', $options);
-		}
-	}
-
-/**
- * delete method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
-	public function delete($id = null) {
-		$this->Image->id = $id;
-		if (!$this->Image->exists()) {
-			throw new NotFoundException(__('Invalid image'));
-		}
-		$this->request->allowMethod('post', 'delete');
-		//		if ($this->Image->delete()) {
-		//		データを削除せず、ステータスを２にする
-		if ($this->Image->saveField('status',2)) {
-			$this->Flash->success(__('The image has been deleted.'));
-		} else {
-			$this->Flash->error(__('The image could not be deleted. Please, try again.'));
-		}
-		return $this->redirect(array('action' => 'index'));
-	}
-/**
-  * compdelete method
-  *
-  * @throws NotFoundException
-  * @param string $id
-  * @return void
-  */
- 	// public function compdelete($id = null) {
- 	// 	$this->Image->id = $id;
- 	// 	if (!$this->Image->exists()) {
- 	// 		throw new NotFoundException(__('Invalid image'));
- 	// 	}
- 	// 	$this->request->allowMethod('post', 'delete');
- 	// 			if ($this->Image->delete()) {
- 	// 		$this->Flash->success(__('The image has been deleted.'));
- 	// 	} else {
- 	// 		$this->Flash->error(__('The image could not be deleted. Please, try again.'));
- 	// 	}
- 	// 	return $this->redirect(array('action' => 'index'));
- 	// }
-
-	public function ajax_sort_change()
-	{
-		$this->autoRender=false;
-		$ids = $this->request->data['id'];
-		for($i=0;$i<count($ids);$i++)
-		{
-			$this->Image->id = $ids[$i];
-			$this->Image->saveField('sort_order', ($i+1));
-		}
-	}
-}
diff --git a/app/Model/Image.php b/app/Model/Image.php
deleted file mode 100644
index 592bd19..0000000
--- a/app/Model/Image.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-App::uses('AppModel', 'Model');
-/**
- * Image Model
- *
- */
-class Image extends AppModel {
-
-/**
- * Validation rules
- *
- * @var array
- */
-	public $validate = array(
-		'name' => array(
-			'notBlank' => array(
-				'rule' => array('notBlank'),
-				//'message' => 'Your custom message here',
-				//'allowEmpty' => false,
-				//'required' => false,
-				//'last' => false, // Stop validation after this rule
-				//'on' => 'create', // Limit validation to 'create' or 'update' operations
-			),
-		),
-	);
-
-    public $actsAs = array(
-	'UploadPack.Upload' => array(
-		'image' => array(     //☆ここでは、"_file_name"を除いたカラム名を書く
-			'quality' => 95,   //☆画質指定、デフォルトでは75
-			'path' => ':webroot/upload/:model/:id/:hash.:extension',
-			'styles' => array(
-				'thumb' => '85x85'  //☆リサイズしたいサイズを書く
-			)
-		)
-	),
-	'Search.Searchable'
-	);
-
-	public $filterArgs = array(
-		'name' => array('type' => 'query', 'method' => 'orConditions'),
-		'status' => array('type' => 'value'),
-	);
-
-	public function orConditions( $data = array() ) {
-		$filter = $data['name'];
-		$cond = array(
-			'OR' => array(
-				$this->alias . '.name LIKE' => '%' . $filter . '%',
-			),
-		);
-		return $cond;
-	}
-
-
-}
diff --git a/app/View/Images/add.ctp b/app/View/Images/add.ctp
deleted file mode 100644
index e300060..0000000
--- a/app/View/Images/add.ctp
+++ /dev/null
@@ -1,17 +0,0 @@
-<div class="form">
-<?php  echo $this->Form->create('Image',array('type'=>'file')); ?> 
-	<fieldset>
-		<legend><?php  echo __('Add Image'); ?></legend>
-		<?php echo $this->Form->input('name'); ?>
-		<?php echo $this->Form->input('image',array('type'=>'file','label'=>'画像')); ?>
-	</fieldset>
-<?php  echo $this->Form->end(__('Submit')); ?>
-</div>
-<?php  echo $this->element('admin_action');?>
-<div class="actions">
-	<h3><?php  echo __('Actions'); ?></h3>
-	<ul>
-
-		<li><?php  echo $this->Html->link(__('List Images'), array('action' => 'index')); ?></li>
-	</ul>
-</div>
diff --git a/app/View/Images/edit.ctp b/app/View/Images/edit.ctp
deleted file mode 100644
index 88c2bde..0000000
--- a/app/View/Images/edit.ctp
+++ /dev/null
@@ -1,27 +0,0 @@
-<div class="images form">
-<?php //echo $this->Form->create('Image'); ?>
-<?php echo $this->Form->create('Image',array('type'=>'file')); ?>
-	<fieldset>
-		<legend><?php echo __('Edit Image'); ?></legend>
-	<?php
-		echo $this->Form->input('id');
-		echo $this->Form->input('name');
-		echo $this->Form->input('image_file_name');
-		echo $this->Form->input('image',array('type'=>'file','label'=>'画像')); 	
-		echo $this->Form->input('status', array(
-			'type' => 'select', 
-		    'options' => array('1' => 'Active', '0' => 'Expire')
-		));
-	?>
-	</fieldset>
-<?php echo $this->Form->end(__('Submit')); ?>
-</div>
-<?php  echo $this->element('admin_action'); ?>
-<div class="actions">
-	<h3><?php echo __('Actions'); ?></h3>
-	<ul>
-
-		<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>
-		<li><?php echo $this->Html->link(__('List Images'), array('action' => 'index')); ?></li>
-	</ul>
-</div>
diff --git a/app/View/Images/index.ctp b/app/View/Images/index.ctp
deleted file mode 100644
index 36723ae..0000000
--- a/app/View/Images/index.ctp
+++ /dev/null
@@ -1,110 +0,0 @@
-<script type="text/javascript">
-// When the document is ready set up our sortable with it's inherant function(s) 
-	$(document).ready(function() {  
-			  $("#sortable tbody").sortable({      
-					update : function () {          
-						  var order = $('#sortable tbody').sortable('toArray');          
-							$.post("/images/ajax_sort_change/",{            
-						   		id:order
-						},function(data){
-					});
-	   			}
-		  });
-	});
-</script>
-
-<div class="images index">
-	<h2><?php echo __('Images'); ?></h2>
-   
-		<div class="section form_search">
-						<?php echo $this->Form->create('Image', array( 
-							'novalidate' => true,
-							'inputDefaults' => array(
-								'div' => 'form-group',
-								'wrapInput' => false,
-								'class' => 'form-control'
-								),				
-							'div' =>false,
-							'class' => 'well well-sm',
-							'url' => array_merge(array(
-							'action' => 'index'),
-									$this->params['pass']) )); ?>
-					<fieldset>
-						<legend>検索</legend>			
-						<?php echo $this->Form->input('name', array(
-										'legend' => false,
-										'placeholder' => '例）kkk',
-										'label' => '名前'
-										)
-									); ?>
-						<?php echo $this->Form->input('type', array(
-										'label'=>'ステータス',
-										'legend' => false,
-										'type'=>'select',
-										'options'=>array(
-								 					'0' => 'expire', '1' => 'active' ,'2'=>'削除済み'
-													),
-										'empty'=>'選択してください')); ?>
-							<?php echo $this->Form->submit('検索', array('div' => false,'class' => 'btn btn-danger')); ?>	
-							<?php echo $this->Form->end(); ?>
-					</fieldset>
-					</div>
-
-<?php echo $this->Paginator->counter(array('format' => __('全{:count}件中 {:start}-{:end}件を表示'))); ?>
-
-
-				<table id="sortable" cellpadding="0" cellspacing="0" class="table table-striped">
-				<thead>
-				<tr>
-						<th><?php echo $this->Paginator->sort('id'); ?></th>
-						<th><?php echo $this->Paginator->sort('name'); ?></th>
-						<th><?php echo $this->Paginator->sort('image_file_name'); ?></th>
-						<th><?php echo $this->Paginator->sort('status'); ?></th>
-						<th><?php echo $this->Paginator->sort('created'); ?></th>
-						<th><?php echo $this->Paginator->sort('updated'); ?></th>
-						<th class="actions"><?php echo __('Actions'); ?></th>
-				</tr>
-				</thead>
-				<tbody>
-				<?php foreach ($images as $image): ?>
-				<tr id="<?php echo $image['Image']['id']?>">
-					<td><span class="glyphicon glyphicon-list"></span></td>
-					<td><?php echo h($image['Image']['name']); ?>&nbsp;</td>
-					<td><?php echo h($image['Image']['image_file_name']); ?>&nbsp;<?php echo $this->upload->uploadImage($image, 'Image.image', array('style' => 'thumb')); ?></td>
-					<td><?php echo h($image['Image']['status']); ?>&nbsp;</td>
-					<td><?php echo h($image['Image']['created']); ?>&nbsp;</td>
-					<td><?php echo h($image['Image']['updated']); ?>&nbsp;</td>
-				<td class="actions">
-					<?php echo $this->Html->link(__('View'), array('action' => 'view', $image['Image']['id']),array('class'=>'btn btn-primary')); ?>
-					<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $image['Image']['id']),array('class'=>'btn btn-primary')); ?>
-					<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $image['Image']['id']),array('class'=>'btn btn-primary','confirm' => __('削除しますか?', $image['Image']['id']))); ?>
-					<?php echo $this->Form->postLink(__('抹消'), array('action' => 'compdelete', $image['Image']['id']),array('class'=>'btn btn-danger-outline','confirm' => __('完全に抹消されます。よろしいすか?', $image['Image']['id']))); ?>
-				</td>
-			</tr>
-		<?php endforeach; ?>
-			</tbody>
-			</table>
-			<p>
-			<?php
-			echo $this->Paginator->counter(array(
-				'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
-			));
-			?>	</p>
-			<div class="paging">
-			<nav>
-			<ul class="pager">
-			<?php
-				echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
-				echo $this->Paginator->numbers(array('separator' => ''));
-				echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
-			?>
-			</ul>
-			</nav>
-			</div>
-		</div>
-<!--		<div class="actions">
-			<h3><?php echo __('Actions'); ?></h3>
-			<ul>
-				<li><?php echo $this->Html->link(__('New Image'), array('action' => 'add'),array('class'=>'btn btn-warning')); ?></li>
-			</ul>
-		</div>-->
diff --git a/app/View/Images/view.ctp b/app/View/Images/view.ctp
deleted file mode 100644
index 893bb22..0000000
--- a/app/View/Images/view.ctp
+++ /dev/null
@@ -1,44 +0,0 @@
-<div class="images view">
-<h2><?php echo __('Image'); ?></h2>
-	<dl>
-		<dt><?php echo __('Id'); ?></dt>
-		<dd>
-			<?php echo h($image['Image']['id']); ?>
-			&nbsp;
-		</dd>
-		<dt><?php echo __('Name'); ?></dt>
-		<dd>
-			<?php echo h($image['Image']['name']); ?>
-			&nbsp;
-		</dd>
-		<dt><?php echo __('Image File Name'); ?></dt>
-		<dd>
-			<?php echo h($image['Image']['image_file_name']); ?>
-			&nbsp;
-		</dd>
-		<dt><?php echo __('Status'); ?></dt>
-		<dd>
-			<?php echo h($image['Image']['status']); ?>
-			&nbsp;
-		</dd>
-		<dt><?php echo __('Created'); ?></dt>
-		<dd>
-			<?php echo h($image['Image']['created']); ?>
-			&nbsp;
-		</dd>
-		<dt><?php echo __('Updated'); ?></dt>
-		<dd>
-			<?php echo h($image['Image']['updated']); ?>
-			&nbsp;
-		</dd>
-	</dl>
-</div>
-<div class="actions">
-	<h3><?php echo __('Actions'); ?></h3>
-	<ul>
-		<li><?php echo $this->Html->link(__('Edit Image'), array('action' => 'edit', $image['Image']['id'])); ?> </li>
-		<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>
-		<li><?php echo $this->Html->link(__('List Images'), array('action' => 'index')); ?> </li>
-		<li><?php echo $this->Html->link(__('New Image'), array('action' => 'add')); ?> </li>
-	</ul>
-</div>
