2006-08-06 11:27:56 +00:00
|
|
|
/*
|
|
|
|
* Helma License Notice
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Helma License
|
|
|
|
* Version 2.0 (the "License"). You may not use this file except in
|
|
|
|
* compliance with the License. A copy of the License is available at
|
|
|
|
* http://adele.helma.org/download/helma/license.txt
|
|
|
|
*
|
|
|
|
* Copyright 1998-2005 Helma Software. All Rights Reserved.
|
|
|
|
*
|
2007-05-30 12:33:51 +00:00
|
|
|
* $RCSfile: Global.js,v $
|
2007-09-28 13:16:38 +00:00
|
|
|
* $Author$
|
|
|
|
* $Revision$
|
|
|
|
* $Date$
|
2006-08-06 11:27:56 +00:00
|
|
|
*/
|
|
|
|
|
2007-12-13 12:21:48 +00:00
|
|
|
/**
|
|
|
|
* @fileoverview Adds useful global macros.
|
|
|
|
* <br /><br />
|
|
|
|
* To use this optional module, its repository needs to be added to the
|
|
|
|
* application, for example by calling app.addRepository('modules/core/Global.js')
|
|
|
|
*/
|
2006-08-06 11:27:56 +00:00
|
|
|
|
|
|
|
app.addRepository("modules/core/String.js");
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* write out a property contained in app.properties
|
|
|
|
* @param Object containing the name of the property
|
|
|
|
*/
|
2007-05-30 12:33:51 +00:00
|
|
|
function property_macro(param, name) {
|
|
|
|
res.write(getProperty(name || param.name) || String.NULL);
|
2006-08-06 11:27:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wrapper to output a string from within a skin
|
|
|
|
* just to be able to use different encodings
|
|
|
|
* @param Object containing the string as text property
|
|
|
|
*/
|
2007-05-30 12:33:51 +00:00
|
|
|
function write_macro(param, text) {
|
|
|
|
res.write(param.text || text || String.NULL);
|
2006-08-06 11:27:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* renders the current datetime
|
|
|
|
* @param Object containing a formatting string as format property
|
|
|
|
*/
|
|
|
|
function now_macro(param) {
|
|
|
|
var d = new Date();
|
|
|
|
if (param.format) {
|
2008-12-16 13:23:33 +00:00
|
|
|
try {
|
|
|
|
res.write(d.format(param.format));
|
|
|
|
} catch (e) {
|
|
|
|
res.write('<span title="' + e + '">[Invalid date format]</span>');
|
|
|
|
}
|
2006-08-06 11:27:56 +00:00
|
|
|
} else if (param.as == "timestamp") {
|
|
|
|
res.write(d.getTime());
|
|
|
|
} else {
|
|
|
|
res.write(d);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* renders a global skin
|
|
|
|
*/
|
2007-05-30 12:33:51 +00:00
|
|
|
var skin_macro = function(param, name) {
|
|
|
|
var skinName = name || param.name;
|
|
|
|
if (skinName) {
|
2007-05-31 13:26:15 +00:00
|
|
|
renderSkin(skinName, param);
|
2006-08-06 11:27:56 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2007-05-30 12:33:51 +00:00
|
|
|
|