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); $action = $action ?? $this->url(null, [], true);
$fulltextSearch = $fulltextSearch ?? $this->params()->fromQuery('fulltext_search'); $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"> <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="text" name="fulltext_search" value="<?php echo $this->escapeHtml($fulltextSearch); ?>">
<input type="submit" value="<?php echo $this->escapeHtml($this->translate('Search')); ?>"> <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
<?php echo $this->hyperlink( $fulltextSearch = $this->params()->fromQuery('fulltext_search');
$this->translate('Advanced item search'), $archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
$this->url(null, ['action' => 'items-advanced', 'class' => 'advanced-search'], ['query' => $this->params()->fromQuery()], true), $archive_collections = $archiveSiteHelper->getCollections();
['class' => 'advanced-search'] ?>
); ?>
<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(); ?> <table>
<thead>
<div class="item results"> <tr>
<ul> <th>Item</th>
<?php foreach ($items as $item): ?> <th>Site</th>
<th>Curator</th>
<th>Collection</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $item): ?>
<?php $sites = $item->sites(); ?> <?php $sites = $item->sites(); ?>
<li> <?php foreach ($sites as $site): ?>
<span class="result-title"><?php echo $item->displayTitle(); ?></span> <?php $site_meta_values = $archiveSiteHelper->getSiteMetaValues($site); ?>
<ul> <tr>
<?php foreach ($sites as $site): ?> <td>
<li><?php echo $this->hyperlink($site->title(), $item->siteUrl($site->slug())); ?></li> <?php echo $this->hyperlink($item->displayTitle(), $item->siteUrl($site->slug())); ?>
<?php endforeach; ?> </td>
</ul> <td>
</li> <?php echo $this->hyperlink($site->title(), $site->siteUrl(), ['class' => 'site-link']); ?>
<?php endforeach; ?> </td>
</ul> <td>
</div> <?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> <h2><?php echo sprintf($this->translate('Search results for “%s”'), $fulltextSearch); ?></h2>
view/common/cross-site-search/results.phtml <div class="results">
<?php <?php
if ($responseSitePages && $responseSitePages->getTotalResults()): if ($responseSitePages && $responseSitePages->getTotalResults()):
$hasResults = true; $hasResults = true;
?> ?>
<div class="site results"> <?php
<h3><?php echo $this->translate('Site pages'); ?></h2> $sitePages = array();
<ul> foreach ($responseSitePages->getContent() as $sitePage) {
<?php foreach ($responseSitePages->getContent() as $sitePage): ?> array_push($sitePages, $sitePage);
<?php $site = $sitePage->site(); ?> }
<li> echo $this->partial('common/cross-site-search/site-page-results', [
<span class="result-title"><?php echo $this->hyperlink($sitePage->title(), $sitePage->siteUrl()); ?></span> 'sitePages' => $sitePages,
<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 endif; ?> <?php endif; ?>
<?php <?php
if ($responseItems && $responseItems->getTotalResults()): if ($responseItems && $responseItems->getTotalResults()):
$hasResults = true; $hasResults = true;
?> ?>
<div class="item results"> <?php
<h3><?php echo $this->translate('Items'); ?></h2> $items = array();
<ul> foreach ($responseItems->getContent() as $item) {
<?php foreach ($responseItems->getContent() as $item): ?> array_push($items, $item);
<?php $sites = $item->sites(); ?> }
<li> echo $this->partial('common/cross-site-search/item-results', [
<span class="result-title"><?php echo $item->displayTitle(); ?></span> 'items' => $items,
<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 endif; ?> <?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> </div>
<?php endif; ?>
<?php if (!$hasResults): ?> <?php if (!$hasResults): ?>
<p><?php echo $this->translate('No result found'); ?> <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"> <table>
<ul> <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 foreach ($sitePages as $sitePage): ?>
<?php $site = $sitePage->site(); ?> <?php $site = $sitePage->site(); ?>
<li> <?php $site_meta_values = $archiveSiteHelper->getSiteMetaValues($site); ?>
<span class="result-title"><?php echo $this->hyperlink($sitePage->title(), $sitePage->siteUrl()); ?></span> <tr>
<span class="result-site"><?php echo $this->hyperlink($site->title(), $site->siteUrl()); ?></span> <td>
</li> <?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; ?> <?php endforeach; ?>
</ul> </tbody>
</div> </table>

View File

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

View File

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