Compare commits
No commits in common. "f633eeb52934ead97e37692be2d507d70f01cc00" and "1b9b6a6f15f82df4dde258301939200e2a9466f3" have entirely different histories.
f633eeb529
...
1b9b6a6f15
|
@ -30,7 +30,6 @@ return [
|
||||||
'DefaultSettings' => [
|
'DefaultSettings' => [
|
||||||
'SketchfabBlockForm' => [
|
'SketchfabBlockForm' => [
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'renderSourceLink' => true,
|
|
||||||
'width' => 600,
|
'width' => 600,
|
||||||
'ratio' => '2',
|
'ratio' => '2',
|
||||||
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
|
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
|
||||||
|
|
|
@ -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',
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,24 +5,16 @@ use Omeka\Api\Request;
|
||||||
use Omeka\Entity\Media;
|
use Omeka\Entity\Media;
|
||||||
use Omeka\Media\Ingester\IngesterInterface;
|
use Omeka\Media\Ingester\IngesterInterface;
|
||||||
use Omeka\Stdlib\ErrorStore;
|
use Omeka\Stdlib\ErrorStore;
|
||||||
use Omeka\File\Downloader;
|
|
||||||
use Zend\Form\Element\Text;
|
use Zend\Form\Element\Text;
|
||||||
use Zend\Http\Client;
|
use Zend\Http\Client;
|
||||||
use Zend\View\Renderer\PhpRenderer;
|
use Zend\View\Renderer\PhpRenderer;
|
||||||
|
|
||||||
class SketchfabMediaIngester implements IngesterInterface
|
class SketchfabMediaIngester implements IngesterInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Downloader
|
|
||||||
*/
|
|
||||||
protected $downloader;
|
|
||||||
protected $client;
|
protected $client;
|
||||||
|
public function __construct($client)
|
||||||
public function __construct($client, Downloader $downloader)
|
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
$this->downloader = $downloader;
|
|
||||||
}
|
}
|
||||||
public function getLabel()
|
public function getLabel()
|
||||||
{
|
{
|
||||||
|
@ -62,14 +54,8 @@ class SketchfabMediaIngester implements IngesterInterface
|
||||||
));
|
));
|
||||||
return false;
|
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.
|
// Set the Media source and data.
|
||||||
$media->setSource($data['o:source']);
|
$media->setSource($data['o:source']);
|
||||||
$media->setData($response_body, true));
|
$media->setData(json_decode($response->getBody(), true));;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,6 @@ class SketchfabMediaFactory implements FactoryInterface
|
||||||
$requestedName,
|
$requestedName,
|
||||||
array $options = null)
|
array $options = null)
|
||||||
{
|
{
|
||||||
return new SketchfabMediaIngester(
|
return new SketchfabMediaIngester($services->get('Omeka\HttpClient'));
|
||||||
$services->get('Omeka\HttpClient'),
|
|
||||||
$services->get('Omeka\File\Downloader')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ class Sketchfab extends AbstractBlockLayout
|
||||||
'o:block[__blockIndex__][o:data][title]' => $data['title'],
|
'o:block[__blockIndex__][o:data][title]' => $data['title'],
|
||||||
'o:block[__blockIndex__][o:data][width]' => $data['width'],
|
'o:block[__blockIndex__][o:data][width]' => $data['width'],
|
||||||
'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'],
|
'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'],
|
||||||
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
|
|
||||||
]);
|
]);
|
||||||
$form->prepare();
|
$form->prepare();
|
||||||
|
|
||||||
|
@ -79,9 +78,7 @@ class Sketchfab extends AbstractBlockLayout
|
||||||
//$height = $width / $block->dataValue('ratio');
|
//$height = $width / $block->dataValue('ratio');
|
||||||
$height = $width / 1.333;
|
$height = $width / 1.333;
|
||||||
return $view->partial('common/block-layout/sketchfab', [
|
return $view->partial('common/block-layout/sketchfab', [
|
||||||
'title' => $block->dataValue('title'),
|
'title' => false,
|
||||||
'renderSourceLink' => $block->dataValue('renderSourceLink'),
|
|
||||||
'item_url' => $attachments[0]->item()->url(),
|
|
||||||
'width' => $width,
|
'width' => $width,
|
||||||
'height' => $height,
|
'height' => $height,
|
||||||
'sketchfab_iframe' => $media->mediaData()['html'],
|
'sketchfab_iframe' => $media->mediaData()['html'],
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
<div class="sketchfab-wrap" style="position:relative;">
|
<div class="sketchfab-wrap" style="position:relative;">
|
||||||
|
|
||||||
<?php if ($renderSourceLink) { ?>
|
<?php
|
||||||
<div class="source-link">
|
if ($title !== false && $title !== "") {
|
||||||
<a href="<?= $item_url ?>">Source</a>
|
$title = sprintf('<p id="sketchfab-title">%s</p>', $title);
|
||||||
</div>
|
} else {
|
||||||
<?php } ?>
|
$title = false;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<?= $sketchfab_iframe ?>
|
<?= $sketchfab_iframe ?>
|
||||||
|
|
||||||
<?php if ($title) { ?>
|
|
||||||
<div class="item_title">
|
|
||||||
<?= $title ?>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue