Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions js/ting-covers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
$('.ting-cover:not(.ting-cover-processing, .ting-cover-processed)', context).each(function(i, e) {
coverData.push(Drupal.extractCoverData(e));
}).addClass('ting-cover-processing');

// $('.ting-cover', context).each(function(i, e) {
// coverData.push(Drupal.extractCoverData(e));
// }).addClass('ting-cover-processing');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment out code.


if (coverData.length > 0) {
//Retrieve covers
Expand Down
25 changes: 12 additions & 13 deletions lib/addi-client/AdditionalInformationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ protected function sendRequest($identifiers)
'authenticationGroup' => $this->group,
'authenticationPassword' => $this->password);
$client = new SoapClient($this->wsdlUrl);

$startTime = explode(' ', microtime());
$response = $client->additionalInformation(array(
$startTime = explode(' ', microtime());
$response = $client->moreInfo(array(
'authentication' => $authInfo,
'identifier' => $identifiers));

Expand All @@ -75,7 +74,7 @@ protected function sendRequest($identifiers)
{
throw new AdditionalInformationServiceException($response->requestStatus->statusEnum.': '.$response->requestStatus->errorText);
}

if (!is_array($response->identifierInformation))
{
$response->identifierInformation = array($response->identifierInformation);
Expand All @@ -91,26 +90,26 @@ protected function extractAdditionalInformation($idName, $response)
foreach($response->identifierInformation as $info)
{
$thumbnailUrl = $detailUrl = NULL;
if (isset($info->identifierKnown) && $info->identifierKnown && $info->image )
if (isset($info->identifierKnown) && $info->identifierKnown && $info->coverImage )
{
if (!is_array($info->image))
if (!is_array($info->coverImage))
{
$info->image = array($info->image);
$info->coverImage = array($info->coverImage);
}
foreach ($info->image as $image)

foreach ($info->coverImage as $image)
{
switch ($image->imageSize) {
case 'thumbnail':
$thumbnailUrl = $image->_;
$thumbnailUrl = $image->_;
break;
case 'detail':
$detailUrl = $image->_;
$detailUrl = $image->_;
break;
default:
// Do nothing other image sizes may appear but ignore them for now
// Do nothing other image sizes may appear but ignore them for now
}
}
}

$additionalInfo = new AdditionalInformation($thumbnailUrl, $detailUrl);
$additionalInformations[$info->identifier->$idName] = $additionalInfo;
Expand Down
13 changes: 11 additions & 2 deletions ting_covers.pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
function ting_covers_objects() {
$covers = array();
$missing_images_local_ids = array();
$missing_images = $missing_images_local_ids = array();

foreach ($_POST['coverData'] as $cover_info) {
//Reverse cover_info before and after explode to make sure that we explode around
Expand All @@ -24,6 +24,10 @@ function ting_covers_objects() {
} else {
//Mark the image for retrieval;
$missing_images_local_ids[] = $local_id;
if (!isset($missing_images['i_' . $local_id])) {
$missing_images['i_' . $local_id] = array();
}
$missing_images['i_' . $local_id][$image_style] = TRUE;
}
}

Expand All @@ -45,14 +49,19 @@ function ting_covers_objects() {

//No cover image found? Cache this for future reference to avoid unnecessary requests
if (!$source_url) {
// foreach ($missing_images['i_' . $local_id] as $image_style => $holder) {
// $covers[$local_id.':'.$image_style] = image_style_url($image_style, 'public://manual/DEFAULT_COVER_IMAGE.jpg');
// }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment out code.

cache_set('ting_covers:'.$local_id, 1, 'cache', $_SERVER['REQUEST_TIME'] + TING_COVERS_CACHE_LIFETIME);
continue;
}

//Try to download the image locally
if ($file = _ting_covers_pages_fetch_image(ting_covers_object_path($local_id), $source_url)) {
//Generate a path corresponding to the downloaded image, styled
$covers[$local_id.':'.$image_style] = image_style_url($image_style, $file->uri);
foreach ($missing_images['i_' . $local_id] as $image_style => $holder) {
$covers[$local_id.':'.$image_style] = image_style_url($image_style, $file->uri);
}
}
}
} catch (Exception $e) {
Expand Down
6 changes: 4 additions & 2 deletions ting_covers.theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function template_preprocess_ting_object_cover(&$variables) {

//If we already have the image available locally then just use it
$path = ting_covers_object_path($object->localId);
if (file_exists($path)) {
//Generate an alt tag
//Generate an alt tag
$alt = implode(', ', $object->creators).': '.$object->title;
if (file_exists($path)) {

$variables['image'] = theme('image_style', array('style_name' => $variables['image_style'], 'path' => $path, 'alt' => $alt));

Expand All @@ -24,6 +24,8 @@ function template_preprocess_ting_object_cover(&$variables) {
//We know that there is no cover available for this object so avoid
//further javascript processing
$variables['classes'][] = 'ting-cover-processed';
// $variables['image'] = theme('image_style', array('style_name' => $variables['image_style'], 'path' => 'public://manual/DEFAULT_COVER_IMAGE.jpg', 'alt' => $alt));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment out code.


}
}

Expand Down