Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fd8cda
commit 07ef045
Showing
13 changed files
with
440 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Full Metal Jewelry website | ||
* Copyright (C) 2009 Stichting Lone Wolves | ||
* Written by Sander Marechal <s.marechal@jejik.com> | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
*/ | ||
|
||
/** | ||
* The Images controller | ||
*/ | ||
class ImagesController extends AppController { | ||
|
||
/** @var array The view helpers */ | ||
public $helpers = array('Header', 'Button'); | ||
|
||
/** @var array The components for this controller */ | ||
public $components = array('Auth'); | ||
|
||
/** | ||
* Nothing to see here, move along... | ||
* | ||
* @return void | ||
*/ | ||
public function index() | ||
{ | ||
$this->redirect('/'); | ||
} | ||
|
||
public function admin_index() | ||
{ | ||
$this->pagination = array( | ||
'conditions' => array('Image.user_id' => $this->Auth->user('id')), | ||
'order' => array('Image.filename' => 'ASC'), | ||
); | ||
|
||
$this->Image->recursive = 0; | ||
$images = $this->paginate(); | ||
foreach ($images as &$image) { | ||
$this->Image->id = $image['Image']['id']; | ||
$this->Image->thumb(170); | ||
$image['Image']['thumb'] = '/img/products/' . $this->Image->getPath(170); | ||
} | ||
|
||
$this->set(compact('images')); | ||
} | ||
|
||
public function admin_delete($id = null) | ||
{ | ||
if (!$id) { | ||
$this->Session->setFlash(__('Invalid id for image', true)); | ||
$this->redirect(array('action'=>'index')); | ||
} | ||
if ($this->Image->delete($id)) { | ||
$this->Session->setFlash(__('Image deleted', true)); | ||
$this->redirect(array('action'=>'index')); | ||
} | ||
$this->Session->setFlash(__('Image was not deleted', true)); | ||
$this->redirect(array('action' => 'index')); | ||
} | ||
|
||
/** | ||
* Upload an image | ||
*/ | ||
function admin_upload() | ||
{ | ||
if (empty($this->data)) { | ||
$this->redirect(array('action' => 'admin_index')); | ||
} | ||
|
||
$this->Image->create(); | ||
$this->Image->save(array('user_id' => $this->Auth->user('id'))); | ||
|
||
$errors = array(); | ||
if (!$this->Image->upload($this->data['image'], $errors)) { | ||
$this->Session->setFlash(implode('<br />', $errors)); | ||
$this->Image->delete(); | ||
} | ||
|
||
$this->Session->setFlash('Image uploaded succesfully'); | ||
$this->redirect(array('action' => 'admin_index')); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.