<?
/*
Plugin Name: WYSI-Wordpress
Plugin URI: http://mudbomb.com/
Description: This plugin adds a more advanced WYSIWYG editor to the Wordpress post editing screen. It includes advanced image handling, including on-the-fly thumbnail resizing and compression. It also includes Martin Chlup&aacute;c's excellent Iimage Manager v 1.4.1.
Version: 5
Author: MudBomb.com
Author URI: http://mudbomb.com/
*/
function wysiwordpress()
{
?>
<style type="text/css">
#quicktags { display: none };
#uploading { display: none };
</style>
<script language="javascript" type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/Wysi-Wordpress/tiny_mce.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/Wysi-Wordpress/wordpress.js"></script>
<?
}
add_action('edit_form_advanced','wysiwordpress');
add_action('edit_page_form','wysiwordpress');
add_action('simple_edit_form','wysiwordpress');
// the PHP below adds Martin Chlupác's Iimage Browser ver 1.4.1
//the Iimage Browser plugin page is at http://fredfred.net/skriker/index.php/iimage-browser
//Martin Chlupác's site is at http://fredfred.net/skriker/

// ====( configuration options )================================================
$ib_use_hack = true; // If you don't want to do the hack, set this to FALSE
                      // For better placement of the button please set this to
                      // TRUE and read the instructions in the README.txt
														  
// ====( STOP EDITING HERE )==================================================== 

/*
IImage Browser Plugin for Wordpress 1.2 and higher
Copyright (C) 2004-2005 Martin Chlupac

based on

Image Browser Plugin for Wordpress 1.2
Copyright (C) 2004 Florian Jung

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
*/

// Create a link to the image selector in the post screen
function ib_print_insert_image_link() {
	global $ib_use_hack;
	if (!strstr($_SERVER['PHP_SELF'], 'post.php')) 
		return 0;
	
	if ($ib_use_hack) {
		print '<a href="iimage-browser.php"'
		    . ' onclick="return insert_image_popup(this, \'IImageBrowser\')">'
		    . '&gt;&gt;Insert Image&lt;&lt;</a> ';
	} else {
		print '<div id="insertimage">'
		    . '<a href="iimage-browser.php"'
		    . ' onclick="return insert_image_popup(this, \'IImageBrowser\')">'
		    . '&gt;&gt;Insert Image&lt;&lt;</a></div>';
	}
}

// The popup needs some CSS and javascript in the head of the page
function ib_print_insert_image_head() {
	print '
	<style type="text/css">
	#insertimage {
		position: absolute;
		top: 4px;
		right: 4px;
		margin: 0; padding: 0;
		font-size: 1em;
	}
	</style>
	<script type="text/javascript">
	<!--
	function insert_image_popup(mylink, windowname) {
		if (! window.focus) return true;
		var href;
		if (typeof(mylink) == "string")
			href = mylink;
		else
			href = mylink.href;
		window.open(href, windowname, "width=700,height=600,scrollbars=yes");
		return false;
	}
	//-->
	</script>
	';
}

// Add actions to call the function
add_action('admin_head',   'ib_print_insert_image_head');
if ($ib_use_hack) {
	add_action('edit_form_advanced_buttons', 'ib_print_insert_image_link');
} else {
	add_action('admin_footer', 'ib_print_insert_image_link');
}

// ex: set tabstop=3:
?>