diff --git a/application/modules/admin/views/scripts/upload/biographie-notice.phtml b/application/modules/admin/views/scripts/upload/biographie-notice.phtml index 23d75320ca00bf4715572fe9bbbd3837f267b6dd..cdead047fc63a762a1a41477002b43d091b651fc 100644 --- a/application/modules/admin/views/scripts/upload/biographie-notice.phtml +++ b/application/modules/admin/views/scripts/upload/biographie-notice.phtml @@ -1,7 +1,6 @@ -<h1 style="text-align: center; margin-bottom: 10px"><?php echo $this->_('Modifier la vignette'); ?></h1> +<h1 style="text-align: center; margin-bottom: 10px"><?php echo $this->_('Modifier la biographie'); ?></h1> <div class="formTable" style="margin: 0 auto"> - <?php if ($this->error) echo '<div class="error">'.$this->_('Erreur: ').$this->error.'</div>'; diff --git a/library/Class/NoticeHtml.php b/library/Class/NoticeHtml.php index 7e1c2396243e5991610346910084637107849e68..455f00e01ad09698e15929c7c7a115287bcf9a2b 100644 --- a/library/Class/NoticeHtml.php +++ b/library/Class/NoticeHtml.php @@ -164,64 +164,6 @@ class Class_NoticeHtml { } -//------------------------------------------------------------------------------------------------------ -// Biographie -//------------------------------------------------------------------------------------------------------ - public function getBiographie($data,$notice) { - if(!$data["biographie"]) - return $this->getNonTrouve("",true); - - $auteur = $notice->getAuteurPrincipal(); - $html=$this->haut_onglet; - $html.='<table width="100%">'; - $html.=sprintf('<tr><td class="notice_info_titre" align="left" width="100%%">%s<font size="-2"> (%s : %s)</font></td></tr>', - $auteur, - $this->_translate->_('Source'), - $data["source"]); - $suite = false; - foreach ($data["biographie"] as $ligne) { - if(!isset($ligne["texte"])) continue; - if(isset($ligne["liste"])){ - $liste='<ul class="notice_info">'; - foreach($ligne["liste"] as $item) $liste.='<li class="notice_liste">'.$item.'</li>'; - $liste.='</ul>'; - $ligne["texte"]=str_replace("@LISTE@",$liste,$ligne["texte"]); - } - if ($suite){ - if(isset($ligne["titre"])) - $html.='<tr><td class="notice_info_titre" align="left" width="100%">'.$ligne["titre"].'</td></tr>'; - - $html.='<tr><td class="notice_info" align="left" width="100%">'.$ligne["texte"].'</td></tr>'; - } - else - { - if(!$data["vignette"]) $vignette=''; - else - { - $vignette = $this->_translate->_('<img src="%s" style="%s" alt="%s" />', - $data["vignette"], - 'border:0;width:100px;float:left;margin-right:5px;cursor:pointer', - $this->_translate->_('Vignette')); - if($data["image"]) - { - $id="auteur_".$notice->getId(); - $vignette='<a id="'.$id.'" href="'.$data["image"].'" rel="lightbox" title="'.$auteur.'">'.$vignette; - $vignette.='</a>'; - $vignette.='<script type="text/javascript">$("a[id=\''.$id.'\']").slimbox({}, null, null)</script>'; - } - } - - $html.='<tr><td><table>'; - $html.='<tr><td class="notice_info">'.$vignette; - $html.=$ligne["texte"].'</td></tr>'; - $html.='</table></td></tr>'; - $suite=true; - } - } - $html.='</table>'; - return $html; - } - //------------------------------------------------------------------------------------------------------ // Bande annonce //------------------------------------------------------------------------------------------------------ diff --git a/library/Class/WebService/AllServices.php b/library/Class/WebService/AllServices.php index 97b8d396a42f6883237a31a6db6915f1a73c56f8..d6cebee106a76f6bd73295ea09e7bd84d8efe180 100644 --- a/library/Class/WebService/AllServices.php +++ b/library/Class/WebService/AllServices.php @@ -174,7 +174,7 @@ class Class_WebService_AllServices { $args['src'] = self::createSecurityKey(); $args['action'] = $service; -/// $args['XDEBUG_SESSION_START'] = 1; + $args['XDEBUG_SESSION_START'] = 1; return json_decode(self::httpGet($url_service, $args), true); diff --git a/library/ZendAfi/View/Helper/Biographie.php b/library/ZendAfi/View/Helper/Biographie.php index 04fdaa7bf28270f13dc379f918cec6b4618cb7e4..d3c33f6623bfcab6c4aec8b3c0f078b3c9f3b2bd 100644 --- a/library/ZendAfi/View/Helper/Biographie.php +++ b/library/ZendAfi/View/Helper/Biographie.php @@ -33,8 +33,77 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement { 'clef_oeuvre' => $notice->getClefOeuvre()]; $data = Class_WebService_AllServices::runServiceAfiBiographie($args); - return $notice_html->getBiographie($data, $notice); + return $this->renderModifierBiographieLink($notice) + .$this->renderBiographie($data, $notice); } + + + public function renderModifierBiographieLink($notice) { + return sprintf('<a href="#" onclick="showPopWin(\'%s\', 750, 350); return false;">%s</a>', + $this->view->url(['module' => 'admin', + 'controller' => 'upload', + 'action' => 'biographie-notice', + 'id' => $notice->getId(), + ]), + $this->view->_('Modifier la biographie')); + } + + + public function renderBiographie($data,$notice) { + if(!$data["biographie"]) + return $this->getNonTrouve("",true); + + $auteur = $notice->getAuteurPrincipal(); + + $html = '<table width="100%">'; + $html.=sprintf('<tr><td class="notice_info_titre" align="left" width="100%%">%s<font size="-2"> (%s : %s)</font></td></tr>', + $auteur, + $this->view->_('Source'), + $data["source"]); + $suite = false; + foreach ($data["biographie"] as $ligne) { + if(!isset($ligne["texte"])) continue; + if(isset($ligne["liste"])){ + $liste='<ul class="notice_info">'; + foreach($ligne["liste"] as $item) $liste.='<li class="notice_liste">'.$item.'</li>'; + $liste.='</ul>'; + $ligne["texte"]=str_replace("@LISTE@",$liste,$ligne["texte"]); + } + if ($suite){ + if(isset($ligne["titre"])) + $html.='<tr><td class="notice_info_titre" align="left" width="100%">'.$ligne["titre"].'</td></tr>'; + + $html.='<tr><td class="notice_info" align="left" width="100%">'.$ligne["texte"].'</td></tr>'; + } + else + { + if(!$data["vignette"]) $vignette=''; + else + { + $vignette = $this->view->_('<img src="%s" style="%s" alt="%s" />', + $data["vignette"], + 'border:0;width:100px;float:left;margin-right:5px;cursor:pointer', + $this->view->_('Vignette')); + if($data["image"]) + { + $id="auteur_".$notice->getId(); + $vignette='<a id="'.$id.'" href="'.$data["image"].'" rel="lightbox" title="'.$auteur.'">'.$vignette; + $vignette.='</a>'; + $vignette.='<script type="text/javascript">$("a[id=\''.$id.'\']").slimbox({}, null, null)</script>'; + } + } + + $html.='<tr><td><table>'; + $html.='<tr><td class="notice_info">'.$vignette; + $html.=$ligne["texte"].'</td></tr>'; + $html.='</table></td></tr>'; + $suite=true; + } + } + $html.='</table>'; + return $html; + } + } ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 0e79abd71e6986f6034060616f73668ac02d2af2..16d916c69ec758152b66a2735ba35ebe1244bf5d 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -1020,4 +1020,61 @@ class NoticeAjaxControllerErrorTagsTest extends AbstractControllerTestCase { } } + + + +class NoticeAjaxControllerBiographieTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + Class_Notice::newInstanceWithId(23, ['auteur_principal' => 'J.K Rowling', + 'clef_oeuvre' => 'HARRY_POTTER']); + + Class_CosmoVar::newInstanceWithId('url_services', ['valeur' => 'http://cache.org']); + + Class_WebService_AllServices::setHttpClient($http_client = Storm_Test_ObjectWrapper::mock() + ->whenCalled('open_url') + ->with('http://cache.org' + .'?auteur='.urlencode('J.K Rowling') + .'&clef_oeuvre=HARRY_POTTER' + .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&action=8') + + ->answers(json_encode(['statut_recherche' => '0', + 'source' => 'Wikipedia', + 'vignette' => 'rowling.jpg', + 'image' => 'rowling_big.jpg', + 'biographie' => [ + ['texte' => 'Auteur de H.Potter'] + ] + ]))); + + $this->dispatch('/opac/noticeajax/biographie/id_notice/23', true); + } + + + /** @test */ + public function htmlShouldContainsTDWithAuteurDeHarryPotter() { + $this->assertXPathContentContains('//td', 'Auteur de H.Potter', $this->_response->getBody()); + } + + + /** @test */ + public function imgShouldContainsRowlingDotJpg() { + $this->assertXPath('//img[@src="rowling.jpg"]'); + } + + + /** @test */ + public function anchorShouldContainsRowlingBigDotJpg() { + $this->assertXPath('//a[@href="rowling_big.jpg"]'); + } + + + /** @test */ + public function linkModifierLaBiographieShouldBeVisible() { + $this->assertXPathContentContains('//a', 'Modifier la biographie'); + } +} + ?> \ No newline at end of file