Package com.caucho.quercus

Examples of com.caucho.quercus.QuercusContext$IncludeKey


      ws = openWrite(response);
     
      // php/6006
      ws.setNewlineString("\n");

      QuercusContext quercus = getQuercus();
     
      env = quercus.createEnv(page, ws, request, response);
      quercus.setServletContext(_servletContext);
     
      try {
        env.start();
       
        // php/2030, php/2032, php/2033
        // Jetty hides server classes from web-app
        // http://docs.codehaus.org/display/JETTY/Classloading
        //
        // env.setGlobalValue("request", env.wrapJava(request));
        // env.setGlobalValue("response", env.wrapJava(response));
        // env.setGlobalValue("servletContext", env.wrapJava(_servletContext));

        StringValue prepend
          = quercus.getIniValue("auto_prepend_file").toStringValue(env);
        if (prepend.length() > 0) {
          Path prependPath = env.lookup(prepend);
         
          if (prependPath == null)
            env.error(L.l("auto_prepend_file '{0}' not found.", prepend));
          else {
            QuercusPage prependPage = getQuercus().parse(prependPath);
            prependPage.executeTop(env);
          }
        }

        env.executeTop();

        StringValue append
          = quercus.getIniValue("auto_append_file").toStringValue(env);
        if (append.length() > 0) {
          Path appendPath = env.lookup(append);
         
          if (appendPath == null)
            env.error(L.l("auto_append_file '{0}' not found.", append));
View Full Code Here


   */
  protected QuercusContext getQuercus()
  {
    synchronized (this) {
      if (_quercus == null)
        _quercus = new QuercusContext();
    }

    return _quercus;
  }
View Full Code Here

        templateController.getHttpServletRequest().setAttribute("org.infoglue.cms.deliver.templateLogic", templateController);
        templateController.getHttpServletRequest().setAttribute("org.infoglue.cms.deliver.portalLogic", portletController);
        templateController.getHttpServletRequest().setAttribute("model", model);
        try
        {
          QuercusContext quercus = new QuercusContext();
          quercus.setServletContext(deliveryContext.getHttpServletRequest().getSession().getServletContext());
          Path pwd = new FilePath(CmsPropertyHandler.getContextRootPath());
          quercus.setPwd(pwd);
          if (! Alarm.isTest() && ! quercus.isResin()) {
            Vfs.setPwd(pwd);
            WorkDir.setLocalWorkDir(pwd.lookup("WEB-INF/work"));
          }

          quercus.init();
          quercus.start();
         
              StringWriter writer = new StringWriter(new CharBuffer(1024));
              writer.openWrite();
             
              ByteArrayInputStream bais = new ByteArrayInputStream(templateAsString.getBytes());
              VfsStream stream = new VfsStream(bais, null);       
              QuercusPage page = quercus.parse(new ReadStream(stream));
             
              WriteStream ws = new WriteStream(writer);
             
              Env env = quercus.createEnv(page, ws, deliveryContext.getHttpServletRequest(), deliveryContext.getHttpServletResponse());
              env.start();
                         
              Value value = page.executeTop(env);
              ws.flush();

              String output = ((StringWriter)ws.getSource()).getString();           
             
              Object returnObject = value.toJavaObject();
 
              //logger.info("output:" + output);
          pw.println(output);
        }
        catch (Throwable e)
        {
          e.printStackTrace();
      }
    }
      else if(scriptController != null)
      {
        scriptController.getRequest().setAttribute("org.infoglue.cms.deliver.scriptLogic", scriptController);
        scriptController.getRequest().setAttribute("org.infoglue.cms.deliver.portalLogic", portletController);
        scriptController.getRequest().setAttribute("model", model);
        try
        {
          QuercusContext quercus = new QuercusContext();
          quercus.setServletContext(scriptController.getRequest().getSession().getServletContext());
          Path pwd = new FilePath(CmsPropertyHandler.getContextRootPath());
          quercus.setPwd(pwd);
          if (! Alarm.isTest() && ! quercus.isResin()) {
            Vfs.setPwd(pwd);
            WorkDir.setLocalWorkDir(pwd.lookup("WEB-INF/work"));
          }

          quercus.init();
          quercus.start();
         
              StringWriter writer = new StringWriter(new CharBuffer(1024));
              writer.openWrite();
             
              ByteArrayInputStream bais = new ByteArrayInputStream(templateAsString.getBytes());
              VfsStream stream = new VfsStream(bais, null);       
              QuercusPage page = quercus.parse(new ReadStream(stream));
             
              WriteStream ws = new WriteStream(writer);
             
              Env env = quercus.createEnv(page, ws, scriptController.getRequest(), scriptController.getResponse());
              env.start();
                         
              Value value = page.executeTop(env);
              ws.flush();
View Full Code Here

  @UsesSymbolTable(replace=false)
  @Name("assert")
  public static Value q_assert(Env env, String code)
  {
    try {
      QuercusContext quercus = env.getQuercus();

      QuercusProgram program = quercus.parseCode(code);

      program = program.createExprReturn();

      Value value = program.execute(env);
View Full Code Here

  {
    try {
      if (log.isLoggable(Level.FINER))
        log.finer("quercus eval: [[" + code + "]]");

      QuercusContext quercus = env.getQuercus();

      QuercusProgram program = quercus.parseCode(code);

      Value value = program.execute(env);

      if (value == null)
        value = NullValue.NULL;
View Full Code Here

      ws = openWrite(response);
     
      // php/6006
      ws.setNewlineString("\n");

      QuercusContext quercus = getQuercus();
     
      env = quercus.createEnv(page, ws, request, response);
      quercus.setServletContext(_servletContext);
     
      try {
        env.start();
       
        // php/2030, php/2032, php/2033
        // Jetty hides server classes from web-app
        // http://docs.codehaus.org/display/JETTY/Classloading
        //
        // env.setGlobalValue("request", env.wrapJava(request));
        // env.setGlobalValue("response", env.wrapJava(response));
        // env.setGlobalValue("servletContext", env.wrapJava(_servletContext));

        StringValue prepend
          = quercus.getIniValue("auto_prepend_file").toStringValue(env);
        if (prepend.length() > 0) {
          Path prependPath = env.lookup(prepend);
         
          if (prependPath == null)
            env.error(L.l("auto_prepend_file '{0}' not found.", prepend));
          else {
            QuercusPage prependPage = getQuercus().parse(prependPath);
            prependPage.executeTop(env);
          }
        }

        env.executeTop();

        StringValue append
          = quercus.getIniValue("auto_append_file").toStringValue(env);
        if (append.length() > 0) {
          Path appendPath = env.lookup(append);
         
          if (appendPath == null)
            env.error(L.l("auto_append_file '{0}' not found.", append));
View Full Code Here

   */
  protected QuercusContext getQuercus()
  {
    synchronized (this) {
      if (_quercus == null)
  _quercus = new QuercusContext();
    }

    return _quercus;
  }
View Full Code Here

    if (isUnicodeSemantics())
      _impl.getQuercus().setUnicodeSemantics(true);

    _impl.init(config);

    QuercusContext quercus = getQuercus();

    quercus.setCompile(_isCompile);
    quercus.setLazyCompile(_isLazyCompile);
    quercus.setCompileFailover(_isCompileFailover);
    quercus.setProfileProbability(_profileProbability);
    quercus.setRequireSource(_isRequireSource);
    quercus.setDatabase(_database);
    quercus.setStrict(_isStrict);
    quercus.setLooseParse(_isLooseParse);
    quercus.setPageCacheSize(_pageCacheSize);
    quercus.setRegexpCacheSize(_regexpCacheSize);
    quercus.setConnectionPool(_isConnectionPool);

    if (_iniPath != null) {
      String realPath = getServletContext().getRealPath(_iniPath);
      quercus.setIniFile(getQuercus().getPwd().lookup(realPath));
    }

    if (_scriptEncoding != null)
      quercus.setScriptEncoding(_scriptEncoding);

    if (_mysqlVersion != null)
      quercus.setMysqlVersion(_mysqlVersion);

    if (_phpVersion != null)
      quercus.setPhpVersion(_phpVersion);

    for (QuercusModule module : _moduleList) {
      quercus.addModule(module);
    }

    for (PhpClassConfig cls : _classList) {
      quercus.addJavaClass(cls.getName(), cls.getType());
    }

    for (PhpClassConfig cls : _classImplList) {
      quercus.addImplClass(cls.getName(), cls.getType());
    }

    for (PhpIni ini : _phpIniList) {
      for (Map.Entry<String,String> entry : ini._propertyMap.entrySet()) {
        quercus.setIni(entry.getKey(), entry.getValue());
      }
    }

    for (ServerEnv serverEnv : _serverEnvList) {
      for (Map.Entry<String,String> entry
           : serverEnv._propertyMap.entrySet()) {
        quercus.setServerEnv(entry.getKey(), entry.getValue());
      }
    }
  }
View Full Code Here

  /**
   * Creates a new Quercus, which can be overridden for security issues.
   */
  protected QuercusContext createQuercus()
  {
    QuercusContext quercus = new QuercusContext();
   
    quercus.init();
   
    return quercus;
  }
View Full Code Here

  private QuercusScriptEngineFactory _factory;
  private final QuercusContext _quercus;

  QuercusScriptEngine(QuercusScriptEngineFactory factory)
  {
    this(factory, new QuercusContext());
  }
View Full Code Here

TOP

Related Classes of com.caucho.quercus.QuercusContext$IncludeKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.