Search in sources :

Example 1 with OutputBuffer

use of php.runtime.output.OutputBuffer in project jphp by jphp-compiler.

the class Environment method popOutputBuffer.

public OutputBuffer popOutputBuffer() throws Throwable {
    Stack<OutputBuffer> outputBuffers = getOutputBuffers();
    if (outputBuffers.empty())
        return null;
    if (outputBuffers.peek().isRoot())
        return null;
    OutputBuffer result = outputBuffers.pop();
    result.close();
    return result;
}
Also used : OutputBuffer(php.runtime.output.OutputBuffer)

Example 2 with OutputBuffer

use of php.runtime.output.OutputBuffer in project jphp by jphp-compiler.

the class OutputFunctions method ob_flush.

public static boolean ob_flush(Environment env, TraceInfo trace) throws Throwable {
    OutputBuffer buffer = env.peekOutputBuffer();
    if (buffer != null && !buffer.isRoot()) {
        buffer.setTrace(trace);
        buffer.flush();
        return true;
    } else {
        env.error(trace, ErrorType.E_NOTICE, "ob_flush(): failed to flush buffer. No buffer to flush");
        return false;
    }
}
Also used : OutputBuffer(php.runtime.output.OutputBuffer)

Example 3 with OutputBuffer

use of php.runtime.output.OutputBuffer in project jphp by jphp-compiler.

the class OutputFunctions method ob_end_flush.

public static boolean ob_end_flush(Environment env, TraceInfo trace) throws Throwable {
    OutputBuffer buffer = env.peekOutputBuffer();
    if (buffer != null && !buffer.isRoot()) {
        buffer.setTrace(trace);
        buffer.flush();
        env.popOutputBuffer();
        return true;
    } else {
        env.error(trace, ErrorType.E_NOTICE, "ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush");
        return false;
    }
}
Also used : OutputBuffer(php.runtime.output.OutputBuffer)

Example 4 with OutputBuffer

use of php.runtime.output.OutputBuffer in project jphp by jphp-compiler.

the class OutputFunctions method ob_get_flush.

public static Memory ob_get_flush(Environment env, TraceInfo trace) throws Throwable {
    OutputBuffer buffer = env.peekOutputBuffer();
    if (buffer != null) {
        if (buffer.isLock()) {
            env.error(trace, "ob_get_flush(): Cannot use output buffering in output buffering display handlers");
            return Memory.FALSE;
        }
        Memory result = buffer.getContents();
        buffer.setTrace(trace);
        buffer.flush();
        return result;
    } else {
        env.error(trace, ErrorType.E_NOTICE, "ob_get_flush(): failed to delete and flush buffer. No buffer to delete or flush");
        return Memory.FALSE;
    }
}
Also used : Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) OutputBuffer(php.runtime.output.OutputBuffer)

Example 5 with OutputBuffer

use of php.runtime.output.OutputBuffer in project jphp by jphp-compiler.

the class OutputFunctions method ob_get_status.

public static Memory ob_get_status(Environment env, boolean fullStatus) {
    if (fullStatus) {
        ArrayMemory result = new ArrayMemory();
        OutputBuffer peek = env.peekOutputBuffer();
        ArrayList<OutputBuffer> list = new ArrayList<OutputBuffer>();
        while (peek != null && !peek.isRoot()) {
            list.add(0, peek);
            peek = peek.getParentOutput();
        }
        for (OutputBuffer e : list) {
            result.add(_get_status(e));
        }
        return result;
    } else {
        OutputBuffer buffer = env.peekOutputBuffer();
        if (buffer == null || buffer.isRoot())
            return new ArrayMemory().toConstant();
        return _get_status(buffer).toConstant();
    }
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ArrayList(java.util.ArrayList) OutputBuffer(php.runtime.output.OutputBuffer)

Aggregations

OutputBuffer (php.runtime.output.OutputBuffer)12 ArrayMemory (php.runtime.memory.ArrayMemory)4 ArrayList (java.util.ArrayList)2 Memory (php.runtime.Memory)2 LongMemory (php.runtime.memory.LongMemory)2 Invoker (php.runtime.invoke.Invoker)1