Location: PHPKode > projects > Write2Left > Plugins/post_amp.php
<?php
/*
+------------------------------------------------------
| Write2Left
| (c) timdorr
| http://www.write2left.com
| hide@address.com
| See License.txt for license info
|------------------------------------------------------
| Script: post_amp.php
| Description:
|   A plugin to auto convert & to &amp;
| Created Aug-6-2003
+------------------------------------------------------
*/

if( !class_exists( 'PostAmp' ) )
{
/* Class: PostAmp
 * Description:
 *   Converts ampersands
 */
class PostAmp
{
	function initialize( $post_id, $extra )
	{
	}

	function filter_post( &$title, &$body, &$extended )
	{
	}

	function filter_input( &$input )
	{
		if( $input['do_amp'] != 0 )
		{
			$input['post_body'] = preg_replace( '#&(?!amp;)#', '&amp;', $input['post_body'] );
			$input['post_extended'] = preg_replace( '#&(?!amp;)#', '&amp;', $input['post_extended'] );
		}
	}

	function get_inputs()
	{
	}

	function get_options()
	{
		global $W2L;

		$retval = '<input type="hidden" name="do_amp" value="0" />';
		$retval .= '<input type="checkbox" name="do_amp" value="1"';
		
		if( !array_key_exists( 'do_amp', $W2L->input ) )
			$retval .= ' checked';
		else if( $W2L->input['do_amp'] != 0 )
			$retval .= ' checked';

		$retval .= ' />Convert &amp; to &amp;amp; (for XHTML compliance)<br />';
		
		return $retval;
	}

	function store_saved( &$input, $extra, $new_id )
	{
	}

	function update_saved( &$input, $extra )
	{
	}
}
}

$this->post_plugins[] = new PostAmp();

?>
Return current item: Write2Left