Search in sources :

Example 51 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class CFMLExpressionInterpreter method identifier.

/**
 * Liest einen Identifier aus und gibt diesen als String zurueck.
 * <br />
 * EBNF:<br />
 * <code>(letter | "_") {letter | "_"|digit};</code>
 * @param firstCanBeNumber
 * @return Identifier.
 */
private String identifier(boolean firstCanBeNumber) {
    if (!cfml.isCurrentLetter() && !cfml.isCurrentSpecial()) {
        if (!firstCanBeNumber)
            return null;
        else if (!cfml.isCurrentDigit())
            return null;
    }
    boolean doUpper;
    PageSource ps = pc == null ? null : pc.getCurrentPageSource();
    if (ps != null)
        doUpper = !isJson && ps.getDialect() == CFMLEngine.DIALECT_CFML && ((MappingImpl) ps.getMapping()).getDotNotationUpperCase();
    else
        // MUST .lucee should not be upper case
        doUpper = !isJson && ((ConfigWebImpl) config).getDotNotationUpperCase();
    StringBuilder sb = new StringBuilder();
    sb.append(doUpper ? cfml.getCurrentUpper() : cfml.getCurrent());
    do {
        cfml.next();
        if (!(cfml.isCurrentLetter() || cfml.isCurrentDigit() || cfml.isCurrentSpecial())) {
            break;
        }
        sb.append(doUpper ? cfml.getCurrentUpper() : cfml.getCurrent());
    } while (cfml.isValidIndex());
    // cfml.substringLower(start,cfml.getPos()-start);
    return sb.toString();
}
Also used : PageSource(lucee.runtime.PageSource)

Example 52 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class AppListenerUtil method getApplicationPageSourceCurr2Root.

public static PageSource getApplicationPageSourceCurr2Root(PageContext pc, PageSource requestedPage, String filename) {
    PageSource ps = requestedPage.getRealPage(filename);
    if (ps.exists()) {
        return ps;
    }
    Array arr = lucee.runtime.type.util.ListUtil.listToArrayRemoveEmpty(requestedPage.getRealpathWithVirtual(), "/");
    // Config config = pc.getConfig();
    for (int i = arr.size() - 1; i > 0; i--) {
        StringBuilder sb = new StringBuilder("/");
        for (int y = 1; y < i; y++) {
            sb.append((String) arr.get(y, ""));
            sb.append('/');
        }
        sb.append(filename);
        ps = ((PageContextImpl) pc).getPageSourceExisting(sb.toString());
        if (ps != null) {
            return ps;
        }
    }
    return null;
}
Also used : Array(lucee.runtime.type.Array) PageSource(lucee.runtime.PageSource)

Example 53 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class ClassicAppListener method _onRequest.

static void _onRequest(PageContext pc, PageSource requestedPage, PageSource application, RequestListener rl) throws PageException {
    PageContextImpl pci = (PageContextImpl) pc;
    pci.setAppListenerType(ApplicationListener.TYPE_CLASSIC);
    // on requestStart
    if (application != null)
        pci._doInclude(new PageSource[] { application }, false, null);
    if (rl != null) {
        requestedPage = rl.execute(pc, requestedPage);
        if (requestedPage == null)
            return;
    }
    // request
    try {
        pci._doInclude(new PageSource[] { requestedPage }, false, null);
    } catch (MissingIncludeException mie) {
        ApplicationContext ac = pc.getApplicationContext();
        boolean rethrow = true;
        if (ac instanceof ClassicApplicationContext) {
            ClassicApplicationContext cfc = (ClassicApplicationContext) ac;
            UDF udf = cfc.getOnMissingTemplate();
            if (udf != null) {
                String targetPage = requestedPage.getRealpathWithVirtual();
                rethrow = (!Caster.toBooleanValue(udf.call(pc, new Object[] { targetPage }, true), true));
            }
        }
        if (rethrow)
            throw mie;
    }
    // on Request End
    if (application != null) {
        PageSource onReqEnd = application.getRealPage(Constants.CFML_CLASSIC_APPLICATION_END_EVENT_HANDLER);
        if (onReqEnd.exists())
            pci._doInclude(new PageSource[] { onReqEnd }, false, null);
    }
}
Also used : UDF(lucee.runtime.type.UDF) MissingIncludeException(lucee.runtime.exp.MissingIncludeException) PageContextImpl(lucee.runtime.PageContextImpl) PageSource(lucee.runtime.PageSource)

Example 54 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class MixedAppListener method getApplicationPageSourceCurrToRoot.

private static PageSource getApplicationPageSourceCurrToRoot(PageContext pc, PageSource requestedPage, RefBoolean isCFC) {
    PageSource res = getApplicationPageSourceCurrent(requestedPage, isCFC);
    if (res != null)
        return res;
    Array arr = lucee.runtime.type.util.ListUtil.listToArrayRemoveEmpty(requestedPage.getRealpathWithVirtual(), "/");
    // Config config = pc.getConfig();
    String path;
    for (int i = arr.size() - 1; i > 0; i--) {
        StringBuilder sb = new StringBuilder("/");
        for (int y = 1; y < i; y++) {
            sb.append((String) arr.get(y, ""));
            sb.append('/');
        }
        path = sb.toString();
        res = ((PageContextImpl) pc).getPageSourceExisting(path.concat(Constants.CFML_APPLICATION_EVENT_HANDLER));
        if (res != null) {
            isCFC.setValue(true);
            return res;
        }
        res = ((PageContextImpl) pc).getPageSourceExisting(path.concat(Constants.CFML_CLASSIC_APPLICATION_EVENT_HANDLER));
        if (res != null)
            return res;
    }
    return null;
}
Also used : Array(lucee.runtime.type.Array) PageSource(lucee.runtime.PageSource)

Example 55 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class MixedAppListener method getApplicationPageSourceCurrent.

private static PageSource getApplicationPageSourceCurrent(PageSource requestedPage, RefBoolean isCFC) {
    PageSource res = requestedPage.getRealPage(Constants.CFML_APPLICATION_EVENT_HANDLER);
    if (res.exists()) {
        isCFC.setValue(true);
        return res;
    }
    res = requestedPage.getRealPage(Constants.CFML_CLASSIC_APPLICATION_EVENT_HANDLER);
    if (res.exists())
        return res;
    return null;
}
Also used : PageSource(lucee.runtime.PageSource)

Aggregations

PageSource (lucee.runtime.PageSource)59 PageContextImpl (lucee.runtime.PageContextImpl)19 Resource (lucee.commons.io.res.Resource)16 Struct (lucee.runtime.type.Struct)10 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)8 Mapping (lucee.runtime.Mapping)7 PageException (lucee.runtime.exp.PageException)7 StructImpl (lucee.runtime.type.StructImpl)7 ConfigImpl (lucee.runtime.config.ConfigImpl)6 ConfigWeb (lucee.runtime.config.ConfigWeb)6 ExpressionException (lucee.runtime.exp.ExpressionException)6 ArrayList (java.util.ArrayList)5 Component (lucee.runtime.Component)5 PageSourceCode (lucee.transformer.util.PageSourceCode)5 IOException (java.io.IOException)4 MissingIncludeException (lucee.runtime.exp.MissingIncludeException)4 Array (lucee.runtime.type.Array)4 LitString (lucee.transformer.expression.literal.LitString)4 HTTPResource (lucee.commons.io.res.type.http.HTTPResource)3 Entry (java.util.Map.Entry)2