diff --git a/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php b/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php index c940257..c78476c 100644 --- a/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php +++ b/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php @@ -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(); @@ -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'); @@ -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'); @@ -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); @@ -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) { @@ -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'); @@ -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'); @@ -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) { @@ -211,6 +258,11 @@ 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) { @@ -218,7 +270,7 @@ public function removeCategoryAction() { } $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.'); @@ -226,6 +278,11 @@ public function removeCategoryAction() { return $this->redirect()->toRoute('admin/playgroundgallery'); } + /** + * Recuperation du Service Category + * + * @return PlaygroundGallery\Service\Category $categoryService + */ public function getCategoryService() { if (!$this->categoryService) { @@ -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) { diff --git a/src/PlaygroundGallery/Form/Category.php b/src/PlaygroundGallery/Form/Category.php index 34f906e..aeead57 100644 --- a/src/PlaygroundGallery/Form/Category.php +++ b/src/PlaygroundGallery/Form/Category.php @@ -11,6 +11,9 @@ class Category extends ProvidesEventsForm { + /** + * @var $serviceManager Service Manager + */ protected $serviceManager; public function __construct ($name = null, ServiceManager $sm, Translator $translator) @@ -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(); @@ -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(); @@ -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 = ''; diff --git a/src/PlaygroundGallery/Service/Media.php b/src/PlaygroundGallery/Service/Media.php index 6003f0a..20c83e7 100644 --- a/src/PlaygroundGallery/Service/Media.php +++ b/src/PlaygroundGallery/Service/Media.php @@ -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;