Skip to content
Snippets Groups Projects
Commit 51af6e90 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #17352 : button in inspector gadget

parent b1a707d7
Branches
Tags
3 merge requests!2660Master,!2594Master,!2549Dev#17352 cosmogramme garder l unimarc natif d une notice
Pipeline #3100 failed with stage
in 20 minutes and 42 seconds
......@@ -29,18 +29,33 @@ class Class_Cosmogramme_Integration_RecordHistory {
$_data,
$_integration,
$_folder_manager,
$_record_id,
$_item_ids = [];
public static function hasHistory($item) {
if (!$id = $item->getId())
return false;
if (!$id_bib = $item->getIdIntBib())
return false;
return (new static('', new Class_Entity(['IdBib' => $id_bib])))
->itemHasHistory($id);
}
public function __construct($data, $integration) {
$this->_data = $data;
$this->_integration = $integration;
}
public function setRecord($record) {
$this->_record_id = $record->getId();
public function itemHasHistory($id) {
if (!$path = $this->_getPathOf($id))
return false;
return $this->getFileSystem()->file_exists($path);
}
......@@ -51,9 +66,6 @@ class Class_Cosmogramme_Integration_RecordHistory {
public function save() {
if (!$this->_record_id)
return $this;
foreach($this->_item_ids as $item_id)
$this->_saveForItem($item_id);
......
......@@ -136,7 +136,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);
......@@ -148,6 +150,25 @@ class ZendAfi_View_Helper_Notice_Unimarc extends Zend_View_Helper_HtmlElement {
}
protected function renderItemDownload($item) {
if (!Class_Cosmogramme_Integration_RecordHistory::hasHistory($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);
......
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