001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.transformer.cfml.evaluator.impl;
020
021import lucee.transformer.bytecode.Body;
022import lucee.transformer.bytecode.BodyBase;
023import lucee.transformer.bytecode.literal.LitBoolean;
024import lucee.transformer.bytecode.statement.tag.Attribute;
025import lucee.transformer.bytecode.statement.tag.Tag;
026import lucee.transformer.bytecode.statement.tag.TagOutput;
027import lucee.transformer.bytecode.util.ASMUtil;
028import lucee.transformer.cfml.evaluator.EvaluatorException;
029import lucee.transformer.cfml.evaluator.EvaluatorSupport;
030import lucee.transformer.library.tag.TagLib;
031import lucee.transformer.library.tag.TagLibTag;
032
033
034/**
035 * Prueft den Kontext des Tag Mail.
036
037 */
038public final class Mail extends EvaluatorSupport {
039
040        /**
041         * @see lucee.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, lucee.transformer.library.tag.TagLibTag)
042         */
043        public void evaluate(Tag tag,TagLibTag libTag) throws EvaluatorException { 
044                if(tag.containsAttribute("query")) {
045                    
046                        
047                    TagLib lib = libTag.getTagLib();
048                    TagLibTag outputTag = lib.getTag("output");
049                    
050                    TagOutput output=new TagOutput(tag.getStart(),null);
051                    output.setFullname(outputTag.getFullName());
052                    output.setTagLibTag(outputTag);
053                    output.addAttribute(new Attribute(false,"output",LitBoolean.TRUE,"boolean"));
054                    output.addAttribute(new Attribute(false,"formail",LitBoolean.TRUE,"boolean"));
055                    
056                    Body body=new BodyBase();//output.getBody();
057                    output.setBody(body);
058                    
059                    ASMUtil.replace(tag,output,false);
060                    body.addStatement(tag);
061
062                    output.addAttribute(tag.removeAttribute("query"));
063                    if(tag.containsAttribute("group"))output.addAttribute(tag.removeAttribute("group"));
064                    if(tag.containsAttribute("groupcasesensitive"))output.addAttribute(tag.removeAttribute("groupcasesensitive"));
065                    if(tag.containsAttribute("startrow"))output.addAttribute(tag.removeAttribute("startrow"));
066                    if(tag.containsAttribute("maxrows"))output.addAttribute(tag.removeAttribute("maxrows"));
067                    
068                    new Output().evaluate(output,outputTag);
069                }
070        }
071}
072
073
074
075