diff --git a/config/module.config.php b/config/module.config.php index daabadb..dc3e843 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -159,4 +159,5 @@ ), ), ), + 'autorize_user' => true, ); \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 735143d..7c4e6db 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,7 @@ - ./tests/PlaygroundGallery + ./tests/PlaygroundGalleryTest diff --git a/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php b/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php index 8191fd2..5e8d2f0 100644 --- a/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php +++ b/src/PlaygroundGallery/Controller/Admin/GalleryAdminController.php @@ -32,7 +32,14 @@ class GalleryAdminController extends AbstractActionController */ public function indexAction() { - $user = $this->zfcUserAuthentication()->getIdentity(); + $config = $this->getServiceLocator()->get('Config'); + if(!array_key_exists('autorize_user', $config) || !$config['autorize_user']) { + $user = null; + } + else { + $user = $this->zfcUserAuthentication()->getIdentity(); + } + $categories = $this->getCategoryService()->getCategoryMapper()->findBy(array('parent' => null)); $medias = $this->getMediaService()->getMediaMapper()->findAll(); diff --git a/src/PlaygroundGallery/Form/Category.php b/src/PlaygroundGallery/Form/Category.php index aeead57..346e2d9 100644 --- a/src/PlaygroundGallery/Form/Category.php +++ b/src/PlaygroundGallery/Form/Category.php @@ -85,6 +85,7 @@ public function __construct ($name = null, ServiceManager $sm, Translator $trans */ private function getWebsites() { + var_dump('hello'); $websites = $this->getServiceManager()->get('playgroundcore_website_service')->getWebsiteMapper()->findAll(); $websitesForm = array(); foreach ($websites as $website) { diff --git a/src/PlaygroundGallery/Form/Media.php b/src/PlaygroundGallery/Form/Media.php index 0f60f69..9e2922d 100644 --- a/src/PlaygroundGallery/Form/Media.php +++ b/src/PlaygroundGallery/Form/Media.php @@ -12,6 +12,7 @@ class Media extends ProvidesEventsForm { protected $serviceManager; + protected $categoryService; public function __construct ($name = null, ServiceManager $sm, Translator $translator) { @@ -127,7 +128,7 @@ public function __construct ($name = null, ServiceManager $sm, Translator $trans } private function getCategories() { - $categories = $this->getServiceManager()->get('playgroundgallery_category_service')->getCategoryMapper()->findBy(array('parent' => null)); + $categories = $this->getCategoryService()->getCategoryMapper()->findBy(array('parent' => null)); $categoriesForm = array(); foreach ($categories as $category) { $this->getChildrenCategories($category, $categoriesForm); @@ -171,4 +172,31 @@ public function setServiceManager (ServiceManager $serviceManager) return $this; } + /** + * Retrieve category service instance + * + * @return CategoryService + */ + public function getCategoryService () + { + if (null === $this->categoryService) { + $this->categoryService = $this->getServiceManager()->get('playgroundgallery_category_service'); + } + + return $this->categoryService; + } + + /** + * Set service category instance + * + * @param ServiceManager $categoryService + * @return this + */ + public function setCategoryService ($categoryService) + { + $this->categoryService = $categoryService; + + return $this; + } + } diff --git a/src/PlaygroundGallery/Service/Category.php b/src/PlaygroundGallery/Service/Category.php index 451849e..637eed9 100644 --- a/src/PlaygroundGallery/Service/Category.php +++ b/src/PlaygroundGallery/Service/Category.php @@ -26,11 +26,6 @@ class Category extends EventProvider implements ServiceManagerAwareInterface */ protected $serviceManager; - /** - * @var UserServiceOptionsInterface - */ - protected $options; - /** * @var categoryForm */ @@ -55,8 +50,9 @@ public function create(array $data) $this->addCategoryParent($category, $data); - - $category = $this->addWebsite($category, $data['websites']); + if(array_key_exists('websites', $data)) { + $category = $this->addWebsite($category, $data['websites']); + } $form->bind($category); $form->setData($data); @@ -148,33 +144,6 @@ public function setCategoryMapper($categoryMapper) return $this; } - /** - * setOptions - * @param ModuleOptions $options - * - * @return PlaygroundGallery\Service\Category $this - */ - public function setOptions(ModuleOptions $options) - { - $this->options = $options; - - return $this; - } - - /** - * getOptions - * - * @return ModuleOptions $optins - */ - public function getOptions() - { - if (!$this->options instanceof ModuleOptions) { - $this->setOptions($this->getServiceManager()->get('playgroundgallery_module_options')); - } - - return $this->options; - } - /** * Retrieve service manager instance * diff --git a/src/PlaygroundGallery/Service/Media.php b/src/PlaygroundGallery/Service/Media.php index 5be2928..8e76217 100644 --- a/src/PlaygroundGallery/Service/Media.php +++ b/src/PlaygroundGallery/Service/Media.php @@ -127,7 +127,6 @@ public function getMediaMapper() if (null === $this->mediaMapper) { $this->mediaMapper = $this->getServiceManager()->get('playgroundgallery_media_mapper'); } - return $this->mediaMapper; } @@ -216,7 +215,7 @@ public function getCategoryMapper() */ public function setCategoryMapper($categoryMapper) { - $this->categoryMapper = $categoryMappers; + $this->categoryMapper = $categoryMapper; return $this; } diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php new file mode 100644 index 0000000..cf7ebc7 --- /dev/null +++ b/tests/Bootstrap.php @@ -0,0 +1,122 @@ + array( + 'module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths), + ), + ); + + $config = ArrayUtils::merge($baseConfig, $testConfig); + + $serviceManager = new ServiceManager(new ServiceManagerConfig()); + $serviceManager->setService('ApplicationConfig', $config); + $serviceManager->get('ModuleManager')->loadModules(); + + static::$serviceManager = $serviceManager; + + static::$config = $config; + + // disable FirePHP for Unit testing + //$firephp = \FirePHP::getInstance(true); + //$firephp->setEnabled(false); + } + + public static function getServiceManager() + { + return static::$serviceManager; + } + + public static function getConfig() + { + return static::$config; + } + + + + protected static function initAutoloader() + { + $vendorPath = static::findParentPath('vendor'); + + if (is_readable($vendorPath . '/autoload.php')) { + $loader = include $vendorPath . '/autoload.php'; + } else { + $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false)); + + if (!$zf2Path) { + throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); + } + + include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; + + } + + AutoloaderFactory::factory(array( + 'Zend\Loader\StandardAutoloader' => array( + 'autoregister_zf' => true, + 'namespaces' => array( + __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, + ), + ), + )); + } + + protected static function findParentPath($path) + { + $dir = __DIR__; + $previousDir = '.'; + while (!is_dir($dir . '/' . $path)) { + $dir = dirname($dir); + if ($previousDir === $dir) return false; + $previousDir = $dir; + } + + return $dir . '/' . $path; + } +} + +Bootstrap::init(); + +// let's avoid session_start(): Cannot send session cookie - headers already sent by +ob_start(); diff --git a/tests/PlaygroundGalleryTest/Mapper/CategoryTest.php b/tests/PlaygroundGalleryTest/Mapper/CategoryTest.php new file mode 100644 index 0000000..9316b86 --- /dev/null +++ b/tests/PlaygroundGalleryTest/Mapper/CategoryTest.php @@ -0,0 +1,98 @@ +sm = Bootstrap::getServiceManager(); + $this->em = $this->sm->get('doctrine.entitymanager.orm_default'); + $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em); + $classes = $this->em->getMetadataFactory()->getAllMetadata(); + $tool->dropSchema($classes); + $tool->createSchema($classes); + + $this->categoryData = array( + 'name' => 'CeciEstUnTitre', + ); + + parent::setUp(); + } + + public function testCanInsertNewRecord() + { + $category = new CategoryEntity(); + $category->populate($this->categoryData); + + // save data + $this->em->persist($category); + $this->em->flush(); + + $this->assertEquals($this->categoryData['name'], $category->getName()); + + return $category->getId(); + } + + /** + * @depends testCanInsertNewRecord + */ + public function testCanUpdateInsertedRecord($id) + { + $data = array( + 'id' => $id + ); + $category = $this->em->getRepository('PlaygroundGallery\Entity\Category')->find($id); + $this->assertInstanceOf('PlaygroundGallery\Entity\Category', $category); + $this->assertEquals($this->categoryData['name'], $category->getName()); + + $category->populate($data); + $this->em->flush(); + + $this->assertEquals($this->categoryData['name'], $category->getName()); + } + + /** + * @depends testCanInsertNewRecord + */ + public function testCanRemoveInsertedRecord($id) + { + $category = $this->em->getRepository('PlaygroundGallery\Entity\Category')->find($id); + $this->assertInstanceOf('PlaygroundGallery\Entity\Category', $category); + + $this->em->remove($category); + $this->em->flush(); + + $category = $this->em->getRepository('PlaygroundGallery\Entity\Category')->find($id); + $this->assertEquals(false, $category); + } + + public function tearDown() + { + $dbh = $this->em->getConnection(); + + unset($this->sm); + unset($this->em); + parent::tearDown(); + } +} \ No newline at end of file diff --git a/tests/PlaygroundGalleryTest/Mapper/MediaTest.php b/tests/PlaygroundGalleryTest/Mapper/MediaTest.php new file mode 100644 index 0000000..83e414f --- /dev/null +++ b/tests/PlaygroundGalleryTest/Mapper/MediaTest.php @@ -0,0 +1,107 @@ +sm = Bootstrap::getServiceManager(); + $this->em = $this->sm->get('doctrine.entitymanager.orm_default'); + $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em); + $classes = $this->em->getMetadataFactory()->getAllMetadata(); + $tool->dropSchema($classes); + $tool->createSchema($classes); + + $this->mediaData = array( + 'name' => 'CeciEstUnTitre', + 'credit' => 'CeciEstUnCredit', + 'url' => 'http://lorempixel.com/400/600/sports/2/', + 'description' => 'CeciEstUneDescription', + ); + + parent::setUp(); + } + + public function testCanInsertNewRecord() + { + $media = new MediaEntity(); + $media->populate($this->mediaData); + + // save data + $this->em->persist($media); + $this->em->flush(); + + $this->assertEquals($this->mediaData['name'], $media->getName()); + $this->assertEquals($this->mediaData['credit'], $media->getCredit()); + $this->assertEquals($this->mediaData['url'], $media->getUrl()); + $this->assertEquals($this->mediaData['description'], $media->getDescription()); + + return $media->getId(); + } + + /** + * @depends testCanInsertNewRecord + */ + public function testCanUpdateInsertedRecord($id) + { + $data = array( + 'id' => $id + ); + $media = $this->em->getRepository('PlaygroundGallery\Entity\Media')->find($id); + $this->assertInstanceOf('PlaygroundGallery\Entity\Media', $media); + $this->assertEquals($this->mediaData['name'], $media->getName()); + + $media->populate($data); + $this->em->flush(); + + $this->assertEquals($this->mediaData['name'], $media->getName()); + $this->assertEquals($this->mediaData['credit'], $media->getCredit()); + $this->assertEquals($this->mediaData['url'], $media->getUrl()); + $this->assertEquals($this->mediaData['description'], $media->getDescription()); + } + + /** + * @depends testCanInsertNewRecord + */ + public function testCanRemoveInsertedRecord($id) + { + $media = $this->em->getRepository('PlaygroundGallery\Entity\Media')->find($id); + $this->assertInstanceOf('PlaygroundGallery\Entity\Media', $media); + + $this->em->remove($media); + $this->em->flush(); + + $media = $this->em->getRepository('PlaygroundGallery\Entity\Media')->find($id); + $this->assertEquals(false, $media); + } + + public function tearDown() + { + $dbh = $this->em->getConnection(); + + unset($this->sm); + unset($this->em); + parent::tearDown(); + } +} \ No newline at end of file diff --git a/tests/PlaygroundGalleryTest/Service/CategoryTest.php b/tests/PlaygroundGalleryTest/Service/CategoryTest.php new file mode 100644 index 0000000..358f986 --- /dev/null +++ b/tests/PlaygroundGalleryTest/Service/CategoryTest.php @@ -0,0 +1,108 @@ +categoryData = array( + 'name' => 'CeciEstUnTitre', + ); + parent::setUp(); + } + + public function testCreateTrue() + { + $service = new \PlaygroundGallery\Service\Category(); + $service->setServiceManager(Bootstrap::getServiceManager()); + + $categoryPostUpdate = new CategoryEntity; + $categoryPostUpdate->populate($this->categoryData); + + $mapper = $this->getMockBuilder('PlaygroundGallery\Mapper\Category') + ->disableOriginalConstructor() + ->getMock(); + $mapper->expects($this->any()) + ->method('insert') + ->will($this->returnValue($categoryPostUpdate)); + $mapper->expects($this->any()) + ->method('update') + ->will($this->returnValue($categoryPostUpdate)); + + $form = $this->getMockBuilder('PlaygroundGallery\Form\Category') + ->disableOriginalConstructor() + ->getMock(); + $form->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('setData') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('isValid') + ->will($this->returnValue(true)); + + $service->setCategoryForm($form); + + $service->setCategoryMapper($mapper); + + $this->categoryData['websites'] = array(); + + $category = $service->create($this->categoryData); + + $this->assertEquals($this->categoryData['name'], $category->getName()); + } + + public function testEditTrue() + { + $service = new \PlaygroundGallery\Service\Category(); + $service->setServiceManager(Bootstrap::getServiceManager()); + + $category = new CategoryEntity; + $category->populate($this->categoryData); + + $mapper = $this->getMockBuilder('PlaygroundGallery\Mapper\Category') + ->disableOriginalConstructor() + ->getMock(); + $mapper->expects($this->any()) + ->method('insert') + ->will($this->returnValue($category)); + $mapper->expects($this->any()) + ->method('update') + ->will($this->returnValue($category)); + + $form = $this->getMockBuilder('PlaygroundGallery\Form\Media') + ->disableOriginalConstructor() + ->getMock(); + $form->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('setData') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('isValid') + ->will($this->returnValue(true)); + + $service->setCategoryForm($form); + + $service->setCategoryMapper($mapper); + + $category = $service->edit(array('name' => 'New one'), $category); + + $this->assertNotEquals($category->getName(), $this->categoryData['name']); + } + + +} \ No newline at end of file diff --git a/tests/PlaygroundGalleryTest/Service/MediaTest.php b/tests/PlaygroundGalleryTest/Service/MediaTest.php new file mode 100644 index 0000000..ffd0283 --- /dev/null +++ b/tests/PlaygroundGalleryTest/Service/MediaTest.php @@ -0,0 +1,211 @@ +mediaData = array( + 'name' => 'CeciEstUnTitre', + 'credit' => 'CeciEstUnCredit', + 'url' => 'http://lorempixel.com/400/600/sports/2/', + 'description' => 'CeciEstUneDescription', + 'category' => 1, + ); + parent::setUp(); + } + + public function testCreateTrue() + { + $service = new \PlaygroundGallery\Service\Media(); + $service->setServiceManager(Bootstrap::getServiceManager()); + + $mediaPostUpdate = new MediaEntity; + $mediaPostUpdate->populate($this->mediaData); + + $mapper = $this->getMockBuilder('PlaygroundGallery\Mapper\Media') + ->disableOriginalConstructor() + ->getMock(); + $mapper->expects($this->any()) + ->method('insert') + ->will($this->returnValue($mediaPostUpdate)); + $mapper->expects($this->any()) + ->method('update') + ->will($this->returnValue($mediaPostUpdate)); + + + $category = new CategoryEntity; + $category->populate(array('name'=>'test')); + $mapperCate = $this->getMockBuilder('PlaygroundGallery\Mapper\Category') + ->disableOriginalConstructor() + ->getMock(); + $mapperCate->expects($this->any()) + ->method('findBy') + ->will($this->returnValue($category)); + + $form = $this->getMockBuilder('PlaygroundGallery\Form\Media') + ->disableOriginalConstructor() + ->getMock(); + $form->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('setData') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('isValid') + ->will($this->returnValue(true)); + + $service->setMediaForm($form); + + $service->setMediaMapper($mapper); + $service->setCategoryMapper($mapperCate); + + $media = $service->create($this->mediaData); + + $this->assertEquals($this->mediaData['name'], $media->getName()); + } + + public function testCreateFalse() + { + $service = new \PlaygroundGallery\Service\Media(); + $service->setServiceManager(Bootstrap::getServiceManager()); + + $mediaPostUpdate = new MediaEntity; + $mediaPostUpdate->setName($this->mediaData['name']); + + $mapper = $this->getMockBuilder('PlaygroundGallery\Mapper\Media') + ->disableOriginalConstructor() + ->getMock(); + $mapper->expects($this->any()) + ->method('insert') + ->will($this->returnValue($mediaPostUpdate)); + $mapper->expects($this->any()) + ->method('update') + ->will($this->returnValue($mediaPostUpdate)); + + $category = new CategoryEntity; + $category->populate(array('name'=>'test')); + $mapperCate = $this->getMockBuilder('PlaygroundGallery\Mapper\Category') + ->disableOriginalConstructor() + ->getMock(); + $mapperCate->expects($this->any()) + ->method('findBy') + ->will($this->returnValue($category)); + + $form = $this->getMockBuilder('PlaygroundGallery\Form\Media') + ->disableOriginalConstructor() + ->getMock(); + $form->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('setData') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('isValid') + ->will($this->returnValue(false)); + + $service->setMediaForm($form); + + $service->setMediaMapper($mapper); + $service->setCategoryMapper($mapperCate); + + $media = $service->create($this->mediaData); + + $this->assertFalse($media); + } + + public function testEditTrue() + { + $service = new \PlaygroundGallery\Service\Media(); + $service->setServiceManager(Bootstrap::getServiceManager()); + + $mediaPostUpdate = new MediaEntity; + $mediaPostUpdate->populate($this->mediaData); + + $mapper = $this->getMockBuilder('PlaygroundGallery\Mapper\Media') + ->disableOriginalConstructor() + ->getMock(); + $mapper->expects($this->any()) + ->method('insert') + ->will($this->returnValue($mediaPostUpdate)); + $mapper->expects($this->any()) + ->method('update') + ->will($this->returnValue($mediaPostUpdate)); + + $form = $this->getMockBuilder('PlaygroundGallery\Form\Media') + ->disableOriginalConstructor() + ->getMock(); + $form->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('setData') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('isValid') + ->will($this->returnValue(true)); + + $service->setMediaForm($form); + + $service->setMediaMapper($mapper); + + $media = $service->edit(array('name' => 'New one'), $mediaPostUpdate); + + $this->assertNotEquals($media->getName(), $this->mediaData['name']); + } + + public function testEditFalse() + { + $service = new \PlaygroundGallery\Service\Media(); + $service->setServiceManager(Bootstrap::getServiceManager()); + + $mediaPostUpdate = new MediaEntity; + $mediaPostUpdate->populate($this->mediaData); + + $mapper = $this->getMockBuilder('PlaygroundGallery\Mapper\Media') + ->disableOriginalConstructor() + ->getMock(); + $mapper->expects($this->any()) + ->method('insert') + ->will($this->returnValue($mediaPostUpdate)); + $mapper->expects($this->any()) + ->method('update') + ->will($this->returnValue($mediaPostUpdate)); + + $form = $this->getMockBuilder('PlaygroundGallery\Form\Media') + ->disableOriginalConstructor() + ->getMock(); + $form->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('setData') + ->will($this->returnValue(true)); + $form->expects($this->any()) + ->method('isValid') + ->will($this->returnValue(false)); + + $service->setMediaForm($form); + + $service->setMediaMapper($mapper); + + $media = $service->edit(array('name' => 'New one'), $mediaPostUpdate); + + $this->assertFalse($media); + } +} \ No newline at end of file diff --git a/tests/TestConfig.php b/tests/TestConfig.php new file mode 100644 index 0000000..1d1d618 --- /dev/null +++ b/tests/TestConfig.php @@ -0,0 +1,21 @@ + array( + 'DoctrineModule', + 'DoctrineORMModule', + 'ZfcBase', + 'ZfcUser', + 'PlaygroundCore', + 'PlaygroundGallery', + ), + 'module_listener_options' => array( + 'config_glob_paths' => array( + '../../config/autoload/{,*.}{global,local,testing}.php', + './config/{,*.}{testing}.php', + ), + 'module_paths' => array( + 'module', + 'vendor', + ), + ), +); diff --git a/tests/config/testing.php b/tests/config/testing.php new file mode 100644 index 0000000..1abcf6a --- /dev/null +++ b/tests/config/testing.php @@ -0,0 +1,16 @@ + array( + 'connection' => array( + 'orm_default' => array( + 'driverClass' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver', + 'params' => array( + 'path'=> __DIR__.'/../data/gallery.db', + ) + ) + ) + ), + 'facebook' => array( + 'fb_appid' => 'xxxxxx', + ) +); diff --git a/tests/data/.gitignore b/tests/data/.gitignore new file mode 100644 index 0000000..56f4809 --- /dev/null +++ b/tests/data/.gitignore @@ -0,0 +1 @@ +/design.db diff --git a/tests/data/dummy.txt b/tests/data/dummy.txt new file mode 100644 index 0000000..fb46fa3 --- /dev/null +++ b/tests/data/dummy.txt @@ -0,0 +1 @@ +dummy.txt \ No newline at end of file diff --git a/tests/data/gallery.db b/tests/data/gallery.db new file mode 100644 index 0000000..e1ee34c Binary files /dev/null and b/tests/data/gallery.db differ diff --git a/view/playground-gallery/gallery-admin/index.phtml b/view/playground-gallery/gallery-admin/index.phtml new file mode 100644 index 0000000..c7f4716 --- /dev/null +++ b/view/playground-gallery/gallery-admin/index.phtml @@ -0,0 +1,396 @@ +plugin('translate')->setTranslatorTextDomain('playgroundgallery'); ?> + +flashMessenger()->setNamespace('playgroundgallery')->getMessages() as $message): ?> + translate($message); ?> + + +formCategory; + + // Gestion des droits + $categoriesByUser = $categories; +?> + +translate('Add a Media'); ?> +

translate('Gallery'); ?>

+
+
+ +

+ translate('Add a Category'); ?> +
+
+
+
+ + + +
+
+ + +
+
+ + +
+
+
 
+ 0 ): ?> + + +
+
+

translate('No media found') ?>

+
+
+
+ + getUrl())); + $mime=''; + if($headers) { + foreach ($headers as $value) { + if(preg_match('%^Content-Type:%', $value)) { + if(strpos($value,'image')!==false){ + $mime = 'image'; + } + } + } + } + else { + continue; + } + ?> +
+ + +
+ + + +
+ + + + + +
+ + getUrl())); + $mime=''; + if($headers) { + foreach ($headers as $value) { + if(preg_match('%^Content-Type:%', $value)) { + if(strpos($value,'image')!==false){ + $mime = 'image'; + } + } + } + } + else { + continue; + } + + // calcul pour l'alignement vertical + $margin = 0; + if($mime=='image') { + $size = getimagesize($media->getUrl()); + $height = $size[1]; + if($height<500) { + $margin = (500-$height)/2; + } + } + ?> +
+ + + +
+ +
+ + +
+ +
+ + + + + + getRole()->getRoleId() != 'c_super_admin') { + + + // Pour la création d'une categorie, on ne peut associer que les pays dont nous avons les droits + $websites = array(); + foreach ($user->getWebsites() as $website) { + $websites[$website->getId()] = $website->getName(); + } + $formCategory->get('websites')->setValueOptions($websites); + + } + ?> + bind(new PlaygroundGallery\entity\Category()) ?> + setAttribute('action', $this->url('admin/playgroundgallery/category/create')) ?> + + + + + + +
+
+
\ No newline at end of file