Commit 6ca0ade3 authored by Pat Kira's avatar Pat Kira Committed by Robert Lyon

Style elasticsearch (bug: 1465107)

behatnotneeded

Change-Id: Id1c17fd3c926a09e24080e454aba672dc9a62549
parent 550d72fe
......@@ -3848,14 +3848,14 @@ function build_portfolio_search_html(&$data) {
foreach ($data->data as &$item) {
$item->ctime = format_date($item->ctime);
if ($item->type == 'view') {
$item->typestr = 'file';
$item->typestr = $item->type;
$item->typelabel = get_string('view');
$v = new View(0, (array)$item);
$v->set('dirty', false);
$item->url = $v->get_url();
}
else if ($item->type == 'collection') {
$item->typestr = 'folder-open';
$item->typestr = $item->type;
$item->typelabel = get_string('Collection', 'collection');
$c = new Collection(0, (array)$item);
$item->url = $c->get_url();
......@@ -3866,13 +3866,9 @@ function build_portfolio_search_html(&$data) {
$item->url = $links['_default'];
$item->typestr = $item->artefacttype;
if ($item->artefacttype == 'task') {
$item->typestr = 'tasks';
$item->typelabel = get_string('Task', 'artefact.plans');
}
else {
if ($item->artefacttype == 'plan') {
$item->typestr = 'plans';
}
$item->typelabel = get_string($item->artefacttype, 'artefact.' . $artefacttypes[$item->artefacttype]->plugin);
}
}
......
......@@ -70,27 +70,49 @@ if (get_config('licensemetadata')) {
PluginSearchElasticsearch::build_results_html($data);
$searchoptions = array(
'all' => get_string('All'),
'tagsonly' => get_string('tagsonly', 'view'),
);
if (isset($options['tagsonly']) && $options['tagsonly'] == true) {
$selectvalue = 'tagsonly';
}
else {
$selectvalue = 'all';
}
$searchform = array(
'name' => 'search',
'renderer' => 'oneline',
'renderer' => 'div',
'checkdirtychange' => false,
'elements' => array(),
);
$searchform['elements']['query'] = array(
'type' => 'text',
'defaultvalue' => $query,
'title' => get_string('pagetitle', 'search.elasticsearch'),
'hiddenlabel' => true,
);
$searchform['elements']['submit'] = array(
'type' => 'submit',
'value' => get_string('search'),
);
$searchform['elements']['tagsonly'] = array(
'type' => 'switchbox',
'value' => (isset($options['tagsonly']) && $options['tagsonly'] == true) ? true : false,
'title' => get_string('tagsonly', 'search.elasticsearch'),
'class' => 'form-inline with-heading elasticsearch-form',
'elements' => array(
'searchwithin' => array (
'type' => 'fieldset',
'class' => 'dropdown-group js-dropdown-group',
'elements' => array(
'query' => array(
'type' => 'text',
'title' => get_string('pagetitle', 'search.elasticsearch') . ': ',
'class' => 'with-dropdown js-with-dropdown',
'defaultvalue' => $query,
),
'tagsonly' => array(
'title' => get_string('searchwithin'). ': ',
'class' => 'dropdown-connect js-dropdown-connect searchviews-type',
'type' => 'select',
'options' => $searchoptions,
'value' => $selectvalue,
),
'submit' => array(
'type' => 'submit',
'class' => 'btn-primary no-label input-group',
'value' => get_string('search'),
)
)
),
),
);
$searchform = pieform($searchform);
......@@ -120,7 +142,15 @@ addLoadEvent(function () {
connect('search_submit', 'onclick', function (event) {
firstpage = true;
replaceChildNodes('messages');
var params = {'query': $('search_query').value, 'tagsonly': $('search_tagsonly').checked, 'limit': $('setlimitselect').value, 'extradata':serializeJSON({'page':'index'})};
if ($('search_tagsonly').value === 'tagsonly') {
var tagsonly = true;
}
else {
var tagsonly = false;
}
var params = {'query': $('search_query').value, 'tagsonly': tagsonly, 'mainfacetterm': null,'limit': $('setlimitselect').value, 'extradata':serializeJSON({'page':'index'})};
p.sendQuery(params);
event.stop();
});
......
......@@ -258,7 +258,6 @@ class ElasticsearchType_artefact extends ElasticsearchType
$record->title = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->title));
$record->description = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->description));
// If user is owner
if ($USER->get('id') == $record->owner) {
switch ($record->artefacttype) {
......@@ -316,6 +315,7 @@ class ElasticsearchType_artefact extends ElasticsearchType
}
break;
case 'socialprofile':
safe_require('artefact', 'internal');
$record->note = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->note));
$socialprofile = new ArtefactTypeSocialprofile($record->id);
$icons = $socialprofile->get_profile_icons(array($record));
......@@ -386,7 +386,7 @@ class ElasticsearchType_artefact extends ElasticsearchType
}
// Thumb
if ($record->artefacttype == 'image') {
if ($record->artefacttype == 'image' || $record->artefacttype == 'profileicon') {
if (isset($record->width) && isset($record->height) && intval($record->width) > 0 && intval($record->height) > 0) {
if ($record->width > $record->height) {
$size = '80x' . intval($record->height * 80 / $record->width);
......
{if $selected == "Media"}
<div class="thumbnail-right">
{if $secfacetterm == "Image" && $record->thumb}
<div class="thumbnail-image"><img src="{$record->thumb}" alt=""></div>
{else}
<div class="thumbnail-image"><img src="{$WWWROOT}search/elasticsearch/theme/raw/images/thumbnail-{$secfacetterm|lower}.png" alt=""></div>
{/if}
{/if}
{if $record->link}
<h3 class="title">
{if $record->artefacttype == 'socialprofile'}
<div class="row">
<div class="col-md-8">
{if ($secfacetterm == "Image" || $record->artefacttype == 'profileicon') && $record->thumb}
<img src="{$record->thumb}" alt="" class="mrm">
<h3 class="title list-group-item-heading text-inline">
{if $record->link}
<a href="{$WWWROOT}{$record->link}">
{$record->title|str_shorten_html:50:true|safe}
</a>
{else}
{$record->title|str_shorten_html:50:true|safe}
{/if}
</h3>
{elseif $record->artefacttype == 'socialprofile'}
<img src="{$record->icon}" alt="{$record->note}">
{$record->note|str_shorten_html:50:true|safe}
<a href="{$record->link}" title="{$record->link}" target="_blank" class="socialprofile">{$record->title|str_shorten_html:50:true|safe}</a>
{else}
<a href="{$WWWROOT}{$record->link}">{$record->title|str_shorten_html:50:true|safe}</a>
{/if}
{else}
<h3 class="title">{$record->title|str_shorten_html:50:true|safe}
{/if}
<span class="artefacttype">
{if $secfacetterm == "Journalentry"}
({str tag=blogpost section=search.elasticsearch})
{elseif $secfacetterm == "Forumpost"}
({str tag=forumpost section=search.elasticsearch})
{elseif $secfacetterm == "Resume"}
({str tag=resume section=search.elasticsearch})
{elseif $secfacetterm == "Wallpost"}
({str tag=wallpost section=search.elasticsearch})
{else}
({$secfacetterm})
{/if}
{if $record->deleted}
({str tag=deleted section=search.elasticsearch})
{/if}
</span></h3>
{if $record->createdbyname}
<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">
{if $record->views|count gt 1}
<strong>{str tag=usedonpages section=search.elasticsearch}:</strong>
<ul>
{foreach from=$record->views key=id item=view}
<li><a href="{$WWWROOT}view/view.php?id={$id}">{$view|str_shorten_html:50:true|safe}</a>
<!-- Profile artefact can only be displayed in views -->
{if $secfacetterm != "Profile"}
|
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">view
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
{elseif $secfacetterm == "Forumpost"}
{str tag=forumpost section=search.elasticsearch}
{elseif $secfacetterm == "Resume"}
{str tag=resume section=search.elasticsearch}
{elseif $secfacetterm == "Wallpost"}
{str tag=wallpost section=search.elasticsearch}
{else}
{$secfacetterm|lower}
{/if}
<h3 class="title list-group-item-heading text-inline">
{if $record->link}
<a href="{$WWWROOT}{$record->link}">
{$record->title|str_shorten_html:50:true|safe}
</a>
</span>
{else}
{$record->title|str_shorten_html:50:true|safe}
{/if}
</li>
{/foreach}
</ul>
{else}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
<ul>
{foreach from=$record->views key=id item=view}
<li><a href="{$WWWROOT}view/view.php?id={$id}">{$view|str_shorten_html:50:true|safe}</a>
<!-- Profile artefact can only be displayed in views -->
{if $secfacetterm != "Profile"}
|
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">view
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
{elseif $secfacetterm == "Forumpost"}
{str tag=forumpost section=search.elasticsearch}
{elseif $secfacetterm == "Resume"}
{str tag=resume section=search.elasticsearch}
{elseif $secfacetterm == "Wallpost"}
{str tag=wallpost section=search.elasticsearch}
{else}
{$secfacetterm|lower}
{/if}
</h3>
{else}
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-{$record->artefacttype} left {if $record->deleted}text-lighttone{/if}"></span>
{if $record->link}
<a href="{$WWWROOT}{$record->link}">
{$record->title|str_shorten_html:50:true|safe}
</a>
</span>
{else}
{$record->title|str_shorten_html:50:true|safe}
{/if}
</li>
</h3>
{/if}
<span class="artefacttype text-lighttone">
{if $secfacetterm == "Journalentry"}
({str tag=blogpost section=search.elasticsearch})
{elseif $secfacetterm == "Forumpost"}
({str tag=forumpost section=search.elasticsearch})
{elseif $secfacetterm == "Resume"}
({str tag=resume section=search.elasticsearch})
{elseif $secfacetterm == "Wallpost"}
({str tag=wallpost section=search.elasticsearch})
{else}
({$secfacetterm})
{/if}
{if $record->deleted}
({str tag=deleted section=search.elasticsearch})
{/if}
</span>
{if $record->createdbyname}
<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>
<!-- 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}
</ul>
</div>
{/if}
</div>
<!-- RESUMEITEMS -->
<div class="col-md-4">
{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}
<!-- VIEWS -->
{if $record->views|count gt 0}
<div class="usedon">
{if $record->views|count gt 1}
<strong>{str tag=usedonpages section=search.elasticsearch}:</strong>
<ul class="list-group list-unstyled">
{foreach from=$record->views key=id item=view}
<li>
<a href="{$WWWROOT}view/view.php?id={$id}">{$view|str_shorten_html:50:true|safe}</a>
<!-- Profile artefact can only be displayed in views -->
{if $secfacetterm != "Profile"} |
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">
view
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
{elseif $secfacetterm == "Forumpost"}
{str tag=forumpost section=search.elasticsearch}
{elseif $secfacetterm == "Resume"}
{str tag=resume section=search.elasticsearch}
{elseif $secfacetterm == "Wallpost"}
{str tag=wallpost section=search.elasticsearch}
{else}
{$secfacetterm|lower}
{/if}
</a>
</span>
{/if}
</li>
{/foreach}
</ul>
{else}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
<ul class="list-group list-unstyled">
{foreach from=$record->views key=id item=view}
<li>
<a href="{$WWWROOT}view/view.php?id={$id}">{$view|str_shorten_html:50:true|safe}</a>
<!-- Profile artefact can only be displayed in views -->
{if $secfacetterm != "Profile"} |
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">
view
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
{elseif $secfacetterm == "Forumpost"}
{str tag=forumpost section=search.elasticsearch}
{elseif $secfacetterm == "Resume"}
{str tag=resume section=search.elasticsearch}
{elseif $secfacetterm == "Wallpost"}
{str tag=wallpost section=search.elasticsearch}
{else}
{$secfacetterm|lower}
{/if}
</a>
</span>
{/if}
</li>
{/foreach}
</ul>
{/if}
</div>
{/if}
</div>
{/if}
<!-- end VIEWS -->
<!-- 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 $selected == "Media"}
</div>
{/if}
<!-- end TAGS -->
{if $record->link}
<h3 class="title">
<a href="{$WWWROOT}{$record->link}">{$record->title|str_shorten_html:50:true|safe}</a>
{else}
<h3 class="title">{$record->title|str_shorten_html:50:true|safe}
{/if}
<span class="artefacttype">
({str tag=document section=search.elasticsearch})
{if $record->deleted}
({str tag=deleted section=search.elasticsearch})
{/if}
</span></h3>
{if $record->createdbyname}
<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>
<!-- VIEWS -->
{if $record->views|count gt 0}
<div class="usedon">
{if $record->views}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
<ul>
{foreach from=$record->views key=id item=view}
<li><a href="{$WWWROOT}view/view.php?id={$id}">{$view|str_shorten_html:50:true|safe}</a>
</li>
<div class="row">
<div class="col-md-8">
{if $record->link}
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-file left"></span>
<a href="{$WWWROOT}{$record->link}">{$record->title|str_shorten_html:50:true|safe}</a>
</h3>
{else}
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-file left"></span>
{$record->title|str_shorten_html:50:true|safe}
</h3>
{/if}
<span class="artefacttype text-lighttone">
({str tag=document section=search.elasticsearch})
{if $record->deleted}
({str tag=deleted section=search.elasticsearch})
{/if}
</span>
{if $record->createdbyname}
<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>
<!-- 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}
</ul>
</div>
{/if}
</div>
{/if}
<!-- end VIEWS -->
<!-- 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}
<!-- VIEWS -->
{if $record->views|count gt 0}
<div class="col-md-4">
<div class="usedon">
{if $record->views}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
<ul class="list-group list-unstyled">
{foreach from=$record->views key=id item=view}
<li><a href="{$WWWROOT}view/view.php?id={$id}">{$view|str_shorten_html:50:true|safe}</a>
</li>
{/foreach}
</ul>
{/if}
</div>
</div>
{/if}
</div>
{/if}
<!-- end TAGS -->
{if $record->deleted}
<h3 class="title">{$record->name} <span class="artefacttype">({str tag=deleted section=search.elasticsearch})</span></h3>
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-folder-open left"></span>
{$record->name}
</h3>
<span class="artefacttype text-lighttone">({str tag=deleted section=search.elasticsearch})</span>
{else}
<h3 class="title"><a href="{$WWWROOT}view/view.php?id={$record->viewid}">{$record->name}</a> <span class="artefacttype">({str tag=collection section=search.elasticsearch})</span></h3>
<h3 class="title">
<span class="icon icon-folder-open left"></span>
<a href="{$WWWROOT}view/view.php?id={$record->viewid}">
{$record->name}
</a>
</h3>
<span class="artefacttype">({str tag=collection section=search.elasticsearch})</span>
{if $record->createdbyname}
<div class="createdby">{str tag=createdby section=search.elasticsearch arg1='<a href="`$record->createdby|profile_url}">`$record->createdbyname|safe`</a>'}</div>
{/if}
......
......@@ -6,14 +6,27 @@
- sort
- tagsonly
*}
<div id="totalresultsdisplay" class="totalresults">{str tag=xsearchresultsfory section=search.elasticsearch arg1=$totalresults arg2='<a href="`$WWWROOT`search/elasticsearch/index.php?query=`$query`">`$query`</a>'}</div>
<div class="tabswrap"><ul class="in-page-tabs searchtab">
{foreach from=$facets item=term}
{if $term.count > 0}
<li{if $term.term == $selected} class="current-tab"{/if}>
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$query}&mainfacetterm={$term.term}{if $tagsonly}&tagsonly=true{/if}&limit={$limit}"{if $term.term == $selected} class="current-tab"{/if}>{str tag=$term.display section=search.elasticsearch} ({$term.count})<span class="accessible-hidden sr-only">({str tag=tab}{if $term.term == $selected} {str tag=selected}{/if})</span></a></li>
{else}
<li><span class="inactive">{str tag=$term.display section=search.elasticsearch}<span class="accessible-hidden sr-only">({str tag=tab} {str tag=disabled})</span></span></li>
{/if}
{/foreach}
</ul></div>
<div id="totalresultsdisplay" class="totalresults view-description lead">
{str tag=xsearchresultsfory section=search.elasticsearch arg1=$totalresults arg2='
<a href="`$WWWROOT`search/elasticsearch/index.php?query=`$query`">`$query`</a>'}
</div>
<div class="elasticsearch-tabswrap">
<ul class="in-page-tabs searchtab nav nav-tabs">
{foreach from=$facets item=term}
{if $term.count > 0}
<li class="{if $term.term == $selected}current-tab active{/if}">
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$query}&mainfacetterm={$term.term}{if $tagsonly}&tagsonly=true{/if}&limit={$limit}"{if $term.term == $selected} class="current-tab"{/if}>{str tag=$term.display section=search.elasticsearch} ({$term.count})
<span class="accessible-hidden sr-only">({str tag=tab}{if $term.term == $selected} {str tag=selected}{/if})</span>
</a>
</li>
{else}
<li>
<a class="inactive">
{str tag=$term.display section=search.elasticsearch}
<span class="accessible-hidden sr-only">({str tag=tab} {str tag=disabled})</span>
</a>
</li>