Index: adsense_injector.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/adsense_injector.admin.inc,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 adsense_injector.admin.inc --- adsense_injector.admin.inc 16 Dec 2008 09:25:58 -0000 1.1.2.3 +++ adsense_injector.admin.inc 17 Dec 2008 06:02:24 -0000 @@ -74,42 +74,23 @@ function adsense_injector_admin_settings /** * What kinds of nodes do we want to insert on...? */ - $form['injection_control'] = array( + $form['content_types'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => FALSE, - '#title' => t('Select Node Types for Insertion'), - '#description' => t('Nodes types to display inline ads - ads are inserted only in the selected node types.'), + '#title' => t('Content types'), ); /** * Enumerate node types, and set up form fields for each. */ - $enabled_count = 0; - $nodetypes = array(); - foreach (node_get_types() as $type => $obj) { - $nodetypes[$type] = $obj->name; - $enabled = variable_get(ADSENSE_INJECTOR_INSERT_AD_NODETYPE . $type, FALSE); - if ($enabled) $enabled_count++; - $form['injection_control']['node_types'][ADSENSE_INJECTOR_INSERT_AD_NODETYPE . $type] = array( - '#type' => 'checkbox', - '#title' => $obj->name, - '#default_value' => $enabled, - '#description' => t('Display inline ads on %nodetype nodes', array('%nodetype' => $obj->name)), - '#required' => FALSE, - ); - } - - // Do some sanity checking. - if ($enabled_count == 0) { - $msg = t('No node types selected (no ads will be inserted because you haven\'t selected any node types for automatic ad insertion.)'); - $form['injection_control']['#collapsed'] = FALSE; - $form['injection_control']['no_nodes_enabled'] = array( - '#type' => 'markup', - '#weight' => -1, - '#value' => '
'. $msg .'
', - ); - } + $form['content_types']['adsense_injector_nodes'] = array( + '#type' => 'checkboxes', + '#title' => t('Content types'), + '#default_value' => variable_get('adsense_injector_nodes', array()), + '#options' => array_map('check_plain', node_get_types('names')), + '#description' => t('Select content types to display inline ads.'), + ); } return system_settings_form($form); Index: adsense_injector.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/adsense_injector.module,v retrieving revision 1.1.2.6.2.3.2.1 diff -u -p -r1.1.2.6.2.3.2.1 adsense_injector.module --- adsense_injector.module 17 Dec 2008 01:42:48 -0000 1.1.2.6.2.3.2.1 +++ adsense_injector.module 17 Dec 2008 06:02:24 -0000 @@ -13,12 +13,6 @@ define('ADSENSE_INJECTOR_APPEND_IN_LISTV define('ADSENSE_INJECTOR_LISTVIEW_INSERTION_TEMPLATE_DEFAULT', '%teaser
[adsense:468x60:1:1]
'); /** - * Prefix for variable table entries - append node type name, store as boolean - * value, nonzero means insert ad content. - */ -define('ADSENSE_INJECTOR_INSERT_AD_NODETYPE', 'adsense_injector_nodetype_'); - -/** * Implementation of hook_nodeapi(). * * If rendering a full page, and the node type one of the configured types, @@ -29,7 +23,8 @@ define('ADSENSE_INJECTOR_INSERT_AD_NODET function adsense_injector_nodeapi(&$node, $op, $teaser, $page) { // insert an ad into the body. if ($op == 'alter') { - if (module_exists('adsense') && _adsense_page_match() && variable_get(ADSENSE_INJECTOR_INSERT_AD_NODETYPE . $node->type, FALSE)) { + $node_type = variable_get('adsense_injector_nodes', array()); + if (module_exists('adsense') && _adsense_page_match() && !empty($node_type[$node->type])) { if ($page) { if (variable_get('adsense_injector_insert_body_ad', ADSENSE_INJECTOR_INSERT_BODY_AD_DEFAULT)) { $body = $node->body;