From 77a6b2c3a5677e58df778080dd8f994e281655ec Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Tue, 24 Apr 2012 17:09:29 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20premie=CC=80re=20interface=20pour=20l'e?= =?UTF-8?q?=CC=81dition=20des=20lieux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 7 ++ .../admin/controllers/LieuController.php | 28 +++++ .../admin/views/scripts/lieu/_lieu.phtml | 13 +++ .../admin/views/scripts/lieu/index.phtml | 17 +++ library/Class/Lieu.php | 31 +++++ .../View/Helper/Admin/MenuGaucheAdmin.php | 4 +- .../ZendAfi/View/Helper/Java/MenuImage.php | 2 +- public/admin/images/picto/compass.png | Bin 0 -> 2015 bytes .../admin/controllers/LieuControllerTest.php | 109 ++++++++++++++++++ tests/library/Class/LieuTest.php | 22 ++++ 10 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 application/modules/admin/controllers/LieuController.php create mode 100644 application/modules/admin/views/scripts/lieu/_lieu.phtml create mode 100644 application/modules/admin/views/scripts/lieu/index.phtml create mode 100644 library/Class/Lieu.php create mode 100644 public/admin/images/picto/compass.png create mode 100644 tests/application/modules/admin/controllers/LieuControllerTest.php create mode 100644 tests/library/Class/LieuTest.php diff --git a/.gitattributes b/.gitattributes index af86b248a99..c6efdad1c8a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -285,6 +285,7 @@ application/modules/admin/controllers/ErrorController.php -text application/modules/admin/controllers/FormationController.php -text application/modules/admin/controllers/I18nController.php -text application/modules/admin/controllers/IndexController.php -text +application/modules/admin/controllers/LieuController.php -text application/modules/admin/controllers/MenusController.php -text application/modules/admin/controllers/ModoController.php -text application/modules/admin/controllers/ModulesController.php -text @@ -378,6 +379,8 @@ application/modules/admin/views/scripts/index/adminvar.phtml -text application/modules/admin/views/scripts/index/adminvaredit.phtml -text application/modules/admin/views/scripts/index/index.phtml -text application/modules/admin/views/scripts/layout.phtml -text +application/modules/admin/views/scripts/lieu/_lieu.phtml -text +application/modules/admin/views/scripts/lieu/index.phtml -text application/modules/admin/views/scripts/menus/_debut.phtml -text application/modules/admin/views/scripts/menus/_fin.phtml -text application/modules/admin/views/scripts/menus/_retour.phtml -text @@ -1642,6 +1645,7 @@ library/Class/Indexation.php -text library/Class/IntBib.php -text library/Class/Isbn.php -text library/Class/IsbnEan.php -text +library/Class/Lieu.php -text library/Class/ListeNotices.php -text library/Class/Localisation.php -text library/Class/Mail.php -text @@ -2353,6 +2357,7 @@ public/admin/images/picto/books.png -text public/admin/images/picto/catalogues.png -text public/admin/images/picto/chat.gif.png -text public/admin/images/picto/cms.gif -text +public/admin/images/picto/compass.png -text svneol=unset#unset public/admin/images/picto/database.png -text public/admin/images/picto/deconnexion.png -text public/admin/images/picto/dossier.png -text @@ -3388,6 +3393,7 @@ tests/application/modules/admin/controllers/CmsControllerTest.php -text tests/application/modules/admin/controllers/FormationControllerTest.php -text tests/application/modules/admin/controllers/I18nControllerTest.php -text tests/application/modules/admin/controllers/IndexControllerTranslationTest.php -text +tests/application/modules/admin/controllers/LieuControllerTest.php -text tests/application/modules/admin/controllers/MenusControllerTest.php -text tests/application/modules/admin/controllers/ModulesControllerTest.php -text tests/application/modules/admin/controllers/NewsletterControllerTest.php -text @@ -3458,6 +3464,7 @@ tests/library/Class/FormationTest.php -text tests/library/Class/GlobalSqlRefactoringTest.php -text tests/library/Class/I18nTest.php -text tests/library/Class/I18nTranslatorTest.php -text +tests/library/Class/LieuTest.php -text tests/library/Class/MailTest.php -text tests/library/Class/MatiereTest.php -text tests/library/Class/MockMailTransport.php -text diff --git a/application/modules/admin/controllers/LieuController.php b/application/modules/admin/controllers/LieuController.php new file mode 100644 index 00000000000..732c8caea72 --- /dev/null +++ b/application/modules/admin/controllers/LieuController.php @@ -0,0 +1,28 @@ +<?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 Admin_LieuController extends Zend_Controller_Action { + public function indexAction() { + $this->view->titre = $this->view->_('Lieux'); + $this->view->lieux = Class_Lieu::getLoader()->findAllBy(array('order' => 'libelle')); + } +} + +?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/lieu/_lieu.phtml b/application/modules/admin/views/scripts/lieu/_lieu.phtml new file mode 100644 index 00000000000..48fb7d28bbc --- /dev/null +++ b/application/modules/admin/views/scripts/lieu/_lieu.phtml @@ -0,0 +1,13 @@ +<li> + <?php + echo sprintf("<div></div><div>%s</div>", $this->lieu->getLibelle()); + echo sprintf("<div class='actions'>%s %s</div>", + $this->tagAnchor(array('action' => 'edit', + 'id' => $this->lieu->getId()), + $this->boutonIco("type=edit")), + + $this->tagAnchor(array('action' => 'delete', + 'id' => $this->lieu->getId()), + $this->boutonIco("type=del"))); + ?> +</li> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/lieu/index.phtml b/application/modules/admin/views/scripts/lieu/index.phtml new file mode 100644 index 00000000000..d2631845e61 --- /dev/null +++ b/application/modules/admin/views/scripts/lieu/index.phtml @@ -0,0 +1,17 @@ +<?php +echo $this->bouton('id=add', + 'picto=add.gif', + 'texte=' . $this->_('Déclarer un nouveau lieu'), + 'url=' . $this->url(array('action' => 'add', + 'id' => null)) + ); +?> + +<ul class="tree"> +<?php + echo $this->partialCycle('lieu/_lieu.phtml', + 'lieu', + $this->lieux, + array('first', 'second')); +?> +</ul> \ No newline at end of file diff --git a/library/Class/Lieu.php b/library/Class/Lieu.php new file mode 100644 index 00000000000..f5c85cf94d7 --- /dev/null +++ b/library/Class/Lieu.php @@ -0,0 +1,31 @@ +<?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 Class_Lieu extends Storm_Model_Abstract { + protected $_table_name = 'lieux'; + + public static function getLoader() { + return self::getLoaderFor(__CLASS__); + } + +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php index fb8d0f6d269..7259b8c09e4 100644 --- a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php +++ b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php @@ -52,7 +52,8 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdmin extends ZendAfi_View_Helper_Base $menu_modules .= $this->addMenu("mail.png", $this->translate()->_("Lettres d'information"), "/admin/newsletter", $acl_admins); if (Class_AdminVar::isFormationEnabled()) { - $menu_modules .= $this->addMenu("formation.png",$this->translate()->_("Formations"), "/admin/formation", $acl_admins); + $menu_modules .= $this->addMenu("formation.png", $this->translate()->_("Formations"), "/admin/formation", $acl_admins); + $menu_modules .= $this->addMenu("compass.png", $this->translate()->_("Lieux"), "/admin/lieu", $acl_admins); } $menu_modules .= $this->closeBoite(); @@ -84,6 +85,7 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdmin extends ZendAfi_View_Helper_Base if (Class_AdminVar::isFormationEnabled()) { $menu_portail .= $this->addMenu("usergroups.png", $this->translate()->_("Groupes"), "/admin/usergroup", $acl_admins); + } $menu_portail .= $this->closeBoite(); diff --git a/library/ZendAfi/View/Helper/Java/MenuImage.php b/library/ZendAfi/View/Helper/Java/MenuImage.php index fc60150c9f2..d578c476f96 100644 --- a/library/ZendAfi/View/Helper/Java/MenuImage.php +++ b/library/ZendAfi/View/Helper/Java/MenuImage.php @@ -62,7 +62,7 @@ class ZendAfi_View_Helper_Java_MenuImage { $id_sous_menu=$id_menu."_".$num_sous_menu; $param_url=$cls_menu->getUrl($sous_menu["type_menu"],$sous_menu["preferences"]); - $html.='<tr><td onclick="window.parent.location=\''.$param_url["url"].'\';">» '.$sous_menu["libelle"].'</td></tr>'; + $html.='<tr><td onclick="window.parent.location=\''.$param_url["url"].'\';">» '.$sous_menu["libelle"].'</td></tr>'; $num_sous_menu++; } $html.='</table>'; diff --git a/public/admin/images/picto/compass.png b/public/admin/images/picto/compass.png new file mode 100644 index 0000000000000000000000000000000000000000..9f89416e26cad9a2637f561eec4c1c097fde59c6 GIT binary patch literal 2015 zcmV<52O#)~P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV000B<X+uL$Nkc;* zP;zf(X>4Tx04R}-Ro!pfR1`mnZ(O7nKcKOW4i$^9Ra0BJ8yc;~21%2p=|UR0&DbiW z$#rfTQ`a`O(`{9s_5yDV_yd5l2Of}kLK+Oj_Ok5(v`JGz71bo9J#^YYXp{DWs&KBa zQ@dTpxRI}aIp=pi@6k0t$5)!;m`NF6-tt{FpOKHBn3g+MAqmexC-gw4rh87hTrL7G z#)U`L!(So6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o9;RB(@xzPR$KX?p>K(@OxexoO1R&-oLM<CXO_# z?4VQdNHmU$rlaeT4&2dfMkMc|_<fQ}vD-^V`1*)S=QkMSkVGL_*xCF3x?@MjMMvjw zYl{mBhmMzgW`Kajtt#9K!*VhQ`+9uZ`t$thES=wAqu~cJjfN!($pQcxd%qsr3AW3P xW<HQL%x-|-p^B2LYIEL1Dx8hHwU_e)=YJ>f$dC1H{ILK4002ovPDHLkV1i`8(TV^7 literal 0 HcmV?d00001 diff --git a/tests/application/modules/admin/controllers/LieuControllerTest.php b/tests/application/modules/admin/controllers/LieuControllerTest.php new file mode 100644 index 00000000000..1deda7c1941 --- /dev/null +++ b/tests/application/modules/admin/controllers/LieuControllerTest.php @@ -0,0 +1,109 @@ +<?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 'AbstractControllerTestCase.php'; + +abstract class LieuControllerTestCase extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + Class_AdminVar::getLoader() + ->newInstanceWithId('FORMATIONS') + ->setValeur(1); + + $this->afi_annecy = Class_Lieu::getLoader() + ->newInstanceWithId(3) + ->setLibelle('AFI Annecy') + ->setAdresse('11, boulevard du fier') + ->setCodePostal('74000') + ->setVille('Annecy') + ->setPays('France'); + + + $this->afi_lognes = Class_Lieu::getLoader() + ->newInstanceWithId(5) + ->setLibelle('AFI Lognes') + ->setAdresse('35, rue de la Maison Rouge') + ->setCodePostal('77185') + ->setVille('Lognes') + ->setPays('France'); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Lieu') + ->whenCalled('findAllBy') + ->with(array('order' => 'libelle')) + ->answers(array($this->afi_annecy, $this->afi_lognes)) + ->beStrict(); + } +} + + + + +class LieuControllerListTest extends LieuControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/lieu'); + } + + + /** @test */ + public function aListItemShouldContainsAnnecy() { + $this->assertXPathContentContains('//ul//li[1]', 'AFI Annecy'); + } + + + /** @test */ + public function aListItemShouldContainsLognes() { + $this->assertXPathContentContains('//ul//li[2]', 'AFI Lognes'); + } + + + /** @test */ + public function annecyShouldHaveLinkToEdit() { + $this->assertXPath('//ul//li[1]//a[contains(@href, "lieu/edit/id/3")]'); + } + + + /** @test */ + public function annecyShouldHaveLinkToDelete() { + $this->assertXPath('//ul//li[1]//a[contains(@href, "lieu/delete/id/3")]'); + } + + + /** @test */ + public function titreShouldBeLieux() { + $this->assertXPathContentContains('//h1', 'Lieux'); + } + + + /** @test */ + public function pageShouldContainsButtonToCreateLieu() { + $this->assertXPathContentContains('//div[contains(@onclick, "lieu/add")]//td', 'Déclarer un nouveau lieu'); + } + + + /** @test */ + function menuGaucheAdminShouldContainsLinkToLieu() { + $this->assertXPathContentContains('//div[@class="menuGaucheAdmin"]//a[contains(@href,"admin/lieu")]', + "Lieux"); + } +} + +?> \ No newline at end of file diff --git a/tests/library/Class/LieuTest.php b/tests/library/Class/LieuTest.php new file mode 100644 index 00000000000..b9e4961e680 --- /dev/null +++ b/tests/library/Class/LieuTest.php @@ -0,0 +1,22 @@ +<?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 + */ + +?> \ No newline at end of file -- GitLab