trim all the things ! and generate the cover in the SQL query

master
Gilles Crettenand 11 years ago
parent 4fcdc76312
commit 590cfd0e6b

@ -76,26 +76,30 @@ class AudioBook extends DbMapping
$multiple = false; $multiple = false;
} }
// The following query should be maintained in sync with the one in the solr data source.
$sql = sprintf("SELECT DISTINCT $sql = sprintf("SELECT DISTINCT
Notices.[NoticeID] AS id, Notices.[NoticeID] AS id,
LTRIM(RTRIM(Notices.[Title])) AS title, LTRIM(RTRIM(Notices.[Title])) AS title,
Notices.[Author] AS author, LTRIM(RTRIM(Notices.[Author])) AS author,
LTRIM(RTRIM(Notices.[NoticeNr])) AS code, LTRIM(RTRIM(Notices.[NoticeNr])) AS code,
Fields.[520] AS summary, Fields.[520] AS summary,
REPLACE(Fields.[260b], ',', '') AS editor, REPLACE(Fields.[260b], ',', '') AS editor,
LEFT(SUBSTRING(Fields.[260c], PATINDEX('%%[0-9]%%', Fields.[260c]), 8000), PATINDEX('%%[^0-9]%%', SUBSTRING(Fields.[260c], PATINDEX('%%[0-9]%%', Fields.[260c]), 8000) + 'X')-1) AS year, LEFT(SUBSTRING(Fields.[260c], PATINDEX('%%[0-9]%%', Fields.[260c]), 8000), PATINDEX('%%[^0-9]%%', SUBSTRING(Fields.[260c], PATINDEX('%%[0-9]%%', Fields.[260c]), 8000) + 'X')-1) AS year,
Fields.[300] AS media, Fields.[300] AS media,
Fields.[490a] AS collection, Fields.[490a] AS collection,
isbn.DisplayText AS isbn, LTRIM(RTRIM(isbn.DisplayText)) AS isbn,
Fields.[901] AS reader, Fields.[901] AS reader,
Fields.[899a] AS cover, Fields.[899a] AS cover,
'' AS category, -- supposed to come from tags 600, 610, 650, 651, 655, 690, 691, 695, 696 but always empty anyway '' AS category, -- supposed to come from tags 600, 610, 650, 651, 655, 690, 691, 695, 696 but always empty anyway
item1.AcquisitionDate AS availabilityDate, item1.AcquisitionDate AS availabilityDate,
ProducerCode.TextFre As producer, LTRIM(RTRIM(ProducerCode.TextFre)) As producer,
LTRIM(RTRIM(ProducerCode.Code)) AS producerCode, LTRIM(RTRIM(ProducerCode.Code)) AS producerCode,
GenreCode.TextFre As genre, LTRIM(RTRIM(GenreCode.TextFre)) As genre,
LTRIM(RTRIM(GenreCode.Code)) AS genreCode, LTRIM(RTRIM(GenreCode.Code)) AS genreCode,
Notices.[coverdisplay], CASE
WHEN Notices.coverdisplay = 2 THEN 'http://fichiers.bibliothequesonore.ch:8089/netbiblio/images/covers/Cover' + CAST(Notices.NoticeID AS VARCHAR) + '_Original.jpg'
ELSE 'http://ecx.images-amazon.com/images/I/' + Fields.[899a] + '._SL320_.jpg'
END AS cover,
Fields.[856u] AS link, Fields.[856u] AS link,
Fields.[856z] AS linkTitle, Fields.[856z] AS linkTitle,
LTRIM(RTRIM(Notices.[MediaType1Code])) AS mediaType LTRIM(RTRIM(Notices.[MediaType1Code])) AS mediaType
@ -112,8 +116,8 @@ class AudioBook extends DbMapping
ELSE Tag ELSE Tag
END AS Field, END AS Field,
CASE CASE
WHEN Tag = '020' THEN CAST(AuthorityID AS varchar) WHEN Tag = '020' THEN LTRIM(RTRIM(CAST(AuthorityID AS varchar)))
ELSE ContentShortPart ELSE LTRIM(RTRIM(ContentShortPart))
END AS Data END AS Data
FROM NoticeFields FROM NoticeFields
WHERE WHERE
@ -150,12 +154,6 @@ class AudioBook extends DbMapping
$books = array(); $books = array();
while($row = $result->next()) { while($row = $result->next()) {
if($row['coverdisplay'] == 2) {
$row['cover'] = 'http://fichiers.bibliothequesonore.ch:8089/netbiblio/images/covers/Cover'.$row['id'].'_Original.jpg';
} else if(strlen($row['cover']) > 0) {
$row['cover'] = 'http://ecx.images-amazon.com/images/I/'.$row['cover'].'._SL320_.jpg';
}
$books[$row['id']] = $raw ? $row : new AudioBook($row); $books[$row['id']] = $raw ? $row : new AudioBook($row);
} }

Loading…
Cancel
Save