Index: adsense.module =================================================================== RCS file: /cvs/drupal/contributions/modules/adsense/adsense.module,v retrieving revision 1.28 diff -u -r1.28 adsense.module --- adsense.module 4 Jan 2006 14:46:55 -0000 1.28 +++ adsense.module 7 Jan 2006 20:59:32 -0000 @@ -6,6 +6,27 @@ define(ADSENSE_MAX_GROUPS, 3); define(ADSENSE_MAX_CHANNELS, 5); +define(ADSENSE_PROFILE_CLIENT_ID, 'profile_google_adsense_client'); +define(ADSENSE_CLIENT_ID, 'adsense_client_id'); +define(ADSENSE_VISIBILITY, 'adsense_visibility'); +define(ADSENSE_ACCESS_PAGES, 'adsense_access_pages'); +define(ADSENSE_AD_TYPE, 'adsense_ad_type_'); +define(ADSENSE_COLOR_TEXT, 'adsense_color_text_'); +define(ADSENSE_COLOR_BORDER, 'adsense_color_border_'); +define(ADSENSE_COLOR_BG, 'adsense_color_bg_'); +define(ADSENSE_COLOR_LINK, 'adsense_color_link_'); +define(ADSENSE_COLOR_URL, 'adsense_color_url_'); +define(ADSENSE_ALT, 'adsense_alt_'); +define(ADSENSE_ALT_INFO, 'adsense_alt_info_'); +define(ADSENSE_AD_CHANNEL, 'adsense_ad_channel_'); +define(ADSENSE_REVENUE_ENABLE, 'adsense_revenue_enable'); +define(ADSENSE_PERCENTAGE, 'adsense_percentage'); +define(ADSENSE_NODE_TYPE, 'adsense_node_type_'); +define(ADSENSE_DISABLE, 'adsense_disable'); +define(ADSENSE_PLACEHOLDER, 'adsense_placeholder'); +define(ADSENSE_PLACEHOLDER_TEXT, 'adsense_placeholder_text'); +define(ADSENSE_PAGE_AD_LIMIT, 'adsense_page_ad_limit'); +define(ADSENSE_SECTION_TARGETING, 'adsense_section_targeting'); /** * This is the array that holds all ad formats. @@ -41,6 +62,30 @@ ); } +define(ADSENSE_MAX_GROUPS, 3); +define(ADSENSE_MAX_CHANNELS, 5); +define(ADSENSE_PROFILE_CLIENT_ID, 'profile_google_adsense_client'); +define(ADSENSE_CLIENT_ID, 'adsense_client_id'); +define(ADSENSE_VISIBILITY, 'adsense_visibility'); +define(ADSENSE_ACCESS_PAGES, 'adsense_access_pages'); +define(ADSENSE_AD_TYPE, 'adsense_ad_type_'); +define(ADSENSE_COLOR_TEXT, 'adsense_color_text_'); +define(ADSENSE_COLOR_BORDER, 'adsense_color_border_'); +define(ADSENSE_COLOR_BG, 'adsense_color_bg_'); +define(ADSENSE_COLOR_LINK, 'adsense_color_link_'); +define(ADSENSE_COLOR_URL, 'adsense_color_url_'); +define(ADSENSE_ALT, 'adsense_alt_'); +define(ADSENSE_ALT_INFO, 'adsense_alt_info_'); +define(ADSENSE_AD_CHANNEL, 'adsense_ad_channel_'); +define(ADSENSE_REVENUE_ENABLE, 'adsense_revenue_enable'); +define(ADSENSE_PERCENTAGE, 'adsense_percentage'); +define(ADSENSE_NODE_TYPE, 'adsense_node_type_'); +define(ADSENSE_DISABLE, 'adsense_disable'); +define(ADSENSE_PLACEHOLDER, 'adsense_placeholder'); +define(ADSENSE_PLACEHOLDER_TEXT, 'adsense_placeholder_text'); +define(ADSENSE_PAGE_AD_LIMIT, 'adsense_page_ad_limit'); +define(ADSENSE_SECTION_TARGETING, 'adsense_section_targeting'); + function adsense_get_ad_code($format) { $all_ads = adsense_ad_formats(); return $all_ads[$format]['code']; @@ -130,6 +175,11 @@
To enable the tags feature, you have to enable the AdSense filter in the input format you are using (e.g. Full HTML or Filtered HTML) from Administer >> Input Formats. Then you have to insert the appropriate tag anywhere in your node where you like the ad to appear.
Note that filters sometimes may have conflicts, and changing the order can make adsense work in some cases.
+For revenue sharing, each author gets an predefined share of ad revenue from clicks occuring on nodes they authored.
+In order for the user to be credited they must have a Google AdSense account before getting ad revenue. As a site admin, please advertise the module\'s author referral link, which provides us with a referral fee from Google, with absolutely no cost to you. This page also contains various useful links and resources on Adsense, and how to optimize your site for it.
+You must setup a profile text field called profile_google_adsense_client. The user must enter the Google Adsense client ID in their profile.
+The site administrator will not see ads displayed as long as they are logged in. @@ -297,6 +347,42 @@ ); } + $form['revenue'] = array( + '#type' => 'fieldset', + '#collapsible' => true, + '#title' => t('Revenue sharing options'), + ); + + $form['revenue'][ADSENSE_REVENUE_ENABLE] = array( + '#type' => 'checkbox', + '#title' => t('Enable Revenue Sharing'), + '#return_value' => 1, + '#default_value' => variable_get(ADSENSE_REVENUE_ENABLE, '0'), + ); + + $form['revenue'][ADSENSE_PERCENTAGE] = array( + '#type' => 'select', + '#title' => t('Percentage of node views going to author'), + '#default_value' => variable_get(ADSENSE_PERCENTAGE, 0), + '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 100)), + ); + + $form['revenue']['content_types'] = array( + '#type' => 'fieldset', + '#collapsible' => true, + '#title' => t('Content types'), + '#description' => t('Content types that have revenue sharing enabled.'), + ); + + foreach(node_get_types() as $type) { + $form['revenue']['content_types'][ADSENSE_NODE_TYPE . $type] = array( + '#type' => 'checkbox', + '#title' => $type, + '#return_value' => 1, + '#default_value' => variable_get(ADSENSE_NODE_TYPE . $type, 0), + ); + } + $form['advanced'] = array( '#type' => 'fieldset', '#collapsible' => true, @@ -388,7 +474,12 @@ return $ad; } function _adsense_get_ad($format, $group, $channel) { - + $sharing = variable_get(ADSENSE_REVENUE_ENABLE, 0); + if ($sharing) { + $ad = _adsense_format($format, $group, $channel); + return $ad; + } + $cache_key = "adsense-$group-$format-$channel"; $cache = cache_get($cache_key); if ($cache) { @@ -406,9 +497,9 @@ } function _adsense_check_if_enabled() { + $client_id = adsense_get_client_id(); - $client_id = variable_get('adsense_client_id', ''); - $disable_ads = variable_get('adsense_disable', '0'); + $disable_ads = variable_get(ADSENSE_DISABLE, '0'); if (!$client_id) { // Google AdSense Client ID is not configured @@ -427,7 +518,7 @@ } function _adsense_check_placeholder() { - if (variable_get('adsense_placeholder', '1')) { + if (variable_get(ADSENSE_PLACEHOLDER, '1')) { // Ads are globally disabled and a place holder is set return true; } @@ -441,7 +532,7 @@ $width = _adsense_get_width($format); $height = _adsense_get_height($format); - $placeholder_text = variable_get('adsense_placeholder_text', t('Google AdSense placeholder here')); + $placeholder_text = variable_get(ADSENSE_PLACEHOLDER_TEXT, t('Google AdSense placeholder here')); $output = '