class CBBParse
{
	private $ToParse = "";
	/* Init */
	function CBBParse( $data )
	{
		$this->ToParse = $data;		
	}
	public function parse()
	{
		$this->ToParse = preg_replace_callback( '#\[row[\s]device=\"(?<device>.+?)\"[\s]\](?<content>.*?)\[/row\]#is', array( &$this, "rep_row" ), $this->ToParse );
		return $this->ToParse;
	}
	/* Replacers */
	private function rep_row( $match )
	{
		$return = "<div class=\"row\">";
		$match["content"] = preg_replace(
			'#\[column[\s]width=\"(?<width>.+?)\"[\s]\](?<content>.*?)\[/column\]#ies',
			"\$this->rep_col( '\\1', '\\2', '".$match["device"]."' )",
			$match["content"]
		);
		$return .= $match["content"];
		$return .= "</div>";
		return $return;
	}
	private function rep_col( $width, $content, $device )
	{
		$with_data = explode("/", $width);
		
		$width = "col-".$device."-".(12/$with_data[1]);
		return "<div class=\"".$width."\">".$content."</div>";
	}
}