Skip to content

Commit

Permalink
Added displayTitle() and displayDescription() for some entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM authored and Daniel Berthereau committed Sep 18, 2020
1 parent 3688539 commit 74c5360
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions application/src/Api/Representation/AssetRepresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public function assetUrl()
return $this->getFileUrl('asset', $this->filename());
}

public function displayTitle()
{
return $this->name();
}

public function thumbnail()
{
return $this;
Expand Down
10 changes: 10 additions & 0 deletions application/src/Api/Representation/SitePageRepresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public function isPublic()
return $this->resource->isPublic();
}

/**
* Alias of title().
*
* @return string
*/
public function displayTitle()
{
return $this->title();
}

/**
* Get the blocks assigned to this page.
*
Expand Down
10 changes: 10 additions & 0 deletions application/src/Api/Representation/SiteRepresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ public function owner()
->getRepresentation($this->resource->getOwner());
}

public function displayTitle()
{
return $this->title();
}

public function displayDescription()
{
return $this->summary();
}

public function siteUrl($siteSlug = null, $canonical = false)
{
if (!$siteSlug) {
Expand Down
7 changes: 3 additions & 4 deletions application/view/omeka/site/index/search.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ $resourceControllers = [
<div class="<?php echo $resourceName; ?> results">
<h2><?php echo $translate($resourceLabels[$resourceName]); ?></h2>

<?php $titleMethod = $resourceName === 'site_pages' ? 'title' : 'displayTitle'; ?>
<?php if ($result['total']): ?>
<ul>
<?php foreach ($result['resources'] as $resource): ?>
<li>
<?php echo $resource->link($resource->$titleMethod()); ?>
</li>
<li><?php echo $resource->link($resource->displayTitle()); ?></li>
<?php endforeach; ?>
</ul>
<?php echo $hyperlink(
Expand All @@ -45,6 +43,7 @@ $resourceControllers = [
true
)
); ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php endif; ?>

0 comments on commit 74c5360

Please sign in to comment.