Location: PHPKode > projects > Community Learning Network > cln/lib/CLN/PlainTextConverter.php
<?php
/*
 * PlainTextConverter Class
 *
 * Copyright (c) 2003-4 St. Christopher House
 *
 * Developed by The Working Group Inc.
 *
 * This program 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, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * @version $Id: PlainTextConverter.php,v 1.2 2004/11/19 04:41:21 cbooth7575 Exp $
 *
 */

require_once 'SimpleXMLParser.php';

class PlainTextConverter extends SimpleXMLParser {

	function tag_open($parser, $tag, $attributes)
	{
		// do nothing with the opening tags
	}

	function cdata($parser, $cdata)
	{
		if(!empty($cdata)) {
			$this->content .= trim($cdata);
		}
	}

	function tag_close($parser, $tag)
	{
		if ($tag == 'P') {
			$this->content .= "\n\n";
		}

		// NEW tags
		else if ($tag == 'BR') {
			$this->content .= "\n";
		}

		// ROW tags
		else if ($tag == 'HR') {
			$this->content .= "----------------------------------------------------------------\n";
		}
	}

} // end of class xml

?>
Return current item: Community Learning Network