Search in sources :

Example 6 with TagLib

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();
}
Also used : TagLibTag(lucee.transformer.library.tag.TagLibTag) CFTag(lucee.runtime.tag.CFTag) CFTagCore(lucee.runtime.tag.CFTagCore) TagLib(lucee.transformer.library.tag.TagLib) Iterator(java.util.Iterator) AppendixTag(lucee.runtime.ext.tag.AppendixTag) Module(lucee.runtime.tag.Module) Map(java.util.Map) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 7 with TagLib

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);
}
Also used : TagLibTag(lucee.transformer.library.tag.TagLibTag) TagLib(lucee.transformer.library.tag.TagLib) PageContextImpl(lucee.runtime.PageContextImpl) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 8 with TagLib

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());
                    }
                }
            }
        }
    }
}
Also used : TagLibTagAttr(lucee.transformer.library.tag.TagLibTagAttr) TagLibTag(lucee.transformer.library.tag.TagLibTag) TagLib(lucee.transformer.library.tag.TagLib)

Example 9 with TagLib

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);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) TagLib(lucee.transformer.library.tag.TagLib) Query(lucee.runtime.type.Query)

Example 10 with TagLib

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);
    }
}
Also used : TagLib(lucee.transformer.library.tag.TagLib) Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) FunctionLib(lucee.transformer.library.function.FunctionLib)

Aggregations

TagLib (lucee.transformer.library.tag.TagLib)19 TagLibTag (lucee.transformer.library.tag.TagLibTag)9 TemplateException (lucee.runtime.exp.TemplateException)5 CustomTagLib (lucee.transformer.library.tag.CustomTagLib)5 Resource (lucee.commons.io.res.Resource)4 ConfigImpl (lucee.runtime.config.ConfigImpl)3 BodyBase (lucee.transformer.bytecode.BodyBase)3 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)3 EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)3 ComponentTemplateException (lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException)3 LitString (lucee.transformer.expression.literal.LitString)3 TagLibException (lucee.transformer.library.tag.TagLibException)3 IOException (java.io.IOException)2 ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)2 Position (lucee.transformer.Position)2 Body (lucee.transformer.bytecode.Body)2 Page (lucee.transformer.bytecode.Page)2 Tag (lucee.transformer.bytecode.statement.tag.Tag)2 ExprTransformer (lucee.transformer.cfml.ExprTransformer)2 AttributeEvaluatorException (lucee.transformer.cfml.attributes.AttributeEvaluatorException)2