adds archove site meta to cross site search results

This commit is contained in:
buttle 2021-05-08 18:27:48 +02:00
parent 111e2218e2
commit 8b602fcbc7
8 changed files with 159 additions and 119 deletions

View File

@ -0,0 +1,28 @@
<?php $fulltextSearch = $this->params()->fromQuery('fulltext_search'); ?>
<?php echo $this->hyperlink(
$this->translate('Advanced item search'),
$this->url(null, ['action' => 'items-advanced', 'class' => 'advanced-search'], ['query' => $this->params()->fromQuery()], true),
['class' => 'advanced-search']
); ?>
<h2><?php echo sprintf($this->translate('Item results for "%s"'), $fulltextSearch); ?></h2>
<?php echo $this->pagination(); ?>
<div class="item results">
<ul>
<?php foreach ($items as $item): ?>
<?php $sites = $item->sites(); ?>
<li>
<span class="result-title"><?php echo $item->displayTitle(); ?></span>
<ul>
<?php foreach ($sites as $site): ?>
<li><?php echo $this->hyperlink($site->title(), $item->siteUrl($site->slug())); ?></li>
<?php endforeach; ?>
</ul>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php echo $this->pagination(); ?>

View File

@ -0,0 +1,17 @@
<?php $fulltextSearch = $this->params()->fromQuery('fulltext_search'); ?>
<h2><?php echo sprintf($this->translate('Site page results for "%s"'), $fulltextSearch); ?></h2>
view/common/cross-site-search/site-page-results.phtml
<div class="site results">
<ul>
<?php foreach ($sitePages as $sitePage): ?>
<?php $site = $sitePage->site(); ?>
<li>
<span class="result-title"><?php echo $this->hyperlink($sitePage->title(), $sitePage->siteUrl()); ?></span>
<span class="result-site"><?php echo $this->hyperlink($site->title(), $site->siteUrl()); ?></span>
</li>
<?php endforeach; ?>
</ul>
</div>

View File

@ -2,7 +2,7 @@
$action = $action ?? $this->url(null, [], true);
$fulltextSearch = $fulltextSearch ?? $this->params()->fromQuery('fulltext_search');
?>
view/common/cross-site-search/fulltext-form.phtml
<form action="<?php echo $this->escapeHtml($action); ?>" class="sitewide-search-form">
<input type="text" name="fulltext_search" value="<?php echo $this->escapeHtml($fulltextSearch); ?>">
<input type="submit" value="<?php echo $this->escapeHtml($this->translate('Search')); ?>">

View File

@ -1,28 +1,54 @@
<?php $fulltextSearch = $this->params()->fromQuery('fulltext_search'); ?>
<?php echo $this->hyperlink(
$this->translate('Advanced item search'),
$this->url(null, ['action' => 'items-advanced', 'class' => 'advanced-search'], ['query' => $this->params()->fromQuery()], true),
['class' => 'advanced-search']
); ?>
<?php
$fulltextSearch = $this->params()->fromQuery('fulltext_search');
$archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
$archive_collections = $archiveSiteHelper->getCollections();
?>
<h2><?php echo sprintf($this->translate('Item results for "%s"'), $fulltextSearch); ?></h2>
<!-- <h2><?php echo sprintf($this->translate('Item results for "%s"'), $fulltextSearch); ?></h2> -->
<!-- <?php echo $this->pagination(); ?> -->
<?php echo $this->pagination(); ?>
<div class="item results">
<ul>
<?php foreach ($items as $item): ?>
<table>
<thead>
<tr>
<th>Item</th>
<th>Site</th>
<th>Curator</th>
<th>Collection</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $item): ?>
<?php $sites = $item->sites(); ?>
<li>
<span class="result-title"><?php echo $item->displayTitle(); ?></span>
<ul>
<?php foreach ($sites as $site): ?>
<li><?php echo $this->hyperlink($site->title(), $item->siteUrl($site->slug())); ?></li>
<?php endforeach; ?>
</ul>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php foreach ($sites as $site): ?>
<?php $site_meta_values = $archiveSiteHelper->getSiteMetaValues($site); ?>
<tr>
<td>
<?php echo $this->hyperlink($item->displayTitle(), $item->siteUrl($site->slug())); ?>
</td>
<td>
<?php echo $this->hyperlink($site->title(), $site->siteUrl(), ['class' => 'site-link']); ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>
<?= $site_meta_values['currator']; ?><br />
<?php endif; ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>
<?= $archive_collections[$site_meta_values['collection']]; ?>
<?php endif; ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>
<?= $site_meta_values['project_date']; ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php echo $this->pagination(); ?>
<?php endforeach; ?>
</tbody>
</table>
<!-- <?php echo $this->pagination(); ?> -->

View File

@ -5,95 +5,36 @@ $hasResults = false;
<h2><?php echo sprintf($this->translate('Search results for “%s”'), $fulltextSearch); ?></h2>
view/common/cross-site-search/results.phtml
<div class="results">
<?php
if ($responseSitePages && $responseSitePages->getTotalResults()):
$hasResults = true;
?>
<div class="site results">
<h3><?php echo $this->translate('Site pages'); ?></h2>
<ul>
<?php foreach ($responseSitePages->getContent() as $sitePage): ?>
<?php $site = $sitePage->site(); ?>
<li>
<span class="result-title"><?php echo $this->hyperlink($sitePage->title(), $sitePage->siteUrl()); ?></span>
<span class="result-site"><?php echo $this->hyperlink($site->title(), $site->siteUrl()); ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php echo $this->hyperlink(
sprintf($this->translate('View all results (%s total)'), $responseSitePages->getTotalResults()),
$this->url(
null,
['action' => 'site-pages'],
['query' => ['fulltext_search' => $fulltextSearch]],
true
)
); ?>
</div>
<?php
$sitePages = array();
foreach ($responseSitePages->getContent() as $sitePage) {
array_push($sitePages, $sitePage);
}
echo $this->partial('common/cross-site-search/site-page-results', [
'sitePages' => $sitePages,
]);
?>
<?php endif; ?>
<?php
if ($responseItems && $responseItems->getTotalResults()):
$hasResults = true;
?>
<div class="item results">
<h3><?php echo $this->translate('Items'); ?></h2>
<ul>
<?php foreach ($responseItems->getContent() as $item): ?>
<?php $sites = $item->sites(); ?>
<li>
<span class="result-title"><?php echo $item->displayTitle(); ?></span>
<ul>
<?php foreach ($sites as $site): ?>
<li><?php echo $this->hyperlink($site->title(), $item->siteUrl($site->slug())); ?></li>
<?php endforeach; ?>
</ul>
</li>
<?php endforeach; ?>
</ul>
<?php echo $this->hyperlink(
sprintf($this->translate('View all results (%s total)'), $responseItems->getTotalResults()),
$this->url(
null,
['action' => 'items'],
['query' => ['fulltext_search' => $fulltextSearch]],
true
)
); ?>
</div>
<?php
$items = array();
foreach ($responseItems->getContent() as $item) {
array_push($items, $item);
}
echo $this->partial('common/cross-site-search/item-results', [
'items' => $items,
]);
?>
<?php endif; ?>
<?php if ($responseItemSets && $responseItemSets->getTotalResults()):
$hasResults = true;
?>
<div class="item-set results">
<h3><?php echo $this->translate('Item sets'); ?></h2>
<ul>
<?php foreach ($responseItemSets->getContent() as $itemSet): ?>
<?php $sites = $itemSet->sites(); ?>
<li>
<span class="result-title"><?php echo $itemSet->displayTitle(); ?></span>
<ul>
<?php foreach ($sites as $site): ?>
<li><?php echo $this->hyperlink($site->title(), $item->siteUrl($site->slug())); ?></li>
<?php endforeach; ?>
</ul>
</li>
<?php endforeach; ?>
</ul>
<?php echo $this->hyperlink(
sprintf($this->translate('View all results (%s total)'), $responseItemSets->getTotalResults()),
$this->url(
null,
['action' => 'item-sets'],
['query' => ['fulltext_search' => $fulltextSearch]],
true
)
); ?>
</div>
<?php endif; ?>
<?php if (!$hasResults): ?>
<p><?php echo $this->translate('No result found'); ?>

View File

@ -1,17 +1,49 @@
<?php $fulltextSearch = $this->params()->fromQuery('fulltext_search'); ?>
<?php
$fulltextSearch = $this->params()->fromQuery('fulltext_search');
$archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
$archive_collections = $archiveSiteHelper->getCollections();
?>
<h2><?php echo sprintf($this->translate('Site page results for "%s"'), $fulltextSearch); ?></h2>
<!-- <h2><?php echo sprintf($this->translate('Site page results for "%s"'), $fulltextSearch); ?></h2> -->
view/common/cross-site-search/site-page-results.phtml
<div class="site results">
<ul>
<table>
<thead>
<tr>
<th>Page</th>
<th>Site</th>
<th>Curator</th>
<th>Collection</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($sitePages as $sitePage): ?>
<?php $site = $sitePage->site(); ?>
<li>
<span class="result-title"><?php echo $this->hyperlink($sitePage->title(), $sitePage->siteUrl()); ?></span>
<span class="result-site"><?php echo $this->hyperlink($site->title(), $site->siteUrl()); ?></span>
</li>
<?php $site_meta_values = $archiveSiteHelper->getSiteMetaValues($site); ?>
<tr>
<td>
<?php echo $this->hyperlink($sitePage->title(), $sitePage->siteUrl()); ?>
</td>
<td>
<?php echo $this->hyperlink($site->title(), $site->siteUrl(), ['class' => 'site-link']); ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>
<?= $site_meta_values['currator']; ?><br />
<?php endif; ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>
<?= $archive_collections[$site_meta_values['collection']]; ?>
<?php endif; ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>
<?= $site_meta_values['project_date']; ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</ul>
</div>
</tbody>
</table>

View File

@ -3,8 +3,7 @@ $summary = $showSummary ? $site->summary() : null;
?>
<tr class="_expandable_site_item">
<td>
<!-- <?php echo $this->hyperlink($site->title(), $site->siteUrl(), ['class' => 'site-link']); ?> -->
<?= $site->title(); ?>
<?php echo $this->hyperlink($site->title(), $site->siteUrl(), ['class' => 'site-link']); ?>
</td>
<td>
<?php if ($site_meta_values != null): ?>

View File

@ -92,9 +92,6 @@ endif;
<?php endif; ?>
</header>
Hello
<div id="content" role="main">
<?php echo $this->content; ?>
</div>