-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a link to display the resource in public view from the admin pa…
…ges (omeka/omeka-s#1259).
- Loading branch information
Showing
7 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace Next\Service\ViewHelper; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use Next\View\Helper\PublicResourceUrl; | ||
use Zend\ServiceManager\Factory\FactoryInterface; | ||
|
||
/** | ||
* Service factory for the PublicResourceUrlFactory view helper. | ||
* | ||
* @todo Set a setting for the default site of the user. | ||
*/ | ||
class PublicResourceUrlFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create and return the PublicResourceUrl view helper | ||
* | ||
* @return PublicResourceUrl | ||
*/ | ||
public function __invoke(ContainerInterface $services, $requestedName, array $options = null) | ||
{ | ||
$defaultSiteSlug = $services->get('ViewHelperManager')->get('defaultSiteSlug'); | ||
return new PublicResourceUrl($defaultSiteSlug()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
namespace Next\View\Helper; | ||
|
||
use Omeka\Api\Representation\AbstractResourceRepresentation; | ||
use Zend\View\Helper\AbstractHelper; | ||
|
||
/** | ||
* View helper to return the url to the public default site page of a resource. | ||
*/ | ||
class PublicResourceUrl extends AbstractHelper | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $defaultSiteSlug; | ||
|
||
/** | ||
* Construct the helper. | ||
* | ||
* @param string|null $defaultSiteSlug | ||
*/ | ||
public function __construct($defaultSiteSlug) | ||
{ | ||
$this->defaultSiteSlug = $defaultSiteSlug; | ||
} | ||
|
||
/** | ||
* Return the url to the public default site page or a resource. | ||
* | ||
* @uses AbstractResourceRepresentation::siteUrl() | ||
* | ||
* @param AbstractResourceRepresentation $resource | ||
* @param bool $canonical Whether to return an absolute URL | ||
* @return string | ||
*/ | ||
public function __invoke(AbstractResourceRepresentation $resource, $canonical = false) | ||
{ | ||
// Manage the case where there is no site. | ||
return $this->defaultSiteSlug | ||
? $resource->siteUrl($this->defaultSiteSlug, $canonical) | ||
: ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
$translate = $this->plugin('translate'); | ||
$escape = $this->plugin('escapeHtml'); | ||
$this->htmlElement('body')->appendAttribute('class', 'item-sets show'); | ||
$viewItemsLink = $this->url( | ||
'admin/default', | ||
['controller' => 'item', 'action' => 'browse'], | ||
[ | ||
'query' => [ | ||
'item_set_id' => $itemSet->id() | ||
] | ||
] | ||
); | ||
if ($owner = $itemSet->owner()) { | ||
$ownerText = $escape($itemSet->owner()->name()); | ||
} else { | ||
$ownerText = $translate('[no owner]'); | ||
} | ||
|
||
$sectionNavs = [ | ||
'item-set-metadata' => $translate('Metadata'), | ||
'item-set-linked' => $translate('Linked resources'), | ||
]; | ||
?> | ||
|
||
<?php echo $this->pageTitle($itemSet->displayTitle(), 1, $translate('Item sets')); ?> | ||
|
||
<div id="page-actions"> | ||
<?php echo $this->hyperlink($translate('Public view'), $this->publicResourceUrl($itemSet), ['class' => 'button', 'target' => '_blank']); ?> | ||
<?php if ($itemSet->userIsAllowed('update')): ?> | ||
<?php echo $itemSet->link($translate('Edit item set'), 'edit', ['class' => 'button']); ?> | ||
<?php endif; ?> | ||
<a href="<?php echo $viewItemsLink; ?>" class="button"><?php echo $translate('View items'); ?></a> | ||
</div> | ||
|
||
<?php echo $this->sectionNav($sectionNavs, 'view.show.section_nav', $itemSet); ?> | ||
|
||
<div id="item-set-metadata" class="active section"> | ||
<?php if ( $itemSet->resourceClass()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Class'); ?></h4> | ||
<div class="value"><?php echo $escape($itemSet->resourceClass()->label()); ?></div> | ||
</div> | ||
<?php endif; ?> | ||
<?php echo $itemSet->displayValues(); ?> | ||
</div> | ||
|
||
<div id="item-set-linked" class="section"> | ||
<?php | ||
$page = $this->params()->fromQuery('page', 1); | ||
$property = $this->params()->fromQuery('property'); | ||
$subjectValues = $itemSet->displaySubjectValues($page, 25); | ||
?> | ||
<?php if ($subjectValues): ?> | ||
<p><?php echo $translate('The following resources link to this item set:'); ?></p> | ||
<?php echo $subjectValues; ?> | ||
<?php else: ?> | ||
<div class="no-resources"> | ||
<p><?php echo $translate('No resources link to this item set.'); ?></p> | ||
</div> | ||
<?php endif; ?> | ||
</div> | ||
|
||
|
||
<div class="active sidebar"> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Created'); ?></h4> | ||
<div class="value"><?php echo $escape($this->i18n()->dateFormat($itemSet->created())); ?></div> | ||
</div> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Owner'); ?></h4> | ||
<div class="value"><?php echo $ownerText; ?></div> | ||
</div> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Visibility'); ?></h4> | ||
<div class="value"><?php echo ($itemSet->isPublic()) ? $escape($translate('Public')) : $escape($translate('Private')); ?></div> | ||
<div class="value"><?php echo ($itemSet->isOpen()) ? $escape($translate('Open to additions')) : $escape($translate('Closed to additions')); ?></div> | ||
</div> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Items'); ?></h4> | ||
<div class="value"><?php echo $this->hyperlink($itemSet->itemCount(), $this->url('admin/default', ['controller' => 'item', 'action' => 'browse'], ['query' => ['item_set_id' => $itemSet->id()]])); ?></div> | ||
</div> | ||
<?php $this->trigger('view.show.sidebar'); ?> | ||
</div> | ||
|
||
<?php $this->trigger('view.show.after'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
$translate = $this->plugin('translate'); | ||
$escape = $this->plugin('escapeHtml'); | ||
$this->htmlElement('body')->appendAttribute('class', 'items show'); | ||
if ($owner = $item->owner()) { | ||
$ownerText = $escape($item->owner()->name()); | ||
} else { | ||
$ownerText = $translate('[no owner]'); | ||
} | ||
|
||
$sectionNavs = [ | ||
'item-metadata' => $translate('Metadata'), | ||
'item-linked' => $translate('Linked resources'), | ||
]; | ||
?> | ||
<?php echo $this->pageTitle($item->displayTitle(), 1, $translate('Items')); ?> | ||
<div id="page-actions"> | ||
<?php echo $this->hyperlink($translate('Public view'), $this->publicResourceUrl($item), ['class' => 'button', 'target' => '_blank']); ?> | ||
<?php if ($item->userIsAllowed('update')): ?> | ||
<?php echo $item->link($translate('Edit item'), 'edit', ['class' => 'button']); ?> | ||
<?php endif; ?> | ||
</div> | ||
|
||
<?php echo $this->sectionNav($sectionNavs, 'view.show.section_nav', $item); ?> | ||
|
||
<div id="item-metadata" class="active section"> | ||
<?php if ( $item->resourceClass()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Class'); ?></h4> | ||
<div class="value"><?php echo $escape($translate($item->resourceClass()->label())); ?></div> | ||
</div> | ||
<?php endif; ?> | ||
<?php echo $item->displayValues(); ?> | ||
</div> | ||
|
||
<div id="item-linked" class="section"> | ||
<?php | ||
$page = $this->params()->fromQuery('page', 1); | ||
$property = $this->params()->fromQuery('property'); | ||
$subjectValues = $item->displaySubjectValues($page, 25, $property); | ||
?> | ||
<?php if ($subjectValues): ?> | ||
<p><?php echo $translate('The following resources link to this item:'); ?></p> | ||
<?php echo $subjectValues; ?> | ||
<?php else: ?> | ||
<div class="no-resources"> | ||
<p><?php echo $translate('No resources link to this item.'); ?></p> | ||
</div> | ||
<?php endif; ?> | ||
</div> | ||
|
||
|
||
<div class="sidebar active"> | ||
<?php echo $this->thumbnail($item, 'square'); ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Visibility'); ?></h4> | ||
<div class="value"><?php echo ($item->isPublic()) ? $escape($translate('Public')) : $escape($translate('Private')); ?></div> | ||
</div> | ||
<?php $itemsets = $item->itemSets(); ?> | ||
<?php if (count($itemsets) > 0): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Item sets'); ?></h4> | ||
<?php foreach ($itemsets as $itemset): ?> | ||
<div class="value item-sets"><?php echo $itemset->link($itemset->displayTitle()); ?></div> | ||
<?php endforeach; ?> | ||
</div> | ||
<?php endif; ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Created'); ?></h4> | ||
<div class="value"><?php echo $escape($this->i18n()->dateFormat($item->created())); ?></div> | ||
</div> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Owner'); ?></h4> | ||
<div class="value"><?php echo $ownerText; ?></div> | ||
</div> | ||
<?php if ($item->media()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Media'); ?></h4> | ||
<?php foreach ($item->media() as $media): ?> | ||
<div class="value"> | ||
<?php echo $media->linkPretty(); ?> | ||
</div> | ||
<?php endforeach; ?> | ||
</div> | ||
<?php endif; ?> | ||
<?php $this->trigger('view.show.sidebar'); ?> | ||
</div> | ||
<?php $this->trigger('view.show.after'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
$translate = $this->plugin('translate'); | ||
$escape = $this->plugin('escapeHtml'); | ||
$this->htmlElement('body')->appendAttribute('class', 'media show'); | ||
|
||
$sectionNavs = [ | ||
'media-metadata' => $translate('Metadata'), | ||
]; | ||
?> | ||
|
||
<?php echo $this->pageTitle($media->displayTitle(), 1, $translate('Media')); ?> | ||
|
||
<div id="page-actions"> | ||
<?php echo $this->hyperlink($translate('Public view'), $this->publicResourceUrl($media), ['class' => 'button', 'target' => '_blank']); ?> | ||
<?php if ($media->userIsAllowed('update')): ?> | ||
<?php echo $media->link($translate('Edit media'), 'edit', ['class' => 'button']); ?> | ||
<?php endif; ?> | ||
</div> | ||
|
||
<?php echo $this->sectionNav($sectionNavs, 'view.show.section_nav', $media); ?> | ||
|
||
<div id="media-metadata" class="active section"> | ||
<?php echo $media->render(); ?> | ||
<?php if ( $media->resourceClass()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Class'); ?></h4> | ||
<div class="value"><?php echo $media->resourceClass()->label(); ?></div> | ||
</div> | ||
<?php endif; ?> | ||
<?php echo $media->displayValues(); ?> | ||
</div> | ||
|
||
<div class="sidebar active"> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Visibility'); ?></h4> | ||
<div class="value"><?php echo ($media->isPublic()) ? $translate('Public') : $translate('Private'); ?></div> | ||
</div> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Part of item'); ?></h4> | ||
<?php $mediaItem = $media->item(); ?> | ||
<div class="value"><?php echo $mediaItem->link($mediaItem->displayTitle()); ?></div> | ||
</div> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Created'); ?></h4> | ||
<div class="value"><?php echo $escape($this->i18n()->dateFormat($media->created())); ?></div> | ||
</div> | ||
<?php if ($media->mediaType()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('MIME type'); ?></h4> | ||
<div class="value"><?php echo $escape($media->mediaType()); ?></div> | ||
</div> | ||
<?php endif; ?> | ||
<?php if (is_numeric($resource->size())): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Size'); ?></h4> | ||
<div class="value"><?php echo sprintf($translate('%s bytes'), number_format($resource->size())); ?></div> | ||
</div> | ||
<?php endif; ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Ingester'); ?></h4> | ||
<div class="value"><?php echo $escape($translate($media->ingesterLabel())); ?></div> | ||
</div> | ||
<?php if ($media->source()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('Source'); ?></h4> | ||
<div class="value"><?php echo $escape($media->source()); ?></div> | ||
</div> | ||
<?php endif; ?> | ||
<?php if ($media->hasThumbnails() || $media->hasOriginal()): ?> | ||
<div class="meta-group"> | ||
<h4><?php echo $translate('File Derivatives'); ?></h4> | ||
<?php if ($media->hasOriginal()): ?> | ||
<div class="value"><a href="<?php echo $escape($media->originalUrl()); ?>"><?php echo $translate('original'); ?></a></div> | ||
<?php endif; ?> | ||
<?php if ($media->hasThumbnails()): ?> | ||
<div class="value"><a href="<?php echo $escape($media->thumbnailUrl('large')); ?>"><?php echo $translate('large'); ?></a></div> | ||
<div class="value"><a href="<?php echo $escape($media->thumbnailUrl('medium')); ?>"><?php echo $translate('medium'); ?></a></div> | ||
<div class="value"><a href="<?php echo $escape($media->thumbnailUrl('square')); ?>"><?php echo $translate('square'); ?></a></div> | ||
<?php endif; ?> | ||
</div> | ||
<?php endif; ?> | ||
<?php $this->trigger('view.show.sidebar'); ?> | ||
</div> | ||
|
||
<?php $this->trigger('view.show.after'); ?> |