function show_conf($row, $id, $form_id, $option) { global $mainframe; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); // identify and initialise the parameters used in this plugin $params_array = array('table_name' => '', 'field_name' => '', 'parameter' => '', 'editable' => '0', 'evaluate' => '0'); $params = $helper->loadParams($row, $params_array); $tables = $db->getTableList(); $script .= "\n function loadfields2()\n {\n \tvar table = \$('table_name').value;\n \tvar test = \$('field_name').getParent();\n \tif (table == '' || table == '--?--' ) {\n \t\ttest.setHTML('<div id=\\'field_name\\'>Please select table name first</div>')\n \t\treturn false;\n \t}\n \tvar url = 'index3.php?option=com_chronocontact&task=ajax&plugin=cf_profile&method=ajaxFields&format=raw';\n \tmyAjax = new Ajax(url, {\n \t\tmethod: 'post',\n \t\tpostBody: 'table='+table,\n \t\tonRequest: function() {\n \t\t\ttest.setHTML('<div id=\\'field_name\\'>Loading . . .</div>')\n \t\t\t},\n \t\tonSuccess: function(req) {\n \t\t\ttest = \$('field_name').getParent();\n \t\t\ttest.setHTML('<div id=\\'field_name\\'></div>');\n\t\t\t\t\ttest = \$('field_name').getParent();\n\t\t\t\t\ttest.setHTML(req);\n \t\t\t}\n \t\t}).request();\n }\n "; ?> <form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm" > <?php echo $pane->startPane("cf_profile"); echo $pane->startPanel('Configure', 'Configure'); ?> <?php //$input = $helper->createHeaderTD('Configure Profile Table plugin', '', true, $attribs['header']); echo $helper->openTableLegend('Configure Profile Table plugin'); $tooltip = "Choose the table to get the data from."; foreach ($tables as $k => $table) { $tables_array[$table] = JHTML::_('select.option', JText::_($table)); } $input = $helper->createSelectTD('Table name', 'params[table_name]', $tables_array, $params->get('table_name'), array('onChange' => 'loadfields2()', 'class' => 'cf_select'), $tooltip, 'table_name'); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "The table column name which to be matched by the parameter;\n \tfor best results, this field must be UNIQUE"; if ($id == 0) { $input = $helper->createTextTD('Target field name', '<div id="field_name">Select Table name first</div>', '', $tooltip); } else { $input = "<td></td>"; $fields_array = array(); $table_fields = $db->getTableFields($params->get('table_name')); foreach ($table_fields[$params->get('table_name')] as $k => $v) { $fields_array[$k] = JHTML::_('select.option', JText::_($k)); } $input = $helper->createSelectTD('Target field name', 'params[field_name]', $fields_array, $params->get('field_name'), array('class' => 'cf_select'), $tooltip, 'field_name'); } echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "The name of the parameter provided in the page url e.g. userid=128."; $input = $helper->createInputTD("'Request' parameter name", 'params[parameter]', $params->get('parameter'), '', $attribs['input'], $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "This will be the default value of the requested parameter in case nothing was in the request!"; $input = $helper->createInputTD("Default Request Parameter value", 'params[default_param_value]', $params->get('default_param_value'), '', $attribs['input'], $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "The type of ordering for the records loaded, this will control if the first or last record is loaded in case the query meets more than 1 record"; $input = $helper->createSelectTD("Oder type", 'params[ordertype]', array("ASC" => JHTML::_('select.option', JText::_("ASC")), "DESC" => JHTML::_('select.option', JText::_("DESC"))), $params->get('ordertype', 'ASC'), array('class' => 'cf_select'), $tooltip, 'ordertype'); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "Will this profile page be editable by users?"; $input = $helper->createYesNoTD("Editable", "params[editable]", '', $params->get('editable', '0'), '', $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "Skip populating these fields"; $input = $helper->createInputTD("Skipped fields list", 'params[skippedarray]', $params->get('skippedarray'), '', $attribs['input'], $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "Will the profile page evaluate code before doing its routine?\n \tThis may need to be enabled if you are generating some fields using PHP and want to load their data!?"; $input = $helper->createYesNoTD("Evaluate code", "params[evaluate]", '', $params->get('evaluate', '0'), '', $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); echo $helper->closeTableLegend(); ?> <?php $hidden_array = array('id' => $id, 'form_id' => $form_id, 'name' => $this->plugin_name, 'event' => $this->event, 'option' => $option, 'task' => 'save_conf'); echo $helper->createHiddenArray($hidden_array); echo $pane->endPanel(); echo $pane->startPanel('Help', "help"); ?> <table border="0" cellpadding="3" cellspacing="0" class='cf_table' > <?php $input = $helper->createHeaderTD('Help for Profile Table plugin', '', true, $attribs['header']); echo $helper->wrapTR($input); ?> <tr> <td colspan='4' style='border:1px solid silver; padding:6px;'> <div>The plugin allows you to read values from any table in the database and include them in your form.</div> <div>It was originally designed to allow access to the jos_users table to create member profiles but it is capable of much more.</div> <div>To use the plugin effectively you will need to call the form from a link on your site. This could be from - for example a list of users, or topics, or events where you have some related information in a database table.</div> <ul><li>Choose the table you want to use in the first drop-down e.g. jos_users to get a user's name and email.</li> <li>Select a field or column name from the table in the second drop down. This should be a field that will uniquely identify the record you want to use e.g. 'id' or 'username' for the jos_user table. NB This drop-down will not appear until you select a table in the first drop-down.</li> <li>In the Target field name box put the name of the field you will use to identify the record e.g. user_id. You will need to add this field to a url calling the form e.g. . . . &chronoformname=my_form&user_id=99 </li> <li>You can then use information from this record in your form by putting {column_name} where you want it to appear e.g. {name} for a users name from the jos_users table.</li> <li>Once this plugin is configured you must enable it in the Form 'Plugins'' tab.</li></ul> </td> </tr> </table> <?php echo $pane->endPanel(); echo $pane->endPane(); ?> </form> <?php if ($style) { $doc->addStyleDeclaration($style); } if ($script) { $doc->addScriptDeclaration($script); } }