--- X:/Homepages/drupal/module/_0809/filterbynodetype/filterbynodetype.module Mon Jun 11 07:55:26 2007 +++ X:/Homepages/drupal/module/_0809/_issues/filterbynodetype_default filter/filterbynodetype.module Sat Sep 13 18:37:26 2008 @@ -1,5 +1,5 @@ format] = $format->name; //needed for Format default selection $form['format_' . $format->format] = array( '#type' => 'fieldset', '#title' => t($format->name), @@ -96,6 +105,23 @@ ); } } + //FORMAT DEFAULT selection + $form['format_default'] = array( + '#type' => 'fieldset', + '#title' => t("Default Format"), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#tree' => FALSE, + ); + foreach ($types as $type) { + $form['format_default']['filterbynodetype_default_' . $type->type] = array( + '#type' => 'select', + '#options' => $options, + '#title' => t($type->name), + '#default_value' => variable_get('filterbynodetype_default_' . $type->type, 0), + ); + } + return system_settings_form($form); } @@ -128,4 +154,27 @@ $output .= drupal_render($form); return $output; +} + +//Adds Default Filter to Node handling +function filterbynodetype_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { + + if (!$node->format) { + + //Get Default Format from settings + $default = variable_get('filterbynodetype_default_' . $node->type, 0); + $formats = filter_formats(); + if ($default && in_array($default,array_keys($formats))) { + $default_format = $default; + } + //no node-type specific default format set or author is not allowed to use node-type specific default formatter + else { + //use site wide default formatter + $default_format = variable_get('filter_default_format', 1); + } + //GLOBAL $conf; + //$conf['filter_default_format'] = $default_format; + $node->format = $default_format; + } + }