My client didnt accept this solution because they want to have ability to have html template in english also (our base langauage is polish).
So I wrote plugin which have two fields - english email template field and OnSubmit Code field. Before email sending plugin change value of this fields.
Here is this plugin. Maybe it will help someone:
<?php
defined('_JEXEC') or die('Restricted access');
global $mainframe;
require_once( $mainframe->getPath( 'class', 'com_chronocontact' ) );
// the class name must be the same as the file name without the .php at the end
$lang =& JFactory::getLanguage();
//print_r($lang);
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'languages'.DS.$lang->_lang.'.ext.php');
class cf_multi_email {
//the next 3 fields must be defined for every plugin
var $result_TITLE = "English Email Template";
var $result_TOOLTIP = "Sets English Email Template";
var $plugin_name = "cf_multi_email"; // must be the same as the class name
var $event = "ONSUBMIT"; // must be defined and in Uppercase, should be ONSUBMIT or ONLOAD
// the next function must exist and will have the backend config code
function show_conf($row, $id, $form_id, $option){
if(!$row->params){
$row->params = "english=
onsubmit=";
}
//$paramsvalues = mosParseParams( $row->params );
$registry = new JRegistry();
$registry->loadINI( $row->params );
$paramsvalues = $registry->toObject( );
$editor =& JFactory::getEditor();
?>
<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
<table border="0" cellpadding="3" cellspacing="0">
<tr style="background-color:#c9c9c9 ">
<td><?php echo JHTML::_('tooltip', "Runt he plugin before or after the email, running it before the email may be necessary to include some data intot he email or even dont get it emailed" ); ?></td>
<td><strong><?php echo "Run Before/After the Email ?"; ?>:</strong> </td>
<td></td>
<td>
<select name="params[onsubmit]" id="params[onsubmit]">
<option<?php if($paramsvalues->onsubmit == 'after_email'){ echo ' selected';} ?> value="after_email">After Email</option>
<option<?php if($paramsvalues->onsubmit == 'before_email'){ echo ' selected';} ?> value="before_email">Before Email</option>
</select>
</td>
</tr>
<tr style="background-color:#c9c9c9 ">
<td><?php echo JHTML::_('tooltip', "" ); ?></td>
<td><strong><?php echo "English Email Template"; ?>:</strong> </td>
<td></td>
<td>
<?php echo $editor->display('extra1', $row->extra1 , '550', '400', '60', '20', false); ?>
</td>
</tr>
<tr style="background-color:#c9c9c9 ">
<td><?php echo JHTML::_('tooltip', "" ); ?></td>
<td><strong><?php echo "On Submit Text Template"; ?>:</strong> </td>
<td></td>
<td>
<?php echo $editor->display('extra2', $row->extra2 , '550', '400', '60', '20', false); ?>
</td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="form_id" value="<?php echo $form_id; ?>" />
<input type="hidden" name="name" value="<?php echo $this->plugin_name; ?>" />
<input type="hidden" name="event" value="<?php echo $this->event; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="save_conf" />
</form>
<?php
}
// this function must exist and may not be changed unless you need to customize something
function save_conf( $option ) {
global $mainframe;
$database =& JFactory::getDBO();
$post = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
$row =& JTable::getInstance('chronocontactplugins', 'Table');
if (!$row->bind( $post )) {
JError::raiseWarning(100, $row->getError());
$mainframe->redirect( "index2.php?option=$option" );
}
///$params = mosGetParam( $_POST, 'params', '' );
$params = JRequest::getVar( 'params', '', 'post', 'array', array(0) );
if (is_array( $params )) {
$txt = array();
foreach ( $params as $k=>$v) {
$txt[] = "$k=$v";
}
$row->params = implode( "\n", $txt );
}
if (!$row->store()) {
JError::raiseWarning(100, $row->getError());
$mainframe->redirect( "index2.php?option=$option" );
}
$mainframe->redirect( "index2.php?option=".$option, "Config Saved" );
}
function onsubmit( $option, $params , $row ) {
jimport('joomla.user.helper');
global $mainframe;
$database =& JFactory::getDBO();
// Check for request forgeries
//JRequest::checkToken() or die( 'Invalid Token' );
// Get required system objects
$pathway =& $mainframe->getPathway();
$config =& JFactory::getConfig();
$authorize =& JFactory::getACL();
$document =& JFactory::getDocument();
$language =& JFactory::getLanguage();
$language->load('com_user');
$LangTag = $language->getTag();
if ($LangTag=='en-GB')
{
$MyForm =& CFChronoForm::getInstance();
$MyForm->formrow->emailtemplate = $row->extra1;
$MyForm->formrow->useremailtemplate = $row->extra1;
$MyForm->formrow->onsubmitcode = $row->extra2;
$MyEmails =& CFEMails::getInstance($MyForm->formrow->id);
foreach($MyEmails->emails as $email)
{
$email->template = $row->extra1;
}
}
}
}
?>