RM-5878 Update the live search lib file with the 5.2 version.

Keep the changes to exclude RM saved searches.
This commit is contained in:
Tom Page
2017-12-11 10:50:23 +00:00
parent eadb2745c3
commit ec6c956a3e

View File

@@ -65,10 +65,10 @@ function getSiteData(siteId) {
}
var site = siteService.getSite(siteId);
var data =
{
shortName: siteId,
title: (site !== null ? site.title : "unknown")
};
{
shortName : siteId,
title : (site !== null ? site.title : "unknown")
};
siteDataCache[siteId] = data;
return data;
}
@@ -80,10 +80,10 @@ function getSiteData(siteId) {
*/
function getQueryTemplate() {
var t =
[{
field: "keywords",
template: "%(cm:name cm:title cm:description TEXT TAG)"
}],
[{
field: "keywords",
template: "%(cm:name cm:title cm:description TEXT TAG)"
}],
qt = new XML(config.script)["default-query-template"];
if (qt != null && qt.length() != 0)
{
@@ -103,18 +103,18 @@ function getDocumentItem(container, node) {
if (node.isDocument)
{
item =
{
nodeRef: node.nodeRef.toString(),
name: node.name,
title: node.properties["cm:title"],
description: node.properties["cm:description"],
modifiedOn: node.properties["cm:modified"],
modifiedBy: node.properties["cm:modifier"],
createdOn: node.properties["cm:created"],
createdBy: node.properties["cm:creator"],
mimetype: node.mimetype,
size: node.size
};
{
nodeRef: node.nodeRef.toString(),
name: node.name,
title: node.properties["cm:title"],
description: node.properties["cm:description"],
modifiedOn: node.properties["cm:modified"],
modifiedBy: node.properties["cm:modifier"],
createdOn: node.properties["cm:created"],
createdBy: node.properties["cm:creator"],
mimetype: node.mimetype,
size: node.size
};
if (container.siteId !== null)
{
item.site = getSiteData(container.siteId);
@@ -123,7 +123,7 @@ function getDocumentItem(container, node) {
if (node.hasAspect("{http://www.alfresco.org/model/content/1.0}thumbnailModification"))
{
var dates = node.properties["lastThumbnailModification"];
for (var i = 0; i < dates.length; i++)
for (var i=0; i<dates.length; i++)
{
if (dates[i].indexOf("doclib") !== -1)
{
@@ -147,19 +147,19 @@ function getDocumentItem(container, node) {
*/
function splitQNamePath(node) {
var path = node.qnamePath,
container = {
container = {
siteId: null,
containerId: null
};
};
if (path.match("^" + SITES_SPACE_QNAME_PATH) == SITES_SPACE_QNAME_PATH)
if (path.match("^"+SITES_SPACE_QNAME_PATH) == SITES_SPACE_QNAME_PATH)
{
var tmp = path.substring(SITES_SPACE_QNAME_PATH.length),
pos = tmp.indexOf('/');
pos = tmp.indexOf('/');
if (pos >= 1)
{
var siteQName = Packages.org.alfresco.util.ISO9075.decode(tmp.split("/")[0]);
siteId = siteQName.substring(siteQName.indexOf(":") + 1);
siteId = siteQName.substring(siteQName.indexOf(":") + 1);
tmp = tmp.substring(pos + 1);
pos = tmp.indexOf('/');
if (pos >= 1)
@@ -208,11 +208,20 @@ function getDocResults(params) {
// ensure a TYPE is specified
var ftsQuery = params.term + ' AND +TYPE:"cm:content"';
// site constraint
if (params.siteId !== null)
{
// use SITE syntax to restrict to specific site
ftsQuery += ' AND SITE:"' + params.siteId + '"';
}
// root node - generally used for overridden Repository root in Share
if (params.rootNode !== null)
{
ftsQuery = 'PATH:"' + rootNode.qnamePath + '//*" AND (' + ftsQuery + ')';
}
// main query construction
ftsQuery = '(' + ftsQuery + ') AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating" AND -TYPE:"fm:post" AND -ASPECT:"sys:hidden" AND -ASPECT:"rma:savedSearch" AND -cm:creator:system';
if (logger.isLoggingEnabled())
@@ -243,13 +252,13 @@ function getDocResults(params) {
}
};
var rs = search.queryResultSet(queryDef);
nodes = rs.nodes,
results = [];
nodes = rs.nodes,
results = [];
if (logger.isLoggingEnabled())
logger.log("Processing resultset of length: " + nodes.length);
for (var i = 0, item; i < nodes.length && i < params.maxResults; i++)
for (var i=0, item; i<nodes.length && i<params.maxResults; i++)
{
// For each node we extract the site/container qname path and then
// let the per-container helper function decide what to do.