Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/CHANGELOG.txt,v retrieving revision 1.1.2.1.2.7 retrieving revision 1.1.4.4.2.5 diff -u -p -w -b -B -r1.1.2.1.2.7 -r1.1.4.4.2.5 --- CHANGELOG.txt 17 Dec 2008 02:05:23 -0000 1.1.2.1.2.7 +++ CHANGELOG.txt 17 Dec 2008 02:04:44 -0000 1.1.4.4.2.5 @@ -1,7 +1,27 @@ -// $Id: CHANGELOG.txt,v 1.1.2.1.2.7 2008/12/17 02:05:23 hswong3i Exp $ +// $Id: CHANGELOG.txt,v 1.1.4.4.2.5 2008/12/17 02:04:44 hswong3i Exp $ -AdSense Injector 5.x-2.x-dev, xxxx-xx-xx (development version) +AdSense Injector 6.x-2.x-dev, xxxx-xx-xx (development version) ---------------------- +- simplify legacy _adsense_injector_count_words(). +- simplify legacy _adsense_injector_minwords_cfg(). + +AdSense Injector 6.x-2.6-rc1, 2008-12-16 +---------------------- +- completely upgrade and port to D6. +- version number starting with 2.6 (sync with D5). +- tested with adsense 6.x-1.0-beta3. +- renew hook_menu(). D6 coming with new implementation. +- watchdog() no longer require for t(). +- hook_nodeapi() coming with new implementation for D6. +- split admin related hook_settings() to adsense_injector.admin.inc. +- retouch adsense_injector.info so group this module with Adsense. +- coding style cleanup. +- validate code with coder module. +- add more documentation. +- clean up license and developer information. +- document project owner and co-maintainer. +- remove legacy admin setting paypal banner. +- remove legacy _dbg(). AdSense Injector 5.x-2.6, 2008-12-16 ---------------------- Index: LICENSE.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/LICENSE.txt,v retrieving revision 1.1.2.1 retrieving revision 1.1.4.2 diff -u -p -w -b -B -r1.1.2.1 -r1.1.4.2 --- LICENSE.txt 16 Dec 2008 08:16:56 -0000 1.1.2.1 +++ LICENSE.txt 16 Dec 2008 08:18:18 -0000 1.1.4.2 @@ -1,4 +1,4 @@ -// $Id: LICENSE.txt,v 1.1.2.1 2008/12/16 08:16:56 hswong3i Exp $ +// $Id: LICENSE.txt,v 1.1.4.2 2008/12/16 08:18:18 hswong3i Exp $ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/README.txt,v retrieving revision 1.1.2.1.2.2 retrieving revision 1.1.4.3 diff -u -p -w -b -B -r1.1.2.1.2.2 -r1.1.4.3 --- README.txt 16 Dec 2008 08:50:57 -0000 1.1.2.1.2.2 +++ README.txt 16 Dec 2008 08:59:55 -0000 1.1.4.3 @@ -1,4 +1,4 @@ -// $Id: README.txt,v 1.1.2.1.2.2 2008/12/16 08:50:57 hswong3i Exp $ +// $Id: README.txt,v 1.1.4.3 2008/12/16 08:59:55 hswong3i Exp $ ABOUT ADSENSE INJECTOR ---------------------- Index: adsense_injector.admin.inc =================================================================== RCS file: adsense_injector.admin.inc diff -N adsense_injector.admin.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ adsense_injector.admin.inc 16 Dec 2008 09:25:58 -0000 1.1.2.3 @@ -0,0 +1,116 @@ + 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#title' => t('Node body ad insertion'), + '#description' => t('Requires adsense.module'), + ); + + if (module_exists('adsense')) { + $form['node_ad_body_insertion']['adsense_injector_insert_body_ad'] = array( + '#type' => 'checkbox', + '#title' => t('Insert inline ad in node body on page views'), + '#default_value' => variable_get('adsense_injector_insert_body_ad', ADSENSE_INJECTOR_INSERT_BODY_AD_DEFAULT), + '#description' => t('Description'), + '#required' => FALSE, + ); + $form['node_ad_body_insertion']['adsense_injector_body_minwords'] = array( + '#type' => 'textfield', + '#title' => t('Minimum node body word count'), + '#default_value' => variable_get('adsense_injector_body_minwords', ADSENSE_INJECTOR_BODY_MINWORDS_DEFAULT), + '#description' => t('The minimum node body word count threshold - only inject if node body has at least this many words.'), + ); + $form['node_ad_body_insertion']['adsense_injector_body_template'] = array( + '#type' => 'textarea', + '#title' => t('Node body ad insertion template'), + '#rows' => 5, + '#cols' => 40, + '#default_value' => variable_get('adsense_injector_body_template', ADSENSE_INJECTOR_BODY_INSERTION_TEMPLATE_DEFAULT), + '#description' => t('Ad insertion template. Substitution variables: %body = full node body text. Insert adsense module filter tags. See the adsense.module settings page for a list of supported formats and help with filter tags.'), + '#required' => TRUE, + ); + + /** + * 'list' insertion (frontpage, taxonomy, etc). + */ + $form['node_ad_list_insertion'] = array( + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#title' => t('Node list ad insertion'), + '#description' => t('Ad insertion in node lists or other non-page view, like front page, taxonomy views.'), + ); + $form['node_ad_list_insertion']['adsense_injector_append_in_listview'] = array( + '#type' => 'checkbox', + '#title' => t('Append an ad after teaser on frontpage and taxonomy lists'), + '#default_value' => variable_get('adsense_injector_append_in_listview', ADSENSE_INJECTOR_APPEND_IN_LISTVIEW_DEFAULT), + '#description' => t('Note: this does not currently support Views module based lists.'), + '#required' => FALSE, + ); + $form['node_ad_list_insertion']['adsense_injector_listview_insertion_template'] = array( + '#type' => 'textarea', + '#title' => t('List ad insertion template'), + '#rows' => 3, + '#cols' => 40, + '#default_value' => variable_get('adsense_injector_listview_insertion_template', ADSENSE_INJECTOR_LISTVIEW_INSERTION_TEMPLATE_DEFAULT), + '#description' => t('Template to use when inserting adsense ad. "%teaser" will be replaced with the node teaser. Insert adsense filter tags. See the adsense.module settings page for a list of supported formats and help with filter tags.'), + '#required' => TRUE, + ); + + /** + * What kinds of nodes do we want to insert on...? + */ + $form['injection_control'] = 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.'), + ); + + /** + * 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 .'
', + ); + } + } + + return system_settings_form($form); +} Index: adsense_injector.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/adsense_injector.info,v retrieving revision 1.1.2.4.2.1 retrieving revision 1.1.2.2.2.1.2.1 diff -u -p -w -b -B -r1.1.2.4.2.1 -r1.1.2.2.2.1.2.1 --- adsense_injector.info 16 Dec 2008 16:08:49 -0000 1.1.2.4.2.1 +++ adsense_injector.info 16 Dec 2008 16:08:30 -0000 1.1.2.2.2.1.2.1 @@ -1,6 +1,7 @@ -; $Id: adsense_injector.info,v 1.1.2.4.2.1 2008/12/16 16:08:49 hswong3i Exp $ +; $Id: adsense_injector.info,v 1.1.2.2.2.1.2.1 2008/12/16 16:08:30 hswong3i Exp $ name = AdSense Injector description = Insert adsense ads into full-page node view, and front page or other list views automatically. -dependencies = adsense +dependencies[] = adsense package = Adsense +core = 6.x Index: adsense_injector.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adsense_injector/adsense_injector.module,v retrieving revision 1.1.2.8.2.7 retrieving revision 1.1.2.6.2.3.2.1 diff -u -p -w -b -B -r1.1.2.8.2.7 -r1.1.2.6.2.3.2.1 --- adsense_injector.module 17 Dec 2008 01:43:13 -0000 1.1.2.8.2.7 +++ adsense_injector.module 17 Dec 2008 01:42:48 -0000 1.1.2.6.2.3.2.1 @@ -1,5 +1,5 @@ type, FALSE)) { if ($page) { if (variable_get('adsense_injector_insert_body_ad', ADSENSE_INJECTOR_INSERT_BODY_AD_DEFAULT)) { - $body = $node->content['body']['#value']; + $body = $node->body; // Get the minimum node body wordcount for insertion. $minwords = variable_get('adsense_injector_body_minwords', ADSENSE_INJECTOR_BODY_MINWORDS_DEFAULT); // Count words in a string. @@ -45,12 +45,12 @@ function adsense_injector_nodeapi(&$node $template = _adsense_process_tags($template); } else { - watchdog('adsense_injector', t('adsense module function _adsense_process_tags() not found'), WATCHDOG_ERROR); + watchdog('adsense_injector', 'adsense module function _adsense_process_tags() not found', WATCHDOG_ERROR); } - $node->content['body']['#value'] = strtr($template, array('%body' => $body)); + $node->body = strtr($template, array('%body' => $body)); } else { - $node->content['body']['#value'] = "". $body; + $node->body = "". $body; } } } @@ -61,9 +61,9 @@ function adsense_injector_nodeapi(&$node $template = _adsense_process_tags($template); } else { - watchdog('adsense_injector', t('adsense module function _adsense_process_tags() not found'), WATCHDOG_ERROR); + watchdog('adsense_injector', 'adsense module function _adsense_process_tags() not found', WATCHDOG_ERROR); } - $node->content['body']['#value'] = strtr($template, array('%teaser' => $node->teaser)); + $node->body = strtr($template, array('%teaser' => $node->teaser)); } } } @@ -73,124 +73,14 @@ function adsense_injector_nodeapi(&$node * Implementation of hook_menu(). */ function adsense_injector_menu() { - $items[] = array( - 'path' => 'admin/settings/adsense_injector', - 'title' => t('AdSense Injector'), - 'description' => t('Insert Google AdSense ads into full node views automatically.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('adsense_injector_admin_settings'), - 'access' => user_access('administer site configuration'), + $items['admin/settings/adsense_injector'] = array( + 'title' => 'AdSense Injector', + 'description' => 'Insert Google AdSense ads into full node views automatically.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('adsense_injector_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'file' => 'adsense_injector.admin.inc', 'type' => MENU_NORMAL_ITEM, ); return $items; } - - -/** - * Implementation of hook_settings(). - */ -function adsense_injector_admin_settings() { - $form = array(); - - $form['node_ad_body_insertion'] = array( - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => FALSE, - '#title' => t('Node body ad insertion'), - '#description' => t('Requires adsense.module'), - ); - - if (module_exists('adsense')) { - $form['node_ad_body_insertion']['adsense_injector_insert_body_ad'] = array( - '#type' => 'checkbox', - '#title' => t('Insert inline ad in node body on page views'), - '#default_value' => variable_get('adsense_injector_insert_body_ad', ADSENSE_INJECTOR_INSERT_BODY_AD_DEFAULT), - '#description' => t('Description'), - '#required' => FALSE, - ); - $form['node_ad_body_insertion']['adsense_injector_body_minwords'] = array( - '#type' => 'textfield', - '#title' => t('Minimum node body word count'), - '#default_value' => variable_get('adsense_injector_body_minwords', ADSENSE_INJECTOR_BODY_MINWORDS_DEFAULT), - '#description' => t('The minimum node body word count threshold - only inject if node body has at least this many words.'), - ); - $form['node_ad_body_insertion']['adsense_injector_body_template'] = array( - '#type' => 'textarea', - '#title' => t('Node body ad insertion template'), - '#rows' => 5, - '#cols' => 40, - '#default_value' => variable_get('adsense_injector_body_template', ADSENSE_INJECTOR_BODY_INSERTION_TEMPLATE_DEFAULT), - '#description' => t('Ad insertion template. Substitution variables: %body = full node body text. Insert adsense module filter tags. See the adsense.module settings page for a list of supported formats and help with filter tags.'), - '#required' => TRUE, - ); - - /** - * 'list' insertion (frontpage, taxonomy, etc). - */ - $form['node_ad_list_insertion'] = array( - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => FALSE, - '#title' => t('Node list ad insertion'), - '#description' => t('Ad insertion in node lists or other non-page view, like front page, taxonomy views.'), - ); - $form['node_ad_list_insertion']['adsense_injector_append_in_listview'] = array( - '#type' => 'checkbox', - '#title' => t('Append an ad after teaser on frontpage and taxonomy lists'), - '#default_value' => variable_get('adsense_injector_append_in_listview', ADSENSE_INJECTOR_APPEND_IN_LISTVIEW_DEFAULT), - '#description' => t('Note: this does not currently support Views module based lists.'), - '#required' => FALSE, - ); - $form['node_ad_list_insertion']['adsense_injector_listview_insertion_template'] = array( - '#type' => 'textarea', - '#title' => t('List ad insertion template'), - '#rows' => 3, - '#cols' => 40, - '#default_value' => variable_get('adsense_injector_listview_insertion_template', ADSENSE_INJECTOR_LISTVIEW_INSERTION_TEMPLATE_DEFAULT), - '#description' => t('Template to use when inserting adsense ad. "%teaser" will be replaced with the node teaser. Insert adsense filter tags. See the adsense.module settings page for a list of supported formats and help with filter tags.'), - '#required' => TRUE, - ); - - /** - * What kinds of nodes do we want to insert on...? - */ - $form['injection_control'] = 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.'), - ); - - /** - * 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 .'
', - ); - } - } - - return system_settings_form($form); -}