Commit af207c8f authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1710727: Allowing collection tags to be indexed



And searched on for elasticsearch.

behatnotneeded

Change-Id: Ib53787ab882496a998b767bbeb3713a3547fd471
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 6943926a)
parent 3c48add2
......@@ -27,6 +27,11 @@ class ElasticsearchType_collection extends ElasticsearchType
'type' => 'string',
'include_in_all' => TRUE
),
'tags' => array(
'type' => 'string',
'index_name' => 'tag',
'include_in_all' => TRUE
),
// the owner can be owner (user), group, or institution
'owner' => array(
'type' => 'long',
......@@ -124,6 +129,7 @@ class ElasticsearchType_collection extends ElasticsearchType
'id' => NULL,
'name' => NULL,
'description' => NULL,
'tags' => NULL,
'owner' => NULL,
'group' => NULL,
'institution' => NULL,
......@@ -141,7 +147,15 @@ class ElasticsearchType_collection extends ElasticsearchType
if (!$record) {
return false;
}
$tags = get_records_array ('collection_tag', 'collection', $id);
if ($tags != false) {
foreach ($tags as $tag) {
$record->tags [] = $tag->tag;
}
}
else {
$record->tags = null;
}
// Access: get view_access info
$access = self::collection_access_records($id);
$accessObj = self::access_process($access);
......@@ -188,7 +202,16 @@ class ElasticsearchType_collection extends ElasticsearchType
}
$record->views = $record_views;
}
// Tags
$tags = get_records_array('collection_tag', 'collection', $id);
if ($tags != false) {
foreach ($tags as $tag) {
$record->tags [] = $tag->tag;
}
}
else {
$record->tags = null;
}
return $record;
}
......
......@@ -20,7 +20,9 @@
<div class="createdby">{str tag=createdby section=search.elasticsearch arg1='<a href="`$record->createdby|profile_url`">`$record->createdbyname|safe`</a>'}</div>
{/if}
<div class="detail">{$record->description|str_shorten_html:140:true|safe}</div>
<div class="tags"><strong>{str tag=pages section=search.elasticsearch}:</strong>
<!-- PAGES -->
<div class="tags">
<strong>{str tag=pages section=search.elasticsearch}:</strong>
{if $record->views}
{foreach from=$record->views key=id item=view name=foo}
<a href="{$WWWROOT}view/view.php?id={$id}">{$view}</a>{if !$.foreach.foo.last}, {/if}
......@@ -29,4 +31,13 @@
{str tag=none section=search.elasticsearch}
{/if}
</div>
<!-- TAGS -->
{if $record->tags|count gt 0}
<div class="tags">
<strong>{str tag=tags section=search.elasticsearch}:</strong>
{foreach from=$record->tags item=tag name=tags}
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if}
{/foreach}
</div>
{/if}
{/if}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment