AAAAadministrator/components/com_chronoforms/form_actions/dynamic_dropdown/cfaction_dynamic_dropdown.php000060400000007700151374273410034343 0ustar00home/academiac/wwwparams); $document = JFactory::getDocument(); JHTML::_('behavior.mootools'); $mainframe = JFactory::getApplication(); $uri = JFactory::getURI(); $dynamic_values = array(); if(!empty($actiondata->content1)){ $config = trim($actiondata->content1); $values = explode("\n", $config); foreach($values as $line){ $line_data = explode(":", trim($line)); $source_value = $line_data[0]; $target_data = $line_data[1]; $target_options = explode(",", $target_data); foreach($target_options as $target_option){ $target_option_data = explode("=", $target_option); $target_option_value = $target_option_data[0]; $dynamic_values[$source_value][$target_option_value] = $target_option_title = trim($target_option_data[1]); } } } $source_id = $params->get('source_dropdown_id', ''); $target_id = $params->get('target_dropdown_id', ''); if(((bool)$params->get('enable_ajax', 0) === true && empty($dynamic_values)) || empty($source_id) || empty($target_id)){ return false; } ob_start(); ?> window.addEvent('load', function() { $('').addEvent('change', function(){ get('enable_ajax', 0) === false): ?> $dynamic_value): ?> if($('').get('value') == ''){ $('').empty(); $option_title): ?> new Element('option', {'value': '', 'text': ''}).inject($('')); $('').fireEvent('change'); } var load_req = new Request({ url: 'index.php?option=com_chronoforms&chronoform=form_name; ?>&event=get('ajax_event_name', ''); ?>', method: 'get', onRequest: function(){ $('').empty(); new Element('option', {'value': '', 'text': 'Loading...'}).inject($('')); }, onSuccess: function(responseText){ $('').empty(); var response_data = responseText.trim().split("\n"); response_data.each(function(line){ var line_data = line.split("="); new Element('option', {'value': line_data[0], 'text': line_data[1]}).inject($('')); }); $('').fireEvent('change'); }, onFailure: function(){ $('').empty(); new Element('option', {'value': '', 'text': 'Loading failed.'}).inject($('')); } }); load_req.send($('').get('name')+'='+$('').get('value')); }); }); form_params->get('dynamic_files', 0) === false){ $document->addScriptDeclaration("//"); }else{ //load the action class $form->loadActionHelper('load_js'); $CfactionLoadJsHelper = new CfactionLoadJsHelper(); $JSactiondata = new stdClass(); $JSactiondata->content1 = $script; $JSParams = new JParameter(''); $JSParams->set('dynamic_file', $form->form_params->get('dynamic_files', 0)); $JSactiondata->params = $JSParams->toString(); $CfactionLoadJsHelper->load($form, $JSactiondata); } } } ?>