|
@@ -1,54 +1,50 @@
|
|
|
<?php
|
|
|
class Gallery {
|
|
|
- public function Index($params) {
|
|
|
- $repo=new AlbumRespository();
|
|
|
+ public function Index(IAlbumRepository $repo) {
|
|
|
$albums=$repo->GetAlbums();
|
|
|
return new View("Gallery/index.view",array("albums"=>$albums));
|
|
|
}
|
|
|
|
|
|
- public function View($params) {
|
|
|
- $album=new Album($params[0],true);
|
|
|
+ public function View($url) {
|
|
|
+ $album=new Album($url,true);
|
|
|
Breadcrumbs::Add($album->AlbumTitle, "");
|
|
|
return new View("Gallery/view.view",array("album"=>$album));
|
|
|
}
|
|
|
|
|
|
- public function Manage($params) {
|
|
|
- $albumRepo=new AlbumRespository();
|
|
|
- $imageRepo=new ImageRepository();
|
|
|
-
|
|
|
+ public function Manage(IAlbumRepository $albumRepo, IImageRepository $imageRepo, $errors) {
|
|
|
$vars=array();
|
|
|
Breadcrumbs::Add("Manage", "");
|
|
|
$vars["albums"]=$albumRepo->GetAlbums(true,true);
|
|
|
- if (isset($params['errors']))
|
|
|
- $vars["errors"]=$params['errors'];
|
|
|
+ if (isset($errors))
|
|
|
+ $vars["errors"]=$errors;
|
|
|
$vars['images']=$imageRepo->GetImagesByAlbum(0);
|
|
|
- if(isset($params['image']))
|
|
|
- $vars['image']=$params['image'];
|
|
|
+ if(isset($image))
|
|
|
+ $vars['image']=$image;
|
|
|
else
|
|
|
$vars['image']=new Image();
|
|
|
return new View("Gallery/manage.view",$vars);
|
|
|
}
|
|
|
|
|
|
- public function Move($params){
|
|
|
- if (!isset($params['moveImages']))
|
|
|
+ public function Move($moveImages, $selected, $selectAlbumNew){
|
|
|
+ if (!isset($moveImages))
|
|
|
return;
|
|
|
//return print_r($params,true);
|
|
|
- foreach ($params['selected'] as $imgId){
|
|
|
+ foreach ($selected as $imgId){
|
|
|
$image=new Image($imgId);
|
|
|
- $image->AlbumId=$params['selectAlbumNew'];
|
|
|
+ $image->AlbumId=$selectAlbumNew;
|
|
|
$image->Save();
|
|
|
}
|
|
|
header("location:/gallery/manage");
|
|
|
}
|
|
|
|
|
|
- public function CreateAlbum($params) {
|
|
|
+ public function CreateAlbum($title,$description) {
|
|
|
Breadcrumbs::Add("Manage", "");
|
|
|
Breadcrumbs::Add("Create Album", "");
|
|
|
$album=new Album();
|
|
|
- if (isset($params['title']))
|
|
|
- $album->AlbumTitle=$params['title'];
|
|
|
- if (isset($params['description']))
|
|
|
- $album->AlbumDescription=$params['description'];
|
|
|
+ if (isset($title))
|
|
|
+ $album->AlbumTitle=$title;
|
|
|
+ if (isset($description))
|
|
|
+ $album->AlbumDescription=$description;
|
|
|
if ($album->AlbumTitle!="" && $album->AlbumDescription!=""){
|
|
|
$album->Save();
|
|
|
header("location:/gallery/manage");
|
|
@@ -57,7 +53,7 @@ class Gallery {
|
|
|
return new View("Gallery/create_album.view",array("album"=>$album));
|
|
|
}
|
|
|
|
|
|
- public function Upload($params) {
|
|
|
+ public function Upload($imageTitle,$imageDesc) {
|
|
|
if (!isset($_FILES['imageFile'])){
|
|
|
header("location: /gallery/manage/");
|
|
|
return;
|
|
@@ -65,7 +61,7 @@ class Gallery {
|
|
|
$errors=array();
|
|
|
$filename=$_FILES['imageFile']['name'];
|
|
|
$tempFile=$_FILES['imageFile']['tmp_name'];
|
|
|
- if ($params['imageTitle']=="")
|
|
|
+ if ($imageTitle=="")
|
|
|
$errors[]="The image doesn't have a title";
|
|
|
if ($_FILES['imageFile']['error'])
|
|
|
$errors[]=Utils::FileUploadErrorToMessage($_FILES['imageFile']['error']);
|
|
@@ -76,8 +72,8 @@ class Gallery {
|
|
|
$errors[]="File is not an image";
|
|
|
}
|
|
|
$image=new Image($filename,$tempFile);
|
|
|
- $image->ImageTitle=$params['imageTitle'];
|
|
|
- $image->ImageDescription=$params['imageDesc'];
|
|
|
+ $image->ImageTitle=$imageTitle;
|
|
|
+ $image->ImageDescription=$imageDesc;
|
|
|
if (count($errors)==0){
|
|
|
$image->Save();
|
|
|
header("location: /gallery/manage/");
|
|
@@ -86,10 +82,10 @@ class Gallery {
|
|
|
return $this->Manage(array("errors"=>$errors,"image"=>$image));
|
|
|
}
|
|
|
|
|
|
- public function JsonLoadAlbum($params) {
|
|
|
+ public function JsonLoadAlbum($albumId) {
|
|
|
$repo=new ImageRepository();
|
|
|
$json='[';
|
|
|
- $images=$repo->GetImagesByAlbum($params[0]);
|
|
|
+ $images=$repo->GetImagesByAlbum($albumId);
|
|
|
foreach ($images as $image)
|
|
|
$json.='{"ImageId":"'.$image->ImageId.'","ImageTitle":"'.$image->ImageTitle.'","Path":"'.$image->Path.'","ThumbnailPath":"'.$image->ThumbnailPath.'"},';
|
|
|
$json=trim($json,',');
|