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

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(
'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,
'title' => get_string('pagetitle', 'search.elasticsearch'),
'hiddenlabel' => true,
);
$searchform['elements']['submit'] = array(
),
'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['elements']['tagsonly'] = array(
'type' => 'switchbox',
'value' => (isset($options['tagsonly']) && $options['tagsonly'] == true) ? true : false,
'title' => get_string('tagsonly', 'search.elasticsearch'),
)
)
),
),
);
$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>
<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}
<div class="thumbnail-image"><img src="{$WWWROOT}search/elasticsearch/theme/raw/images/thumbnail-{$secfacetterm|lower}.png" alt=""></div>
{$record->title|str_shorten_html:50:true|safe}
{/if}
{/if}
{if $record->link}
<h3 class="title">
{if $record->artefacttype == 'socialprofile'}
</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>
<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>
{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>
{else}
<a href="{$WWWROOT}{$record->link}">{$record->title|str_shorten_html:50:true|safe}</a>
{$record->title|str_shorten_html:50:true|safe}
{/if}
{else}
<h3 class="title">{$record->title|str_shorten_html:50:true|safe}
{/if}
<span class="artefacttype">
</h3>
{/if}
<span class="artefacttype text-lighttone">
{if $secfacetterm == "Journalentry"}
({str tag=blogpost section=search.elasticsearch})
{elseif $secfacetterm == "Forumpost"}
......@@ -34,13 +49,27 @@
{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}
</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}
</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}
......@@ -49,21 +78,22 @@
{if $resume->qualname}<li>{$resume->qualname}</li>{/if}
{/foreach}
</ul>
{/if}
<!-- end RESUMEITEMS -->
<!-- VIEWS -->
{if $record->views|count gt 0}
{/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>
<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>
<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"}
|
{if $secfacetterm != "Profile"} |
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">view
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">
view
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
{elseif $secfacetterm == "Forumpost"}
......@@ -83,14 +113,15 @@
</ul>
{else}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
<ul>
<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>
<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"}
|
{if $secfacetterm != "Profile"} |
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">view
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">
view
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
{elseif $secfacetterm == "Forumpost"}
......@@ -110,17 +141,6 @@
</ul>
{/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"}
{/if}
</div>
</div>
{/if}
<!-- end TAGS -->
{if $record->link}
<h3 class="title">
<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>
{else}
<h3 class="title">{$record->title|str_shorten_html:50:true|safe}
{/if}
<span class="artefacttype">
</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></h3>
{if $record->createdbyname}
</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>
<!-- VIEWS -->
{if $record->views|count gt 0}
{/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}
</div>
{/if}
</div>
<!-- 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>
<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>
......@@ -28,14 +44,7 @@
</ul>
{/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}
</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}
<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{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>
<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><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>
<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>
{/if}
{/foreach}
</ul></div>
{/foreach}
</ul>
</div>
{if $record->deleted}
<div class="groupsdetails">
<h3 class="title">{$record->name} ({str tag=deleted section=search.elasticsearch})</h3>
</div>
<h3 class="title list-group-item-heading">
<span class="icon icon-users left text-lighttone"></span>
{$record->name} ({str tag=deleted section=search.elasticsearch})
</h3>
{else}
<div class="groupsdetails">
<h3 class="title"><a href="{$WWWROOT}group/view.php?id={$record->id}">{$record->name}</a></h3>
<div class="groupadmin">{str tag=groupadmins section=group}:
<h3 class="title list-group-item-heading">
<span class="icon icon-users left"></span>
<a href="{$WWWROOT}group/view.php?id={$record->id}">
{$record->name}
</a>
</h3>
<p class="groupdesc">{$record->description|str_shorten_html:140:true|safe}</p>
{if $record->groupadmins}
<div class="groupadmin text-small">
<strong>{str tag=groupadmins section=group}:</strong>
{foreach name=admins from=$record->groupadmins item=user}
<a href="{profile_url($user)}">{$user|display_name}</a>
{if !$.foreach.admins.last}, {/if}
{/foreach}
</div>
<div class="detail">{$record->description|str_shorten_html:140:true|safe}</div>
{/if}
</div>
{/if}
\ No newline at end of file
{if $record->deleted}
<h3 class="title">$record->subject <span class="artefacttype">({str tag=deletedforumpost section=search.elasticsearch})</span></h3>
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-commenting-o left"></span>
{$record->subject}
</h3>
<span class="artefacttype text-lighttone">({str tag=deletedforumpost section=search.elasticsearch})</span>
{else}
<h3 class="title"><a href="{$WWWROOT}interaction/forum/topic.php?id={$record->topic}#post{$record->id}">{$record->subject}</a> <span class="artefacttype">({str tag=forumpost section=search.elasticsearch})</span></h3>
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-commenting-o left"></span>
<a href="{$WWWROOT}interaction/forum/topic.php?id={$record->topic}#post{$record->id}">
{$record->subject}
</a>
</h3>
<span class="artefacttype text-lighttone">({str tag=forumpost section=search.elasticsearch})</span>
<div class="source"><strong>{str tag='forum' section='search.elasticsearch'}:</strong> {$record->forumname} ({$record->groupname})</div>
<div class="poster"><strong>{str tag='forumpostedbylabel' section='search.elasticsearch'}:</strong> {str tag=forumpostedby section=search.elasticsearch arg1='$record->authorlink|safe' arg2='$record->ctime'}</div>
<div class="detail">{$record->body|str_shorten_html:140:true:false|safe}</div>
......
{if $record->deleted}
<h3 class="title">{$record->title}</h3>
<span class="icon icon-comments-o left text-lighttone"></span>
<h3 class="title list-group-item-heading">{$record->title}</h3>
<span class="artefacttype text-lighttone">({str tag=deletedforumpost section=search.elasticsearch})</span>
{else}
<h3 class="title"><a href="{$WWWROOT}interaction/forum/view.php?id={$record->id}">{$record->title}</a> <span class="artefacttype">({str tag=forum section=search.elasticsearch})</span></h3>
<h3 class="title list-group-item-heading text-inline">
<span class="icon icon-comments-o left"></span>
<a href="{$WWWROOT}interaction/forum/view.php?id={$record->id}">
{$record->title}
</a>
</h3>
<span class="artefacttype text-lighttone">({str tag=forum section=search.elasticsearch})</span>
<div class="detail">{$record->description|str_shorten_html:140:true|safe}</div>
{/if}
......@@ -8,11 +8,25 @@
- license
- tagsonly
*}
<div id="results_filter" class="search-filter-content">
<strong class="filtertitle">{str tag=filterresultsby section=search.elasticsearch}:</strong>
<div id="results_filter" class="search-filter-content btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="icon icon-filter left"></span>
<span class="sr-only">{str tag=filterresultsby section=search.elasticsearch}</span>
{foreach from=$contentfilter item=term}
<span {if $term.term != $contentfilterselected} class="hidden"{/if}>{$term.display} ({$term.count})</span>
{/foreach}
<span class="icon icon-caret-down right"></span>
</button>
<ul class="dropdown-menu" role="menu">
{foreach from=$contentfilter item=term}
{if $term.count > 0}
<div class="filtername"><a href="{$WWWROOT}search/elasticsearch/index.php?query={$query}&mainfacetterm={$selected}&secfacetterm={$term.term}&owner={$owner}&sort={$sort}&license={$license}{if $tagsonly}&tagsonly=true{/if}&limit={$limit}"{if $term.term == $contentfilterselected} class="selected"{/if}>{$term.display} ({$term.count})</a></div>
<li class="filtername">
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$query}&mainfacetterm={$selected}&secfacetterm={$term.term}&owner={$owner}&sort={$sort}&license={$license}{if $tagsonly}&tagsonly=true{/if}&limit={$limit}"{if $term.term == $contentfilterselected} class="selected"{/if}>
{$term.display} ({$term.count})
</a>
</li>
{/if}
{/foreach}
</ul>
</div>
\ No newline at end of file
......@@ -8,18 +8,24 @@
- license
*}
{if isset($license_on)}
<div id="results_filter" class="search-filter-license">
<div id="results_filter" class="search-filter-license pieform with-label-widthauto form-condensed">
<input type="hidden" id="search-filter-license-url" value="{$WWWROOT}search/elasticsearch/index.php?query={$query}&mainfacetterm={$selected}&secfacetterm={$contentfilterselected}&sort={$sort}&owner={$owner}{if $tagsonly}&tagsonly=true{/if}&limit={$limit}" />
<label for="search-filter-license" class="filtertitle">{str tag=license section=search.elasticsearch}:</label>
<div class="form-group select">
<label for="search-filter-license" class="filtertitle">
{str tag=license section=search.elasticsearch}: