AAAAindex.html000066600000000035151374433120006546 0ustar00 autocomplete_processor.ctp000066600000012045151374433120012065 0ustar00
Autocomplete Processor
Header(array('settings' => 'Settings', 'other' => 'Other', 'help' => 'Help'), 'autocomplete_processor_config_{n}'); ?> tabStart('settings'); ?> getTableList(); $options = array(); foreach($tables as $table){ $options[$table] = $table; } ?> input('action_autocomplete_processor_{n}_table_name_config', array('type' => 'select', 'label' => 'Table', 'options' => $options, 'empty' => " - ", 'class' => 'medium_input', 'smalldesc' => "The table name to load the data from.")); ?> input('action_autocomplete_processor_{n}_field_name_config', array('type' => 'text', 'label' => "Field Name", 'smalldesc' => 'The name of the field which will be sent and its value will be queried against the table.')); ?> input('action_autocomplete_processor_{n}_column_name_config', array('type' => 'text', 'label' => "Column name(s)", 'class' => 'medium_input', 'smalldesc' => 'The column name which will be searched for the data (should exist in the table selected above), you may enter more than 1 separated by comma and all of them will be searched.')); ?> input('action_autocomplete_processor_{n}_content1_config', array('type' => 'textarea', 'label' => "Code", 'rows' => 20, 'cols' => 70, 'smalldesc' => 'You can place PHP code(with tags) here to override the results, check the help tab for how to.')); ?> tabEnd(); ?> tabStart('other'); ?> input('action_autocomplete_processor_{n}_minLength_config', array('type' => 'text', 'label' => "Minimum length", 'smalldesc' => 'Minimum number of characters before a request is initiated.')); ?> input('action_autocomplete_processor_{n}_maxChoices_config', array('type' => 'text', 'label' => "Max choice", 'smalldesc' => 'Maximum number of choices to load.')); ?> input('action_autocomplete_processor_{n}_maxLength_config', array('type' => 'text', 'label' => "Max Length", 'smalldesc' => 'Maximum number for the string length.')); ?> tabEnd(); ?> tabStart('help'); ?>

tabEnd(); ?>
.htaccess000066600000000177151374433120006356 0ustar00 Order allow,deny Deny from all autocomplete_processor.php000066600000006223151374433120012067 0ustar00 'Autocomplete Processor', 'tooltip' => 'Process the auto complete request for some field and send back the results.'); var $group = array('id' => 'power_fields', 'title' => 'Power Fields'); function load($clear){ if($clear){ $action_params = array( 'table_name' => '', 'field_name' => '', 'minLength' => 3, 'maxChoices' => 10, 'maxLength' => 50, 'content1' => '', 'column_name' => '' ); } return array('action_params' => $action_params); } function run($form, $actiondata){ $params = new JParameter($actiondata->params); $mainframe = JFactory::getApplication(); //settings, vars $min = $params->get('minLength', 3); $max = $params->get('maxLength', 50); $choices = $params->get('maxChoices', 10); $search = (string)$form->get_array_value($form->data, explode('.', $params->get('field_name', 'search'))); $result = array(); //quick validation if(strlen($search) >= $min && strlen($search) <= $max && $params->get('table_name', '') && $params->get('column_name', '')){ $database = JFactory::getDBO(); if(strpos($params->get('column_name', ''), ",") !== false){ $fields = explode(",", $params->get('column_name', '')); $where = array(); foreach($fields as $field){ $where[] = "`".trim($field)."` LIKE '%".$search."%'"; } $where = implode(" OR ", $where); }else{ $fields = array($params->get('column_name', '')); $where = "`".$params->get('column_name', '')."` LIKE '%".$search."%'"; } //echo "SELECT DISTINCT * FROM `".$params->get('table_name', '')."` WHERE ".$where." LIMIT ".$choices; $database->setQuery("SELECT DISTINCT ".$params->get('column_name', '*')." FROM `".$params->get('table_name', '')."` WHERE ".$where." LIMIT ".$choices); $data = $database->loadAssocList(); if(!is_array($data)){ $form->data['_PLUGINS_']['autocomplete_processor']['data'] = $form->data['_PLUGINS_']['autocomplete_processor']['result'] = $result = $data = array(); }else{ $form->data['_PLUGINS_']['autocomplete_processor']['data'] = $data; foreach($fields as $field){ foreach($data as $elem){ $result[] = $elem[$field]; } } $form->data['_PLUGINS_']['autocomplete_processor']['result'] = $result; } //allow custom data control $custom = $actiondata->content1; eval('?>'.$custom); //sleep(4); // delay if you want //push the JSON out header('Content-type: application/json'); echo json_encode($form->data['_PLUGINS_']['autocomplete_processor']['result']); $mainframe->close(); }else{ $form->data['_PLUGINS_']['autocomplete_processor']['result'] = array(); //push the JSON out header('Content-type: application/json'); echo json_encode($form->data['_PLUGINS_']['autocomplete_processor']['result']); $mainframe->close(); } } } ?>