use of lucee.transformer.library.tag.TagLibTag 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.TagLibTag 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.TagLibTag in project Lucee by lucee.
the class CFTag method getAttributeRequirments.
private static TagLibTag getAttributeRequirments(Component cfc, boolean runtime) {
Struct meta = null;
Member mem = cfc != null ? cfc.getMember(Component.ACCESS_PRIVATE, KeyConstants._metadata, true, false) : null;
if (mem != null)
meta = Caster.toStruct(mem.getValue(), null, false);
if (meta == null)
return null;
TagLibTag tag = new TagLibTag(null);
// TAG
// type
String type = Caster.toString(meta.get(ATTRIBUTE_TYPE, "dynamic"), "dynamic");
if ("fixed".equalsIgnoreCase(type))
tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_FIXED);
else
// else if("mixed".equalsIgnoreCase(type))tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_MIXED);
// else if("noname".equalsIgnoreCase(type))tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_NONAME);
tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_DYNAMIC);
if (!runtime) {
// hint
String hint = Caster.toString(meta.get(KeyConstants._hint, null), null);
if (!StringUtil.isEmpty(hint))
tag.setDescription(hint);
}
// ATTRIBUTES
Struct attributes = Caster.toStruct(meta.get(KeyConstants._ATTRIBUTES, null), null, false);
if (attributes != null) {
Iterator<Entry<Key, Object>> it = attributes.entryIterator();
// Iterator it = attributes.entrySet().iterator();
Entry<Key, Object> entry;
TagLibTagAttr attr;
Struct sct;
String name;
Object defaultValue;
while (it.hasNext()) {
entry = it.next();
name = Caster.toString(entry.getKey(), null);
if (StringUtil.isEmpty(name))
continue;
attr = new TagLibTagAttr(tag);
attr.setName(name);
sct = Caster.toStruct(entry.getValue(), null, false);
if (sct != null) {
attr.setRequired(Caster.toBooleanValue(sct.get(KeyConstants._required, Boolean.FALSE), false));
attr.setType(Caster.toString(sct.get(KeyConstants._type, "any"), "any"));
defaultValue = sct.get(KeyConstants._default, null);
if (defaultValue != null)
attr.setDefaultValue(defaultValue);
if (!runtime) {
attr.setDescription(Caster.toString(sct.get(KeyConstants._hint, null), null));
attr.setRtexpr(Caster.toBooleanValue(sct.get(RT_EXPR_VALUE, Boolean.TRUE), true));
}
}
tag.setAttribute(attr);
}
}
return tag;
}
use of lucee.transformer.library.tag.TagLibTag 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.TagLibTag in project Lucee by lucee.
the class ConfigImpl method createTag.
public void createTag(TagLib tl, String filename) {
// Jira 1298
// filename.substring(0,filename.length()-(getCFCExtension().length()+1));
String name = toName(filename);
TagLibTag tlt = new TagLibTag(tl);
tlt.setName(name);
tlt.setTagClassDefinition("lucee.runtime.tag.CFTagCore", getIdentification(), null);
tlt.setHandleExceptions(true);
tlt.setBodyContent("free");
tlt.setParseBody(false);
tlt.setDescription("");
tlt.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_MIXED);
TagLibTagAttr tlta = new TagLibTagAttr(tlt);
tlta.setName("__filename");
tlta.setRequired(true);
tlta.setRtexpr(true);
tlta.setType("string");
tlta.setHidden(true);
tlta.setDefaultValue(filename);
tlt.setAttribute(tlta);
tlta = new TagLibTagAttr(tlt);
tlta.setName("__name");
tlta.setRequired(true);
tlta.setRtexpr(true);
tlta.setHidden(true);
tlta.setType("string");
tlta.setDefaultValue(name);
tlt.setAttribute(tlta);
tlta = new TagLibTagAttr(tlt);
tlta.setName("__isweb");
tlta.setRequired(true);
tlta.setRtexpr(true);
tlta.setHidden(true);
tlta.setType("boolean");
tlta.setDefaultValue(this instanceof ConfigWeb ? "true" : "false");
tlt.setAttribute(tlta);
tl.setTag(tlt);
}
Aggregations