diff --git a/VERSIONS_WIP/27763 b/VERSIONS_WIP/27763 new file mode 100644 index 0000000000000000000000000000000000000000..46733b3ae0fd23e28b36aa620c1ae34f66fbf832 --- /dev/null +++ b/VERSIONS_WIP/27763 @@ -0,0 +1 @@ + - ticket #27763 : Sitothèque : avoir une option pour désindexer un site, comme pour les articles \ No newline at end of file diff --git a/application/modules/admin/views/scripts/sito/sitoadd.phtml b/application/modules/admin/views/scripts/sito/sitoadd.phtml deleted file mode 100644 index 411deb85f28143cc891be1a9966d96c58037b4bb..0000000000000000000000000000000000000000 --- a/application/modules/admin/views/scripts/sito/sitoadd.phtml +++ /dev/null @@ -1 +0,0 @@ -<?php echo $this->render('sito/sitoform.phtml'); ?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/sito/sitoedit.phtml b/application/modules/admin/views/scripts/sito/sitoedit.phtml deleted file mode 100644 index 411deb85f28143cc891be1a9966d96c58037b4bb..0000000000000000000000000000000000000000 --- a/application/modules/admin/views/scripts/sito/sitoedit.phtml +++ /dev/null @@ -1 +0,0 @@ -<?php echo $this->render('sito/sitoform.phtml'); ?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/sito/sitoform.phtml b/application/modules/admin/views/scripts/sito/sitoform.phtml deleted file mode 100644 index 235c2c57ef8b86d83c4308b2e4c0e1cab360d811..0000000000000000000000000000000000000000 --- a/application/modules/admin/views/scripts/sito/sitoform.phtml +++ /dev/null @@ -1,76 +0,0 @@ -<div class="content_edit_head"> - <?php echo $this->_('Localisation') . ' : ' . $this->site->getBibLibelle(); ?> -</div> - -<div class="form"> - <form name="form" action="<?php echo $this->url() ?>" method="post"> - <fieldset> - <legend><?php echo $this->traduire('Sitothèque'); ?></legend> - <span class="error"><?php echo implode('<br/>', $this->site->getErrors()); ?></span> - <table> - <tr> - <td class="droite"><?php echo $this->traduire('Catégorie'); ?> </td> - <td class="gauche" style="width:536px;"><?php echo $this->combo_cat; ?> </td> - </tr> - <tr> - <td class="droite"> <?php echo $this->traduire('Titre'); ?> *</td> - <td class="gauche"> <input type="text" id="titre" size="60" name="titre" onkeypress="if (event.keyCode == 13) {javascript:PicToolbarOver( getElementById('menu_item975'), 'menu_item975');this.form.submit();return false;}" value="<?php echo $this->escape(trim($this->site->getTitre()));?>" maxlength="80"/></td> - </tr> - <tr> - <td class="droite"> <?php echo $this->traduire('Url'); ?> *</td> - <td class="gauche"> <input type="text" name="url" size="60" onkeypress="if (event.keyCode == 13) {javascript:PicToolbarOver( getElementById('menu_item975'), 'menu_item975');this.form.submit();return false;}" value="<?php echo $this->escape(trim($this->site->getUrl()));?>" maxlength="250"/></td> - </tr> - <tr> - <td class="droite" style="vertical-align:top"><?php echo $this->traduire('Commentaire'); ?></td> - <td class="gauche"> <TEXTAREA name="description" rows="5" cols="50"><?php echo $this->escape(trim($this->site->getDescription()));?></TEXTAREA></td> - </tr> - <tr> - <td style="font-size:8pt;text-align:right;vertical-align:top;"> </td> - <td style="text-align: center" class="info">Entrez la liste des mots-clefs et expressions qui caractérisent ce site séparés avec des ;</td> - </tr> - <tr> - <td class="droite" style="vertical-align:top"><?php echo $this->traduire('Tags'); ?></td> - <td class="gauche"> <TEXTAREA name="tags" rows="5" cols="50"><?php echo $this->escape(trim($this->site->getTags()));?></TEXTAREA> - </tr> - - </table> - </fieldset> - - <?php - if (defined('DEVELOPMENT')) { - ?> - <fieldset> - <legend><?php echo $this->traduire('Indexation'); ?></legend> - <table > - <tr> - <td> - <?php echo $this->domaineSelect($this->site); ?> - </td> - </tr> - </table> - </fieldset> - <?php } ?> - - <table> - <tr> - <td style="text-align:right"> <?php echo $this->bouton('type=V'); ?></td> - <td> - <?php echo $this->bouton('id=c_2', - 'picto=back.gif', - 'texte=Retour', - 'url='.$this->url(['action' => 'index', - 'id_cat' => $this->site->getIdCat()]), - 'largeur=120px'); - ?> - </td> - </tr> - </table> - </form> -</div> -<br> - - - <script> - oField = document.getElementById('titre'); - oField.focus(); - </script> diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 19dae8187bafcdd1736c8d3db7db0d157f8960b5..6bf6f9b5653243208920ab0509930fc31376d559 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -1,7 +1,8 @@ <?php error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","275"); + +define("PATCH_LEVEL","276"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/sql/patch/patch_272.php b/cosmogramme/sql/patch/patch_272.php index 73c2cc32a6add91c7cd6b3bb8decb2a04db05339..4972c7b96fb5a405915bc7170b1ddaf07bf08be9 100644 --- a/cosmogramme/sql/patch/patch_272.php +++ b/cosmogramme/sql/patch/patch_272.php @@ -8,4 +8,4 @@ try { $adapter->query('ALTER TABLE notices_avis ADD INDEX (flags)'); } -?> \ No newline at end of file +?> diff --git a/cosmogramme/sql/patch/patch_276.php b/cosmogramme/sql/patch/patch_276.php new file mode 100644 index 0000000000000000000000000000000000000000..096640528ce212670b6ba600adbd41c3b2e6eda4 --- /dev/null +++ b/cosmogramme/sql/patch/patch_276.php @@ -0,0 +1,7 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); + +try { + $adapter->query('alter table `sito_url` add column `indexation` boolean default true'); +} catch (Exception $e) {} +?> \ No newline at end of file diff --git a/library/Class/Sitotheque.php b/library/Class/Sitotheque.php index f6196568a08bd824f9cfa641ba34b56ae1de13f1..43afaf9e770b8768545f90b244d63885f24d2616 100644 --- a/library/Class/Sitotheque.php +++ b/library/Class/Sitotheque.php @@ -34,7 +34,6 @@ class Class_SitothequeModelSite extends BaseItem { - class SitothequeLoader extends Storm_Model_Loader { /** @@ -137,6 +136,7 @@ class Class_Sitotheque extends Storm_Model_Abstract { 'titre' => '', 'url' => '', 'description' => '', + 'indexation' => true, 'tags' => '', 'domaine_ids' => '']; @@ -153,6 +153,16 @@ class Class_Sitotheque extends Storm_Model_Abstract { } + public function hasToBeIndexed() { + return $this->isIndexable(); + } + + + public function isIndexable() { + return (bool)$this->getIndexation(); + } + + public function getIdZone() { if (!$this->hasZone()) return 0; diff --git a/library/ZendAfi/Form/Admin/Sitotheque.php b/library/ZendAfi/Form/Admin/Sitotheque.php index 3eee25227012fd8b11f0e7deff92096ed8e79885..9dba6d35f2a64010cd0c078c12df49ba6c8ad1e9 100644 --- a/library/ZendAfi/Form/Admin/Sitotheque.php +++ b/library/ZendAfi/Form/Admin/Sitotheque.php @@ -39,6 +39,10 @@ class ZendAfi_Form_Admin_Sitotheque extends ZendAfi_Form { 'url', ['label' => $this->_('Url'), 'size' => 50]) + ->addElement('checkbox', + 'indexation', + ['label' => $this->_('Indexer le site dans le catalogue ?')]) + ->addElement('textarea', 'description', ['label' => $this->_('Commentaire'), @@ -54,7 +58,7 @@ class ZendAfi_Form_Admin_Sitotheque extends ZendAfi_Form { ]) - ->addDisplayGroup(['id_cat', 'titre', 'url', 'description'], + ->addDisplayGroup(['id_cat', 'titre', 'url', 'description', 'indexation'], 'sitotheque', ['legend' => $this->_('Sitothèque')]) diff --git a/tests/application/modules/admin/controllers/SitothequeControllerTest.php b/tests/application/modules/admin/controllers/SitothequeControllerTest.php index eeaa0bb5e3ca855c9eec0bf95602d6737daae7ef..f5d95a7bb0c2c8cb24c707b0063bef063a388815 100644 --- a/tests/application/modules/admin/controllers/SitothequeControllerTest.php +++ b/tests/application/modules/admin/controllers/SitothequeControllerTest.php @@ -265,6 +265,11 @@ class SitothequeControllerAddActionTest extends SitothequeControllerTestCase { $this->assertXPathContentContains('//select[@id="field_2"]//option', 'web links', $this->_response->getBody()); } + /** @test */ + public function indexationCheckboxShouldBeDisplayed() { + $this->assertXPath('//input[@type="checkbox"][@name="indexation"]'); + } + } @@ -285,6 +290,7 @@ class SitothequeControllerPostAddActionTest extends SitothequeControllerTestCase $this->postDispatch('/admin/sito/add/id_cat/2', ['titre' => 'google', 'url' => 'http://www.google.fr', + 'indexation' => '1', 'id_items' => '23-23', 'field_2' => 'livres', 'domaine_ids' => 10], @@ -333,6 +339,33 @@ class SitothequeControllerPostAddActionTest extends SitothequeControllerTestCase $this->assertTrue($this->cache->methodHasBeenCalled('clean')); } + /** @test */ + public function siteShouldBeIndexed() { + $this->assertNotNull(Class_Sitotheque::findFirstBy(['order'=>'titre desc'])->getNotice()); + } +} + + + + +class SitothequeControllerNotIndexedPostAddActionTest extends SitothequeControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->postDispatch('/admin/sito/add/id_cat/2', + ['titre' => 'google', + 'url' => 'http://www.google.fr', + 'indexation' => '0', + 'id_items' => '23-23', + 'field_2' => 'livres', + 'domaine_ids' => 10], + true); + } + + /** @test */ + public function siteShouldNotBeIndexed() { + $this->assertNull(Class_Sitotheque::findFirstBy(['order'=>'titre desc'])->getNotice()); + } }