<?php
/* 
   ======================================================================
   Copyright © 2007 by Francisco Burzi
   http://phpnuke.org             
                                                                  
   AntiSlaed CMS based on:                                          
                                                                    
   RNuke (http://rusnuke.com)                                        
   EdogsNuke (http://edogs.ru)                                       
   XNuke (http://xnuke.info)                                         
   phpBB (http://phpbb.com)                                      
   Code modifications by AntiSlaed Team, March 2008                  
   http://antislaedcms.ru                                        
                                                                     
   Please contact us, if you have any questions about AntiSlaedCMS
   mailto: admin@antislaedcms.ru      
                                                                       
   AntiSlaed CMS is free software. You can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by 
   the Free Software Foundation; either version 2 of the License.
   ======================================================================
*/
/**
 * SPAW Editor v.2 Output class
 *
 * Controls output of shared code to the client, prevents duplicates, etc. 
 * @package spaw2
 * @subpackage Output  
 * @author Alan Mendelevich <alan@solmetra.lt> 
 * @copyright UAB Solmetra
 */
 
/**
 * Controls output of shared code to the client, prevents duplicates, etc.
 * @package spaw2
 * @subpackage Output
 */   
class SpawOutput
{
  /**
   * Workaround for "static" class variable under php4
   * @access private
   */      
  function &buf()
  {
    static $buf;
    
    return $buf;
  }
  
  /**
   * Adds code to output buffer
   * @param string $name name of the code block
   * @param string $code code for output
   * @static   
   */
  function add($name, $code)
  {
    $buf = &SpawOutput::buf();
    $buf[$name] = $code;
  }
  
  /**
   * Returns content of the output
   * @returns string
   * @static   
   */
  function get()
  {
    $buf = &SpawOutput::buf();
    $str_buf = '';
    foreach($buf as $code)
    {
      $str_buf .= $code . "\r\n"; 
    }
    return $str_buf;
  }  
  
  /**
   * Outputs content of the buffer
   * @static       
   */       
  function show()
  {
    echo SpawOutput::get();
  }           
}

?>
