Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (5)
- ticket #73870 : Inspector Gadget : Après activation de la variable INSPECTOR_GADGET_MARC_XML,
l'Inspector Gadget d'une notice est capable d'afficher l'unimarc interne de Bokeh en marc-xml
\ No newline at end of file
......@@ -363,7 +363,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'BUID' => Class_AdminVar_Meta::newRawText($this->_('Identifiant unique (attention: la modification de cette variable impactera les outils de suivi de cette installation)'))->bePrivate(),
'STATUS_REPORT_PUSH_URL' => Class_AdminVar_Meta::newRawText($this->_('URL destinataire du rapport d\'état du système (0 pour désactiver)'), ['value' => 'http://pola.afi-sa.net/smile.php'])->bePrivate(),
'STATUS_REPORT_TAGS' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des tags à ajouter au rapport d\'état du système'))->bePrivate(),
'FEATURES_TRACKING_ENABLE' => Class_AdminVar_Meta::newOnOff('Affiche les dernières modifications apportés au logiciel Bokeh', ['value' => 1])->bePrivate()
'FEATURES_TRACKING_ENABLE' => Class_AdminVar_Meta::newOnOff('Affiche les dernières modifications apportés au logiciel Bokeh', ['value' => 1])->bePrivate(),
'INSPECTOR_GADGET_MARC_XML' => Class_AdminVar_Meta::newOnOff('Affiche le MARC XML de la notice dans Inspector Gadget')->bePrivate()
];
}
......@@ -903,6 +904,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
public static function isInspectorGadgetMarcXmlEnabled() {
return Class_AdminVar::isModuleEnabled('INSPECTOR_GADGET_MARC_XML');
}
public function getBabelthequeId() {
$mathes = [];
if (preg_match('/bw_([^\.]+)\.js/', (string)Class_AdminVar::get('BABELTHEQUE_JS'), $matches))
......
<?php
/**
* Copyright (c) 2012-2017, 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 Class_Testing_Yaz {
use Trait_StaticCommand, Trait_StaticFileSystem;
public function marcToMarcXml($unimarc) {
if(!$unimarc)
return [];
$filename = $this->_writeUnimarcInFile($unimarc);
$cmd = static::getCommand();
$cmd->exec(sprintf('yaz-marcdump -i marc -o marcxml %s', $filename));
static::getFileSystem()->unlink($filename);
return $cmd->getOutput();
}
protected function _writeUnimarcInFile($unimarc) {
$filename = PATH_TEMP . md5($unimarc) . '.marc';
static::getFileSystem()->unlink($filename);
static::getFileSystem()->file_put_contents($filename, $unimarc);
return $filename;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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
*/
trait Trait_Yaz {
protected static $_yaz;
public static function setYaz($yaz) {
static::$_yaz = $yaz;
}
public static function getYaz() {
if (null !== self::$_yaz)
return self::$_yaz;
return new Class_Testing_Yaz();
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@
class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
use Trait_Translator;
use Trait_Translator, Trait_Yaz;
protected $_headers;
protected $_zones;
......@@ -39,7 +39,8 @@ class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
. $this->_tag('div',
$this->renderTabs()
. $this->renderZones($notice)
. $this->renderItems($notice),
. $this->renderItems($notice)
. $this->renderMarcXml($notice),
['class' => 'ig-tabs']);
}
......@@ -67,11 +68,16 @@ class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
protected function renderTabs() {
return $this->_tag('ul',
$this->_tag('li', $this->_tag('a', $this->_('Zones'),
['href' => '#ig-tab-zones']))
. $this->_tag('li', $this->_tag('a', $this->_('Exemplaires'),
['href' => '#ig-tab-items'])));
$lis = [$this->_tag('li', $this->_tag('a', $this->_('Zones'),
['href' => '#ig-tab-zones'])),
$this->_tag('li', $this->_tag('a', $this->_('Exemplaires'),
['href' => '#ig-tab-items']))];
if(Class_AdminVar::isInspectorGadgetMarcXmlEnabled())
$lis [] = $this->_tag('li', $this->_tag('a', $this->_('MARC-XML'),
['href' => '#ig-tab-marc-xml']));
return $this->_tag('ul', implode($lis));
}
......@@ -139,6 +145,33 @@ class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
}
protected function renderMarcXml($notice) {
if(!Class_AdminVar::isInspectorGadgetMarcXmlEnabled())
return '';
$content = ($marc_xml = $this->_prettyPrint(static::getYaz()->marcToMarcXml($notice->getUnimarc())))
? $marc_xml
: $this->_tag('p', $this->_('Impossible d\'afficher le MARC-XML de cette notice.'), ['class' => 'error']);
return $this->_tag('div', $content, ['id' => 'ig-tab-marc-xml']);
}
protected function _prettyPrint($marc_xml_array) {
if(!$marc_xml_array)
return '';
if(empty($marc_xml_array))
return '';
$output = array_map(function($row)
{
return htmlspecialchars($row);
}, $marc_xml_array);
return implode(BR, $output);
}
public function __call($name, $args) {
if ('visit' != substr($name, 0, 5))
throw new RuntimeException('Call to unknown method ' . get_class($this) . '::' . $name);
......
......@@ -45,4 +45,8 @@
.inspector-gadget .ig-accordion {
height: 100%;
}
.inspector-gadget #ig-tab-marc-xml {
text-align: left;
}
\ No newline at end of file
......@@ -91,4 +91,59 @@ class RechercheControllerSearchResultWithInspectorGadgetTest extends AbstractCon
public function buttonConfigurationOfSearchShouldBePresent() {
$this->assertXPathContentContains('//button', 'Configuration de la recherche');
}
}
class RechercheControllerViewnoticeWithInspectorGadgetAndMarcXMLEnabledTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('INSPECTOR_GADGET_MARC_XML', 1);
$cmd = $this->mock()
->whenCalled('exec')
->answers(true)
->whenCalled('getOutput')
->answers(['<collection xmlns="http://www.loc.gov/MARC21/slim">',
'<record>',
'<leader>01185nam0a2200217 450 </leader>',
'<controlfield tag="001">2774</controlfield>',
'<datafield tag="010" ind1=" " ind2=" ">',
'<subfield code="a">2-84563-280-0</subfield>']);
$filesystem = $this->mock()
->whenCalled('unlink')
->answers(true)
->whenCalled('file_put_contents')
->answers(true);
Class_Testing_Yaz::setCommand($cmd);
Class_Testing_Yaz::setFileSystem($filesystem);
$this->fixture('Class_Notice',
['id' => 2,
'type_doc' => Class_TypeDoc::DILICOM,
'unimarc' => "01185nam0 2200217 450 0010005000000100031000050350016000360900009000520990038000611000041000991010008001402000036001482100013001842150011001973300660002083330010008686760006008787000028008848010026009129020029009382774 a2-84563-280-0d19,90 Euros aALOES355754 a2774 c2017-12-11d2018-03-16tLIVREx12 a20171211 frey50  afre aSeras-tu là ?fGuillaume Musso cXOd2012 a301 p. aUn seul geste aurait suffi pour tout changer. Qui n'a jamais rêvé de revenir à cet instant décisif où le bonheur était possible ? San Francisco. Elliott, médecin passionné, ne s'est jamais consolé de la disparition d'Ilena, la femme qu'il aimait, morte il y a trente ans. Un jour, par une circonstance extraordinaire, il est ramené en arrière et rencontre le jeune homme qu'il était, trente ans plus tôt. Il est revenu à l'instant décisif où un geste de lui peut sauver Ilena. Et modifier l'implacable destin qui a figé son sort à jamais. Un stupéfiant face-à-face, Une histoire d'amour bouleversante, Un suspense à couper le souffle. aAG 14 aR aMussobGuillaume960415 aFRbCALUIREc20060516 981440aroman francophone",
'alpha_titre' => '',
'alpha_auteur' => '']);
$this->dispatch('/opac/recherche/viewnotice/id/2/inspector_gadget/1', true);
}
/** @test */
public function tabMarcXMLShouldBePresent() {
$this->assertXPathContentContains('//button[contains(@onclick, "#ig-tab-marc-xml")]', 'Notice Bokeh');
}
/** @test */
public function marcXMLShouldBePresent() {
$this->assertXPathContentContains('//button[contains(@onclick, "controlfield")]', 'Notice Bokeh');
}
}
\ No newline at end of file