|
|
@ -15,17 +15,6 @@ searchController.search = function(req, res, next) {
|
|
|
|
return next();
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
categories.getCategoriesByPrivilege('categories:cid', req.uid, 'read', function(err, categories) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return next(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
categories = categories.filter(function(category) {
|
|
|
|
|
|
|
|
return category && !category.link;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req.params.term = validator.escape(req.params.term);
|
|
|
|
req.params.term = validator.escape(req.params.term);
|
|
|
|
var page = Math.max(1, parseInt(req.query.page, 10)) || 1;
|
|
|
|
var page = Math.max(1, parseInt(req.query.page, 10)) || 1;
|
|
|
|
if (req.query.categories && !Array.isArray(req.query.categories)) {
|
|
|
|
if (req.query.categories && !Array.isArray(req.query.categories)) {
|
|
|
@ -56,8 +45,7 @@ searchController.search = function(req, res, next) {
|
|
|
|
results.pagination = pagination.create(page, results.pageCount, req.query);
|
|
|
|
results.pagination = pagination.create(page, results.pageCount, req.query);
|
|
|
|
results.showAsPosts = !req.query.showAs || req.query.showAs === 'posts';
|
|
|
|
results.showAsPosts = !req.query.showAs || req.query.showAs === 'posts';
|
|
|
|
results.showAsTopics = req.query.showAs === 'topics';
|
|
|
|
results.showAsTopics = req.query.showAs === 'topics';
|
|
|
|
results.breadcrumbs = breadcrumbs;
|
|
|
|
results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]);
|
|
|
|
results.categories = categories;
|
|
|
|
|
|
|
|
results.expandSearch = !req.params.term;
|
|
|
|
results.expandSearch = !req.params.term;
|
|
|
|
|
|
|
|
|
|
|
|
plugins.fireHook('filter:search.build', {data: data, results: results}, function(err, data) {
|
|
|
|
plugins.fireHook('filter:search.build', {data: data, results: results}, function(err, data) {
|
|
|
@ -67,8 +55,6 @@ searchController.search = function(req, res, next) {
|
|
|
|
res.render('search', data.results);
|
|
|
|
res.render('search', data.results);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = searchController;
|
|
|
|
module.exports = searchController;
|
|
|
|