diff --git a/.gitattributes b/.gitattributes index 3d18309cf22ebad3965f4cd60e7d756636a89fe5..2d9fd2d2f17d6df133543adc97c80a04f484d24b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1985,6 +1985,7 @@ library/ZendAfi/Filters/Serialize.php -text library/ZendAfi/Filters/WriteSql.php -text library/ZendAfi/Form.php -text library/ZendAfi/Form/Album.php -text +library/ZendAfi/Form/Album/Ressource.php -text library/ZendAfi/Form/Decorator/Ckeditor.php -text library/ZendAfi/Form/Decorator/CochesSuggestion.php -text library/ZendAfi/Form/Decorator/DatePicker.php -text @@ -3645,6 +3646,7 @@ tests/application/modules/admin/controllers/AdminAuthControllerTest.php -text tests/application/modules/admin/controllers/AdminAvisModerationControllerTest.php -text tests/application/modules/admin/controllers/AdminControllerTest.php -text tests/application/modules/admin/controllers/AdminIndexControllerTest.php -text +tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php -text tests/application/modules/admin/controllers/AlbumControllerTest.php -text tests/application/modules/admin/controllers/BibControllerTest.php -text tests/application/modules/admin/controllers/CatalogueControllerTest.php -text diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index fd011801675625f9ceb317d5635ba79d453e06c9..b2fb9c031280f86150a66308b0bfdc4fbdadbc0c 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -219,6 +219,35 @@ class Admin_AlbumController extends Zend_Controller_Action { } + public function addRessourceAction () { + if (null === ($album = Class_Album::find($this->_getParam('id')))) { + $this->_redirect('admin/album'); + return; + } + + $this->view->album = $album; + $ressource = Class_AlbumRessource::newInstance() + ->setAlbum($album); + $form = $this->_ressourceForm($ressource); + + if ($this->_request->isPost() && ($form->isValid($this->_request->getPost()))) { + $ressource->updateAttributes($this->_request->getPost()); + if ($ressource->getAlbum()->save() + && $ressource->save() + && $ressource->receiveFile()) { + $this->_helper->notify(sprintf('Média %s sauvegardé', + $ressource->getTitre())); + $this->_redirect('admin/album/edit_ressource/id/' + . $ressource->getId()); + return; + } + } + + $this->view->errors = $ressource->getErrors(); + $this->view->form = $form; + } + + public function editressourceAction() { if (null === ($ressource = Class_AlbumRessource::getLoader() ->find($this->_getParam('id')))) { @@ -379,44 +408,7 @@ class Admin_AlbumController extends Zend_Controller_Action { * @return Zend_Form */ protected function _ressourceForm($ressource) { - return $this->view->newForm(array( - 'id' => 'ressourceForm', - 'enctype' => Zend_Form::ENCTYPE_MULTIPART)) - ->setAction($this->view->url()) - ->addElement('image', 'fichier', array( - 'label' => 'Fichier *', - 'required' => true, - 'basePath' => $ressource->getOriginalsPath(), - 'baseUrl' => $ressource->getThumbnailsUrl(), - 'thumbnailUrl' => $ressource->getThumbnailUrl())) - - ->addElement('text', 'titre', array( - 'label' => 'Titre', - 'size' => '80')) - - ->addElement('text', 'folio', array( - 'label' => 'Folio', - 'size' => '20')) - - - ->addElement('text', 'link_to', array( 'label' => 'Lien vers', - 'size' => '80', - 'validators' => array(new ZendAfi_Validate_Url()))) - - ->addElement('ckeditor', 'description') - - ->addElement('listeSuggestion', 'matiere',array('label' => 'Matières / sujets', - 'name' => 'matiere', - 'rubrique' => 'matiere')) - - ->addDisplayGroup(array('titre', 'folio', 'fichier', 'link_to', 'matiere'), - 'ressource', - array('legend' => 'Media')) - ->addDisplayGroup(array('description'), - 'ressource_desc', - array('legend' => 'Description')) - - ->populate($ressource->toArray()); + return ZendAfi_Form_Album_Ressource::newWith($ressource); } /** @@ -437,11 +429,7 @@ class Admin_AlbumController extends Zend_Controller_Action { unset($values['fichier']); unset($values['pdf']); - $video_url = $values['video_url']; - unset($values['video_url']); $album->updateAttributes($values); - $album->setVideoUrl($video_url); - if ($album->save() && $album->receiveFile() && $album->receivePDF()) { $this->_helper->notify('Album sauvegardé'); diff --git a/application/modules/admin/views/scripts/album/edit-images.phtml b/application/modules/admin/views/scripts/album/edit-images.phtml index 9a8408e33f85b73868ecc7337c71394087966ea7..6b92545603f9e368f23d08599723a0d6db8c5421 100644 --- a/application/modules/admin/views/scripts/album/edit-images.phtml +++ b/application/modules/admin/views/scripts/album/edit-images.phtml @@ -1,6 +1,13 @@ <?php echo $this->partial('album/_album_panel.phtml', array('album' => $this->album)); + +echo $this->bouton('id=add_link', + 'picto=add.gif', + 'texte=' . $this->_('Ajouter un media'), + 'url=' . $this->url(['action' => 'add-ressource', 'id' => $this->album->getId()]), + 'largeur=250px;' + ); ?> <center> diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php index 93dc4b76f86d7cad08153a291971adbf945db182..c2bb3d089c418a0051ebe0a9c37d41eb43a3aa6c 100644 --- a/library/Class/TypeDoc.php +++ b/library/Class/TypeDoc.php @@ -132,16 +132,13 @@ class Class_TypeDoc extends Storm_Model_Abstract { const EPUB = 102; const OAI = 103; const ARTEVOD = 104; - const STREAMING_VIDEO = 105; - public static function getDefaultTypeDocs() { - return array(self::LIVRE_NUM => 'Livres numérisés', - self::DIAPORAMA => 'Diaporamas', - self::EPUB => 'E-Books', - self::OAI => 'OAI', - self::ARTEVOD => 'Arte VOD', - self::STREAMING_VIDEO => 'Vidéo en ligne'); + return [self::LIVRE_NUM => 'Livres numérisés', + self::DIAPORAMA => 'Diaporamas', + self::EPUB => 'E-Books', + self::OAI => 'OAI', + self::ARTEVOD => 'Arte VOD']; } diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index 4c513de57e1fd08b3c7cf8c5ce02960fe6121d71..fcdb9a8675dc0a9be253cb4f8f96df2f77323482 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -29,7 +29,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ->populate($album->toArray()) ->addVignetteFor($album) ->addFileFor($album) - ->addVideoUrlFor($album) ->addDisplayGroup(['titre', 'sous_titre', 'cat_id', @@ -49,7 +48,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'provenance', 'id_langue', 'type_doc_id', - 'video_url', 'cote', 'matiere', 'dewey', @@ -119,16 +117,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ->addElement('textarea', 'tags', ['label' => 'Tags', 'rows' => 2]); - - Class_ScriptLoader::getInstance() - ->addInlineScript("function toggleAlbumVideoUrl() { - if ('" . Class_TypeDoc::STREAMING_VIDEO . "' == \$('#type_doc_id').val()) { - $('#video_url').parents('tr').show(); - return true; - } - $('#video_url').parents('tr').hide();}") - ->addJQueryReady('toggleAlbumVideoUrl();'); - } @@ -166,18 +154,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'baseUrl' => $album->getBaseUrl(), 'actionUrl' => $this->getView()->url(['action' => 'album-delete-pdf'])])); } - - - /** - * @param $album Class_Album - * @return ZendAfi_Form_Album - */ - public function addVideoUrlFor($album) { - return $this->addElement('text', 'video_url', - ['label' => 'Adresse de la vidéo', - 'size' => 80, - 'value' => $album->getVideoUrl()]); - } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Album/Ressource.php b/library/ZendAfi/Form/Album/Ressource.php new file mode 100644 index 0000000000000000000000000000000000000000..1dca6ecb9e66eac237009a474f3952dfb6a624da --- /dev/null +++ b/library/ZendAfi/Form/Album/Ressource.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_Form_Album_Ressource extends ZendAfi_Form { + use Trait_Translator; + + /** + * @param $model Class_AlbumRessource + * @return ZendAfi_Form_Album_Ressource + */ + public static function newWith($model) { + $form = new self(); + + $form + ->populate($model->toArray()) + ->addFileFor($model) + + ->addDisplayGroup(array('titre', 'folio', 'fichier', 'link_to', 'matiere'), + 'ressource', + array('legend' => 'Media')) + + ->addDisplayGroup(array('description'), + 'ressource_desc', + array('legend' => 'Description')); + + return $form; + } + + + public function init() { + parent::init(); + $this + ->setAttrib('id', 'ressourcesForm') + ->setAttrib('enctype', self::ENCTYPE_MULTIPART) + + ->addElement('text', 'titre', ['label' => 'Titre', + 'size' => '80']) + + ->addElement('text', 'folio', ['label' => 'Folio', + 'size' => '20']) + + + ->addElement('url', 'link_to', ['label' => 'Lien vers', + 'size' => '80']) + + ->addElement('ckeditor', 'description') + + ->addElement('listeSuggestion', 'matiere', ['label' => 'Matières / sujets', + 'name' => 'matiere', + 'rubrique' => 'matiere']); + + } + + + /** + * @param $album Class_AlbumRessource + * @return ZendAfi_Form_Album_Ressource + */ + public function addFileFor($model) { + return $this->addElement('file', 'fichier', ['label' => 'Fichier']); + } +} + +?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php b/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3bbe76ac11986cbf2d04bf920513c9cd371e516b --- /dev/null +++ b/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +require_once 'AdminAbstractControllerTestCase.php'; + + +abstract class Admin_AlbumControllerPharoVideosTestCase extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + Class_Album::newInstanceWithId(777) + ->setCategorie(Class_AlbumCategorie::newInstanceWithId(1) + ->setLibelle('Languages de prog.')); + + } +} + + +class Admin_AlbumControllerPharoVideosIndexTest extends Admin_AlbumControllerPharoVideosTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/album/edit_images/id/777', true); + } + + + /** @test */ + public function linkToAddRessourceShouldBePresent() { + $this->assertXPath('//div[contains(@onclick, "/album/add-ressource/id/777")]'); + } +} + + + +class Admin_AlbumControllerPharoVideosAddTest extends Admin_AlbumControllerPharoVideosTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/album/add-ressource/id/777', true); + } + + + /** @test */ + public function inputForTitreShouldBePresent() { + $this->assertXPath('//input[@type="text"][@name="titre"]'); + } +} \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index fff1b9942f2b9e386cbe5c1b230d03d2563621c5..dfbfb9339daee6ce53c9ef2d776bee8a0bbcd3b5 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -639,8 +639,7 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest extends Admin_Al $data = ['titre' => 'Renaissance', 'sous_titre' => 'Ze Renaissance', - 'description' => 'Oeuvres majeures sous François 1er', - 'video_url' => 'http://www.youtube.com/watch?v=FqXYGBZooHg&feature=html5_ns&list=UUzfAMGBG12oxX7dSYAurMGA&playnext=1']; + 'description' => 'Oeuvres majeures sous François 1er']; $this ->getRequest() @@ -663,7 +662,7 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest extends Admin_Al return true; }); - $this->dispatch('/admin/album/add_album_to/id/38'); + $this->dispatch('/admin/album/add_album_to/id/38', true); $this->new_album = $this->_album_wrapper->getFirstAttributeForLastCallOn('save'); } @@ -692,25 +691,12 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest extends Admin_Al } - /** @test */ - public function newAlbumNotesShouldContainVideoUrl() { - $this->assertEquals('http://www.youtube.com/watch?v=FqXYGBZooHg&feature=html5_ns&list=UUzfAMGBG12oxX7dSYAurMGA&playnext=1', - $this->new_album->getNotesAsArray()[0]['data']['a']); - } - - - /** @test */ - public function newAlbumNotesShouldContainVideoType() { - $this->assertEquals('video', - $this->new_album->getNotesAsArray()[0]['data']['x']); - } - - /** @test */ public function shouldRedirectToEditAlbum() { $this->assertRedirectTo('/admin/album/edit_album/id/67'); } + /** @test */ public function categoryShouldBePatrimoine() { $this->assertEquals('Patrimoine', $this->new_album->getCategorie()->getLibelle()); @@ -889,12 +875,6 @@ class Admin_AlbumControllerEditAlbumMesBDTest extends Admin_AlbumControllerTestC } - /** @test */ - public function formShouldHaveAInputForVideoUrl() { - $this->assertXPath('//input[@type="text"][@name="video_url"]'); - } - - /** @test */ function formShouldHaveTagSuggestForMatiere() { $this->assertXPath("//input[@name='matiere'][@value='1;3;5']"); @@ -954,12 +934,6 @@ class Admin_AlbumControllerEditAlbumMesRomans extends Admin_AlbumControllerTestC $this->assertXPathContentContains("//select[@name='id_langue']//option[@value='dak']", 'dakota'); } - - - /** @test */ - public function formShouldHaveVideoUrlAsExpected() { - $this->assertXPath('//input[@name="video_url"][@value="http://www.youtube.com/watch?v=FqXYGBZooHg&feature=html5_ns&list=UUzfAMGBG12oxX7dSYAurMGA&playnext=1"]'); - } } @@ -1286,13 +1260,6 @@ class Admin_AlbumControllerAlbumHarlockEditRessourceOneActionTest extends Admin_ } - /** @test */ - function imageOneDotPngShouldBeDisplayed() { - $this->assertXPath('//img[@src="' . BASE_URL . '/userfiles/album/999/thumbs/media/1.png"]', - $this->_response->getBody()); - } - - /** @test */ function inputFileShouldBeVisible() { $this->assertXPath('//input[@type="file"]'); diff --git a/tests/library/Class/TypeDocTest.php b/tests/library/Class/TypeDocTest.php index 64aade08de4f5eb7113b9b6ad02cf2bea370e5ea..d2c0d4be8b3fbf84fbf806558b78931c0f53c43b 100644 --- a/tests/library/Class/TypeDocTest.php +++ b/tests/library/Class/TypeDocTest.php @@ -35,7 +35,7 @@ class TypeDocTest extends PHPUnit_Framework_TestCase { /** @test */ function instancesCountShouldBeHeight() { - $this->assertEquals(9, count($this->types_docs)); + $this->assertEquals(8, count($this->types_docs)); } @@ -67,7 +67,7 @@ class TypeDocTest extends PHPUnit_Framework_TestCase { function saveNewInstanceVideoShouldUpdateTypesDocsVars() { Class_TypeDoc::newWithLabel('videos')->save(); - $this->assertEquals("0:non identifié\r\n1:livres\r\n2:périodiques\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD\r\n105:Vidéo en ligne\r\n106:videos", + $this->assertEquals("0:non identifié\r\n1:livres\r\n2:périodiques\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD\r\n105:videos", $this->cosmo_types->getListe()); } @@ -78,7 +78,7 @@ class TypeDocTest extends PHPUnit_Framework_TestCase { ->setLabel('journaux') ->save(); - $this->assertEquals("0:non identifié\r\n1:livres\r\n2:journaux\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD\r\n105:Vidéo en ligne", + $this->assertEquals("0:non identifié\r\n1:livres\r\n2:journaux\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD", $this->cosmo_types->getListe(), 'Current value: '.$this->cosmo_types->getListe()); } @@ -96,7 +96,7 @@ class TypeDocTest extends PHPUnit_Framework_TestCase { ->setLabel('CD') ->save(); - $this->assertEquals("0:non identifié\r\n1:livres\r\n2:périodiques\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD\r\n105:Vidéo en ligne\r\n106:videos\r\n107:CD", + $this->assertEquals("0:non identifié\r\n1:livres\r\n2:périodiques\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD\r\n105:videos\r\n106:CD", $this->cosmo_types->getListe(), 'Current value: '.$this->cosmo_types->getListe()); } @@ -106,7 +106,7 @@ class TypeDocTest extends PHPUnit_Framework_TestCase { function deleteLivresShouldUpdateTypesDocsVar() { array_at(1, $this->types_docs)->delete(); - $this->assertEquals("0:non identifié\r\n2:périodiques\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD\r\n105:Vidéo en ligne", + $this->assertEquals("0:non identifié\r\n2:périodiques\r\n100:Livres numérisés\r\n101:Diaporamas\r\n102:E-Books\r\n103:OAI\r\n104:Arte VOD", $this->cosmo_types->getListe()); } @@ -121,8 +121,7 @@ class TypeDocTest extends PHPUnit_Framework_TestCase { 101 => 'Diaporamas', 102 => 'E-Books', 103 => 'OAI', - 104 => 'Arte VOD', - 105 => 'Vidéo en ligne']); + 104 => 'Arte VOD']); }