store zip file in Solr too

master
Gilles Crettenand 11 years ago
parent 7b2c4c18ee
commit 6e2a707df1

@ -252,8 +252,8 @@ class NetBiblio extends WebService
return array( return array(
'id' => $f['id'], 'id' => $f['id'],
'samples' => array('set' => isset($f['samples']) ? $f['samples'] : array()), 'samples' => array('set' => isset($f['samples']) ? $f['samples'] : array()),
// for now, we don't know how to save the zip without the hash 'zip' => array('set' => isset($f['zip']['uri']) ? $f['zip']['uri'] : ''),
'zip' => '', // array('set' => isset($f['zip']['uri']) ? $f['zip']['uri'] : ''), 'zip_size' => array('set' => isset($f['zip']['size']) ? $f['zip']['size'] : 0),
); );
}, $files))); }, $files)));
@ -291,9 +291,13 @@ class NetBiblio extends WebService
} }
unset($b['samples']); unset($b['samples']);
if(isset($b['zip']) && strlen($b['zip']) > 0) { if(isset($b['zip']) && strlen($b['zip']) > 0) {
$files['zip'] = $b['zip']; $files['zip'] = array(
'uri' => $b['zip'],
'size' => $b['zip_size'],
);
} }
unset($b['zip']); unset($b['zip']);
unset($b['zip_size']);
if(! empty($files)) { if(! empty($files)) {
$b['files'] = $files; $b['files'] = $files;
@ -337,6 +341,28 @@ class NetBiblio extends WebService
$this->SetFiles($files); $this->SetFiles($files);
} }
// add hash, client and login into zip file uri
$books = array_map(function($b) {
if(strlen($this->login) > 0 && isset($b['files']['zip']['uri'])) {
$key = 'babf2cfbe2633c3082f8cfffdb3d9008b4b3b300';
$hash = sha1($this->client.$this->login.$key.$b['code'].date('Ymd'));
$b['files']['zip']['uri'] = str_replace(array(
'{client}',
'{login}',
'{hash}',
), array(
$this->client,
$this->login,
$hash,
), $b['files']['zip']['uri']);
} else {
unset($b['files']['zip']);
}
return $b;
}, $books);
return $books; return $books;
} }

Loading…
Cancel
Save