<?php
/**
* @package Mambo Open Source
* @subpackage Modules
* @copyright (C) 2005 - 2006 Mambo Foundation Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure
* that Mambo remained free Open Source software owned and managed by the community.
* Mambo is Free Software
*/ 

class TOOLBAR_modules {
    /**
	* Draws the menu for a New module
	*/
   
    function _NEW()	{
        mosMenuBar::startTable();
        mosMenuBar::preview( 'modulewindow' );
        mosMenuBar::spacer();
        mosMenuBar::save();
        mosMenuBar::spacer();
        mosMenuBar::apply();
        mosMenuBar::spacer();
        mosMenuBar::cancel();
        mosMenuBar::spacer();
        mosMenuBar::help( $ref.'new' );
        mosMenuBar::endTable();
    }

    /**
	* Draws the menu for Editing an existing module
	*/
    function _EDIT( $cur_template, $publish ) {
        global $id;

        mosMenuBar::startTable();
		?>
			<td><a class="toolbar" href="#" onClick="if (typeof document.adminForm.content == 'undefined') { alert('<?php echo T_('You can only preview typed modules.') ?>'); } else { var content = document.adminForm.content.value; content = content.replace('#', '');  var title = document.adminForm.title.value; title = title.replace('#', ''); window.open('popups/modulewindow.php?title=' + title + '&content=' + content + '&t=<?php echo $cur_template; ?>', 'win1', 'status=no,toolbar=no,scrollbars=auto,titlebar=no,menubar=no,resizable=yes,width=200,height=400,directories=no,location=no'); }" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('preview','','images/preview_f2.png',1);"><img src="images/preview.png" alt="<?php echo T_('Preview') ?>" border="0" name="preview" align="middle"><br /><?php echo T_('Preview') ?></a></td>
		<?php
		mosMenuBar::spacer();
		mosMenuBar::save();
		mosMenuBar::spacer();
		mosMenuBar::apply();
		mosMenuBar::spacer();
		if ( $id ) {
		    // for existing content items the button is renamed `close`
		    mosMenuBar::cancel( 'cancel', T_('Close') );
		} else {
		    mosMenuBar::cancel();
		}
		mosMenuBar::spacer();

		$result = '';
		if ($_POST) {
		    $cid = (int) $GLOBALS['cid'][0];
		} else {
		    $cid = (int) $_GET['id'];
		}
		$database =& mamboDatabase::getInstance();
		$database->setQuery('select module from #__modules where id = '.$cid);
		$result = substr($database->loadResult(), 4);

		mosMenuBar::help( $result ? $result : 'edit' );
		mosMenuBar::endTable();
    }
    function _DEFAULT() {
        mosMenuBar::startTable();
        mosMenuBar::publishList();
        mosMenuBar::spacer();
        mosMenuBar::unpublishList();
        mosMenuBar::spacer();
        mosMenuBar::custom( 'copy', 'copy.png', 'copy_f2.png', T_('Copy'), true );
        mosMenuBar::spacer();
        mosMenuBar::addNewX();
        mosMenuBar::spacer();
        mosMenuBar::editListX();
        mosMenuBar::spacer();
        mosMenuBar::deleteList();
        mosMenuBar::spacer();
        mosMenuBar::help( 'admin.manager' );
        mosMenuBar::endTable();
    }
}
?>
