--- editablefields.module 2009-09-21 12:36:06.000000000 -0700 +++ modified.editablefields.module 2009-09-21 12:32:03.000000000 -0700 @@ -34,32 +34,54 @@ function editablefields_menu() { * Implementation of hook_theme(). */ function editablefields_theme() { - return array( - 'editablefields_formatter_editable' => array( - 'arguments' => array('element' => NULL), - 'function' => 'theme_editablefields_formatter_editable', - ), - 'editablefields_formatter_clicktoedit' => array( - 'arguments' => array('element' => NULL), - 'function' => 'theme_editablefields_formatter_editable', - ), - ); + $theme = array(); + $content_types = _content_field_types(); + + foreach ($content_types as $type => $data) { + foreach ($data['formatters'] as $formatter => $info) { + if (!isset($formatters['editablefields_formatter_editable_'.$formatter])) { + $theme['editablefields_formatter_editable_'.$formatter] = array( + 'arguments' => array('element' => NULL), + 'function' => 'theme_editablefields_formatter_editable', + ); + } + if (!isset($formatters['editablefields_formatter_clicktoedit_'.$formatter])) { + $theme['editablefields_formatter_clicktoedit_'.$formatter] = array( + 'arguments' => array('element' => NULL), + 'function' => 'theme_editablefields_formatter_editable', + ); + } + } + + } + return $theme; } /** * Implementation of hook_field_formatter_info(). */ function editablefields_field_formatter_info() { - return array( - 'editable' => array( - 'label' => t('Editable'), - 'field types' => array_keys(_content_field_types()), - ), - 'clicktoedit' => array( - 'label' => t('Click to Edit'), - 'field types' => array_keys(_content_field_types()), - ), - ); + $content_types = _content_field_types(); + $formatters = array(); + + foreach ($content_types as $type => $data) { + foreach ($data['formatters'] as $formatter => $info) { + if (!isset($formatters['editable_'.$formatter])) { + $formatters['editable_'.$formatter] = array( + 'label' => t($info['label'].' - Editable'), + 'field types' => $info['field types'], + ); + } + if (!isset($formatters['clicktoedit_'.$formatter])) { + $formatters['clicktoedit_'.$formatter] = array( + 'label' => t($info['label'].' - Click to Edit'), + 'field types' => $info['field types'], + ); + } + } + + } + return $formatters; } /** @@ -76,21 +98,19 @@ function theme_editablefields_formatter_ if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) { } - - + + $formatter_name = preg_replace('/^[^_]*_/', '', $element['#formatter']); // See if access to this form element is restricted, // if so, skip widget processing and just set the value. if (!node_access('update',$node) || !content_access('edit', $field)) { // can't edit - $formatter_name = 'default'; if ($formatter = _content_get_formatter($formatter_name, $field['type'])) { $theme = $formatter['module'] .'_formatter_'. $formatter_name; return theme($theme, $element); } } else { - $formatter_name = 'default'; if ($formatter = _content_get_formatter($formatter_name, $field['type'])) { if (!isset($js_ready)) { $js_ready = TRUE; @@ -107,7 +127,7 @@ function theme_editablefields_formatter_ } $theme = $formatter['module'] .'_formatter_'. $formatter_name; $class="editablefields"; - if ($element['#formatter'] == 'clicktoedit') { + if (preg_match('/^clicktoedit_/', $element['#formatter'])) { $class .=" clicktoedit"; } // CORE handling shoudl have a div on each,