Commit 53db7f11 authored by Robert Lyon's avatar Robert Lyon

Allowing resume achievements be searchable (Bug #1444905)

A patch to allow the resume content be part of the search

Currently only the parent artefact info is included in the search
index rather than the items content.

Also list the item titles on search results page

Change-Id: I39142467aa40134ba21eb1124e974342cff297ac
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 2c6ea727
......@@ -25,6 +25,7 @@ $string['bypassindexname'] = 'Bypass index';
$string['bypassindexnamedescription'] = '(Optional) If provided, Mahara will load index data into this index name instead of the main index name.';
$string['collection'] = 'Collection';
$string['confignotset'] = '(not set)';
$string['contains'] = 'Contains';
$string['createdby'] = 'Created by %s';
$string['createdbyanon'] = 'Created by (author\'s name hidden)';
$string['cronlimit'] = 'Cron record limit';
......
......@@ -203,6 +203,36 @@ class ElasticsearchType_artefact extends ElasticsearchType
$terms = explode("|", $artefacttypesmap_array[$record->artefacttype]);
$record->mainfacetterm = $terms[2];
$record->secfacetterm = $terms[1];
require_once(get_config('docroot') . 'artefact/resume/lib.php');
if (PluginArtefactResume::is_active()) {
// If the artefacttype is one of the résumé ones we need to get the description
// from this artefact's related résumé table. There is a one -> many relationship between
// the artefact and the items but seen as all resume items are added
// to a page when choosing One résumé field, rather than selecting them individually,
// we can just blob together all the info for this résumé artefact into $record->description.
$resumetypes = ArtefactTypeResumeComposite::get_composite_artefact_types();
if (in_array($terms[0], $resumetypes)) {
try {
$query = "SELECT * FROM {artefact_resume_" . $terms[0] . "} WHERE artefact = ?";
$results = get_records_sql_assoc($query, array($record->id));
}
catch (SQLException $e) {
// Table doesn't exist
$results = array();
}
foreach ($results as $result) {
$items = get_object_vars($result);
foreach ($items as $key => $item) {
if (!in_array($key, array('id', 'artefact','displayorder'))) {
$record->description .= $item . ' ';
}
}
}
}
}
// AS the field "sort" is not analyzed, we need to clean it (remove html tags & lowercase)
$record->sort = strtolower(strip_tags($record->title));
......@@ -297,6 +327,23 @@ class ElasticsearchType_artefact extends ElasticsearchType
}
}
require_once(get_config('docroot') . 'artefact/resume/lib.php');
if (PluginArtefactResume::is_active()) {
// If the artefacttype is one of the résumé ones we need to fetch the related item info
$resumetypes = PluginArtefactResume::composite_tabs();
if (array_key_exists($record->artefacttype, $resumetypes)) {
try {
$query = "SELECT * FROM {artefact_resume_" . $record->artefacttype . "} WHERE artefact = ?";
$results = get_records_sql_assoc($query, array($record->id));
}
catch (SQLException $e) {
// Table doesn't exist
$results = array();
}
$record->resumeitems = $results;
}
}
// VIEWS get all the views the artefact is included into.
// artefact parents are folder, blog, plan, cpd
$sql = 'SELECT COALESCE(v.id, vp.id) AS id, COALESCE(v.title, vp.title) AS title
......
......@@ -39,6 +39,18 @@
<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:100:true|safe}</div>
<!-- RESUMEITEMS -->
{if $record->resumeitems|count gt 0}
<strong>{str tag=contains section=search.elasticsearch}:</strong>
<ul>
{foreach from=$record->resumeitems key=rid item=resume}
{if $resume->title}<li>{$resume->title}</li>{/if}
{if $resume->jobtitle}<li>{$resume->jobtitle}</li>{/if}
{if $resume->qualname}<li>{$resume->qualname}</li>{/if}
{/foreach}
</ul>
{/if}
<!-- end RESUMEITEMS -->
<!-- VIEWS -->
{if $record->views|count gt 0}
<div class="usedon">
......
Markdown is supported
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