* Added User.popLocation() and User.popLocation() methods for temporarily storing a user's location, ie. to get back where the user came from when it was necessary to login

* Removed Root.searchSites() method (will be back later)
 * Added checks for empty searches in Site.search_action()
This commit is contained in:
Tobi Schäfer 2007-10-17 16:25:01 +00:00
parent 3d0fae4302
commit 1c3c51a0e1
7 changed files with 46 additions and 72 deletions

View file

@ -362,26 +362,30 @@ Site.prototype.referrers_action = function() {
};
Site.prototype.search_action = function() {
var search = stripTags(req.postParams.q);
var db = getDBConnection("antville");
var query = 'select id from content where site_id = ' + this._id +
" and prototype = 'Story' and status <> 'closed' and " +
" metadata like '%title:\"%" + search + "%\"%' or " +
" metadata like '%text:\"%" + search + "%\"%' " +
" order by created desc limit 25";
var rows = db.executeRetrieval(query);
var ref, counter = 0;
res.push();
while (rows.next()) {
ref = Story.getById(rows.getColumnItem("id"));
ref.renderSkin("Story#preview");
counter += 1;
var search = req.postParams.q = stripTags(req.postParams.q);
if (!search) {
res.message = gettext("Please enter a query in the search form.");
} else {
var db = getDBConnection("antville");
var query = 'select id from content where site_id = ' + this._id +
" and prototype = 'Story' and status <> 'closed' and " +
" (metadata like '%title:\"%" + search + "%\"%' or " +
" metadata like '%text:\"%" + search + "%\"%') " +
" order by created desc limit 25";
var rows = db.executeRetrieval(query);
var ref, counter = 0;
res.push();
while (rows.next()) {
ref = Story.getById(rows.getColumnItem("id"));
ref.renderSkin("Story#preview");
counter += 1;
}
rows.release();
res.message = ngettext("Found {0} result.", "Found {0} results.", counter);
res.data.body = res.pop();
}
rows.release();
res.message = ngettext("Found {0} result.", "Found {0} results.", counter);
res.data.title = gettext('Search results for "{0}" in site "{1}"',
search, this.title);
res.data.body = res.pop();
this.renderSkin("page");
return;
};