2001-06-18 08:57:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* check if email-adress is syntactically correct
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function checkEmail(address) {
|
|
|
|
|
var m = new Mail();
|
|
|
|
|
m.addTo(address);
|
|
|
|
|
if (m.status)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function checks if req.data.date[Year|Month|Date|Hours|Minutes] is valid
|
|
|
|
|
* if correct, creates dateobject and returns it
|
|
|
|
|
* otherwise false
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function checkDate() {
|
|
|
|
|
if (req.data.dateYear && req.data.dateMonth && req.data.dateDate && req.data.dateHours && req.data.dateMinutes) {
|
|
|
|
|
var ts = new Date();
|
|
|
|
|
ts.setYear(parseInt(req.data.dateYear));
|
|
|
|
|
ts.setMonth(parseInt(req.data.dateMonth));
|
|
|
|
|
ts.setDate(parseInt(req.data.dateDate));
|
|
|
|
|
ts.setHours(parseInt(req.data.dateHours));
|
|
|
|
|
ts.setMinutes(parseInt(req.data.dateMinutes));
|
|
|
|
|
ts.setSeconds(0);
|
|
|
|
|
return (ts);
|
|
|
|
|
} else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-20 10:28:26 +00:00
|
|
|
|
/**
|
2002-02-10 16:35:54 +00:00
|
|
|
|
* function checks if the string passed contains special characters like
|
2001-06-20 10:28:26 +00:00
|
|
|
|
* spaces, brackets etc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function isClean(str) {
|
2002-02-10 16:35:54 +00:00
|
|
|
|
var invalidChar = new RegExp("[^a-z,^A-Z,^0-9]");
|
|
|
|
|
if (invalidChar.exec(str))
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function checks if the string passed contains any characters that
|
|
|
|
|
* are forbidden in URLS
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function isCleanForURL(str) {
|
2002-02-14 10:32:30 +00:00
|
|
|
|
var invalidChar = new RegExp("[\\/?&=\\+#<23><><EFBFBD><EFBFBD>\\\\]");
|
2002-02-14 10:29:02 +00:00
|
|
|
|
invalidChar.ignoreCase = true;
|
2002-02-10 16:35:54 +00:00
|
|
|
|
if (invalidChar.exec(str))
|
2001-06-20 10:28:26 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2001-09-05 21:22:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2002-06-26 16:56:08 +00:00
|
|
|
|
* function checks if there is a site-object in path
|
|
|
|
|
* if true, it returns it
|
|
|
|
|
* if false, it returns root
|
2001-09-05 21:22:55 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2002-06-02 15:41:43 +00:00
|
|
|
|
function getParent() {
|
2002-06-26 16:56:08 +00:00
|
|
|
|
if (path.site)
|
|
|
|
|
return (path.site);
|
2002-06-02 15:41:43 +00:00
|
|
|
|
else
|
2001-09-05 21:22:55 +00:00
|
|
|
|
return (root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function creates macro-tags out of plain urls in text
|
|
|
|
|
* does this with three replace-operations
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function formatLinks(str) {
|
|
|
|
|
var pre = "<% this.link to=\"";
|
|
|
|
|
var mid = "\" text=\"";
|
|
|
|
|
var post = "\" %>";
|
|
|
|
|
var l0 = new RegExp("<a href\\s*=\\s*\"?([^\\s\"]+)?\"?[^>]*?>([^<]*?)</a>");
|
|
|
|
|
var l1 = new RegExp("([fhtpsr]+:\\/\\/[^\\s]+?)([\\.,;\\)\\]\"]?(\\s|$))");
|
|
|
|
|
var l2 = new RegExp("(<%[^%]*?)" + pre + "(.*?)" + mid + ".*?" + post + "([^%]*?%>)");
|
|
|
|
|
l0.ignoreCase = l1.ignoreCase = l2.ignoreCase = true;
|
|
|
|
|
l0.global = l1.global = l2.global = true;
|
|
|
|
|
|
|
|
|
|
str = str.replace(l0, pre + "$1" + mid + "$2" + post);
|
|
|
|
|
str = str.replace(l1, pre + "$1" + mid + "$1" + post + "$3");
|
|
|
|
|
str = str.replace(l2, "$1$2$3");
|
|
|
|
|
return (str);
|
2001-09-07 13:13:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function activates URLs to HTML link tags
|
|
|
|
|
*/
|
2001-11-23 20:38:58 +00:00
|
|
|
|
|
2001-09-07 13:13:39 +00:00
|
|
|
|
function activateLinks (str) {
|
|
|
|
|
var pre = "<a href=\"";
|
|
|
|
|
var mid = "\">";
|
|
|
|
|
var post = "</a>";
|
|
|
|
|
|
|
|
|
|
var l1 = new RegExp("(^|\\s)([fhtpsr]+:\\/\\/[^\\s]+?)([\\.,;\\)\\]\"]?(\\s|$))");
|
|
|
|
|
l1.ignoreCase = true;
|
|
|
|
|
l1.global = true;
|
|
|
|
|
|
|
|
|
|
// this is odd, but we have to run the regexp twice to catch URLs
|
|
|
|
|
// which imediately follow each other. This is because the leading
|
|
|
|
|
// and trailing whitespaces are part of the expression, and if there's only
|
|
|
|
|
// one whitespace character between two URLs, the first match eats it up
|
|
|
|
|
// and the second URL doesn't match.
|
|
|
|
|
str = str.replace(l1, "$1" + pre + "$2" + mid + "$2" + post + "$4");
|
|
|
|
|
str = str.replace(l1, "$1" + pre + "$2" + mid + "$2" + post + "$4");
|
2001-12-04 13:12:44 +00:00
|
|
|
|
|
2001-12-10 22:48:59 +00:00
|
|
|
|
// because of caching of text i had to disable the following
|
|
|
|
|
// it's now done in text_macro() of comment and story
|
|
|
|
|
// and in title_macro() of story
|
2001-12-04 13:12:44 +00:00
|
|
|
|
// do Wiki style substitution
|
2001-12-10 22:48:59 +00:00
|
|
|
|
// return (doWikiStuff (str));
|
|
|
|
|
return (str);
|
2001-09-07 13:13:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 10:55:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* function checks if url is correct
|
|
|
|
|
* if not it assumes that http is the protocol
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function evalURL(url) {
|
2001-12-10 22:48:59 +00:00
|
|
|
|
if (url && url.indexOf("://") < 0)
|
2001-10-02 10:55:33 +00:00
|
|
|
|
return ("http://" + url);
|
|
|
|
|
return (url);
|
2001-10-07 19:27:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function checks if user has permanent cookies
|
|
|
|
|
* storing username and password
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function autoLogin() {
|
2002-06-02 15:41:43 +00:00
|
|
|
|
if (session.user)
|
2001-10-07 19:27:48 +00:00
|
|
|
|
return;
|
|
|
|
|
var name = req.data.avUsr;
|
|
|
|
|
var pw = req.data.avPw;
|
|
|
|
|
if (!name || !pw)
|
|
|
|
|
return;
|
2002-06-02 15:41:43 +00:00
|
|
|
|
var u = root.users.get(name);
|
2001-10-07 19:27:48 +00:00
|
|
|
|
if (!u)
|
|
|
|
|
return;
|
2002-03-27 12:36:41 +00:00
|
|
|
|
if (Packages.helma.util.MD5Encoder.encode(u.password) != pw)
|
2001-10-07 19:27:48 +00:00
|
|
|
|
return;
|
|
|
|
|
else {
|
2002-06-02 18:21:16 +00:00
|
|
|
|
if (session.login(name,u.password)) {
|
2002-06-12 17:19:47 +00:00
|
|
|
|
u.lastVisit = new Date();
|
2002-06-26 16:56:08 +00:00
|
|
|
|
res.message = getMsg("confirm","welcome",new Array(path.site ? path.site.title : root.getSysTitle(),session.user.name));
|
2001-10-07 19:27:48 +00:00
|
|
|
|
} else
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-10-21 12:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-22 20:11:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* function checks if user is logged in or not
|
|
|
|
|
* if false, it redirects to the login-page
|
|
|
|
|
* but before it stores the url to jump back (if passed as argument)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function checkIfLoggedIn(referrer) {
|
2002-06-02 15:41:43 +00:00
|
|
|
|
if (!session.user) {
|
2002-01-22 20:11:14 +00:00
|
|
|
|
// user is not logged in
|
|
|
|
|
if (referrer)
|
2002-06-02 15:41:43 +00:00
|
|
|
|
session.data.referrer = referrer;
|
2002-06-26 16:56:08 +00:00
|
|
|
|
res.redirect(path.site ? path.site.members.href("login") : root.members.href("login"));
|
2002-01-22 20:11:14 +00:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-21 12:02:20 +00:00
|
|
|
|
/**
|
2001-11-03 09:16:59 +00:00
|
|
|
|
* function checks if the name of the requested object has a slash in it
|
2002-06-26 16:56:08 +00:00
|
|
|
|
* if true, it tries to fetch the appropriate parent-object (either site or root)
|
2001-11-03 09:16:59 +00:00
|
|
|
|
* and to fetch the object with the requested name in the specified collection
|
|
|
|
|
* @param String Name of the object to retrieve
|
|
|
|
|
* @param String Name of the pool to search in
|
|
|
|
|
* @return Obj Object with two properties: one containing the parent-object of the pool,
|
|
|
|
|
* the other containing the object itself;
|
|
|
|
|
* If parent or object is null, the function returns null.
|
2001-10-21 12:02:20 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2001-11-03 09:16:59 +00:00
|
|
|
|
function getPoolObj(objName,pool) {
|
|
|
|
|
var p = new Object();
|
|
|
|
|
if (objName.indexOf("/") >= 0) {
|
|
|
|
|
var objPath = objName.split("/");
|
|
|
|
|
p.parent = (!objPath[0] || objPath[0] == "root") ? root : root.get(objPath[0]);
|
|
|
|
|
p.objName = objPath[1];
|
2001-10-21 12:02:20 +00:00
|
|
|
|
} else {
|
2002-06-26 16:56:08 +00:00
|
|
|
|
p.parent = path.site;
|
2001-11-03 09:16:59 +00:00
|
|
|
|
p.objName = objName;
|
2001-10-21 12:02:20 +00:00
|
|
|
|
}
|
2001-11-03 09:16:59 +00:00
|
|
|
|
if (!p.parent)
|
2001-10-21 12:02:20 +00:00
|
|
|
|
return null;
|
2001-11-03 09:16:59 +00:00
|
|
|
|
p.obj = p.parent[pool].get(p.objName);
|
|
|
|
|
if (!p.obj)
|
2001-10-21 12:02:20 +00:00
|
|
|
|
return null;
|
2001-11-03 09:16:59 +00:00
|
|
|
|
return (p);
|
2001-10-30 13:00:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-10 22:48:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* function builds an array containing
|
|
|
|
|
* default dateformat-patterns
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function getDefaultDateFormats(version) {
|
|
|
|
|
var patterns = new Array();
|
|
|
|
|
if (version == "short") {
|
|
|
|
|
patterns[0] = "yyyy.MM.dd, HH:mm";
|
|
|
|
|
patterns[1] = "yyyy.MM.dd, h:mm a";
|
|
|
|
|
patterns[2] = "dd.MM.yyyy, HH:mm";
|
|
|
|
|
patterns[3] = "dd.MM.yyyy, h:mm a";
|
|
|
|
|
patterns[4] = "MM.dd, HH:mm";
|
|
|
|
|
patterns[5] = "MM.dd, h:mm a";
|
|
|
|
|
patterns[6] = "dd.MM, HH:mm";
|
|
|
|
|
patterns[7] = "dd.MM, h:mm a";
|
|
|
|
|
patterns[8] = "d.M, HH:m";
|
|
|
|
|
patterns[9] = "d.M, h:m a";
|
|
|
|
|
patterns[10] = "HH:mm";
|
|
|
|
|
patterns[11] = "h:mm a";
|
|
|
|
|
patterns[12] = "EEEE, HH:mm";
|
|
|
|
|
patterns[13] = "EEEE, h:mm a";
|
|
|
|
|
patterns[14] = "EE, HH:mm";
|
|
|
|
|
patterns[15] = "EE, h:mm a";
|
|
|
|
|
} else {
|
|
|
|
|
patterns[0] = "EEEE, dd. MMMM yyyy, HH:mm";
|
|
|
|
|
patterns[1] = "EEEE, dd. MMMM yyyy, h:mm a";
|
|
|
|
|
patterns[2] = "EEEE, MMMM dd yyyy, h:mm a";
|
|
|
|
|
patterns[3] = "EE, dd. MMM. yyyy, HH:mm";
|
|
|
|
|
patterns[4] = "EE, dd. MMM. yyyy, h:mm a";
|
|
|
|
|
patterns[5] = "EE, MMM dd yyyy, h:mm a";
|
|
|
|
|
patterns[6] = "EE, dd.MM.yyyy, HH:mm";
|
|
|
|
|
patterns[7] = "EE, dd.MM.yyyy, h:mm a";
|
|
|
|
|
patterns[8] = "EE, MM.dd.yyyy, h:mm a";
|
|
|
|
|
patterns[9] = "dd.MM.yyyy, HH:mm";
|
|
|
|
|
patterns[10] = "MM.dd.yyyy, h:mm a";
|
|
|
|
|
patterns[11] = "yyyy.MM.dd, HH:mm";
|
|
|
|
|
patterns[12] = "yyyy.MM.dd, h:mm a";
|
|
|
|
|
patterns[13] = "dd.MM, HH:mm";
|
|
|
|
|
patterns[14] = "MM.dd, h:mm a";
|
|
|
|
|
}
|
|
|
|
|
return (patterns);
|
2001-12-19 16:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is a simple logger that creates a DB entry for
|
|
|
|
|
* each request that contains an HTTP referrer. This is
|
|
|
|
|
* done by direct DB interface due to performance reasons.
|
|
|
|
|
*/
|
2002-01-07 14:38:48 +00:00
|
|
|
|
|
2001-12-19 16:22:34 +00:00
|
|
|
|
function logAccess() {
|
2002-07-08 14:01:13 +00:00
|
|
|
|
if (req.data.http_referer) {
|
|
|
|
|
var site = path.site ? path.site : root;
|
|
|
|
|
var referrer = req.data.http_referer;
|
2002-04-25 13:43:45 +00:00
|
|
|
|
|
2002-06-26 16:56:08 +00:00
|
|
|
|
// no logging at all if the referrer comes from the same site
|
2002-04-26 13:05:10 +00:00
|
|
|
|
// or is not a http-request
|
|
|
|
|
if (referrer.indexOf("http") < 0)
|
|
|
|
|
return;
|
2002-07-08 14:01:13 +00:00
|
|
|
|
var siteHref = site.href().toLowerCase();
|
|
|
|
|
if (referrer.toLowerCase().indexOf(siteHref.substring(0,siteHref.length-1)) >= 0)
|
2002-04-26 13:05:10 +00:00
|
|
|
|
return;
|
2002-04-25 13:43:45 +00:00
|
|
|
|
|
2002-07-08 14:01:13 +00:00
|
|
|
|
var storyID = path.story ? path.story._id : null;
|
|
|
|
|
|
|
|
|
|
// we're doing this with direct db access here
|
|
|
|
|
// (there's no need to do it with prototypes):
|
|
|
|
|
var c = getDBConnection("antville");
|
|
|
|
|
var dbError = c.getLastError();
|
|
|
|
|
if (dbError) {
|
|
|
|
|
app.__app__.logEvent("Error establishing DB connection: " + dbError);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var query = "insert into AV_ACCESSLOG (ACCESSLOG_F_SITE, ACCESSLOG_F_TEXT, ACCESSLOG_REFERRER, ACCESSLOG_IP, ACCESSLOG_BROWSER) values (" + site._id + ", " + storyID + ", '" + referrer + "', '" + req.data.http_remotehost + "', '" + req.data.http_browser + "')";
|
|
|
|
|
c.executeCommand(query);
|
|
|
|
|
var dbError = c.getLastError();
|
|
|
|
|
if (dbError) {
|
|
|
|
|
app.__app__.logEvent("Error executing SQL query: " + dbError);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-12-19 16:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-06-26 16:56:08 +00:00
|
|
|
|
* to register updates of a site at weblogs.com
|
2001-12-19 16:22:34 +00:00
|
|
|
|
* (and probably other services, soon), this
|
|
|
|
|
* function can be called via the scheduler.
|
|
|
|
|
*/
|
2002-01-30 16:17:37 +00:00
|
|
|
|
|
2002-06-26 16:56:08 +00:00
|
|
|
|
function pingUpdatedSites() {
|
2002-04-29 13:48:48 +00:00
|
|
|
|
// var period = 1000 * 60 * 60; // one hour
|
2002-04-29 11:01:23 +00:00
|
|
|
|
|
2002-04-29 13:48:48 +00:00
|
|
|
|
var c = getDBConnection("antville");
|
2002-06-12 17:19:47 +00:00
|
|
|
|
var dbError = c.getLastError();
|
|
|
|
|
if (dbError) {
|
|
|
|
|
app.__app__.logEvent("Error establishing DB connection: " + dbError);
|
2002-04-29 13:48:48 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-04-29 11:01:23 +00:00
|
|
|
|
|
2002-06-26 16:56:08 +00:00
|
|
|
|
var query = "select SITE_ID from AV_SITE where SITE_ISONLINE = 1 and SITE_ENABLEPING = 1 and (SITE_LASTUPDATE > SITE_LASTPING or SITE_LASTPING is null)";
|
2002-04-29 13:48:48 +00:00
|
|
|
|
var rows = c.executeRetrieval(query);
|
2002-06-12 17:19:47 +00:00
|
|
|
|
var dbError = c.getLastError();
|
|
|
|
|
if (dbError) {
|
|
|
|
|
app.__app__.logEvent("Error executing SQL query: " + dbError);
|
2002-04-29 13:48:48 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-04-29 11:01:23 +00:00
|
|
|
|
|
2002-04-29 13:48:48 +00:00
|
|
|
|
while (rows.next()) {
|
|
|
|
|
var id = rows.getColumnItem("ID");
|
2002-06-26 16:56:08 +00:00
|
|
|
|
var site = root.get(id.toString());
|
|
|
|
|
app.__app__.logEvent("Notifying weblogs.com for updated site '" + site.alias + "' (id " + id + ")");
|
2002-04-29 14:17:58 +00:00
|
|
|
|
blog.ping();
|
2002-04-29 13:48:48 +00:00
|
|
|
|
}
|
2002-04-29 11:01:23 +00:00
|
|
|
|
|
2002-04-29 13:48:48 +00:00
|
|
|
|
rows.release();
|
|
|
|
|
return;
|
2001-12-19 16:22:34 +00:00
|
|
|
|
}
|
2002-01-22 20:11:14 +00:00
|
|
|
|
|
2002-04-29 11:01:23 +00:00
|
|
|
|
|
2002-04-08 11:53:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* parse a timestamp into a date object. This is used when users
|
|
|
|
|
* want to set createtime explicitly when creating/editing stories.
|
|
|
|
|
*
|
|
|
|
|
* @param time The time as string
|
|
|
|
|
* @param format The format of the time string
|
|
|
|
|
* @return The parsed Date
|
|
|
|
|
*/
|
|
|
|
|
function parseTimestamp (time, format) {
|
|
|
|
|
var df = new java.text.SimpleDateFormat (format);
|
2002-06-26 16:56:08 +00:00
|
|
|
|
if (path.site)
|
|
|
|
|
df.setTimeZone(path.site.getTimeZone());
|
2002-04-08 11:53:31 +00:00
|
|
|
|
return df.parse (time);
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-27 18:50:48 +00:00
|
|
|
|
/**
|
2002-06-26 16:56:08 +00:00
|
|
|
|
* function formats a date to a string. It checks if a site object is
|
2002-05-27 18:50:48 +00:00
|
|
|
|
* in the request path and if so uses its locale and timezone.
|
|
|
|
|
*
|
|
|
|
|
* @param ts Date to be formatted
|
|
|
|
|
* @param format The format string
|
|
|
|
|
* @return The date formatted as string
|
|
|
|
|
*/
|
|
|
|
|
function formatTimestamp(ts,dformat) {
|
|
|
|
|
// date format parsing is quite expensive, but date formats
|
|
|
|
|
// are not thread safe, so what we do is to cache them per request
|
|
|
|
|
// in the response object using "timeformat_<format>" as key.
|
|
|
|
|
var sdf = res.data["timeformat_"+dformat];
|
|
|
|
|
if (!sdf) {
|
|
|
|
|
var fmt = "yyyy/MM/dd HH:mm";
|
2002-06-26 16:56:08 +00:00
|
|
|
|
if (path.site) {
|
2002-05-27 18:50:48 +00:00
|
|
|
|
if (dformat == "short")
|
2002-06-26 16:56:08 +00:00
|
|
|
|
fmt = path.site.shortdateformat ? path.site.shortdateformat : "dd.MM HH:mm";
|
2002-05-27 18:50:48 +00:00
|
|
|
|
else if (dformat == "long")
|
2002-06-26 16:56:08 +00:00
|
|
|
|
fmt = path.site.longdateformat ? path.site.longdateformat : "yyyy/MM/dd HH:mm";
|
2002-05-27 18:50:48 +00:00
|
|
|
|
else if (dformat)
|
|
|
|
|
fmt = dformat;
|
2002-06-26 16:56:08 +00:00
|
|
|
|
sdf = new java.text.SimpleDateFormat(fmt,path.site.getLocale());
|
|
|
|
|
sdf.setTimeZone(path.site.getTimeZone())
|
2002-05-27 18:50:48 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (dformat)
|
|
|
|
|
fmt = dformat;
|
2002-06-26 16:56:08 +00:00
|
|
|
|
sdf = new java.text.SimpleDateFormat(fmt,root.getLocale());
|
2002-05-27 18:50:48 +00:00
|
|
|
|
}
|
|
|
|
|
res.data["timeformat_"+dformat] = sdf;
|
|
|
|
|
}
|
|
|
|
|
var result = tryEval("sdf.format(ts)");
|
|
|
|
|
if (result.error)
|
2002-06-26 16:56:08 +00:00
|
|
|
|
return (getMsg("error","wrongDateFormat"));
|
2002-05-27 18:50:48 +00:00
|
|
|
|
return (result.value);
|
|
|
|
|
}
|
2002-04-29 11:01:23 +00:00
|
|
|
|
|
2002-01-22 20:11:14 +00:00
|
|
|
|
/**
|
2002-06-26 16:56:08 +00:00
|
|
|
|
* scheduler performing auto-disposal of inactive sites
|
|
|
|
|
* and auto-blocking of private sites
|
2002-03-27 11:08:30 +00:00
|
|
|
|
*/
|
2002-01-22 20:11:14 +00:00
|
|
|
|
|
2002-03-27 11:08:30 +00:00
|
|
|
|
function scheduler() {
|
2002-06-26 16:56:08 +00:00
|
|
|
|
// call autocleanup
|
|
|
|
|
root.manage.autoCleanUp();
|
|
|
|
|
// notify updated sites
|
|
|
|
|
pingUpdatedSites();
|
2002-04-08 11:53:31 +00:00
|
|
|
|
}
|
2002-06-02 15:41:43 +00:00
|
|
|
|
|
2002-06-03 16:59:03 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DEPRECATED!
|
|
|
|
|
* this function was used to replicate a read-only
|
|
|
|
|
* javascript object (like a nacro's param object)
|
|
|
|
|
* for the purpose of creating a writeable clone.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function cloneObject(obj) {
|
|
|
|
|
var clone = new Object();
|
|
|
|
|
if (typeof obj != "object")
|
|
|
|
|
return(obj);
|
|
|
|
|
for (var i in obj)
|
|
|
|
|
clone[i] = obj[i];
|
|
|
|
|
return(clone);
|
|
|
|
|
}
|
2002-06-12 17:19:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function constructs a server-message
|
|
|
|
|
* @param String Name of message to display
|
|
|
|
|
* @param optional String (or Array containing several Strings)
|
|
|
|
|
* to pass to message-skin
|
|
|
|
|
* @return String rendered message
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function getMsg(msgClass,name,value) {
|
|
|
|
|
// create array containing languages to search for message
|
|
|
|
|
var languages = new Array();
|
2002-06-26 16:56:08 +00:00
|
|
|
|
if (path && path.site && path.site.language)
|
|
|
|
|
languages[0] = (path.site.getLocale().getLanguage());
|
|
|
|
|
languages[languages.length] = (root.getLocale()).getLanguage();
|
|
|
|
|
// the last language to search for messages is always english
|
2002-06-12 17:19:47 +00:00
|
|
|
|
languages[languages.length] = "en";
|
|
|
|
|
// loop over languages and try to find the message
|
|
|
|
|
for (var i in languages) {
|
|
|
|
|
var lang = app.data[languages[i]];
|
|
|
|
|
if (lang && lang[msgClass] && lang[msgClass][name]) {
|
|
|
|
|
var message = lang[msgClass][name];
|
|
|
|
|
// create param-object needed to render Skin
|
|
|
|
|
var param = new Object();
|
|
|
|
|
// check if value passed is actually an array
|
|
|
|
|
if (value && typeof(value) == typeof(String()))
|
|
|
|
|
param.value1 = value;
|
|
|
|
|
else if (value && value.length > 0) {
|
|
|
|
|
for (var i in value)
|
|
|
|
|
param["value" + (parseInt(i)+1)] = value[i];
|
|
|
|
|
}
|
|
|
|
|
return (renderSkinAsString(createSkin(message),param));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// still no message found, so return
|
|
|
|
|
return ("[couldn't find message!]");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function creates a result-object that contains a message
|
|
|
|
|
* and a property indicating if this result-object is classified
|
|
|
|
|
* as error or not
|
|
|
|
|
* @param String Class of message
|
|
|
|
|
* @param String Name of message
|
|
|
|
|
* @param optional String (or Array containing several Strings)
|
|
|
|
|
* to pass to message-skin
|
|
|
|
|
* @param Boolean flag indicating error or not
|
|
|
|
|
* @return Obj result-Object
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function createResultObj(msgClass,msg,value,error) {
|
|
|
|
|
var result = new Object();
|
|
|
|
|
result.message = getMsg(msgClass,msg,value);
|
|
|
|
|
result.error = error;
|
|
|
|
|
return (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* wrapper-function to create a result-object of type "error"
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function getError(messageName,value) {
|
|
|
|
|
return (createResultObj("error",messageName,value,true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* wrapper-function to create a result-object of type "confirm"
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function getConfirm(messageName,value) {
|
|
|
|
|
return (createResultObj("confirm",messageName,value,false));
|
2002-07-08 14:01:13 +00:00
|
|
|
|
}
|