Skip to content

Commit

Permalink
CCC-83 add phpdoc and bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
fozeek committed Dec 18, 2013
1 parent 231d1b3 commit 72d5ac4
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@
class GalleryAdminController extends AbstractActionController
{

/**
* @var $mediaService Service de l'entity media
*/
protected $mediaService;

/**
* @var $categoryService Service de l'entity category
*/
protected $categoryService;

/**
* liste des médias d'un Média
*
* @return ViewModel Templates de la liste des medias
*/
public function indexAction()
{
$user = $this->zfcUserAuthentication()->getIdentity();
Expand All @@ -36,6 +48,11 @@ public function indexAction()
return new ViewModel(compact('medias', 'categories', 'formMedia', 'formCategory', 'user'));
}

/**
* Création d'un Média
*
* @redirect vers la liste des medias
*/
public function createAction()
{
$form = $this->getServiceLocator()->get('playgroundgallery_media_form');
Expand All @@ -62,6 +79,11 @@ public function createAction()
return $this->redirect()->toRoute('admin/playgroundgallery');
}

/**
* Edition d'un Média
*
* @redirect vers la liste des medias
*/
public function editAction()
{
$mediaId = $this->getEvent()->getRouteMatch()->getParam('mediaId');
Expand Down Expand Up @@ -94,6 +116,11 @@ public function editAction()
return $this->redirect()->toRoute('admin/playgroundgallery');
}

/**
* Vérifie la validité d'une url
*
* @return boolean $headersBool validité de l'url
*/
public function checkValidUrl($url) {
$handle = curl_init($url);

Expand All @@ -112,6 +139,11 @@ public function checkValidUrl($url) {
return $headersBool;
}

/**
* Suppression d'un Média
*
* @redirect vers la liste des medias
*/
public function removeAction() {
$mediaId = $this->getEvent()->getRouteMatch()->getParam('mediaId');
if (!$mediaId) {
Expand All @@ -125,6 +157,11 @@ public function removeAction() {
return $this->redirect()->toRoute('admin/playgroundgallery');
}

/**
* Téléchargement d'un media
*
* @redirect vers la liste des medias
*/
public function downloadAction()
{
$mediaId = $this->getEvent()->getRouteMatch()->getParam('mediaId');
Expand Down Expand Up @@ -161,6 +198,11 @@ public function downloadAction()
return $response;
}

/**
* Creation d'une Categorie
*
* @redirect vers la liste des medias
*/
public function createCategoryAction() {
$form = $this->getServiceLocator()->get('playgroundgallery_category_form');
$form->setAttribute('method', 'post');
Expand All @@ -180,6 +222,11 @@ public function createCategoryAction() {
return $this->redirect()->toRoute('admin/playgroundgallery');
}

/**
* Edition d'une Categorie
*
* @redirect vers la liste des medias
*/
public function editCategoryAction() {
$categoryId = $this->getEvent()->getRouteMatch()->getParam('categoryId');
if (!$categoryId) {
Expand Down Expand Up @@ -211,21 +258,31 @@ public function editCategoryAction() {
return $this->redirect()->toRoute('admin/playgroundgallery');
}

/**
* Suppresion d'une Categorie
*
* @redirect vers la liste des medias
*/
public function removeCategoryAction() {
$categoryId = $this->getEvent()->getRouteMatch()->getParam('categoryId');
if (!$categoryId) {
return $this->redirect()->toRoute('admin/playgroundgallery');
}
$category = $this->getCategoryService()->getCategoryMapper()->findByid($categoryId);

if(count($category->getChildren())==0) {
if(count($category->getChildren())==0 && count($category->getMedias())==0) {
$category = $this->getCategoryService()->getCategoryMapper()->remove($category);
} else {
$this->flashMessenger()->setNamespace('playgroundgallery')->addMessage('Error : you can\'t remove a category who contains one or more categories.');
}
return $this->redirect()->toRoute('admin/playgroundgallery');
}

/**
* Recuperation du Service Category
*
* @return PlaygroundGallery\Service\Category $categoryService
*/
public function getCategoryService()
{
if (!$this->categoryService) {
Expand All @@ -234,6 +291,11 @@ public function getCategoryService()
return $this->categoryService;
}

/**
* Recuperation du Service Media
*
* @return PlaygroundGallery\Service\Media $mediaService
*/
public function getMediaService()
{
if (!$this->mediaService) {
Expand Down
17 changes: 17 additions & 0 deletions src/PlaygroundGallery/Form/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
class Category extends ProvidesEventsForm
{

/**
* @var $serviceManager Service Manager
*/
protected $serviceManager;

public function __construct ($name = null, ServiceManager $sm, Translator $translator)
Expand Down Expand Up @@ -75,6 +78,11 @@ public function __construct ($name = null, ServiceManager $sm, Translator $trans

}

/**
* Récupère la liste des websites
*
* @return array $websitesForm liste des websites
*/
private function getWebsites()
{
$websites = $this->getServiceManager()->get('playgroundcore_website_service')->getWebsiteMapper()->findAll();
Expand All @@ -85,6 +93,11 @@ private function getWebsites()
return $websitesForm;
}

/**
* Récupère la liste des categories
*
* @return array $websitesForm liste des categories
*/
private function getCategories() {
$categories = $this->getServiceManager()->get('playgroundgallery_category_service')->getCategoryMapper()->findBy(array('parent' => null));
$categoriesForm = array();
Expand All @@ -94,6 +107,10 @@ private function getCategories() {
return $categoriesForm;
}

/**
* Récupère la liste des categories enfants d'une categorie
*
*/
private function getChildrenCategories($category, &$categoriesForm, $wave = 1) {

$prefixe = '';
Expand Down
4 changes: 4 additions & 0 deletions src/PlaygroundGallery/Service/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public function edit(array $data, $media)
$form->bind($media);

$form->setData($data);
$media->setDescription($data['description']);
$media->setName($data['name']);
$media->setCredit($data['credit']);
$media->setUrl($data['url']);

if (!$form->isValid()) {
return false;
Expand Down

0 comments on commit 72d5ac4

Please sign in to comment.