antville/code/HopObject/HopObject.js

647 lines
15 KiB
JavaScript
Raw Normal View History

//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
/**
* @fileOverview Defines the extensions of Helmas built-in
* HopObject prototype.
*/
/**
*
* @param {HopObject} collection
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
* @param {Object} options Optional flags, e.g. to force or prevent any
* conditional checks of individual prototypes remove() methods
*/
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
HopObject.remove = function(options) {
var item;
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
while (this.size() > 0) {
item = this.get(0);
if (item.constructor.remove) {
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
item.constructor.remove.call(item, options);
} else if (!options) {
item.remove();
} else {
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
throw Error("Missing static " + item.constructor.name +
".remove() method");
}
}
return;
}
/**
*
* @param {String} name
* @param {HopObject} collection
*/
HopObject.getFromPath = function(name, collection) {
if (name) {
var site;
if (name.contains("/")) {
var parts = name.split("/");
site = root.get(parts[0]);
name = parts[1];
} else {
site = res.handlers.site;
}
if (site && site.getPermission("main")) {
return site[collection].get(name);
}
}
return null;
}
/**
* Helmas built-in HopObject with Antvilles extensions.
* @name HopObject
* @constructor
*/
/**
*
* @param {Object} values
*/
HopObject.prototype.map = function(values) {
for (var i in values) {
this[i] = values[i];
}
return;
}
/**
*
*/
HopObject.prototype.onRequest = function() {
// Checking if we are on the correct host to prevent at least some XSS issues
if (req.action !== "notfound" && req.action !== "error" &&
this.href().startsWith("http://") &&
!this.href().toLowerCase().startsWith(req.servletRequest.scheme +
"://" + req.servletRequest.serverName.toLowerCase())) {
res.redirect(this.href(req.action === "main" ? String.EMPTY : req.action));
}
* Fixed reference to parent site in Archive * Fixed _children.filter in Archive * Added missing permission checks * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument * Added HopObject.macro_macro() method to display userland macro code * Removed colorpicker (will be replaced by third-party library) * Removed obsolete global constants and functions * Overhauled and tested global userland macros like story_macro(), image_macro() etc. * Implemented global list_macro() to replace any special listFoobar_macro() methods * Moved global autoLogin() method into User prototype * Overhauled global randomize_macro() * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail() * Re-added accidentally removed subskins to Members.skin * Fixed some skin names which were changed recently * Remove delete_action() from Membership * Fixed foreign key of images collection in Membership * Removed global username_macro() and replaced it with appropriate membership macros * Moved contents of systemscripts.skin into javascript.skin in Root prototype * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root * Added accessname to sites collection in Root * Upgraded jQuery to version 1.2.1 * Replaced call for global history_macro() with corresponding list_macro() call * Renamed "public" collection of Stories prototype to "featured" * Moved a lot of styles from Root's style.skin to the one in Site * Added comments collection to Site * Moved embed.skin as subskin #embed into Site.skin * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode) * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie * Moved a lot of code into compatibility module
2007-10-11 23:03:17 +00:00
User.autoLogin();
res.handlers.membership = User.getMembership();
* Fixed reference to parent site in Archive * Fixed _children.filter in Archive * Added missing permission checks * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument * Added HopObject.macro_macro() method to display userland macro code * Removed colorpicker (will be replaced by third-party library) * Removed obsolete global constants and functions * Overhauled and tested global userland macros like story_macro(), image_macro() etc. * Implemented global list_macro() to replace any special listFoobar_macro() methods * Moved global autoLogin() method into User prototype * Overhauled global randomize_macro() * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail() * Re-added accidentally removed subskins to Members.skin * Fixed some skin names which were changed recently * Remove delete_action() from Membership * Fixed foreign key of images collection in Membership * Removed global username_macro() and replaced it with appropriate membership macros * Moved contents of systemscripts.skin into javascript.skin in Root prototype * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root * Added accessname to sites collection in Root * Upgraded jQuery to version 1.2.1 * Replaced call for global history_macro() with corresponding list_macro() call * Renamed "public" collection of Stories prototype to "featured" * Moved a lot of styles from Root's style.skin to the one in Site * Added comments collection to Site * Moved embed.skin as subskin #embed into Site.skin * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode) * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie * Moved a lot of code into compatibility module
2007-10-11 23:03:17 +00:00
if (User.getCurrentStatus() === User.BLOCKED) {
session.data.status = 403;
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
session.data.error = gettext("Your account has been blocked.") + String.SPACE +
gettext("Please contact an administrator for further information.");
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
User.logout();
res.redirect(root.href("error"));
}
if (res.handlers.site.status === Site.BLOCKED &&
!User.require(User.PRIVILEGED)) {
session.data.status = 403;
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
session.data.error = gettext("The site you requested has been blocked.") +
String.SPACE + gettext("Please contact an administrator for further information.");
res.redirect(root.href("error"));
}
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
res.handlers.layout = res.handlers.site.layout || new Layout;
res.skinpath = res.handlers.layout.getSkinPath();
if (!this.getPermission(req.action)) {
if (!session.user) {
User.setLocation(root.href() + req.path);
res.message = gettext("Please login first.");
res.redirect(res.handlers.site.members.href("login"));
}
User.getLocation();
res.status = 401;
res.data.title = gettext("{0} 401 Error", root.title);
res.data.body = root.renderSkinAsString("$Root#error", {error:
gettext("You are not allowed to access this part of the site.")});
res.handlers.site.renderSkin("Site#page");
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
session.data.error = null;
res.stop();
}
res.meta.values = {};
res.handlers.site.renderSkinAsString("Site#values");
return;
}
/**
* @returns Boolean
*/
HopObject.prototype.getPermission = function() {
return true;
}
// Marking some prototype names used in res.message of HopObject.delete_action()
markgettext("Comment");
markgettext("File");
markgettext("Image");
markgettext("Membership");
markgettext("Poll");
markgettext("Story");
HopObject.prototype.delete_action = function() {
if (req.postParams.proceed) {
try {
var parent = this._parent;
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
var url = this.constructor.remove.call(this, req.postParams) ||
parent.href();
res.message = gettext("{0} was successfully deleted.", gettext(this._prototype));
res.redirect(User.getLocation() || url);
} catch(ex) {
res.message = ex;
app.log(ex);
}
}
res.data.action = this.href(req.action);
res.data.title = gettext("Confirm Deletion");
res.data.body = this.renderSkinAsString("$HopObject#confirm", {
text: this.getConfirmText()
});
res.handlers.site.renderSkin("Site#page");
return;
}
/**
* @returns {Object}
*/
HopObject.prototype.touch = function() {
return this.map({
modified: new Date,
modifier: session.user
});
}
/**
*
*/
HopObject.prototype.log = function() {
var entry = new LogEntry(this, "main");
app.data.entries.push(entry);
return;
}
/**
*
* @param {String} action
*/
HopObject.prototype.notify = function(action) {
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
var self = this;
var site = res.handlers.site;
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
var getPermission = function(scope, mode, status) {
if (scope === Admin.NONE || mode === Site.NOBODY ||
status === Site.BLOCKED) {
return false;
}
var scopes = [Admin.REGULAR, Admin.TRUSTED];
if (scopes.indexOf(status) < scopes.indexOf(scope)) {
return false;
}
if (!Membership.require(mode)) {
return false;
}
return true;
}
// Helper method for debugging
var renderMatrix = function() {
var buf = ['<table border=1 cellspacing=0>'];
for each (var scope in Admin.getNotificationScopes()) {
for each (var mode in Site.getNotificationModes()) {
for each (var status in Site.getStatus()) {
var perm = getPermission(scope.value, mode.value, status.value);
buf.push('<tr style="');
perm && buf.push('color: blue;');
if (scope.value === root.notificationScope && mode.value ===
site.notificationMode && status.value === site.status) {
buf.push(' background-color: yellow;');
}
buf.push('">');
buf.push('<td>', scope.value, '</td>');
buf.push('<td>', status.value, '</td>');
buf.push('<td>', mode.value, '</td>');
buf.push('<td>', perm, '</td>');
buf.push('</tr>');
}
}
}
buf.push('</table>');
res.write(buf.join(""));
return;
}
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
switch (action) {
case "comment":
action = "create"; break;
}
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
var currentMembership = res.handlers.membership;
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
site.members.forEach(function() {
var membership = res.handlers.membership = this;
if (getPermission(root.notificationScope, site.notificationMode, site.status)) {
sendMail(membership.creator.email, gettext("[{0}] Notification of site changes",
root.title), self.renderSkinAsString("$HopObject#notify_" + action));
}
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features * Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype * Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites * Renamed Root.getScopes() method to Admin.getNotificationScopes() * Renamed User.getScopes() method to Admin.getCreationScopes() * Added Admin.getPhaseOutModes() method * Removed obsolete code * Fixed and renamed Admin.privateSites to Admin.restrictedSites collection * Finally added simple and reasonable quota implementation * Fixed gettext_macro() and ngettext_macro() with check for necessary arguments * Removed sender argument from global sendMail() method – instead, the root.replyTo property is used * Fixed some i18n messages * Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen * Completely rewrote HopObject.notify() method (hopefully fixing issue 49) * Check free disk space before invoking create_action() of Files and Images prototypes * Modified output of Membership.toString() method * Fixed some linebreaks in Membership.skin * Added option to set session.data.error for additonal information in $Root#error skin * Slightly modified output of $Root#health skin * Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode * Removed qualifyingDate property from Root * Renamed Root.qualifyingPeriod property to Root.probationPeriod * Removed autoCleanupEnabled and autoCleanupStartTime properties from Root * Added replyTo property to Root * Rewrote Root.getCreationPermission() method * Added #notify_blocking and #notify_deletion skins to $Site.skin * Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified * Added Site.diskspace_macro() returning the free disk space in MB * Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
});
res.handlers.membership = currentMembership;
return;
}
/**
* @returns {Tag[]}
*/
HopObject.prototype.getTags = function() {
var tags = [];
if (typeof this.tags === "object") {
this.tags.list().forEach(function(item) {
item.tag && tags.push(item.tag.name);
});
}
return tags;
}
/**
*
* @param {Tag[]|String} tags
*/
HopObject.prototype.setTags = function(tags) {
if (typeof this.tags !== "object") {
return String.EMPTY;
}
if (!tags) {
tags = [];
} else if (tags.constructor === String) {
tags = tags.split(/\s*,\s*/);
}
var diff = {};
var tag;
for (var i in tags) {
// Trim and remove troublesome characters (like ../.. etc.)
// We call getAccessName with a virgin HopObject to allow most names
tag = tags[i] = this.getAccessName.call(new HopObject, File.getName(tags[i]));
if (tag && diff[tag] == null) {
diff[tag] = 1;
}
}
this.tags.forEach(function() {
if (!this.tag) {
return;
}
diff[this.tag.name] = (tags.indexOf(this.tag.name) < 0) ? this : 0;
});
for (var tag in diff) {
switch (diff[tag]) {
case 0:
// Do nothing (tag already exists)
break;
case 1:
// Add tag to story
this.addTag(tag);
break;
default:
// Remove tag
this.removeTag(diff[tag]);
}
}
return;
}
/**
*
* @param {String} name
*/
HopObject.prototype.addTag = function(name) {
this.tags.add(new TagHub(name, this, session.user));
return;
}
/**
*
* @param {String} tag
*/
HopObject.prototype.removeTag = function(tag) {
var parent = tag._parent;
if (parent.size() === 1) {
parent.remove();
}
tag.remove();
return;
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.skin_macro = function(param, name) {
if (!name) {
return;
}
if (name.contains("#")) {
this.renderSkin(name);
} else {
var prototype = this._prototype || "Global";
this.renderSkin(prototype + "#" + name);
}
return;
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.input_macro = function(param, name) {
param.name = name;
param.id = name;
param.value = this.getFormValue(name);
return html.input(param);
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.textarea_macro = function(param, name) {
param.name = name;
param.id = name;
param.value = this.getFormValue(name);
return html.textArea(param);
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.select_macro = function(param, name) {
param.name = name;
param.id = name;
var options = this.getFormOptions(name);
if (options.length < 2) {
param.disabled = "disabled";
}
return html.dropDown(param, options, this.getFormValue(name));
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.checkbox_macro = function(param, name) {
param.name = name;
param.id = name;
var options = this.getFormOptions(name);
if (options.length < 2) {
param.disabled = "disabled";
}
param.value = String((options[1] || options[0]).value);
param.selectedValue = String(this.getFormValue(name));
var label = param.label;
delete param.label;
html.checkBox(param);
if (label) {
html.element("label", label, {"for": name});
}
return;
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.radiobutton_macro = function(param, name) {
param.name = name;
param.id = name;
var options = this.getFormOptions(name);
if (options.length < 2) {
param.disabled = "disabled";
}
param.value = String(options[0].value);
param.selectedValue = String(this.getFormValue(name));
var label = param.label;
delete param.label;
html.radioButton(param);
if (label) {
html.element("label", label, {"for": name});
}
return;
}
/**
*
* @param {Object} param
* @param {String} name
*/
HopObject.prototype.upload_macro = function(param, name) {
param.name = name;
param.id = name;
param.value = this.getFormValue(name);
renderSkin("$Global#upload", param);
return;
}
/**
*
* @param {Object} param
* @param {HopObject} [handler]
*/
* Fixed reference to parent site in Archive * Fixed _children.filter in Archive * Added missing permission checks * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument * Added HopObject.macro_macro() method to display userland macro code * Removed colorpicker (will be replaced by third-party library) * Removed obsolete global constants and functions * Overhauled and tested global userland macros like story_macro(), image_macro() etc. * Implemented global list_macro() to replace any special listFoobar_macro() methods * Moved global autoLogin() method into User prototype * Overhauled global randomize_macro() * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail() * Re-added accidentally removed subskins to Members.skin * Fixed some skin names which were changed recently * Remove delete_action() from Membership * Fixed foreign key of images collection in Membership * Removed global username_macro() and replaced it with appropriate membership macros * Moved contents of systemscripts.skin into javascript.skin in Root prototype * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root * Added accessname to sites collection in Root * Upgraded jQuery to version 1.2.1 * Replaced call for global history_macro() with corresponding list_macro() call * Renamed "public" collection of Stories prototype to "featured" * Moved a lot of styles from Root's style.skin to the one in Site * Added comments collection to Site * Moved embed.skin as subskin #embed into Site.skin * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode) * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie * Moved a lot of code into compatibility module
2007-10-11 23:03:17 +00:00
HopObject.prototype.macro_macro = function(param, handler) {
var ctor = this.constructor;
if ([Story, Image, File, Poll].indexOf(ctor) > -1) {
res.encode("<% ");
res.write(handler || ctor.name.toLowerCase());
res.write(String.SPACE);
res.write(quote(this.name || this._id));
* Fixed reference to parent site in Archive * Fixed _children.filter in Archive * Added missing permission checks * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument * Added HopObject.macro_macro() method to display userland macro code * Removed colorpicker (will be replaced by third-party library) * Removed obsolete global constants and functions * Overhauled and tested global userland macros like story_macro(), image_macro() etc. * Implemented global list_macro() to replace any special listFoobar_macro() methods * Moved global autoLogin() method into User prototype * Overhauled global randomize_macro() * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail() * Re-added accidentally removed subskins to Members.skin * Fixed some skin names which were changed recently * Remove delete_action() from Membership * Fixed foreign key of images collection in Membership * Removed global username_macro() and replaced it with appropriate membership macros * Moved contents of systemscripts.skin into javascript.skin in Root prototype * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root * Added accessname to sites collection in Root * Upgraded jQuery to version 1.2.1 * Replaced call for global history_macro() with corresponding list_macro() call * Renamed "public" collection of Stories prototype to "featured" * Moved a lot of styles from Root's style.skin to the one in Site * Added comments collection to Site * Moved embed.skin as subskin #embed into Site.skin * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode) * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie * Moved a lot of code into compatibility module
2007-10-11 23:03:17 +00:00
res.encode(" %>");
}
return;
}
* Fixed reference to parent site in Archive * Fixed _children.filter in Archive * Added missing permission checks * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument * Added HopObject.macro_macro() method to display userland macro code * Removed colorpicker (will be replaced by third-party library) * Removed obsolete global constants and functions * Overhauled and tested global userland macros like story_macro(), image_macro() etc. * Implemented global list_macro() to replace any special listFoobar_macro() methods * Moved global autoLogin() method into User prototype * Overhauled global randomize_macro() * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail() * Re-added accidentally removed subskins to Members.skin * Fixed some skin names which were changed recently * Remove delete_action() from Membership * Fixed foreign key of images collection in Membership * Removed global username_macro() and replaced it with appropriate membership macros * Moved contents of systemscripts.skin into javascript.skin in Root prototype * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root * Added accessname to sites collection in Root * Upgraded jQuery to version 1.2.1 * Replaced call for global history_macro() with corresponding list_macro() call * Renamed "public" collection of Stories prototype to "featured" * Moved a lot of styles from Root's style.skin to the one in Site * Added comments collection to Site * Moved embed.skin as subskin #embed into Site.skin * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode) * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie * Moved a lot of code into compatibility module
2007-10-11 23:03:17 +00:00
/**
*
*/
HopObject.prototype.kind_macro = function() {
var type = this.constructor.name.toLowerCase();
switch (type) {
default:
res.write(gettext(type));
break;
}
return;
}
/**
*
* @param {String} name
* @returns {Number|String}
*/
HopObject.prototype.getFormValue = function(name) {
if (req.isPost()) {
return req.postParams[name];
} else {
var value = this[name] || req.queryParams[name] || String.EMPTY;
return value instanceof HopObject ? value._id : value;
}
}
/**
* @returns {Object[]}
*/
HopObject.prototype.getFormOptions = function() {
return [{value: true, display: "enabled"}];
}
/**
* @returns {HopObject}
* @param {Object} param
* @param {String} property
*/
HopObject.prototype.self_macro = function(param, property) {
return property ? this[property] : this;
}
/**
*
*/
HopObject.prototype.type_macro = function() {
return res.write(this.constructor.name);
}
/**
*
* @param {Object} param
* @param {String} url
* @param {String} text
*/
HopObject.prototype.link_macro = function(param, url, text) {
if (url && text) {
var action = url.split(/#|\?/)[0];
if (this.getPermission(action)) {
renderLink.call(global, param, url, text, this);
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
}
} else {
res.write("[Insufficient link parameters]");
}
return;
}
/**
*
* @param {Object} param
* @param {String} format
*/
HopObject.prototype.created_macro = function(param, format) {
if (this.isPersistent()) {
format || (format = param.format);
res.write(formatDate(this.created, format));
}
return;
}
/**
*
* @param {Object} param
* @param {String} format
*/
HopObject.prototype.modified_macro = function(param, format) {
if (this.isPersistent()) {
format || (format = param.format);
res.write(formatDate(this.modified, format));
}
return;
}
/**
*
* @param {Object} param
* @param {String} mode
*/
HopObject.prototype.creator_macro = function(param, mode) {
if (!this.creator || this.isTransient()) {
return;
}
mode || (mode = param.as);
if (mode === "link" && this.creator.url) {
html.link({href: this.creator.url}, this.creator.name);
} else if (mode === "url") {
res.write(this.creator.url);
} else {
res.write(this.creator.name);
} return;
}
/**
*
* @param {Object} param
* @param {String} mode
*/
HopObject.prototype.modifier_macro = function(param, mode) {
if (!this.modifier || this.isTransient()) {
return;
}
mode || (mode = param.as);
if (mode === "link" && this.modifier.url) {
html.link({href: this.modifier.url}, this.modifier.name);
} else if (mode === "url") {
res.write(this.modifier.url);
} else {
res.write(this.modifier.name);
}
return;
}
/**
* @returns {String}
*/
HopObject.prototype.getTitle = function() {
* Refactored code and skins in respect for comprehensive i18n * Refactored and unified remove() methods and calls for greater flexibility as well as reliability * Added option to remove all comments by a user to Comment.remove() method and $Comment#delete skin * Added global #listItemFlag skin as well as listItemFlag_macro() for rendering vertically written text of items in a list view (e.g. closed) * Fixed bug in gettext_macro() and ngettext_macro() causing incorrect whitespace * Refactored timezone and locale handling * Modified automatic translation of untitled links in HopObject.link_macro() * Added honeypot to login and registration forms * Fixed client-side JavaScript to be evaluated when login or registration form is submitted, not only when the submit button is clicked * Removed redundant filter expression from DB mapping of Membership.images collection * Added Membership.content collection * Changed terminology from open to running polls, thus renaming Polls.open_action() method and Polls.open collection * Moved a lot of CSS used in root or administration sections from Site#stylesheet to $Root#stylesheet skin * Added Root.updateDomains() method (most likely already obsolete) * Removed Root.processHref() method (only necessary for very advanced setup) and obsolete comments * Fixed Root.xgettext() method to correctly read UTF-8 encoded data * Fixed Site.deleted_macro() to return the date object for late formatting * Refactored Site.processHref() for more convenient custom domain name mapping * Renamed Skins.advanced_action() method to Skins.all_action() * Removed redundant filter from Stories.comments collection * Removed unnecessary filter from Story.comments collection
2010-01-10 14:40:36 +00:00
return this.title || gettext(this.__name__.capitalize());
}
/**
* @returns {String}
*/
HopObject.prototype.toString = function() {
return this.constructor.name + " #" + this._id;
}
/**
*
* @param {String} text
* @param {Object} param
* @param {String} action
* @returns {String}
*/
HopObject.prototype.link_filter = function(text, param, action) {
action || (action = ".");
res.push();
renderLink(param, action, text, this);
return res.pop();
}