diff --git a/application/modules/opac/controllers/RssController.php b/application/modules/opac/controllers/RssController.php index 713f1ef9d7499ab8f0e206c3a9b25439fbe1a1a9..741a2cc937a3e55871b00b859ac06a276466c4b6 100644 --- a/application/modules/opac/controllers/RssController.php +++ b/application/modules/opac/controllers/RssController.php @@ -256,8 +256,7 @@ class RssController extends Zend_Controller_Action public function critiquesAction() { - $id_profil = $this->_getParam('id_profil'); - $profil = Class_Profil::find($id_profil); + $profil = Class_Profil::find($this->_getParam('id_profil')); $id_module = $this->_getParam('id_module'); $preferences = $profil->getModuleAccueilPreferences($id_module, 'CRITIQUES'); $liste_avis = Class_AvisNotice::getAvisFromPreferences($preferences); @@ -277,10 +276,10 @@ class RssController extends Zend_Controller_Action $desc = $avis_helper->avis($avis, 0, $vignette_link_to_avis = true); - $entry = array("titre" => $avis->getEntete(), - "lien" => $this->view->absoluteUrl('/blog/viewavis/id/'.$avis->getFirstNotice()->getId().'-'.$avis->getIdUser()), - "desc" => '<![CDATA['.$this->filtreNews($desc).']]>'); - $data_rss["items"][] = $entry; + $entry = ['titre' => $avis->getEntete(), + 'lien' => $this->view->absoluteUrl('/blog/viewavis/id/'.$avis->getFirstNotice()->getId().'-'.$avis->getIdUser()), + 'desc' => '<![CDATA['.$this->filtreNews($desc).']]>']; + $data_rss['items'][] = $entry; } $this->getHelper('ViewRenderer')->setNoRender(); @@ -330,13 +329,11 @@ class RssController extends Zend_Controller_Action } - - function filtreNews($contenu_news) - { + protected function filtreNews($contenu_news) { $contenu = preg_replace('/ src="/',' src="http://'.$_SERVER['SERVER_NAME'].'/',$contenu_news); $contenu = preg_replace('/ src=\'\//',' src=\'http://'.$_SERVER['SERVER_NAME'].'/',$contenu_news); $contenu = preg_replace('^{FIN}^','',$contenu); - return($contenu); + return $contenu; } diff --git a/library/ZendAfi/View/Helper/RenderRss.php b/library/ZendAfi/View/Helper/RenderRss.php index 63c9fb97023963708e922ece512106268dcc17d5..165d9cfcd4eb347fe6e2fa8c34ed71598a4879e5 100644 --- a/library/ZendAfi/View/Helper/RenderRss.php +++ b/library/ZendAfi/View/Helper/RenderRss.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_RenderRss extends Zend_View_Helper_Abstract { public function renderRss($data) { @@ -64,7 +64,8 @@ class ZendAfi_View_Helper_RenderRss extends Zend_View_Helper_Abstract { $media_contents = []; if (preg_match('/<img/', $description)) { - $description = preg_replace('/<!\[CDATA\[(.*)\]\]>/s', '$1', $description); + $description = trim(preg_replace('/<!\[CDATA\[(.*)\]\]>/s', '$1', $description)); + $description = trim(preg_replace('/<p>(.*)\<\/p>/s', '$1', $description)); $doc = new DOMDocument(); $doc->loadHTML($description); $imgs = $doc->getElementsByTagName('img'); diff --git a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php index 639717fc256b9dfc8bcecaa9ef79caef48c0b93a..bb0f30a5a341cdcb74e1f87e55993f5c93a99b21 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php @@ -292,7 +292,7 @@ abstract class AvisControllersFixturesTestCase extends AbonneFlorenceIsLoggedCon $this->avis_millenium = Class_AvisNotice::newInstanceWithId(13, [ 'entete' => "J'adore", - 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul><div>', + 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', 'note' => 5, 'date_avis' => '2011-03-18 13:00:00', 'user' => $this->florence, @@ -448,7 +448,7 @@ class AbonneControllerAvisViewAvisActionTest extends AvisControllersFixturesTest /** @test */ public function allAvisContentShouldBeDisplay() { - $this->assertContains('<p><div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul><div></p>', $this->_response->getBody()); + $this->assertContains('<p><div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div></p>', $this->_response->getBody()); } @@ -594,12 +594,12 @@ class AbonneControllerAvisBlogControllerLastCritiquesTest extends AvisController public function testPotterIsBeforeMillenium() { - $this->assertXPathContentContains("//div[@class='critique'][2]//h2", 'Potter et la chambre des secrets',$this->_response->getBody()); + $this->assertXPathContentContains("//div[@class='critique'][3]//h2", 'Potter et la chambre des secrets',$this->_response->getBody()); } public function testAvisLostShouldDisplayOeuvreNonTrouvee() { - $this->assertXPathContentContains("//div[@class='critique'][3]//h2", 'Oeuvre non trouvée'); + $this->assertXPathContentContains("//div[@class='critique'][4]//h2", 'Oeuvre non trouvée'); } } @@ -665,18 +665,19 @@ class AbonneControllerAvisBlogControllerViewCritiquesWithoutModuleTest extends M class AbonneControllerAvisRssControllerLastCritiquesTest extends ModuleSelectionCritiquesTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/rss/critiques/id_profil/2/id_module/3', true); - $this->body = $this->getResponse()->getBody(); - } - public function testMilleniumIsHere() { - $this->assertNotEquals(false, strpos($this->body, 'Millenium')); + + /** @test */ + public function milleniumShouldBePresent() { + $this->assertContains('Millenium', $this->_response->getBody()); } - public function testPotterIsHere() { - $this->assertNotEquals(false, strpos($this->body, 'Potter')); + + /** @test */ + public function potterShouldBePresent() { + $this->assertContains('Potter', $this->_response->getBody()); } }