--- _filterbynodetype.module 2007-06-18 07:39:03.000000000 +0200 +++ filterbynodetype.module 2007-06-18 07:52:26.000000000 +0200 @@ -37,34 +37,35 @@ function filterbynodetype_form_alter($fo } } - if (2 == count(element_children($formats))) { // 1 format and 1 extra item for the link - // If there's only one filter left, fold it down to just the description - $formats = $form['body_filter']['format']; - unset($form['body_filter']['format']); + if (count(element_children($formats)) <= 2) { // 1 format and 1 extra item for the link // We don't know what the IDs are of the two fields, so we have to iterate to get them. foreach (element_children($formats) as $element) { if (isset($formats[$element]['#title'])) { // This is a filter, so we assign it to the filter set as the only option. - $form['body_filter']['format'][$element] = array( + $formats[$element] = array( '#type' => 'value', '#value' => $element, - '#parents' => array('format'), + '#parents' => $formats[$element]['#parents'], ); - $form['body_filter']['format']['format'] = array( // I have no idea why it uses this structure, but this is what filter.module does. + $formats['format'] = array( // I have no idea why it uses this structure, but this is what filter.module does. '#type' => 'item', '#description' => $formats[$element]['#description'], ); - } - else { - // It's the guidelines text. - $form['body_filter']['format']['guidelines_link'] = array( - '#value' => $formats[$element]['#value'], - ); + foreach (element_properties($formats) as $element) { + unset($formats[$element]); + } } } } - if (1 == count(element_children($formats))) { // 1 extra item for the link, which means there's no filters left - // Do nothing. The form becomes unsubmittable all on its own. + if (module_exists('content') && module_exists('text')) { + $fields = db_query("SELECT field_name FROM {node_field_instance} WHERE type_name = '%s' AND widget_type = 'text';",$type); + while($field = db_fetch_object($fields)) { + foreach (element_children($form[$field->field_name]) as $element) { + if (isset($form[$field->field_name][$element]['format'])) { + $form[$field->field_name][$element]['format'] = $formats; + } + } + } } } }