Compare commits

..

No commits in common. "f633eeb52934ead97e37692be2d507d70f01cc00" and "1b9b6a6f15f82df4dde258301939200e2a9466f3" have entirely different histories.

6 changed files with 11 additions and 55 deletions

View File

@ -30,7 +30,6 @@ return [
'DefaultSettings' => [
'SketchfabBlockForm' => [
'title' => '',
'renderSourceLink' => true,
'width' => 600,
'ratio' => '2',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',

View File

@ -29,24 +29,5 @@ class SketchfabBlockForm extends Form
],
]);
$this->add([
'type' => Element\Checkbox::class,
'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]',
'options' => [
'label' => 'Display a link to the item',
//'use_hidden_element' => true,
'checked_value' => true,
'unchecked_value' => false,
],
]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][title]',
'type' => Element\Text::class,
'options' => [
'label' => 'Sub-title',
]
]);
}
}

View File

@ -5,24 +5,16 @@ use Omeka\Api\Request;
use Omeka\Entity\Media;
use Omeka\Media\Ingester\IngesterInterface;
use Omeka\Stdlib\ErrorStore;
use Omeka\File\Downloader;
use Zend\Form\Element\Text;
use Zend\Http\Client;
use Zend\View\Renderer\PhpRenderer;
class SketchfabMediaIngester implements IngesterInterface
{
/**
* @var Downloader
*/
protected $downloader;
protected $client;
public function __construct($client, Downloader $downloader)
public function __construct($client)
{
$this->client = $client;
$this->downloader = $downloader;
}
public function getLabel()
{
@ -62,14 +54,8 @@ class SketchfabMediaIngester implements IngesterInterface
));
return false;
}
$response_body = json_decode($response->getBody());
$thumbnail_url = $response_body->thumbnail_url;
$tempFile = $this->downloader->download($thumbnail_url);
if ($tempFile) {
$tempFile->mediaIngestFile($media, $request, $errorStore, false);
}
// Set the Media source and data.
$media->setSource($data['o:source']);
$media->setData($response_body, true));
$media->setData(json_decode($response->getBody(), true));;
}
}

View File

@ -11,9 +11,6 @@ class SketchfabMediaFactory implements FactoryInterface
$requestedName,
array $options = null)
{
return new SketchfabMediaIngester(
$services->get('Omeka\HttpClient'),
$services->get('Omeka\File\Downloader')
);
return new SketchfabMediaIngester($services->get('Omeka\HttpClient'));
}
}

View File

@ -50,7 +50,6 @@ class Sketchfab extends AbstractBlockLayout
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'],
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]);
$form->prepare();
@ -79,9 +78,7 @@ class Sketchfab extends AbstractBlockLayout
//$height = $width / $block->dataValue('ratio');
$height = $width / 1.333;
return $view->partial('common/block-layout/sketchfab', [
'title' => $block->dataValue('title'),
'renderSourceLink' => $block->dataValue('renderSourceLink'),
'item_url' => $attachments[0]->item()->url(),
'title' => false,
'width' => $width,
'height' => $height,
'sketchfab_iframe' => $media->mediaData()['html'],

View File

@ -1,19 +1,15 @@
<div class="sketchfab-wrap" style="position:relative;">
<?php if ($renderSourceLink) { ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<?php } ?>
<?php
if ($title !== false && $title !== "") {
$title = sprintf('<p id="sketchfab-title">%s</p>', $title);
} else {
$title = false;
}
?>
<?= $sketchfab_iframe ?>
<?php if ($title) { ?>
<div class="item_title">
<?= $title ?>
</div>
<?php } ?>
</div>