use of lucee.transformer.library.tag.TagLib in project Lucee by lucee.
the class GetBaseTagList method getName.
private static String getName(PageContext pc, Tag tag) {
Class clazz = tag.getClass();
if (clazz == CFImportTag.class)
clazz = CFTag.class;
String className = clazz.getName();
TagLib[] tlds = ((ConfigImpl) pc.getConfig()).getTLDs(pc.getCurrentTemplateDialect());
TagLibTag tlt;
for (int i = 0; i < tlds.length; i++) {
// String ns = tlds[i].getNameSpaceAndSeparator();
Map tags = tlds[i].getTags();
Iterator it = tags.keySet().iterator();
while (it.hasNext()) {
tlt = (TagLibTag) tags.get(it.next());
if (tlt.getTagClassDefinition().isClassNameEqualTo(className)) {
// custm tag
if (tag instanceof AppendixTag) {
AppendixTag atag = (AppendixTag) tag;
if (atag.getAppendix() != null && !(tag instanceof Module)) {
return tlt.getFullName().toUpperCase() + atag.getAppendix().toUpperCase();
}
}
// built in cfc based custom tag
if (tag instanceof CFTagCore) {
if (((CFTagCore) tag).getName().equals(tlt.getAttribute("__name").getDefaultValue()))
return tlt.getFullName().toUpperCase();
continue;
}
return tlt.getFullName().toUpperCase();
}
}
}
return ListUtil.last(className, ".", true).toUpperCase();
}
use of lucee.transformer.library.tag.TagLib in project Lucee by lucee.
the class GetTagData method _call.
private static Struct _call(PageContext pc, String nameSpace, String strTagName, int dialect) throws PageException {
TagLib[] tlds;
tlds = ((ConfigImpl) pc.getConfig()).getTLDs(dialect);
TagLib tld = null;
TagLibTag tag = null;
for (int i = 0; i < tlds.length; i++) {
tld = tlds[i];
if (tld.getNameSpaceAndSeparator().equalsIgnoreCase(nameSpace)) {
tag = tld.getTag(strTagName.toLowerCase());
if (tag != null)
break;
}
}
if (tag == null)
throw new ExpressionException("tag [" + nameSpace + strTagName + "] is not a built in tag");
// CFML Based Function
Class clazz = null;
try {
clazz = tag.getTagClassDefinition().getClazz();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (clazz == CFTagCore.class) {
PageContextImpl pci = (PageContextImpl) pc;
boolean prior = pci.useSpecialMappings(true);
try {
return cfmlBasedTag(pc, tld, tag);
} finally {
pci.useSpecialMappings(prior);
}
}
return javaBasedTag(tld, tag);
}
use of lucee.transformer.library.tag.TagLib in project Lucee by lucee.
the class TagUtil method _addTagMetaData.
private static void _addTagMetaData(PageContext pc, ConfigWebImpl cw, int dialect) {
TagLibTagAttr attrFileName, attrIsWeb;
String filename;
Boolean isWeb;
TagLibTag tlt;
TagLib[] tlds = cw.getTLDs(dialect);
for (int i = 0; i < tlds.length; i++) {
Map<String, TagLibTag> tags = tlds[i].getTags();
Iterator<TagLibTag> it = tags.values().iterator();
while (it.hasNext()) {
tlt = it.next();
if (tlt.getTagClassDefinition().isClassNameEqualTo("lucee.runtime.tag.CFTagCore")) {
attrFileName = tlt.getAttribute("__filename");
attrIsWeb = tlt.getAttribute("__isweb");
if (attrFileName != null && attrIsWeb != null) {
filename = Caster.toString(attrFileName.getDefaultValue(), null);
isWeb = Caster.toBoolean(attrIsWeb.getDefaultValue(), null);
if (filename != null && isWeb != null) {
addTagMetaData(pc, tlds[i], tlt, filename, isWeb.booleanValue());
}
}
}
}
}
}
use of lucee.transformer.library.tag.TagLib in project Lucee by lucee.
the class Admin method doGetTLDs.
/**
* @throws PageException
*/
private void doGetTLDs() throws PageException {
lucee.runtime.type.Query qry = new QueryImpl(new String[] { "displayname", "namespace", "namespaceseparator", "shortname", "type", "description", "uri", "elclass", "elBundleName", "elBundleVersion", "source" }, new String[] { "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar" }, 0, "tlds");
int dialect = "lucee".equalsIgnoreCase(getString("dialect", "cfml")) ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML;
TagLib[] libs = config.getTLDs(dialect);
for (int i = 0; i < libs.length; i++) {
qry.addRow();
qry.setAt("displayname", i + 1, libs[i].getDisplayName());
qry.setAt("namespace", i + 1, libs[i].getNameSpace());
qry.setAt("namespaceseparator", i + 1, libs[i].getNameSpaceSeparator());
qry.setAt("shortname", i + 1, libs[i].getShortName());
qry.setAt("type", i + 1, libs[i].getType());
qry.setAt("description", i + 1, libs[i].getDescription());
qry.setAt("uri", i + 1, Caster.toString(libs[i].getUri()));
qry.setAt("elclass", i + 1, libs[i].getELClassDefinition().getClassName());
qry.setAt("elBundleName", i + 1, libs[i].getELClassDefinition().getName());
qry.setAt("elBundleVersion", i + 1, libs[i].getELClassDefinition().getVersionAsString());
qry.setAt("source", i + 1, StringUtil.emptyIfNull(libs[i].getSource()));
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
use of lucee.transformer.library.tag.TagLib in project Lucee by lucee.
the class XMLConfigWebFactory method loadFilesystem.
/**
* @param configServer
* @param config
* @param doc
* @throws ExpressionException
* @throws TagLibException
* @throws FunctionLibException
*/
private static void loadFilesystem(ConfigServerImpl configServer, ConfigImpl config, Document doc, boolean doNew) throws ExpressionException, TagLibException, FunctionLibException {
if (configServer != null) {
Resource src = configServer.getConfigDir().getRealResource("distribution");
Resource trg = config.getConfigDir().getRealResource("context/");
copyContextFiles(src, trg);
}
Resource configDir = config.getConfigDir();
boolean hasCS = configServer != null;
Element fileSystem = getChildByName(doc.getDocumentElement(), "file-system");
if (fileSystem == null)
fileSystem = getChildByName(doc.getDocumentElement(), "filesystem");
String strAllowRealPath = null;
String strDeployDirectory = null;
// String strTempDirectory=null;
String strTLDDirectory = null;
String strFLDDirectory = null;
String strTagDirectory = null;
String strFunctionDirectory = null;
// get library directories
if (fileSystem != null) {
strAllowRealPath = getAttr(fileSystem, "allow-realpath");
strDeployDirectory = ConfigWebUtil.translateOldPath(fileSystem.getAttribute("deploy-directory"));
// strTempDirectory=ConfigWebUtil.translateOldPath(fileSystem.getAttribute("temp-directory"));
strTLDDirectory = ConfigWebUtil.translateOldPath(fileSystem.getAttribute("tld-directory"));
strFLDDirectory = ConfigWebUtil.translateOldPath(fileSystem.getAttribute("fld-directory"));
strTagDirectory = ConfigWebUtil.translateOldPath(fileSystem.getAttribute("tag-directory"));
strFunctionDirectory = ConfigWebUtil.translateOldPath(fileSystem.getAttribute("function-directory"));
}
// set default directories if necessary
if (StringUtil.isEmpty(strFLDDirectory))
strFLDDirectory = "{lucee-config}/library/fld/";
if (StringUtil.isEmpty(strTLDDirectory))
strTLDDirectory = "{lucee-config}/library/tld/";
if (StringUtil.isEmpty(strFunctionDirectory))
strFunctionDirectory = "{lucee-config}/library/function/";
if (StringUtil.isEmpty(strTagDirectory))
strTagDirectory = "{lucee-config}/library/tag/";
// Deploy Dir
Resource dd = ConfigWebUtil.getFile(configDir, strDeployDirectory, "cfclasses", configDir, FileUtil.TYPE_DIR, config);
config.setDeployDirectory(dd);
// init TLDS
if (hasCS) {
config.setTLDs(ConfigImpl.duplicate(configServer.getTLDs(CFMLEngine.DIALECT_CFML), false), CFMLEngine.DIALECT_CFML);
config.setTLDs(ConfigImpl.duplicate(configServer.getTLDs(CFMLEngine.DIALECT_LUCEE), false), CFMLEngine.DIALECT_LUCEE);
} else {
ConfigServerImpl cs = (ConfigServerImpl) config;
config.setTLDs(ConfigImpl.duplicate(new TagLib[] { cs.cfmlCoreTLDs }, false), CFMLEngine.DIALECT_CFML);
config.setTLDs(ConfigImpl.duplicate(new TagLib[] { cs.luceeCoreTLDs }, false), CFMLEngine.DIALECT_LUCEE);
}
// TLD Dir
if (strTLDDirectory != null) {
Resource tld = ConfigWebUtil.getFile(config, configDir, strTLDDirectory, FileUtil.TYPE_DIR);
if (tld != null)
config.setTldFile(tld, CFMLEngine.DIALECT_BOTH);
}
// Tag Directory
if (strTagDirectory != null) {
Resource dir = ConfigWebUtil.getFile(config, configDir, strTagDirectory, FileUtil.TYPE_DIR);
createTagFiles(config, configDir, dir, doNew);
if (dir != null) {
config.setTagDirectory(dir);
}
}
// allow realpath
if (hasCS) {
config.setAllowRealPath(configServer.allowRealPath());
}
if (!StringUtil.isEmpty(strAllowRealPath, true)) {
config.setAllowRealPath(Caster.toBooleanValue(strAllowRealPath, true));
}
// Init flds
if (hasCS) {
config.setFLDs(ConfigImpl.duplicate(configServer.getFLDs(CFMLEngine.DIALECT_CFML), false), CFMLEngine.DIALECT_CFML);
config.setFLDs(ConfigImpl.duplicate(configServer.getFLDs(CFMLEngine.DIALECT_LUCEE), false), CFMLEngine.DIALECT_LUCEE);
} else {
ConfigServerImpl cs = (ConfigServerImpl) config;
config.setFLDs(ConfigImpl.duplicate(new FunctionLib[] { cs.cfmlCoreFLDs }, false), CFMLEngine.DIALECT_CFML);
config.setFLDs(ConfigImpl.duplicate(new FunctionLib[] { cs.luceeCoreFLDs }, false), CFMLEngine.DIALECT_LUCEE);
}
// FLDs
if (strFLDDirectory != null) {
Resource fld = ConfigWebUtil.getFile(config, configDir, strFLDDirectory, FileUtil.TYPE_DIR);
if (fld != null)
config.setFldFile(fld, CFMLEngine.DIALECT_BOTH);
}
// Function files (CFML)
if (strFunctionDirectory != null) {
Resource dir = ConfigWebUtil.getFile(config, configDir, strFunctionDirectory, FileUtil.TYPE_DIR);
createFunctionFiles(config, configDir, dir, doNew);
if (dir != null)
config.setFunctionDirectory(dir);
}
}
Aggregations