Skip to content
Snippets Groups Projects
Commit 55ed4fde authored by Graham Cole's avatar Graham Cole
Browse files

use amazon's description for books that have none

parent f3c44ca5
No related branches found
No related tags found
No related merge requests found
......@@ -98,11 +98,27 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) {
$book['author'] = htmlentities2($book['author']);
$book['onloan'] = ($book['onloan'] == 't') ? true : false;
// Extract amazon data (maybe this should be stored in separate field in the db?)
$simple_xml = simplexml_load_string($book['amazon_data']);
//FIXME: figure out how to tell if there was usable amazon data after all
//$book['description'] = $simple_xml->Items->Item->EditorialReviews->EditorialReview->Content;
if (!isset($book['description'])) {
// no book description in the database, try using Amazon data
// Extract amazon data (maybe this should be stored in separate fields in the db?)
$simple_xml = simplexml_load_string($book['amazon_data']);
$book['description'] = @$simple_xml->Items->Item->EditorialReviews->EditorialReview->Content;
if (isset($book['description'])) {
// tidy description markup
$tidy_config['doctype'] = 'omit';
$tidy_config['output-xhtml'] = true;
$tidy_config['show-body-only'] = true;
$tidy_config['logical-emphasis'] = true;
$book['description'] = tidy_repair_string($book['description'], $tidy_config);
// update db so we don't have to do this next time
$DB->Execute("UPDATE books SET description=? WHERE id=?", array($book['description'],$book['id']));
}
}
$smarty->assign("book", $book);
......
<div class="box">
<div class="boxhead"><h2>{$book.title}</h2></div>
<div class="boxcontent">
{if $editable == true}
<form action="" method="POST">
<input type="text" name="title" value="{$book.title}" />
<input type="text" name="author" value="{$book.author}" />
<input type="text" name="publisher" value="{$book.publisher}" />
<textarea name="description" value="{$book.description}" />
</form>
{/if}
<strong>{if $book.onloan}On loan{else}Book Available{/if}</strong>
{if $book.image_url != ""}<img class="emblem" src="{$book.image_url|escape}" alt="{$book.title|escape}" />{/if}
<p>Author: {$book.author}</p>
{if isset($book.description)}
<div>{$book.description}</div>
{/if}
<div class="clear"></div>
</div>
<div class="hollowfoot"><div><div></div></div></div>
</div>
......@@ -13,20 +13,9 @@
{/foreach}
{elseif $mode == 'display'}
<div class="box">
<div class="boxhead"><h2>{$book.title}</h2></div>
<div class="boxcontent">
{if $book.image_url != ""}<img class="emblem" src="{$book.image_url|escape}" alt="{$book.title|escape}" />{/if}
<p>{$book.author}</p>
<p>{$book.description}</p>
{if $book.onloan}<p>On loan</p>{else}<p>Book Available</p>{/if}
{if $editable==true}
<p>Loan stuff to people maybe</p>
{/if}
<div class="clear"></div>
</div>
<div class="hollowfoot"><div><div></div></div></div>
</div>
{include file=library-book.tpl book=$book}
{elseif $mode == 'search'}
<h3>Search Results</h3>
{if $results|@count < 1}<p>No results found</p>
......@@ -49,4 +38,4 @@
{if $librarian == true}
<p><a href="{$baseurl}/Knowledge/Library/Admin">Library Admin</a></p>
{/if}
<p>Images provided by <a href="http://www.amazon.co.uk">Amazon</a></p>
<p>Images and descriptions provided by <a href="http://www.amazon.co.uk">Amazon</a></p>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment