getPath( 'class', 'com_chronocontact' ) ); // the class name must be the same as the file name without the .php at the end class cf_multi_language { //the next 3 fields must be defined for every plugin var $result_TITLE = "Multi Language"; var $result_TOOLTIP = "Define translations for any string at your form"; var $plugin_name = "cf_multi_language"; // must be the same as the class name var $event = "ONLOAD"; // must be defined and in Uppercase, should be ONSUBMIT or ONLOAD var $plugin_keys =''; // the next function must exist and will have the backend config code function show_conf($row, $id, $form_id, $option){ global $mainframe; $database =& JFactory::getDBO(); $paramsvalues = new JParameter($row->params); $tables = $database->getTableList(); jimport('joomla.html.pane'); $pane =& JPane::getInstance('tabs'); ?>
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 onload( $option, $row, $params, $html_string ) { global $mainframe; $my = JFactory::getUser(); $database =& JFactory::getDBO(); $lang =& JFactory::getLanguage(); $LangTag = $lang->getTag(); $supportedLanguages = explode(",", trim($params->get('languages'))); $LangCount = 1; $LangArray = array(); $Lang_Temp_Array = array(); $cfLangDone = false; foreach($supportedLanguages as $supportedLanguage){ if($LangTag == trim($supportedLanguage)){ $LangData = $row->{"extra".$LangCount}; $Lang_Temp_Array = explode("\n", $LangData); if(count($Lang_Temp_Array)){ foreach($Lang_Temp_Array as $Lang_Temp_Element){ $This_Lang_Element = explode("=", $Lang_Temp_Element); $LangArray[$This_Lang_Element[0]] = $This_Lang_Element[1]; } foreach($LangArray as $original => $translation){ $html_string = str_replace($original, $translation, $html_string); } } $cfLangDone = true; } //create the default language array if(trim($params->get('default_language')) == trim($supportedLanguage)){ $LangData = $row->{"extra".$LangCount}; $Lang_Temp_Array = explode("\n", $LangData); if(count($Lang_Temp_Array)){ foreach($Lang_Temp_Array as $Lang_Temp_Element){ $This_Lang_Element = explode("=", $Lang_Temp_Element); $DefaultLangArray[$This_Lang_Element[0]] = $This_Lang_Element[1]; } } } $LangCount++; } //if no translations found, do default language if(!$cfLangDone && trim($params->get('default_language'))){ foreach($DefaultLangArray as $original => $translation){ $html_string = str_replace($original, $translation, $html_string); } } return $html_string ; } } ?>