Examples of PHPEvalWrapper


Examples of com.dotmarketing.scripting.util.php.PHPEvalWrapper

  public Object call(Object object, String method, Object[] args) throws BSFException {
    Env env = php.createEnv(null, null, null, null);
    env.start();
    populateEnv(env);
    Value v = null;
    PHPEvalWrapper phpw = null;
    if(object instanceof PHPEvalWrapper){
      phpw = (PHPEvalWrapper)object;
    }else{
      phpw = (PHPEvalWrapper)eval(object.toString(), -1, -1, "");
    }
    List<Function> funs = phpw.getFunctions();
    Value[] values = null;
    if(args != null){
      values = new Value[args.length];
      for (int i = 0; i < args.length; i++) {
        Object o = args[i];
        values[i] = env.wrapJava(o);
      }
    }
   
    try{
      if(funs != null && funs.size() > 0){
        v = callFunctionFromFunctionList(funs, method, env, values);
      }else{
        v = callFunctionOnPage(phpw.getPage(), method, env, values);
      }
    }catch (Exception e) {
      Logger.error(this, e.getMessage(),e );
      throw new BSFException("Unable to find function name " + method != null ? method : "" + " to call");
    }
View Full Code Here

Examples of com.dotmarketing.scripting.util.php.PHPEvalWrapper

  }
 
  public Object eval(String source, int lineNo, int columnNo, Object oscript) throws BSFException {
    String scriptText = oscript.toString();
    Path path;
    PHPEvalWrapper wrapper = new PHPEvalWrapper();
    if(source.endsWith(".php")){
      String filePath = source.substring(source.indexOf('/'),source.length());
      path = buildRootPath(source).lookup(filePath);
      if(UtilMethods.isSet(scriptText)){
        wrapper = evaluateCodePage(path, scriptText);
View Full Code Here

Examples of com.dotmarketing.scripting.util.php.PHPEvalWrapper

    } catch (IOException e) {
      Logger.error(this, e.getMessage(), e);
      throw new BSFException(BSFException.REASON_IO_ERROR, e.getMessage(), e);
    }
   
    PHPEvalWrapper wrapper = new PHPEvalWrapper();
    StringWriter sw = new StringWriter();
    WriterStreamImpl writerImpl = new WriterStreamImpl();
        writerImpl.setWriter(sw);

    WriteStream writeStream = new WriteStream(writerImpl);
   
    Env env = php.createEnv(page, writeStream, null, null);
    env.start();
    populateEnv(env);
    page.executeTop(env);
    Value v = qp.execute(env);
   
    List<Function> funcs = qp.getFunctionList();
    if(funcs != null){
      wrapper.setFunctions(funcs);
    }
 
    PrintWriter pw = writeStream.getPrintWriter();
    pw.flush();
   
    wrapper.setValue(v);
    wrapper.setOut(sw.toString());
    return wrapper;
  }
View Full Code Here

Examples of com.dotmarketing.scripting.util.php.PHPEvalWrapper

      page = php.parse(path);
    } catch (IOException e) {
      Logger.error(this, e.getMessage(), e);
      throw new BSFException(BSFException.REASON_IO_ERROR, e.getMessage(), e);
    }
    PHPEvalWrapper wrapper = new PHPEvalWrapper();
    StringWriter sw = new StringWriter();
    WriterStreamImpl writerImpl = new WriterStreamImpl();
        writerImpl.setWriter(sw);

    WriteStream writeStream = new WriteStream(writerImpl);
   
    Env env = php.createEnv(page, writeStream, null, null);
    env.start();
    populateEnv(env);
    Value v = page.executeTop(env);
    PrintWriter pw = writeStream.getPrintWriter();
    pw.flush();
    wrapper.setPage(page);
    wrapper.setOut(sw.toString());
    wrapper.setValue(v);
    return wrapper;
  }
View Full Code Here

Examples of com.dotmarketing.scripting.util.php.PHPEvalWrapper

    } catch (IOException e) {
      Logger.error(this, e.getMessage(), e);
      throw new BSFException(BSFException.REASON_IO_ERROR, e.getMessage(), e);
    }
   
    PHPEvalWrapper wrapper = new PHPEvalWrapper();
    StringWriter sw = new StringWriter();
    WriterStreamImpl writerImpl = new WriterStreamImpl();
        writerImpl.setWriter(sw);

    WriteStream writeStream = new WriteStream(writerImpl);
   
    Env env = php.createEnv(null, writeStream, null, null);
    env.start();
    populateEnv(env);
    Value v = qp.execute(env);
   
    List<Function> funcs = qp.getFunctionList();
    if(funcs != null){
      wrapper.setFunctions(funcs);
    }
 
    PrintWriter pw = writeStream.getPrintWriter();
    pw.flush();
   
    wrapper.setValue(v);
    wrapper.setOut(sw.toString());
    return wrapper;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.