use of lucee.transformer.bytecode.statement.tag.TagOutput in project Lucee by lucee.
the class Output method evaluate.
@Override
public void evaluate(Tag tag, TagLibTag libTag, FunctionLib[] flibs) throws EvaluatorException {
TagOutput output = (TagOutput) tag;
// check if inside a query tag
TagOutput parent = output;
// encodeFor
Attribute encodeFor = tag.getAttribute("encodefor");
if (encodeFor != null) {
Expression encodeForValue = CastString.toExprString(encodeFor.getValue());
if (encodeForValue instanceof Literal) {
Literal l = (Literal) encodeForValue;
short df = (short) -1;
short encType = ESAPIEncode.toEncodeType(l.getString(), df);
if (encType != df)
encodeForValue = encodeForValue.getFactory().createLitInteger(encType);
}
addEncodeToChildren(tag.getBody().getStatements().iterator(), encodeForValue, getEncodeForFunction(flibs));
}
// query
boolean hasParentWithGroup = false;
boolean hasParentWithQuery = false;
boolean hasQuery = tag.containsAttribute("query");
while ((parent = getParentTagOutput(parent)) != null) {
if (!hasParentWithQuery)
hasParentWithQuery = parent.hasQuery();
if (!hasParentWithGroup)
hasParentWithGroup = parent.hasGroup();
if (hasParentWithQuery && hasParentWithGroup)
break;
}
if (hasQuery && hasParentWithQuery)
throw new EvaluatorException("Nesting of tags cfoutput with attribute query is not allowed");
if (hasQuery)
output.setType(TagOutput.TYPE_QUERY);
else if (tag.containsAttribute("group") && hasParentWithQuery)
output.setType(TagOutput.TYPE_GROUP);
else if (hasParentWithQuery) {
if (hasParentWithGroup)
output.setType(TagOutput.TYPE_INNER_GROUP);
else
output.setType(TagOutput.TYPE_INNER_QUERY);
} else
output.setType(TagOutput.TYPE_NORMAL);
// attribute maxrows and endrow not allowd at the same time
if (tag.containsAttribute("maxrows") && tag.containsAttribute("endrow"))
throw new EvaluatorException("Wrong Context, you cannot use attribute maxrows and endrow at the same time.");
}
use of lucee.transformer.bytecode.statement.tag.TagOutput in project Lucee by lucee.
the class Mail method evaluate.
@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
if (tag.containsAttribute("query")) {
TagLib lib = libTag.getTagLib();
TagLibTag outputTag = lib.getTag("output");
TagOutput output = new TagOutput(tag.getFactory(), tag.getStart(), null);
output.setFullname(outputTag.getFullName());
output.setTagLibTag(outputTag);
output.addAttribute(new Attribute(false, "output", tag.getFactory().TRUE(), "boolean"));
output.addAttribute(new Attribute(false, "formail", tag.getFactory().TRUE(), "boolean"));
// output.getBody();
Body body = new BodyBase(tag.getFactory());
output.setBody(body);
ASMUtil.replace(tag, output, false);
body.addStatement(tag);
output.addAttribute(tag.removeAttribute("query"));
if (tag.containsAttribute("group"))
output.addAttribute(tag.removeAttribute("group"));
if (tag.containsAttribute("groupcasesensitive"))
output.addAttribute(tag.removeAttribute("groupcasesensitive"));
if (tag.containsAttribute("startrow"))
output.addAttribute(tag.removeAttribute("startrow"));
if (tag.containsAttribute("maxrows"))
output.addAttribute(tag.removeAttribute("maxrows"));
new Output().evaluate(output, outputTag);
}
}
Aggregations