Location: PHPKode > projects > Blackwolf CMF > projectBlackWolf/lib/Output/Manager/Standard.class.php
<?php
/* Please see the README and LICENSE files. */


/**
 * This is an output manager for standard HTTP
 */
class Output_Manager_Standard extends Output_Manager {
    protected $level;
    protected $queue;

    public function __construct($disable_buffer=false) {
        if (!$disable_buffer) {
            ob_start();
            $this->level = ob_get_level();
        } else {
            $this->queue = array();
        }
        $this->disabled = false;
    }

    public function publish() {
        if($this->disabled){return false;}
        if (isset($this->level)) {
            while (ob_get_level() >= $this->level) {
                ob_end_flush();
            }
        } else {
            $queue_element = is_array($this->queue)?array_shift($this->queue):NULL;
            while ($queue_element != NULL) {
                echo($queue_element);
                $queue_element = array_shift($this->queue);
            }
        }
    }
    public function end_publish(){
        if($this->disabled){return false;}
        if(isset($this->level)){
            while(ob_get_status()){
                ob_end_flush();
            }
        } else {
            $this->publish();
        }
        $this->disabled = true;
    }

    public function queue($in) {
        if (isset($this->level)) {
            echo($in);
        } else {
            $queue[] = $in;
        }
        $this->disabled = false;
    }

    public function queue_jump($in) {
        if (isset($this->level)) {
            $this_buffer = NULL;
            $stack = array();
            while (ob_get_level() > $this->level) {
                $stack[] = ob_get_clean();
            }
            $this_buffer = ob_get_contents();
            @ob_clean();
            echo($in);
            echo($this_buffer);
            while (count($stack) > 0) {
                ob_start();
                echo(array_pop($arrayarray));
            }
        } else {
            array_unshift($this->queue, $in);
        }
        $this->disabled = false;
    }

    public function queue_length() {
        if (isset($this->level)) {
            return ob_get_level();
        }
        return count($this->queue);
    }
    
    public function disabled(){
        return $this->disabled;
    }

    public function get_text() {
        if (isset($this->level)) {
            return ob_get_contents();
        } else {
            return $this->queue[0];
        }
    }
    
    public function clean(){
        if (isset($this->level)) {
            @ob_clean();
        } else {
            unset($this->queue);
        }
    }
    
    public function disable(){
        $this->disabled = true;
    }
}

?>
Return current item: Blackwolf CMF