diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index f2dd6d98619ab9e49c11ad71600ce704e8163443..c9b427f080b6000e525b96338c595c2567d1ed9c 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Admin_AlbumController extends Zend_Controller_Action { + use Trait_Translator; + protected $_baseUrlOptions = array('module' => 'admin', 'controller' => 'album'); public function init() { @@ -368,107 +370,104 @@ class Admin_AlbumController extends Zend_Controller_Action { * @return Zend_Form */ protected function _albumForm($album) { - $form = $this->view->newForm(array('id' => 'album', - 'enctype' => Zend_Form::ENCTYPE_MULTIPART)); + $form = $this->view->newForm(['id' => 'album', + 'enctype' => Zend_Form::ENCTYPE_MULTIPART]); $vignette_element = new ZendAfi_Form_Element_Image('fichier', - array( - 'label' => 'Vignette<br/><em style="font-size:80%;font-weight:normal">(jpg, gif, png)</em>', - 'escape' => false, - 'basePath' => $album->getBasePath(), - 'baseUrl' => $album->getBaseUrl(), - 'thumbnailUrl' => $album->getThumbnailUrl(), - 'actionUrl' => $this->view->url(array('action' => 'album-delete-vignette')))); + ['label' => 'Vignette<br/><em style="font-size:80%;font-weight:normal">(jpg, gif, png)</em>', + 'escape' => false, + 'basePath' => $album->getBasePath(), + 'baseUrl' => $album->getBaseUrl(), + 'thumbnailUrl' => $album->getThumbnailUrl(), + 'actionUrl' => $this->view->url(['action' => 'album-delete-vignette'])]); $vignette_element ->getDecorator('label') ->setOption('escape', false); $form - ->addElement('text', 'titre', array('label' => 'Titre *', - 'size' => 80, - 'required' => true, - 'allowEmpty' => false)) - ->addElement('text', 'sous_titre', array('label' => 'Sous-titre', - 'size' => 80)) - - ->addElement('select', 'cat_id', array('label' => 'Catégorie', - 'multiOptions' => Class_AlbumCategorie::getLoader()->getAllLibelles())) + ->addElement('text', 'titre', ['label' => 'Titre *', + 'size' => 80, + 'required' => true, + 'allowEmpty' => false]) + ->addElement('text', 'sous_titre', ['label' => 'Sous-titre', + 'size' => 80]) + + ->addElement('select', 'cat_id', ['label' => 'Catégorie', + 'multiOptions' => Class_AlbumCategorie::getAllLibelles()]) + ->addElement('checkbox', 'visible', ['label' => $this->_('Visible')]) ->addElement($vignette_element) ->addElement(new ZendAfi_Form_Element_File('pdf', - array( - 'label' => 'Album PDF', + [ 'label' => 'Album PDF', 'escape' => false, 'basePath' => $album->getBasePath(), 'baseUrl' => $album->getBaseUrl(), - 'actionUrl' => $this->view->url(array('action' => 'album-delete-pdf'))))) + 'actionUrl' => $this->view->url(['action' => 'album-delete-pdf'])])) - ->addElement('text', 'auteur', array('label' => 'Auteur', - 'size' => 80)) + ->addElement('text', 'auteur', ['label' => 'Auteur', + 'size' => 80]) ->addElement('ckeditor', 'description') - ->addElement('text', 'annee', array('label' => "Année d'édition", - 'size' => 4, - 'maxlength' => 4)) + ->addElement('text', 'annee', ['label' => "Année d'édition", + 'size' => 4, + 'maxlength' => 4]) - ->addElement('text', 'editeur', array('label' => 'Editeur', - 'size' => 80)) + ->addElement('text', 'editeur', ['label' => 'Editeur', + 'size' => 80]) - ->addElement('text', 'cote', array('label' => 'Cote', - 'size' => 20)) + ->addElement('text', 'cote', ['label' => 'Cote', + 'size' => 20]) - ->addElement('text', 'provenance', array('label' => 'Provenance', - 'size' => 80)) + ->addElement('text', 'provenance', ['label' => 'Provenance', + 'size' => 80]) - ->addElement('select', 'id_langue', array('label' => 'Langue', - 'multioptions' => Class_CodifLangue::allByIdLibelle())) + ->addElement('select', 'id_langue', ['label' => 'Langue', + 'multioptions' => Class_CodifLangue::allByIdLibelle()]) - ->addElement('select', 'type_doc_id', array('label' => 'Type de document', - 'multioptions' => Class_TypeDoc::allByIdLabelForAlbum())) + ->addElement('select', 'type_doc_id', ['label' => 'Type de document', + 'multioptions' => Class_TypeDoc::allByIdLabelForAlbum()]) ->addElement('listeSuggestion', 'matiere', - array('label' => 'Matières / sujets', - 'name' => 'matiere', - 'rubrique' => 'matiere')) - - ->addElement('listeSuggestion', 'dewey', array('label' => 'Indices dewey', - 'name' => 'dewey', - 'rubrique' => 'dewey')) - - ->addElement('cochesSuggestion', 'genre', array('label' => 'Genres', - 'name' => 'genre', - 'rubrique' => 'genre')) - - ->addElement('textarea', 'tags', array('label' => 'Tags', - 'rows' => 2)) - ->addDisplayGroup( - array('titre', - 'sous_titre', - 'cat_id', - 'fichier', - 'pdf'), + ['label' => 'Matières / sujets', + 'name' => 'matiere', + 'rubrique' => 'matiere']) + + ->addElement('listeSuggestion', 'dewey', ['label' => 'Indices dewey', + 'name' => 'dewey', + 'rubrique' => 'dewey']) + + ->addElement('cochesSuggestion', 'genre', ['label' => 'Genres', + 'name' => 'genre', + 'rubrique' => 'genre']) + + ->addElement('textarea', 'tags', ['label' => 'Tags', + 'rows' => 2]) + ->addDisplayGroup(['titre', + 'sous_titre', + 'cat_id', + 'fichier', + 'pdf'], 'album', - array("legend" => "Album")) - ->addDisplayGroup( - array('description'), + ["legend" => "Album"]) + + ->addDisplayGroup(['description'], 'album_desc', - array("legend" => "Description")) - ->addDisplayGroup( - array( - 'auteur', - 'annee', - 'editeur', - 'provenance', - 'id_langue', - 'type_doc_id', - 'cote', - 'matiere', - 'dewey', - 'genre', - 'tags'), + ["legend" => "Description"]) + + ->addDisplayGroup(['auteur', + 'annee', + 'editeur', + 'provenance', + 'id_langue', + 'type_doc_id', + 'cote', + 'matiere', + 'dewey', + 'genre', + 'tags'], 'album_metadata', - array("legend" => "Metadonnées")) + ["legend" => "Metadonnées"]) ->populate($album->toArray()); return $form; @@ -643,7 +642,7 @@ class Admin_AlbumController extends Zend_Controller_Action { 'label' => "Gérer les médias", 'caption' => 'formatedCount'), array('url' => $this->_getUrlForAction('preview_album'), - 'icon' => 'ico/show.gif', + 'icon' => function($model) {return $model->isVisible() ? 'ico/show.gif' : 'ico/hide.gif';}, 'label' => "Visualisation de l'album"), array('url' => $this->_getUrlForAction('delete_album'), 'icon' => 'ico/del.gif', diff --git a/application/modules/admin/views/scripts/album/_album.phtml b/application/modules/admin/views/scripts/album/_album.phtml index e20b67455297a20f61e29050d7afa840cc5e2145..c9dd6c815312b7282d1992c14c7b736ba59a5437 100644 --- a/application/modules/admin/views/scripts/album/_album.phtml +++ b/application/modules/admin/views/scripts/album/_album.phtml @@ -16,7 +16,7 @@ ), array( 'action' => 'preview_album', - 'icon' => 'show.gif', + 'icon' => $this->album->isVisible() ? 'show.gif' : 'hide.gif', 'help' => "Visualisation de l'album" ), array( diff --git a/library/ZendAfi/View/Helper/TreeView.php b/library/ZendAfi/View/Helper/TreeView.php index afab653e56a63eb1d4df7034754a38877ca2ea26..ae34cbe8740c1a45cf567783558de72f455c1397 100644 --- a/library/ZendAfi/View/Helper/TreeView.php +++ b/library/ZendAfi/View/Helper/TreeView.php @@ -190,6 +190,9 @@ class ZendAfi_View_Helper_TreeView extends Zend_View_Helper_Abstract { $action['url'] = sprintf($action['url'], $model->getId()); + if (isset($action['icon']) && is_a($action['icon'], 'Closure')) + $action['icon'] = $action['icon']($model); + $html .= $this->_renderAction($action); } diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 2fad4132045f1724250f2a210c15f5360f708234..5ce4e7ed30d2c18eac72dd8cc96fcc7fe7212be6 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -44,62 +44,59 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes $this->_album_wrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album'); Class_AlbumCategorie::getLoader() - ->newInstanceWithId(2) - ->setParentId(0) - ->setLibelle('Favoris') - ->setSousCategories(array()) - ->setAlbums(array()); + ->newInstanceWithId(2) + ->setParentId(0) + ->setLibelle('Favoris') + ->setSousCategories(array()) + ->setAlbums(array()); Class_AlbumCategorie::getLoader() - ->newInstanceWithId(6) - ->setLibelle('Adulte') - ->setParentId(2) - ->setSousCategories(array()) - ->setAlbums(array()); + ->newInstanceWithId(6) + ->setLibelle('Adulte') + ->setParentId(2) + ->setSousCategories(array()) + ->setAlbums(array()); Class_AlbumCategorie::getLoader() - ->newInstanceWithId(38) - ->setParentId(0) - ->setSousCategories(array()) - ->setAlbums(array()) - ->setLibelle('Patrimoine'); + ->newInstanceWithId(38) + ->setParentId(0) + ->setSousCategories(array()) + ->setAlbums(array()) + ->setLibelle('Patrimoine'); Class_Album::getLoader() - ->newInstanceWithId(43) - ->setTitre('Mes BD') - ->setAuteur('Laurent') - ->setTags('bd;dessin') - ->setDateMaj('2011-10-05 17:12:00') - ->setDescription('Les préférées') - ->setAnnee(1978) - ->beDiaporama() - ->setIdOrigine('DC023') - ->setMatiere('1;3;5') - ->setDewey('10;12') - ->setGenre('65;66;67') - ->setPdf('souvigny.pdf') - ->setProvenance('Prieuré, Souvigny') - ->setCote('MS001'); + ->newInstanceWithId(43) + ->setTitre('Mes BD') + ->setAuteur('Laurent') + ->setTags('bd;dessin') + ->setDateMaj('2011-10-05 17:12:00') + ->setDescription('Les préférées') + ->setAnnee(1978) + ->beDiaporama() + ->setIdOrigine('DC023') + ->setMatiere('1;3;5') + ->setDewey('10;12') + ->setGenre('65;66;67') + ->setPdf('souvigny.pdf') + ->setProvenance('Prieuré, Souvigny') + ->setCote('MS001') + ->setVisible(false); Class_Album::getLoader() - ->newInstanceWithId(44) - ->setTitre('Bible Souvigny') - ->beLivreNumerique() - ->setThumbnailAttributes( - array( - 'thumbnail_width' => 350, - 'thumbnail_left_page_crop_left' => 10, - 'thumbnail_left_page_crop_right' => 5, - 'thumbnail_left_page_crop_bottom' => 2, - 'thumbnail_right_page_crop_left' => 5)) - ->setRessources(array()); + ->newInstanceWithId(44) + ->setTitre('Bible Souvigny') + ->beLivreNumerique() + ->setThumbnailAttributes(['thumbnail_width' => 350, + 'thumbnail_left_page_crop_left' => 10, + 'thumbnail_left_page_crop_right' => 5, + 'thumbnail_left_page_crop_bottom' => 2, + 'thumbnail_right_page_crop_left' => 5]) + ->setRessources([]); Class_Album::getLoader() - ->newInstanceWithId(24) - ->setTitre('Mes Romans') - ->setLangue(''); - - + ->newInstanceWithId(24) + ->setTitre('Mes Romans') + ->setLangue(''); } } @@ -148,7 +145,7 @@ class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase { ->whenCalled('countBy') ->answers(1); - $this->dispatch('/admin/album'); + $this->dispatch('/admin/album', true); } @@ -248,6 +245,18 @@ class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase { } + /** @test */ + public function albumMesRomansPreviewLinkImgShouldBeShowDotGif() { + $this->assertXPath("//a[contains(@href, 'preview_album/id/24')]//img[contains(@src, '/show.gif')]"); + } + + + /** @test */ + public function albumMesBDPreviewLinkImgShouldBeHideDotGif() { + $this->assertXPath("//a[contains(@href, 'preview_album/id/43')]//img[contains(@src, '/hide.gif')]"); + } + + /** @test */ public function albumMesRomansShouldHaveDeleteLink() { $this->assertXPath("//a[contains(@href, 'delete_album/id/24')]"); @@ -791,6 +800,12 @@ class Admin_AlbumControllerEditAlbumMesBDTest extends Admin_AlbumControllerTestC } + /** @test */ + public function formShouldHaveACheckBoxForVisible() { + $this->assertXPath('//form//input[@type="checkbox"][@name="visible"][@checked="checked"]'); + } + + /** @test */ public function formShouldHaveATextFieldForCote() { $this->assertXPath("//form[@id='album']//input[@type='text'][@name='cote'][@value='MS001']");