From b85692faf886114ccd63ed93c6f008991076e291 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Thu, 5 Nov 2015 17:42:48 +0100 Subject: [PATCH] rel #32494 fix site creation for enssib --- .../admin/controllers/SitoController.php | 9 ++++--- library/ZendAfi/View/Helper/TagWebSite.php | 2 +- .../controllers/SitothequeControllerTest.php | 27 +++++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/application/modules/admin/controllers/SitoController.php b/application/modules/admin/controllers/SitoController.php index 21bb76910ce..d8f5831db99 100644 --- a/application/modules/admin/controllers/SitoController.php +++ b/application/modules/admin/controllers/SitoController.php @@ -75,10 +75,10 @@ class Admin_SitoController extends ZendAfi_Controller_Action { $album = Class_Album::newInstance(['type_doc_id' => Class_TypeDoc::WEBSITE, 'categorie' => $category]); - $album->setTitre($dom->queryXpath('//head/title')->current()->textContent); + $album->setTitre(trim($dom->queryXpath('//head/title')->current()->textContent)); - $description_node = $dom->queryXpath('//head/meta[@name="description"]')->current(); - $album->setDescription($description_node->getAttribute('content')); + if ($description_node = $dom->queryXpath('//head/meta[@name="description"]')->current()) + $album->setDescription($description_node->getAttribute('content')); $resource = Class_AlbumRessource::newInstance(['url' => $url, 'titre' => $album->getTitre()]); @@ -87,10 +87,11 @@ class Admin_SitoController extends ZendAfi_Controller_Action { $thumbnailer = (new Class_WebService_WebSiteThumbnail()); $poster_name = $thumbnailer->fileNameFromUrl($url); - $poster_path = $resource->getThumbnailPath(); + $poster_path = $resource->getPosterPath(); $resource->getFolderManager()->ensure($poster_path); $thumbnailer->getThumbnailer()->fetchUrlToFile($url, $poster_path . $poster_name); $resource->setPoster($poster_name); + $resource->createThumbnail(); return $album; } diff --git a/library/ZendAfi/View/Helper/TagWebSite.php b/library/ZendAfi/View/Helper/TagWebSite.php index e509f487337..8ffbd21eb90 100644 --- a/library/ZendAfi/View/Helper/TagWebSite.php +++ b/library/ZendAfi/View/Helper/TagWebSite.php @@ -53,7 +53,7 @@ class ZendAfi_View_Helper_TagWebSite extends ZendAfi_View_Helper_BaseHelper { '', ['src' => $site->getPosterUrl(), 'title' => $this->_('Ouvrir le site dans un nouvel onglet'), - 'style' => 'width:100%']); + 'style' => 'max-width: 100%']); } } diff --git a/tests/application/modules/admin/controllers/SitothequeControllerTest.php b/tests/application/modules/admin/controllers/SitothequeControllerTest.php index 2d144df706f..fc77994e1b0 100644 --- a/tests/application/modules/admin/controllers/SitothequeControllerTest.php +++ b/tests/application/modules/admin/controllers/SitothequeControllerTest.php @@ -607,7 +607,7 @@ class SitothequeControllerDeleteCategorieInformationsTest extends SitothequeCont -class SitothequeControllerImportFromUrlTest extends AbstractControllerTestCase { +class SitothequeControllerImportCnedFromUrlTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true, $_cned; @@ -635,7 +635,7 @@ class SitothequeControllerImportFromUrlTest extends AbstractControllerTestCase { /** @test */ - public function albumCategorieShouldBeWebsite() { + public function albumCategorieShouldBeSitotheque() { $this->assertEquals('Sites web', $this->_cned->getCategorie()->getLibelle()); } @@ -666,4 +666,27 @@ class SitothequeControllerImportFromUrlTest extends AbstractControllerTestCase { } + +class SitothequeControllerImportEnssibFromUrlTest extends AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true, + $_enssib; + + public function setUp() { + parent::setUp(); + $this->postDispatch('/admin/sito/create', + ['url' => 'http://www.enssib.fr']); + + $this->_enssib = Class_Album::find(1); + } + + + /** @test */ + public function titleShouldBeEnssib() { + $this->assertEquals('Accueil | Enssib', + $this->_enssib->getTitre()); + } +} + + ?> \ No newline at end of file -- GitLab