<?php
/**
 * @version $Id$
 * @package    Contact_Enhanced
 * @subpackage Base
 * @author     Douglas Machado {@link http://ideal.fok.com.br}
 * @author     Created on 11-Nov-09
 * @license		GNU/GPL, see license.txt
 * Contact Enhanced  is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
* @package     Joomla
* @subpackage  Contact
*/
class TOOLBAR_contact
{
   /**
   * Draws the menu for a New Contact
   */
   function _EDIT($edit) {
      $cid = JRequest::getVar( 'cid', array(0), '', 'array' );

      $text = ( $edit ? JText::_( 'Edit' ) : JText::_( 'New' ) );

      JToolBarHelper::title( JText::_( 'Contact' ) .': <small><small>[ '. $text .' ]</small></small>', 'generic.png' );

      //JToolBarHelper::custom( 'save2new', 'new.png', 'new_f2.png', 'Save & New', false,  false );
      //JToolBarHelper::custom( 'save2copy', 'copy.png', 'copy_f2.png', 'Save To Copy', false,  false );
      JToolBarHelper::save();
      JToolBarHelper::apply();
      if ( $edit ) {
         // for existing items the button is renamed `close`
         JToolBarHelper::cancel( 'cancel', 'Close' );
      } else {
         JToolBarHelper::cancel();
      }
      
   }

   function _DEFAULT() {

      JToolBarHelper::title( JText::_( 'Contact Enhanced Manager' ), 'generic.png' );
      JToolBarHelper::publishList();
      JToolBarHelper::unpublishList();
      JToolBarHelper::deleteList();
      JToolBarHelper::editListX();
      JToolBarHelper::addNewX();
      JToolBarHelper::preferences('com_contact_enhanced', '500');

   }
	function _DOC() {

      JToolBarHelper::title( JText::_( 'Contact Enhanced' ).': <small><small>[ '. JText::_('About') .' ]</small></small>', 'generic.png' );

   }
}
class TOOLBAR_custom_field
{
   /**
   * Draws the menu for a New Contact
   */
   function _EDIT($edit) {
      $cid = JRequest::getVar( 'cid', array(0), '', 'array' );

      $text = ( $edit ? JText::_( 'Edit' ) : JText::_( 'New' ) );

      JToolBarHelper::title( JText::_( 'Custom Field' ) .': <small><small>[ '. $text .' ]</small></small>', 'generic.png' );

      //JToolBarHelper::custom( 'save2new', 'new.png', 'new_f2.png', 'Save & New', false,  false );
      //JToolBarHelper::custom( 'save2copy', 'copy.png', 'copy_f2.png', 'Save To Copy', false,  false );
      JToolBarHelper::save('saveCF');
      JToolBarHelper::apply('applyCF');
      if ( $edit ) {
         // for existing items the button is renamed `close`
         JToolBarHelper::cancel( 'cancelCF', 'Close' );
      } else {
         JToolBarHelper::cancel('cancelCF');
      }
   }
   
	function _COPY()
	{
		JToolBarHelper::title( JText::_( 'Copy Custom Fields' ), 'copy_f2.png' );
		JToolBarHelper::custom( 'copysaveCF', 'save.png', 'save_f2.png', 'Save', false );
		JToolBarHelper::cancel('showCF');
	}

   function _DEFAULT() {
   	$user = & JFactory::getUser();
   	
      JToolBarHelper::title( JText::_( 'Custom Field Manager' ), 'generic.png' );
      JToolBarHelper::publishList('CFpublish');
      JToolBarHelper::unpublishList('CFunpublish');
      JToolBarHelper::deleteList('','removeCF');
      JToolBarHelper::customX( 'copyCF', 'copy.png', 'copy_f2.png', 'Copy' );
      
      JToolBarHelper::editListX('editCF');
      JToolBarHelper::addNewX('newCF');
      if (strtolower($user->usertype)=="super administrator") {
			JToolBarHelper::customX( 'exportCF', 'export', 'restore.png', 'Export' );
			$bar = & JToolBar::getInstance('toolbar');
			$bar->addButtonPath(JPATH_COMPONENT.DS.'buttons');
			$js	= ' onclick="document.ceImportSliderBox.toggle();" ';
			// Add a back button
			$bar->appendButton( 'Javascript', 'import', JText::_('Import'), '#',$js );
      }
     
   }
}