| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Views handler configuration form. 5 */ 6 function data_search_admin_form(&$form_state, $table) { 7 drupal_set_title(check_plain($table->get('title'))); 8 9 $schema = $table->get('table_schema'); 10 $meta = $table->get('meta'); 11 12 $form = array(); 13 14 if (count($schema['primary key']) != 1) { 15 drupal_set_message(t('Only tables with a single-field primary key can be indexed.'), 'error'); 16 return $form; 17 } 18 19 // Keep table. 20 $form['#table'] = $table; 21 22 // Existing fields. 23 $form['fields'] = array('#tree' => TRUE); 24 if (isset($schema['fields'])) { 25 $enabled_fields = data_search_get_fields($table); 26 foreach ($schema['fields'] as $field_name => $field) { 27 $form['fields'][$field_name] = array(); 28 $form['fields'][$field_name]['name'] = array('#value' => $field_name); 29 $form['fields'][$field_name]['search'] = array( 30 '#type' => 'checkbox', 31 '#default_value' => in_array($field_name, $enabled_fields), 32 ); 33 } 34 } 35 $form['submit'] = array( 36 '#type' => 'submit', 37 '#value' => t('Save'), 38 ); 39 return $form; 40 } 41 42 /** 43 * Submit handler for search form. 44 */ 45 function data_search_admin_form_submit(&$form, &$form_state) { 46 $table = $form['#table']; 47 $meta = $table->get('meta'); 48 if (isset($form_state['values']['fields'])) { 49 foreach ($form_state['values']['fields'] as $field_name => $settings) { 50 foreach ($settings as $setting => $value) { 51 $meta['fields'][$field_name][$setting] = $value; 52 } 53 } 54 } 55 $table->update(array('meta' => $meta)); 56 views_invalidate_cache(); 57 } 58 59 /** 60 * Theme data_search_admin_form. 61 */ 62 function theme_data_search_admin_form($form) { 63 64 // Format existing fields. 65 $rows = array(); 66 foreach (element_children($form['fields']) as $e) { 67 $row = array(); 68 foreach (element_children($form['fields'][$e]) as $f) { 69 $row[] = drupal_render($form['fields'][$e][$f]); 70 } 71 $rows[] = $row; 72 } 73 74 $header = array(t('Name'), t('Search index')); 75 $output = theme('table', $header, $rows); 76 $output .= drupal_render($form); 77 return $output; 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |