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 (11)
Showing
with 373 additions and 31 deletions
'17352' =>
['Label' => $this->_('Visualisation du fichier envoyé par le SIGB pour chaque notice'),
'Desc' => $this->_('Bokeh conserve le dernier fichier reçu du SIGB pour chaque notice. Celui-ce est téléchargeable à partir d'Inspector Gadget. Nécessite une activation.'),
'Image' => '',
'Video' => '',
'Category' => 'Catalogue',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Date' => '2018-04-13'],
\ No newline at end of file
- ticket #17352 : Cosmogramme: Bokeh conserve le dernier fichier reçu du SIGB pour chaque notice. Celui-ce est téléchargeable à partir d'Inspector Gadget. Nécessite une activation.
\ No newline at end of file
......@@ -989,13 +989,8 @@ class AbonneController extends ZendAfi_Controller_Action {
$datas[] = $exemplaire->toUnimarcIso2709();
}
$response = $this->_response;
$response->clearAllHeaders();
$filename = 'prets_' . $this->_user->getId() . '-' . uniqid() . '.txt';
$response->setHeader('Content-Type', 'application/octet-stream; name="' . $filename . '"', true);
$response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"', true);
$response->setBody(implode('', $datas));
$this->_helper->binaryDownload(implode($datas), $filename);
}
......
......@@ -746,32 +746,21 @@ class RechercheController extends ZendAfi_Controller_Action {
public function downloadRecordAction() {
if (!$record = Class_Notice::find($this->_getParam('id', 0))) {
$this->_redirect('/');
return;
}
if (!$record = Class_Notice::find($this->_getParam('id', 0)))
return $this->_redirect('/');
$this->_helper->getHelper('ViewRenderer')->setNoRender(true);
if ($layout = Zend_Layout::getMvcInstance())
$layout->disableLayout();
$response = Zend_Controller_Front::getInstance()->getResponse();
$response->canSendHeaders(true);
$this->_helper->binaryDownload($record->getUnimarc(), $record->getId() . '.txt');
}
$response->clearAllHeaders();
$response->setHeader('Content-Type', 'application/octet-stream; name="' . $record->getId() . '.txt"', true);
$response->setHeader('Content-Transfer-Encoding', 'binary', true);
$unimarc = $record->getUnimarc();
$response->setHeader('Content-Length', strlen($unimarc), true);
$response->setHeader('Expires', '0');
$response->setHeader('Cache-Control', 'no-cache, must-revalidate');
$response->setHeader('Pragma', 'no-cache');
$response->setHeader('Content-Disposition', 'attachment; filename="' . $record->getId() . '.txt"', true);
public function downloadItemAction() {
if (!$item = Class_Exemplaire::find($this->_getParam('id', 0)))
return $this->_redirect('/');
$response->sendHeaders();
if (!$raw_record = Class_Cosmogramme_Integration_RawRecord::findFor($item))
return $this->_redirect('/');
echo $unimarc;
$this->_helper->binaryDownload($raw_record->getData(), $raw_record->getName());
}
......
......@@ -75,6 +75,9 @@ class notice_integration {
protected $_codif_provider;
protected $_raw_data;
public function __construct() {
$this->indexation = indexation::getInstance();
$this->filtrer_fulltext = Class_CosmoVar::get("filtrer_fulltext");
......@@ -146,6 +149,8 @@ class notice_integration {
public function traiteNotice($data) {
global $sql;
$this->_raw_data = $data;
$id_bib = $this->id_bib;
if(!$this->analyseur)
......@@ -156,7 +161,7 @@ class notice_integration {
unset($this->notice);
if(!$this->analyseur->ouvrirNotice($data,$this->id_profil,$this->sigb,$this->type_doc_force)) {
if(!$this->analyseur->ouvrirNotice($data, $this->id_profil, $this->sigb, $this->type_doc_force)) {
$this->erreur=$this->analyseur->getLastError();
return 0;
}
......@@ -489,6 +494,7 @@ class notice_integration {
$notice = Class_Notice::newInstance($this->noticeToDBEnreg());
$notice->save();
$this->statut = static::RECORD_INSERT;
return $notice->getId();
}
......@@ -746,6 +752,11 @@ class notice_integration {
if($record = Class_Notice::find($id_notice))
$record->setDateMaj(dateDuJour(2))->save();
(new Class_Cosmogramme_Integration_RawRecord($this->_raw_data,
$this->notice['id_origine'],
$this->id_int_bib))
->save();
Class_Exemplaire::clearCache();
Class_Notice::clearCache();
}
......
......@@ -396,7 +396,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
protected function _getCosmogrammeVars() {
return [
'DATE_LAST_FULL_INTEGRATION_USERS' => Class_AdminVar_Meta::newDefault($this->_('Date du dernier import total des abonnés (modifié par cosmogramme)')),
'INTEGRATIONS_TOO_LONG_ALERT_THRESHOLD' => Class_AdminVar_Meta::newDefault($this->_('Seuil d\'alerte en heures pour détecter que les traitements d\'intégration prennent trop de temps. Par défaut: 2', ['value' => 2]))
'INTEGRATIONS_TOO_LONG_ALERT_THRESHOLD' => Class_AdminVar_Meta::newDefault($this->_('Seuil d\'alerte en heures pour détecter que les traitements d\'intégration prennent trop de temps. Par défaut: 2', ['value' => 2])),
'KEEP_LAST_SIGB_RECORD' => Class_AdminVar_Meta::newOnOff($this->_('Conserve le dernier fichier transmis par le SIGB pour chaque notice. Celui-ci est téléchargeable à partir de l\'Inspecteur Gadget.'))->bePrivate(),
];
}
......@@ -957,6 +958,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
return Class_AdminVar::isBibNumEnabled()
&& Class_AdminVar::get('SITO_IN_ALBUMS');
}
public function shouldKeepLastSigbRecord() {
return Class_AdminVar::isModuleEnabled('KEEP_LAST_SIGB_RECORD');
}
}
......
......@@ -127,4 +127,4 @@ class Class_Cosmogramme_Integration_PhaseNotice
public static function setServiceRunner($runner) {
static::$_service_runner = $runner;
}
}
\ 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
*/
class Class_Cosmogramme_Integration_RawRecord {
use Trait_Versionable;
protected
$_library_id,
$_data,
$_id,
$_date;
public static function hasVersionFor($item) {
return static::isActive()
? static::_newFor($item)->hasVersion()
: false;
}
public static function findFor($item) {
if (!static::isActive())
return;
$instance = static::_newFor($item);
return ($instance = $instance->loadLastVersion())
? $instance
: null;
}
public static function isActive() {
return Class_AdminVar::shouldKeepLastSigbRecord();
}
protected static function _newFor($item) {
return new static('', $item->getIdOrigine(), $item->getIdIntBib());
}
public function __construct($data, $id, $library_id) {
$this->_library_id = $library_id;
$this->_data = $data;
$this->_id = $id;
}
public function getId() {
return $this->_id;
}
public function getLibraryId() {
return $this->_library_id;
}
public function getData() {
return $this->_data;
}
public function getName() {
return 'raw_record_'
. implode('_',
[$this->_library_id,
$this->_id,
$this->_humanDate()]);
}
public function save() {
if (!$this->_isValid())
return;
$this->newVersionWith(['id' => $this->_id,
'library_id' => $this->_library_id,
'data' => $this->_data]);
}
protected function _isValid() {
return static::isActive() && is_string($this->_data);
}
public function loadLastVersion() {
if (!static::isActive()
|| (!$version = $this->getLastVersion()))
return;
$this->_data = $version->getData()['data'];
$this->_date = $version->getDate();
return $this;
}
protected function _humanDate() {
return $this->_date
? date('Y-m-d', $this->_date)
: '';
}
}
<?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_Version_FilePersistence_RawRecord extends Class_Version_FilePersistence {
protected function _getMaxStack() {
return 1;
}
protected function _getFolderPath($versions) {
return $this->_getRootPath()
. implode('/', [static::BASE_PATH,
$this->_sanitize($versions->getName()),
$this->_sanitize($versions->getLibraryId()),
$this->_sanitize($versions->getKey())]);
}
protected function _fileName() {
return
$this->getTimeSource()->dateFormat('Y-m-d_His')
. '.json';
}
}
<?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_Versions_RawRecord extends Class_Versions {
protected static
$_file_persistence = 'Class_Version_FilePersistence_RawRecord';
protected
$_name = 'raw_record',
$_library_id;
public function __construct($model) {
parent::__construct($model);
$this->_library_id = $model->getLibraryId();
}
public function getLibraryId() {
return $this->_library_id;
}
}
<?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 ZendAfi_Controller_Action_Helper_BinaryDownload
extends Zend_Controller_Action_Helper_Abstract {
public function direct($content, $filename) {
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')
->setNoRender(true);
if ($layout = Zend_Layout::getMvcInstance())
$layout->disableLayout();
$response = $this->getResponse();
$response->canSendHeaders(true);
$response->clearAllHeaders();
$response->setHeader('Content-Type', 'application/octet-stream; name="' . $filename . '"', true);
$response->setHeader('Content-Transfer-Encoding', 'binary', true);
$response->setHeader('Content-Length', strlen($content), true);
$response->setHeader('Expires', '0');
$response->setHeader('Cache-Control', 'no-cache, must-revalidate');
$response->setHeader('Pragma', 'no-cache');
$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"', true);
$response->sendHeaders();
echo $content;
}
}
......@@ -127,7 +127,9 @@ class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
$html .= $this->_tag('strong', $label . ' : ')
. call_user_func([$item, $getter])
. $this->_tag('br');
$html .= $this->renderItem995($item);
$html .= $this->renderItem995($item)
. $this->renderItemDownload($item);
return $this->_tag('h3', $item->getBibLibelle() . ' ' . $item->getCodeBarres())
. $this->_tag('div', $html);
......@@ -139,6 +141,25 @@ class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
}
protected function renderItemDownload($item) {
if (!Class_Cosmogramme_Integration_RawRecord::hasVersionFor($item))
return '';
$download_url = $this->view->url(['controller' => 'recherche',
'action' => 'download-item',
'id' => $item->getId()],
null, true);
$button = (new Class_Entity)
->setText($this->_('Télécharger le fichier d\'origine'))
->setImage(Class_Admin_Skin::current()->renderActionIconOn('down', $this->view))
->setAttribs(['style' => 'float:right;',
'onclick' => 'document.location.href=\'' . $download_url .'\'']);
return $this->view->admin_Button($button);
}
public function __call($name, $args) {
if ('visit' != substr($name, 0, 5))
throw new RuntimeException('Call to unknown method ' . get_class($this) . '::' . $name);
......
<?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 RawRecordUnimarcVersionTest extends ModelTestCase {
protected
$_storm_default_to_volatile = true,
$_record;
public function setUp() {
parent::setUp();
$marc = file_get_contents(__DIR__ . '/audiard_herosdiscret.uni');
$this->_record = new Class_Cosmogramme_Integration_RawRecord($marc, '694479', 12);
}
/** @test */
public function whenNotActivatedShouldNotHaveCreatedOneVersion() {
Class_AdminVar::set('KEEP_LAST_SIGB_RECORD', 0);
$this->_record->save();
$this->assertEquals(0, $this->_record->numberOfVersions());
}
/** @test */
public function whenActivatedShouldHaveCreatedOneVersion() {
Class_AdminVar::set('KEEP_LAST_SIGB_RECORD', 1);
$this->_record->save();
$this->assertEquals(1, $this->_record->numberOfVersions());
}
}
01518ngm0 2200349 450 001000700000071002700007073001800034100001300052200004500065210001900110215001600129300013500145345001800280606002200298686001300320686004100333686003500374700007300409702005300482702005200535702004800587702004500635702004900680702005300729702003400782702003300816702003800849801001700887932001000904992012500914995012901039694479 a826030-9bStudio Canal a5050582603095 a201411061 aUn héros très discretfJacques Audiard cAliceleod1996 a1 DVD, 1h41 aD'après le roman de Jean-François Deniau. - Bonus : interview du réalisateur et Alain Le Henry. Scènes commentées. Making of. b826030-9cDVD acinéma français aF2PCDM4 aFictiontFiction2Code_Statistique_1 aFilmtFilm2Code_Statistique_2 1aAudiardbJacques31000251106g3006Metteur en scène ou réalisateur 1aDesplatbAlexandre3100025081142306Compositeur 1aDeniaubJean-François3100013496740706Auteur 1aKassovitzbMathieu3100021986940056Acteur 1aGrinbergbAnouk3130350006040056Acteur 1aKiberlainbSandrine310003627044005gActeur 1aTrintignantbJean-Louis3100022982340056Acteur 1aDupontelbAlbert40056Acteur 1aBarentinbNadia40056Acteur 1aLe HenrybAlain40006Intervenant 2aFrc20150829 aDrame uhttp://ecx.images-amazon.com/images/I/51%2BE27GCzjL._SL160_.jpgvhttp://ecx.images-amazon.com/images/I/51%2BE27GCzjL.jpg aMédiathèquef31879003220456kF AUDm20150829qdrgfopv12[DISPO][Disponible][0][1][][0][0][0][0]42015-02-1367778197
\ No newline at end of file