Commit 46a59377 authored by Laurent's avatar Laurent
Browse files

dev #86172 On author page view, Bokeh now fetch Wikidata, BNF, ISNI and...

dev #86172 On author page view, Bokeh now fetch Wikidata, BNF, ISNI and YouTube channel identifiers.

On author page view, Bokeh adds INA interviews and first three videos of author's YouTube channel when available.

Improve AJAXification of thumbnails rendering for records
parent 066ea25f
Pipeline #6220 canceled with stage
in 32 seconds
- ticket #86172 : Enrichissements : import des identifiants Wikidata, BNF Ark, ISNI et YouTube dans la codification des auteurs. Enrichissement YouTube et INA des pages auteur.
\ No newline at end of file
......@@ -49,6 +49,9 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
public function thumbnailAction() {
if (!$record = Class_Notice::find((int)$this->_getParam('id')))
return $this->_redirectClose($this->_getReferer());
$this->view->titre = $this->_('Modifier la vignette');
$form = new ZendAfi_Form_VignetteNotice(['action' => $this->view->url(['module' => 'admin',
......@@ -67,7 +70,7 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
}
$this->view->form = $form;
$this->view->url_vignette = Class_Notice::find((int)$this->_getParam('id'))->fetchUrlVignette();
$this->view->url_vignette = $record->fetchUrlLocalVignette();
}
......
......@@ -24,11 +24,51 @@ class AuthorController extends ZendAfi_Controller_Action {
if (!$author = $this->_findAuthor())
throw new Zend_Controller_Action_Exception($this->view->_('Désolé, cette page n\'existe pas'), 404);
$this->_addInspectorGadget($author);
$this->view->author_description = new Class_CodifAuteur_Description($author);
$this->view->titre = $this->view->_('Auteur');
}
public function renderYoutubeChannelAction() {
session_write_close();
$this->getHelper('ViewRenderer')->setNoRender();
if (!$author = $this->_findAuthor())
return;
$items = [];
foreach((new Class_WebService_Youtube())
->videosOfChannel($author->getYoutubeChannelId()) as $video) {
$items[] = $this->view->tag('div',
$this->view->tag('iframe', '', ['src' => $video->getEmbedUrl()])
.
$this->view->tag('h3', $video->getTitle()));
if (3 == count($items))
break;
}
$html = $this->view->tag('div', implode($items));
$this->_response->setHeader('Content-Type', 'text/html;charset=utf-8');
$this->_response->setBody($html);
}
protected function _addInspectorGadget($author) {
if (!$ig = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget'))
return;
if(!$ig->isEnabled())
return;
$ig->addButton(new Class_Entity(['Label' => $this->_('Auteur Bokeh'),
'Content' => $this->view->renderAuthorMetadata($author)]));
}
protected function _findAuthor() {
if ($id = (int)$this->_getParam('id'))
return Class_CodifAuteur::find($id);
......
......@@ -343,6 +343,7 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
public function videosAction() {
$width = $this->_getParam('width', 500) - 8; //8px du skin de l'INA sur lequel on n'a pas la main
$height = (int)($width * 4/5);
$author = $this->_getParam('author', $this->notice->getAuteurPrincipal());
if ($num_video = $this->_getParam("num_video", 0)) {
$num_video = $num_video-1;
......@@ -352,8 +353,8 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
}
unset($_SESSION["video_interview"]);
$notice=$this->notice->getNotice("JA");
if(!trim($notice["A"])) {
if(!$author) {
$html=$this->notice_html->getNonTrouve($this->view->_("Cette notice n'a pas d'auteur."),true);
$this->_sendResponseWithScripts($html);
return;
......@@ -361,10 +362,8 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
if($this->service_afi > "") {
$args = ['titre' => $notice['J'],
'auteur' => $notice['A'],
'width' => $width,
'height' => $height];
$args = ['auteur' => $author,
'width' => $width];
$data = Class_WebService_AllServices::runServiceAfiInterviews($args);
$source = $data["source"];
$videos = $data["videos"];
......
......@@ -491,6 +491,7 @@ class RechercheController extends ZendAfi_Controller_Action {
$viewRenderer->setNoRender();
session_write_close();
$this->_response->setHeader('Content-Type', 'image/png');
$record = Class_Notice::find((int)$this->_getParam('id'));
(new Class_WebService_Vignette())
->renderThumbnail($record->getId(),
......
......@@ -290,6 +290,6 @@ class RssController extends Zend_Controller_Action
$notice->getAuteurPrincipal(),
$notice->getEditeur(),
$notice->getAnnee(),
$this->view->absoluteUrl($notice->fetchUrlVignette()));
$this->view->absoluteUrl($notice->fetchUrlLocalVignette()));
}
}
......@@ -9,7 +9,7 @@ Class_ScriptLoader::getInstance()
$html = '';
foreach($this->notices as $notice)
$html .= $this->tagAnchor($this->urlNotice($notice, $this->preferences, null, true),
$this->tagImg($this->absoluteUrl($notice->fetchUrlVignette()),
$this->tagImg($this->absoluteUrl($notice->fetchUrlLocalVignette()),
['title' => $notice->getTitrePrincipal()]),
['target' => '_parent']);
......
......@@ -8,7 +8,7 @@ Class_ScriptLoader::getInstance()
$records_html = '';
foreach($this->notices as $notice) {
$onclick = "window.parent.location='". $this->urlNotice($notice, $this->preferences, null, true) . "';";
$records_html .= $this->tagImg($this->absoluteUrl($notice->fetchUrlVignette(true)),
$records_html .= $this->tagImg($this->absoluteUrl($notice->fetchUrlLocalVignette()),
['title' => $notice->getTitrePrincipal(),
'onclick' => $onclick,
'width' => $this->preferences["op_largeur_img"] . 'px',
......
......@@ -49,7 +49,7 @@ function mycarousel_initCallback(carousel) {
$lis = '';
foreach($this->notices as $notice) {
$img = $this->tagImg($this->absoluteUrl($notice->fetchUrlVignette()),
$img = $this->tagImg($this->absoluteUrl($notice->fetchUrlLocalVignette()),
['title' => $notice->getTitrePrincipal(),
'width' => $this->preferences["op_largeur_img"],
'height' => $this->preferences["op_hauteur_img"]]);
......
<?php
$lis = '';
foreach($this->records as $record) {
$img = $this->tagImg($this->absoluteUrl($record->fetchUrlVignette()),
$img = $this->tagImg($this->absoluteUrl($record->fetchUrlLocalVignette()),
['title' => $record->getTitrePrincipal(),
'width' => $this->preferences["op_largeur_img"],
'height' => $this->preferences["op_hauteur_img"]]);
......
......@@ -15,7 +15,7 @@ Class_ScriptLoader::getInstance()
$anchors = '';
foreach($this->notices as $notice) {
$img = $this->tagImg($this->absoluteUrl($notice->fetchUrlVignette()),
$img = $this->tagImg($this->absoluteUrl($notice->fetchUrlLocalVignette()),
['border' => '0',
'width' => $this->preferences['op_largeur_img'],
'height' => $this->preferences['op_hauteur_img'],
......
......@@ -14,7 +14,7 @@ if(!$hauteur) $hauteur=110;
$images = '';
foreach($this->notices as $notice){
$images .= $this->tagAnchor($this->urlNotice($notice, $this->preferences, null, true),
$this->tagImg($this->absoluteUrl($notice->fetchUrlVignette()),
$this->tagImg($this->absoluteUrl($notice->fetchUrlLocalVignette()),
['alt' => $this->_('vignette notice') . ' ' . $notice->getTitrePrincipal(),
'title' => $notice->getTitrePrincipal(),
'width' => $largeur,
......
<table border="0" cellpadding="3" cellspacing="1">
<tr>
<td rowspan="2" valign="top">
<img src="<?php print($this->notice->fetchUrlVignette()); ?>" width="90px" onclick="<?php print($this->notice->fetchUrlImage());?> " style="cursor:pointer"/>
<img src="<?php print($this->notice->fetchUrlLocalVignette()); ?>" width="90px" onclick="<?php print($this->notice->fetchUrlImage());?> " style="cursor:pointer"/>
</td>
<td valign="top" width="550px">
<table width="100%">
......
......@@ -4,7 +4,7 @@ echo $this->toolbar($this->_("Recherche"),
<ul data-role="listview" data-inset="true" class="doctype_<?php echo $this->notice->getTypeDoc();?>">
<li data-theme="c">
<img src="<?php echo $this->notice->fetchUrlVignette();?>">
<img src="<?php echo $this->notice->fetchUrlLocalVignette();?>">
<h3><?php echo $this->iconeSupport($this->notice->getTypeDoc()) . $this->notice->getTitrePrincipal() ;?></h3>
<p class="serie">
<?php
......
<?php
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try {
$adapter->query('alter table codif_auteur add column wikidata_id varchar(255)');
$adapter->query('alter table codif_auteur add column youtube_channel_id varchar(255)');
$adapter->query('alter table codif_auteur add column isni varchar(255)');
$adapter->query('alter table codif_auteur add column ark varchar(255)');
$adapter->query('alter table codif_auteur add index wikidata_id (wikidata_id)');
} catch(Exception $e) {}
......@@ -435,7 +435,7 @@ class Class_AvisNotice extends Storm_Model_Abstract {
public function getUrlVignette() {
if (!$notice = $this->getFirstNotice())
return '';
return $notice->fetchUrlVignette();
return $notice->fetchUrlLocalVignette();
}
......
......@@ -118,7 +118,11 @@ class Class_CodifAuteur extends Storm_Model_Abstract {
$_default_attribute_values = ['libelle' => '',
'mots_renvois' => '',
'id_bnf' => '',
'date_creation' => ''];
'date_creation' => '',
'wikidata_id' => '',
'youtube_channel_id' => '',
'isni' => '',
'ark' => ''];
public function getCategorie() {
return;
......
......@@ -34,6 +34,11 @@ class Class_CodifAuteur_Description {
}
public function getId() {
return $this->_author->getId();
}
public function getLabel() {
return $this->_author->getLibelle();
}
......@@ -61,6 +66,11 @@ class Class_CodifAuteur_Description {
}
public function getYoutubeChannelId() {
return $this->_author->getYoutubeChannelId();
}
public function getRecords() {
if (isset($this->_all_records))
return $this->_all_records;
......@@ -93,6 +103,14 @@ class Class_CodifAuteur_Description {
$this->getRecords(),
$this->getAssociatedAuthors());
$author_attribs = array_intersect_key($data, ['wikidata_id' => '',
'youtube_channel_id' => '',
'ark' => '',
'isni' => '']);
$this->_author
->updateAttributes($author_attribs)
->save();
if ($biography = $data['biographie']) {
$biography = $this->_enrichBiographyWithRecords($biography,
$this->getRecords(),
......@@ -157,7 +175,9 @@ class Class_CodifAuteur_Description {
$associated_authors = [];
foreach($facets as $code => $count) {
$id = substr($code, 1);
$associated_authors[$id] = ['author' => Class_CodifAuteur::find($id),
if (!$collaborator = Class_CodifAuteur::find($id))
continue;
$associated_authors[$id] = ['author' => $collaborator,
'occurences' => $count];
}
......
......@@ -1579,7 +1579,7 @@ class Class_Notice extends Storm_Model_Abstract {
$visitor->visitTypeDoc($this->getTypeDoc());
$visitor->visitNatureDoc($this->getNatureDocs());
if ($this->hasVignette()) {
$visitor->visitVignette(Class_Url::absolute($this->fetchUrlVignette()));
$visitor->visitVignette(Class_Url::absolute($this->fetchUrlLocalVignette()));
$visitor->visitImage(Class_Url::absolute($this->fetchUrlImage()));
}
$visitor->visitIsbn($this->getIsbn());
......
......@@ -32,11 +32,7 @@ class Class_Notice_Thumbnail {
if ($this->_shouldRetry($record, $record->getUrlVignette()))
return $this->_service->getAjaxUrl($record);
$url = $record->getUrlVignette();
return $this->_service->isNoData($url)
? $this->_rawThumbnailUrl($record)
: $url;
return $record->getUrlVignette();
}
......
Markdown is supported
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