? .DS_Store
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/elements/README.txt,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 README.txt
--- README.txt	5 Aug 2010 22:51:28 -0000	1.1.4.2
+++ README.txt	11 Dec 2010 17:24:51 -0000
@@ -2,68 +2,13 @@ Description
 ===========
 Elements intends to become a library that provides complex form elements for developers to use in their modules.
 
-Written by Heine Deelstra.
-
-This module was commissioned by the NCRV (http://www.ncrv.nl/).
-
 Elements provided
 =================
 
-1. tableselect
-
-
-1. tableselect
-===============
-Provides a table with checkboxes or radios in the first column (similar to the table on admin/user/user).
-
-$header = array(
-  'field_key' => 'field_title',
-  'field_key1' => 'field_title1',
-);
-
-$options = array(
-  'id1'=> array(
-    'field_key' => 'value',
-    'field_key1' => 'another value',
-  ),
-
-  'id2'=> array(
-    'field_key' => 'value',
-    'field_key1' => 'another value',
-  ),
-);
-
-$form['test_multiselect'] = array(
-  '#type'=> 'tableselect',
-  '#header' => $header,
-  '#options'=> $options,
-  '#default_value'=> array('id1' => ''),
-);
-
-
-$form['test_single_select'] = array(
-  '#type'=> 'tableselect',
-  '#header' => $header,
-  '#options'=> $options,
-  '#multiple' => FALSE,
-  '#default_value'=> 'id1',
-);
+1. emailfield
+2. searchfield
+3. telfield
+4. urlfield
+5. numberfield
+6. rangefield
 
-Properties tableselect
-======================
-#header
-  The table header, an array of field_key => title pairs.
-#options
-  The data displayed in the table. Nested array of id => array pairs where the array is an array of field_key => value pairs.
-#multiple
-  Determines whether multiple values can be selected. Displays checkboxes when TRUE, radios when FALSE.
-    Default: TRUE
-#js_select
-  Whether to provide advanced selection behaviour (SELECT ALL checkbox, SHIFT-select).
-    Default: TRUE - when #multiple is TRUE.
-    When #multiple is FALSE, always FALSE.
-#default_value
-  Provide an array of id => x pairs for the ids that should be selected by default when #multiple is TRUE.
-  Provide the id as a scalar for the id that should be selected by default when #multiple is FALSE.
-#empty
-  The message to show in a table row if there are no rows to display.
Index: elements.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/elements/elements.info,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 elements.info
--- elements.info	2 Dec 2009 11:22:11 -0000	1.1.4.2
+++ elements.info	11 Dec 2010 17:24:51 -0000
@@ -1,4 +1,6 @@
 ; $Id: elements.info,v 1.1.4.2 2009/12/02 11:22:11 davereid Exp $
 name = Elements
 description = Provides a library of Form API elements.
-core = 6.x
+core = 7.x
+files[] = elements.module
+files[] = elements.theme.inc
Index: elements.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/elements/elements.module,v
retrieving revision 1.1.2.2.2.9
diff -u -p -r1.1.2.2.2.9 elements.module
--- elements.module	10 Aug 2010 05:30:16 -0000	1.1.2.2.2.9
+++ elements.module	11 Dec 2010 17:24:51 -0000
@@ -2,101 +2,67 @@
 // $Id: elements.module,v 1.1.2.2.2.9 2010/08/10 05:30:16 davereid Exp $
 
 /**
- * Implements hook_elements().
+ * Implements hook_element_info().
  */
-function elements_elements() {
-  $types['tableselect'] = array(
-    '#input' => TRUE,
-    '#js_select' => TRUE,
-    '#multiple' => TRUE,
-    '#process' => array('form_process_tableselect'),
-    '#options' => array(),
-    '#empty' => '',
-  );
+function elements_element_info() {
   $types['emailfield'] = array(
     '#input' => TRUE,
     '#size' => 60,
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('form_expand_ahah'),
-    '#value_callback' => 'form_type_textfield_value',
+    '#process' => array('ajax_process_form'),
+    '#theme' => 'emailfield',
+    '#theme_wrappers' => array('form_element'),
+  );
+  $types['numberfield'] = array(
+    '#input' => TRUE,
+    '#process' => array('ajax_process_form'),
+    '#theme' => 'numberfield',
+    '#theme_wrappers' => array('form_element'),
+  );
+  $types['rangefield'] = array(
+    '#input' => TRUE,
+    '#process' => array('ajax_process_form'),
+    '#theme' => 'rangefield',
+    '#theme_wrappers' => array('form_element'),
   );
   $types['searchfield'] = array(
     '#input' => TRUE,
     '#size' => 60,
-    '#maxlength' => 255,
+    '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('form_expand_ahah'),
-    '#value_callback' => 'form_type_textfield_value',
+    '#process' => array('ajax_process_form'),
+    '#theme' => 'searchfield',
+    '#theme_wrappers' => array('form_element'),
   );
   $types['telfield'] = array(
     '#input' => TRUE,
     '#size' => 20,
-    '#autocomplete_path' => FALSE,
-    '#process' => array('form_expand_ahah'),
-    '#value_callback' => 'form_type_textfield_value',
+    '#process' => array('ajax_process_form'),
+    '#theme' => 'telfield',
+    '#theme_wrappers' => array('form_element'),
   );
   $types['urlfield'] = array(
     '#input' => TRUE,
     '#size' => 80,
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('form_expand_ahah'),
-    '#value_callback' => 'form_type_textfield_value',
-  );
-  // Due to a name conflict with theme_number that already exists in CCK,
-  // this field needs to be named 'numberfield'.
-  $types['numberfield'] = array(
-    '#input' => TRUE,
-    '#process' => array('form_expand_ahah'),
-    '#value_callback' => 'form_type_textfield_value',
-  );
-  $types['rangefield'] = array(
-    '#input' => TRUE,
-    '#process' => array('form_expand_ahah'),
-    '#value_callback' => 'form_type_textfield_value',
-  );
-  // Add placeholder support to textfields and textareas.
-  $types['textfield'] = array(
-    '#process' => array('form_process_placeholder'),
-  );
-  $types['textarea'] = array(
-    '#process' => array('form_process_placeholder'),
+    '#process' => array('ajax_process_form'),
+    '#theme' => 'urlfield',
+    '#theme_wrappers' => array('form_element'),
   );
+
   return $types;
 }
 
 /**
- * Implements hook_theme().
+ * Implements hook_element_info_alter().
  */
-function elements_theme() {
-  // @todo Move theme functions to elements.theme.inc
-  return array(
-    'tableselect' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'element_html5' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'emailfield' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'searchfield' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'telfield' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'urlfield' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'numberfield' => array(
-      'arguments' => array('element' => NULL),
-    ),
-    'rangefield' => array(
-      'arguments' => array('element' => NULL),
-    ),
-  );
+function elements_element_info_alter(&$type) {
+  // Add placeholder support to textfields and textareas.
+  if (isset($types['textfield']) || isset($types['textarea'])) {
+    $types['textfield']['#process'][] = 'form_process_placeholder';
+  }
 }
 
 /**
@@ -109,286 +75,56 @@ function elements_theme() {
  *   The processed element.
  */
 function form_process_placeholder($element) {
-  if (isset($element['#placeholder'])) {
+  if (isset($element['#placeholder']) && !isset($element['#attributes']['placeholder'])) {
     // If the placeholder FAPI property is set, simply add it to the form's
     // attributes so it will be output in the HTML tag.
     $element['#attributes']['placeholder'] = $element['#placeholder'];
   }
-  return $element;
-}
-
-/**
- * Helper function to format an HTML 5 form element.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
- */
-function theme_element_html5($element) {
-  $element['#attributes'] = array_merge(array(
-    'type' => substr($element['#type'], 0, -5),
-    'name' => $element['#name'],
-    'id' => $element['#id'],
-    'value' => $element['#value'],
-  ), $element['#attributes']);
-
-  if (!empty($element['#size'])) {
-    $element['#attributes'] += array('size' => $element['#size']);
-  }
-  if (!empty($element['#maxlength'])) {
-    $element['#attributes'] += array('maxlength' => $element['#maxlength']);
-  }
-  if (!empty($element['#placeholder'])) {
-    $element['#attributes'] += array('placeholder' => $element['#placeholder']);
-  }
-
-  $class = array('form-' . $element['#type']);
-  $extra = '';
-  $output = '';
-
-  if ($element['#autocomplete_path'] && menu_valid_path(array('link_path' => $element['#autocomplete_path']))) {
-    drupal_add_js('misc/autocomplete.js');
-    $class[] = 'form-autocomplete';
-    $extra =  '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], array('absolute' => TRUE))) .'" disabled="disabled" />';
-  }
-  _form_set_class($element, $class);
-
-  if (isset($element['#field_prefix'])) {
-    $output .= '<span class="field-prefix">'. $element['#field_prefix'] .'</span> ';
-  }
-
-  $output .= '<input' . drupal_attributes($element['#attributes']) .' />';
-
-  if (isset($element['#field_suffix'])) {
-    $output .= ' <span class="field-suffix">'. $element['#field_suffix'] .'</span>';
-  }
-
-  return theme('form_element', $element, $output) . $extra;
-}
-
-/**
- * Format an e-mail form field.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
- */
-function theme_emailfield($element) {
-  return theme_element_html5($element);
-}
 
-/**
- * Format a search form field.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
- */
-function theme_searchfield($element) {
-  return theme_element_html5($element);
-}
-
-/**
- * Format a mail form field.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
- */
-function theme_telfield($element) {
-  return theme_element_html5($element);
-}
-
-/**
- * Format an URL form field.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
- */
-function theme_urlfield($element) {
-  return theme_element_html5($element);
-}
-
-/**
- * Format a number form field.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
- */
-function theme_numberfield($element) {
-  if (isset($element['#min'])) {
-    $element['#attributes']['min'] = $element['#min'];
-  }
-  if (isset($element['#max'])) {
-    $element['#attributes']['max'] = $element['#max'];
-  }
-  if (isset($element['#step'])) {
-    $element['#attributes']['step'] = $element['#step'];
-  }
-
-  return theme_element_html5($element);
+  return $element;
 }
 
 /**
- * Format a range form field.
- *
- * @param $element
- *   An associative array containing the properties of the element.
- *
- * @return
- *   A themed HTML string representing the form field.
+ * A helper function to set the placeholder for our define elements.
  */
-function theme_rangefield($element) {
-  return theme_numberfield($element);
+function _elements_set_placeholder(&$element) {
+  $element = form_process_placeholder($element);
 }
 
 /**
- * Create the correct amount of checkbox or radio elements to populate the table.
- *
- * @param $element
- *   An associative array containing the properties and children of the
- *   tableselect element.
- * @return
- *   The processed element.
- */
-function form_process_tableselect($element) {
-  if ($element['#multiple']) {
-    $value = is_array($element['#value']) ? $element['#value'] : array();
-  }
-  else {
-    // Advanced selection behaviour make no sense for radios.
-    $element['#js_select'] = FALSE;
-  }
-
-  $element['#tree'] = TRUE;
-
-  if (count($element['#options']) > 0) {
-    if (!isset($element['#default_value']) || $element['#default_value'] === 0) {
-      $element['#default_value'] = array();
-    }
-
-    // Create a checkbox or radio for each item in #options in such a way that
-    // the value of the tableselect element behaves as if it had been of type
-    // checkboxes or radios.
-    foreach ($element['#options'] as $key => $choice) {
-      // Do not overwrite manually created children.
-      if (!isset($element[$key])) {
-        if ($element['#multiple']) {
-          $element[$key] = array(
-            '#type' => 'checkbox',
-            '#title' => '',
-            '#return_value' => $key,
-            '#default_value' => isset($value[$key]),
-            '#attributes' => $element['#attributes'],
-            '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
-            '#disabled' => (isset($choice['#disabled'])) ? $choice['#disabled'] : NULL,
-            '#processed' => TRUE, // NEW
-          );
-        }
-        else {
-          // Generate the parents as the autogenerator does, so we will have a
-          // unique id for each radio button.
-          //$parents_for_id = array_merge($element['#parents'], array($key));
-          $element[$key] = array(
-            '#type' => 'radio',
-            '#title' => '',
-            '#return_value' => $key,
-            '#default_value' => ($element['#default_value'] == $key) ? $key : NULL,
-            '#attributes' => $element['#attributes'],
-            '#parents' => $element['#parents'],
-            //'#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
-            '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
-            '#disabled' => (isset($choice['#disabled'])) ? $choice['#disabled'] : NULL,
-            '#spawned' => TRUE, // NEW
-          );
-        }
-      }
-    }
-  }
-  else {
-    $element['#value'] = array();
-  }
-  return $element;
-}
-
-/**
- * Format a table with radio buttons or checkboxes.
- *
- * @param $variables
- *   An associative array containing:
- *   - element: An associative array containing the properties and children of
- *     the tableselect element.
- *     Each option in $variables['element']['#options'] can contain an array
- *     keyed by '#attributes' which is added to the row's HTML attributes.
- *     @see theme_table
- *     Properties used: header, options, empty, js_select.
- *
- * @return
- *   A themed HTML string representing the table.
- *
- * Example:
- *
- * @code
- * $options = array();
- * $options[0]['title'] = "A red row"
- * $options[0]['#attributes'] = array ('class' => array('red-row'));
- * $options[1]['title'] = "A blue row"
- * $options[1]['#attributes'] = array ('class' => array('blue-row'));
- *
- * $form['myselector'] = array (
- * '#type' => 'tableselect',
- * '#title' => 'My Selector'
- * '#options' => $options,
- * );
- * @ingroup themeable
+ * Implements hook_theme().
  */
-function theme_tableselect($element) {
-  $rows = array();
-  $header = $element['#header'];
-  if (!empty($element['#options'])) {
-    // Generate a table row for each selectable item in #options.
-    foreach ($element['#options'] as $key => $value) {
-      $row = array();
-
-      $row['data'] = array();
-      if (isset($value['#attributes'])) {
-        $row += $value['#attributes'];
-      }
-
-      // Render the checkbox / radio element.
-      unset($element[$key]['#printed']); // NEW
-      $row['data'][] = drupal_render($element[$key]);
-
-      // As theme_table only maps header and row columns by order, create the
-      // correct order by iterating over the header fields.
-      foreach ($element['#header'] as $fieldname => $title) {
-        $row['data'][] = $element['#options'][$key][$fieldname];
-      }
-      $rows[] = $row;
-    }
-    // Add an empty header or a "Select all" checkbox to provide room for the
-    // checkboxes/radios in the first table column.
-    $first_col = $element['#js_select'] ? array(theme('table_select_header_cell')) : array('');
-    $header = array_merge($first_col, $element['#header']);
-  }
-  elseif ($element['#empty']) {
-    // If there are no selectable options, display the empty text over the
-    // entire width of the table.
-    $rows[] = array(array('data' => $element['#empty'], 'colspan' => count($header)));
-  }
-  return theme('table', $header, $rows);
-}
+function elements_theme() {
+  return array(
+    'emailfield' => array(
+      'arguments' => array('element' => NULL),
+      'render element' => 'element',
+      'file' => 'elements.theme.inc',
+    ),
+    'numberfield' => array(
+      'arguments' => array('element' => NULL),
+      'render element' => 'element',
+      'file' => 'elements.theme.inc',
+    ),
+    'rangefield' => array(
+      'arguments' => array('element' => NULL),
+      'render element' => 'element',
+      'file' => 'elements.theme.inc',
+    ),
+    'searchfield' => array(
+      'arguments' => array('element' => NULL),
+      'render element' => 'element',
+      'file' => 'elements.theme.inc',
+    ),
+    'telfield' => array(
+      'arguments' => array('element' => NULL),
+      'render element' => 'element',
+      'file' => 'elements.theme.inc',
+    ),
+    'urlfield' => array(
+      'arguments' => array('element' => NULL),
+      'render element' => 'element',
+      'file' => 'elements.theme.inc',
+    ),
+  );
+}
\ No newline at end of file
