Skip to content
Snippets Groups Projects
Commit d7c66073 authored by Laurent's avatar Laurent
Browse files

Merge branch 'hotline_#18668_wkipedia_api' into 'stable'

Hotline #18668 wkipedia api

See merge request !833
parents 97b9c099 2ba68563
Branches
Tags
2 merge requests!896Master,!850Master
- ticket #18668 : évolution du rendu des biographies en provenance de l'API de wikipedia.
\ No newline at end of file
......@@ -22,6 +22,8 @@
class Class_WebService_AllServices {
const RETOUR_SERVICE_OK = 2;
const SVC_API = '2.0';
private static $_http_client;
private $services = [
......@@ -151,6 +153,7 @@ class Class_WebService_AllServices {
$args = array();
$args['src'] = self::createSecurityKey();
$args['api'] = self::SVC_API;
$args['action'] = $service;
return json_decode(self::httpGet($url_service, $args),
......
......@@ -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_Biographie extends Zend_View_Helper_HtmlElement {
......@@ -25,10 +25,10 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement {
public function biographie($notice) {
$notice_html = new Class_NoticeHtml();
if (!$auteur = $notice->getAuteurPrincipal())
if (!$auteur = $notice->getAuteurPrincipal())
return $notice_html->getNonTrouve($this->view->_("Cette notice n'a pas d'auteur"),true);
if (!Class_CosmoVar::get('url_services'))
if (!Class_CosmoVar::get('url_services'))
return $notice_html->getNonTrouve($this->view->_("Service non disponible"));
$args = ['auteur' => $auteur,
......@@ -45,7 +45,7 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement {
return '';
return sprintf('<a href="#" onclick="showPopWin(\'%s\', 750, 350); return false;">%s</a>',
$this->view->url(['module' => 'admin',
$this->view->url(['module' => 'admin',
'controller' => 'upload',
'action' => 'biographie-notice',
'id' => $notice->getId(),
......@@ -60,6 +60,12 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement {
$data["biographie"] = [];
}
$source = $this->view->tag('p', $this->view->_('Source'). ' : ' . $data['source']);
$biographie = $data['biographie'];
if(!is_array($biographie) && preg_match("/<[^<]+>/", $biographie) != 0)
return $source . $biographie;
$auteur = $notice->getAuteurPrincipal();
$html = '<table width="100%">';
......@@ -77,7 +83,7 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement {
$ligne["texte"]=str_replace("@LISTE@",$liste,$ligne["texte"]);
}
if ($suite){
if(isset($ligne["titre"]))
if(isset($ligne["titre"]))
$html.='<tr><td class="notice_info_titre" align="left" width="100%"><h3>'.$ligne["titre"].'</h3></td></tr>';
$html.='<tr><td class="notice_info" align="left" width="100%">'.$ligne["texte"].'</td></tr>';
......@@ -99,7 +105,7 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement {
$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>';
......
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_BiographieAuthorTest extends ViewHelperTestCase {
public function setUp() {
parent::setUp();
$view = new ZendAfi_Controller_Action_Helper_View();
$this->_helper = new ZendAfi_View_Helper_Biographie();
$this->_helper->setView($view);
$this->_html = $this->_helper->renderBiographie(['source' => 'wiki',
'biographie' => '<p>A html biographie !</p>'],
$this->fixture('Class_Notice',
['id' => 1]));
}
/** @test */
public function biographieShouldContainsHtml() {
$this->assertEquals('<p >Source : wiki</p><p>A html biographie !</p>', $this->_html);
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment