/[drupal]/contributions/modules/textlinkads/textlinkads.module
ViewVC logotype

Diff of /contributions/modules/textlinkads/textlinkads.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5, Sat Feb 10 04:32:46 2007 UTC revision 1.6, Thu Jun 5 23:36:00 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id$
3    
4  define('TEXTLINKADS_VERSION', '$Id: textlinkads.module,v 1.4 2007/02/10 04:24:40 kbahey Exp $');  define('TEXTLINKADS_VERSION', '$Id: textlinkads.module,v 1.5 2007/02/10 04:32:46 kbahey Exp $');
5  define('TEXTLINKADS_MODULE_PATH', drupal_get_path('module', 'textlinkads'));  //define('TEXTLINKADS_MODULE_PATH', drupal_get_path('module', 'textlinkads'));
6    
7  function textlinkads_help($section) {  function textlinkads_help($path, $arg) {
8    switch ($section) {    switch ($path) {
9      case 'admin/help#textlinkads':      case 'admin/help#textlinkads':
10        $output = '<p>'. t('The Text-Link-Ads module allows you to sell advertising space on your site via %tla', array('%tla' => '<a href="http://www.text-link-ads.com/">Text-Link-Ads.com</a>')).'</p>';        $output = '<p>'. t('The Text-Link-Ads module allows you to sell advertising space on your site via %tla', array('%tla' => '<a href="http://www.text-link-ads.com/">Text-Link-Ads.com</a>')) .'</p>';
11        $output .= '<p>'. t('With the Text-Link-Ads module: <blockquote><p>YOU can choose to approve or deny any Text Link Ads sold prior to the links being published on your website. This ensures that only quality and relevant links appear on your website.</p><p>You make money. Sales, invoicing, and customer service are all handled by TLA. You can receive payment via check or PayPal. Payments are sent to publishers the first of every month with a $25 minimum payout.</p></blockquote>') .'</p>';        $output .= '<p>'. t('With the Text-Link-Ads module: <blockquote><p>YOU can choose to approve or deny any Text Link Ads sold prior to the links being published on your website. This ensures that only quality and relevant links appear on your website.</p><p>You make money. Sales, invoicing, and customer service are all handled by TLA. You can receive payment via check or PayPal. Payments are sent to publishers the first of every month with a $25 minimum payout.</p></blockquote>') .'</p>';
12        $output .= '<p>'. t('For more information see the Text-Link-Ads.com <a href="http://www.text-link-ads.com/publisher_program.php">Publisher Program page</a>.'). '</p>';        $output .= '<p>'. t('For more information see the Text-Link-Ads.com <a href="http://www.text-link-ads.com/publisher_program.php">Publisher Program page</a>.') .'</p>';
13        $output .= '<h2>'. t('Module features'). '</h2>';        $output .= '<h2>'. t('Module features') .'</h2>';
14        $output .= '<ul><li>'. t('%Simplified_setup right on your site. All you need is your Website XML Key from Text-Link-Ads.com and you\'re ready to start publishing ads.', array('%Simplified_setup' => l(t('Simplified setup'), 'admin/settings/textlinkads'))). '</li>';        $output .= '<ul><li>'. t('%Simplified_setup right on your site. All you need is your Website XML Key from Text-Link-Ads.com and you\'re ready to start publishing ads.', array('%Simplified_setup' => l(t('Simplified setup'), 'admin/settings/textlinkads'))) .'</li>';
15        $output .= '<li>'. t('A %built_in_tool to customize the looks of the ads, including borders, background color, link color and font size.', array('%built_in_tool' => l(t('built-in tool'), 'admin/settings/textlinkads'))). '</li>';        $output .= '<li>'. t('A %built_in_tool to customize the looks of the ads, including borders, background color, link color and font size.', array('%built_in_tool' => l(t('built-in tool'), 'admin/settings/textlinkads'))) .'</li>';
16        $output .= '<li>'. t('Access to your %publisher_statistics from within your website. See your site details, including how much money you\'ve earned and how many links are being served.', array('%publisher_statistics' => l(t('publisher statistics'), 'textlinkads/stats'))). '</li>';        $output .= '<li>'. t('Access to your %publisher_statistics from within your website. See your site details, including how much money you\'ve earned and how many links are being served.', array('%publisher_statistics' => l(t('publisher statistics'), 'textlinkads/stats'))) .'</li>';
17        $output .= '<li>'. t('Cron-based updates of your ads. The ad links are kept up to date via Drupal\'s cron functionality.'). '</li></ul>';        $output .= '<li>'. t('Cron-based updates of your ads. The ad links are kept up to date via Drupal\'s cron functionality.') .'</li></ul>';
18        $output .= '<h2>'. t('Getting started'). '</h2>';        $output .= '<h2>'. t('Getting started') .'</h2>';
19        $output .= '<ol>';        $output .= '<ol>';
20        $output .= '<li>'. t('Install the module by placing it in the modules directory and enabling it from the %admin_modules page. No database changes are necessary.', array('%admin_modules page' => l('admin/modules','admin/modules'))). '</li>';        $output .= '<li>'. t('Install the module by placing it in the modules directory and enabling it from the %admin_modules page. No database changes are necessary.', array('%admin_modules page' => l('admin/modules', 'admin/modules'))) .'</li>';
21        $output .= '<li>'. t('Sign up for a <a href="http://www.text-link-ads.com/log.php?logfunc=login&action=create_account">Text-Link-Ads.com publisher account</a> and make note of your <a href="http://www.text-link-ads.com/my_account.php?view=my_sites">Website XML Key</a>.'). '</li>';        $output .= '<li>'. t('Sign up for a <a href="http://www.text-link-ads.com/log.php?logfunc=login&action=create_account">Text-Link-Ads.com publisher account</a> and make note of your <a href="http://www.text-link-ads.com/my_account.php?view=my_sites">Website XML Key</a>.') .'</li>';
22        $output .= '<li>'. t('Browse to the %admin_settings_textlinkads page on your site. Enter the <strong>Website XML Key</strong> in the field of the same name.', array('%admin_settings_textlinkads' => l('admin/settings/textlinkads', 'admin/settings/textlinkads'))). '</li>';        $output .= '<li>'. t('Browse to the %admin_settings_textlinkads page on your site. Enter the <strong>Website XML Key</strong> in the field of the same name.', array('%admin_settings_textlinkads' => l('admin/settings/textlinkads', 'admin/settings/textlinkads'))) .'</li>';
23        $output .= '<li>'. t('On the same page, enter the <strong>Ad Block Heading</strong>. Your links will be available as a block. The value you enter will be the title of the block. You may leave this field blank.'). '</li>';        $output .= '<li>'. t('On the same page, enter the <strong>Ad Block Heading</strong>. Your links will be available as a block. The value you enter will be the title of the block. You may leave this field blank.') .'</li>';
24        $output .= '<li>'. t('On the same page, use the <strong>Textlinkads Appearance Settings</strong> settings to customize the way your ad links look. Press <strong>Submit</strong> to save all of the settings for this page.'). '</li>';        $output .= '<li>'. t('On the same page, use the <strong>Textlinkads Appearance Settings</strong> settings to customize the way your ad links look. Press <strong>Submit</strong> to save all of the settings for this page.') .'</li>';
25        $output .= '<li>'. t('Now you must enable the block that will show your ad links. Browse to the %blocks_administration_page and enable the block entitled <strong>text link ads advertisments</strong>', array('%blocks_administration_page' => l(t('blocks administration page'), 'admin/block'))). '</li>';        $output .= '<li>'. t('Now you must enable the block that will show your ad links. Browse to the %blocks_administration_page and enable the block entitled <strong>text link ads advertisments</strong>', array('%blocks_administration_page' => l(t('blocks administration page'), 'admin/block'))) .'</li>';
26        $output .= '<li>'. t('Your site will communicate with the Text-Link-Ads.com site every time cron.php is run. If you have already configured cron jobs for your site ads will start appearing in the block as soon as the next cron run completes (note that Text-Link-Ads.com must sell some links for your site first). If you don\'t have cron tasks enabled follow the <a href="http://drupal.org/cron">directions found on Drupal.org</a> for doing so. You may also consider installing the <a href="http://drupal.org/project/poormanscron">Poormanscron module</a> to help. As a last resort, you can manually trigger cron by %clicking_this_link (will result in the screen going blank... that\'s normal).', array('%clicking_this_link' => url(t('clicking this link'), 'cron.php'))). '</li>';        $output .= '<li>'. t('Your site will communicate with the Text-Link-Ads.com site every time cron.php is run. If you have already configured cron jobs for your site ads will start appearing in the block as soon as the next cron run completes (note that Text-Link-Ads.com must sell some links for your site first). If you don\'t have cron tasks enabled follow the <a href="http://drupal.org/cron">directions found on Drupal.org</a> for doing so. You may also consider installing the <a href="http://drupal.org/project/poormanscron">Poormanscron module</a> to help. As a last resort, you can manually trigger cron by %clicking_this_link (will result in the screen going blank... that\'s normal).', array('%clicking_this_link' => url(t('clicking this link'), 'cron.php'))) .'</li>';
27        $output .= '<li>'. t('Once you have set everything up properly and Text-Link-Ads.com has sold some links on your site, you can %monitor_your_statistics_and_earnings from your Drupal site. All that is required is the same password that you use to log onto the Text-Link-Ads.com site. Enjoy!', array('%monitor_your_statistics_and_earnings' => l('monitor your statistics and earnings', 'textlinkads/stats'))). '</li>';        $output .= '<li>'. t('Once you have set everything up properly and Text-Link-Ads.com has sold some links on your site, you can %monitor_your_statistics_and_earnings from your Drupal site. All that is required is the same password that you use to log onto the Text-Link-Ads.com site. Enjoy!', array('%monitor_your_statistics_and_earnings' => l('monitor your statistics and earnings', 'textlinkads/stats'))) .'</li>';
28        $output .= '</ol>';        $output .= '</ol>';
29        return $output;        return $output;
30    
31      case 'admin/settings/textlinkads':      case 'admin/settings/textlinkads':
32        return '<p>'. t('You are using version %version of the Text-Link-Ads module.', array('%version' => TEXTLINKADS_VERSION)). '</p><p>'. t('For complete instructions on configuring this module, refer to the %help_pages.', array('%help_pages' => l(t('Help pages'), 'admin/help/textlinkads'))). '</p>';        return '<p>'. t('You are using version %version of the Text-Link-Ads module.', array('%version' => TEXTLINKADS_VERSION)) .'</p><p>'. t('For complete instructions on configuring this module, refer to the %help_pages.', array('%help_pages' => l(t('Help pages'), 'admin/help/textlinkads'))) .'</p>';
33    }    }
34  }  }
35    
# Line 37  function textlinkads_perm() { Line 38  function textlinkads_perm() {
38  }  }
39    
40  function textlinkads_cron() {  function textlinkads_cron() {
41    if( variable_get('textlinkads_last_update', 0) < (time() - 3600) || strlen(textlinkads_get_links('text')) < 20) {    if ( variable_get('textlinkads_last_update', 0) < (time() - 3600) || strlen(textlinkads_get_links('text')) < 20) {
42      textlinkads_check_update();      textlinkads_check_update();
43    }    }
44  }  }
45    
46  function textlinkads_menu($may_cache) {  function textlinkads_menu() {
47    $items = array();    $items = array();
48    if ($may_cache) {      $items['textlinkads/stats'] = array(
     $items[] = array(  
49        'title'    => t('TextLinkAds stats'),        'title'    => t('TextLinkAds stats'),
50        'path'     => 'textlinkads/stats',        'page callback' => 'textlinkads_stats_page',
51          'access arguments'   => array('administer text link ads'),
52        'type'     => MENU_NORMAL_ITEM,        'type'     => MENU_NORMAL_ITEM,
       'callback' => 'textlinkads_stats_page',  
       'access'   => user_access('administer text link ads'),  
53        );        );
54    
55      $items[] = array(      $items['textlinkads/update_now'] = array(
56        'path'     => 'textlinkads/update_now',        'page callback' => 'textlinkads_check_update',
57        'callback' => 'textlinkads_check_update',        'type'     => MENU_NORMAL_ITEM,
58        'type'     => MENU_CALLBACK,        'access arguments'   => array('administer text link ads'),
       'access'   => user_access('administer text link ads'),  
       );  
   
     $items[] = array(  
       'title'       => t('TextLinkAds Settings'),  
       'description' => t('Settings for the TextLinkAds module'),  
       'path'        => 'admin/settings/textlinkads',  
       'callback'    => 'drupal_get_form',  
       'callback arguments' => array('textlinkads_admin_settings'),  
       'access'      => user_access('administer text link ads'),  
       'type'        => MENU_NORMAL_ITEM,  
59        );        );
   }  
60    
61      $items['admin/settings/tla'] = array(
62        'title' => t('TextLinkAds Settings'),
63        'description' => t('Settings for the TextLinkAds module'),
64        'page callback' => 'drupal_get_form',
65        'page arguments' => array('textlinkads_admin_settings'),
66        'access arguments' => array('administer site configuration'),
67      );
68    return $items;    return $items;
69  }  }
70    
# Line 90  function textlinkads_block($op = 'list', Line 84  function textlinkads_block($op = 'list',
84    }    }
85  }  }
86    
87    function textlinkads_theme() {
88      return array(
89        'textlinkads_rss_ad' => array(
90          'arguments' => array('link'),
91        ),
92        'textlinkads_ads' => array(
93          'arguments' => array('link'),
94        ),
95        'textlinkads_stats' => array(
96          'arguments' => array('stats_data'),
97        ),
98        'textlinkads_themer_colors' => array(
99          'arguemnts' => array('form'),
100        ),
101      );
102    }
103    
104  function textlinkads_content() {  function textlinkads_content() {
105    $output = theme('textlinkads_ads', textlinkads_get_links('text'));    $output = theme('textlinkads_ads', textlinkads_get_links('text'));
106    return $output;    return $output;
107  }  }
108    
109  function textlinkads_admin_settings() {  function textlinkads_admin_settings() {
110    
111    if (!empty($_POST)) {    if (!empty($_POST)) {
112      variable_set('textlinkads_last_update', 0);      variable_set('textlinkads_last_update', 0);
113    }    }
# Line 114  function textlinkads_admin_settings() { Line 126  function textlinkads_admin_settings() {
126    );    );
127    
128    drupal_set_html_head(textlinkads_get_js());    drupal_set_html_head(textlinkads_get_js());
129      drupal_add_js(drupal_get_path('module', 'textlinkads') .'/textlinkads.js');
130    $total_options = drupal_map_assoc(array(4, 6, 8, 10));    $total_options = drupal_map_assoc(array(4, 6, 8, 10));
131    $row_options = drupal_map_assoc(array(1, 2, 3, 4, 8, 10));    $row_options = drupal_map_assoc(array(1, 2, 3, 4, 8, 10));
132    $font_options = drupal_map_assoc(array(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18));    $font_options = drupal_map_assoc(array(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18));
# Line 145  function textlinkads_admin_settings() { Line 158  function textlinkads_admin_settings() {
158      '#size' => 8,      '#size' => 8,
159      '#maxlength' => 7,      '#maxlength' => 7,
160      '#default_value' => variable_get('textlinkads_border_color', '#000000'),      '#default_value' => variable_get('textlinkads_border_color', '#000000'),
161      '#suffix' => '<a href="#" onclick="cp2.select(document.getElementById(\'edit-textlinkads_border_color\'),\'border_color_picker\');return false;" id="border_color_picker" name="border_color_picker">Pick Color</a>',      '#suffix' => '<a href="#" onclick="cp2.select(document.getElementById(\'edit-textlinkads-border-color\'),\'border_color_picker\');return false;" id="border_color_picker" name="border_color_picker">Pick Color</a>',
162      );      );
163    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_no_border'] = array(    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_no_border'] = array(
164      '#type' => 'checkbox',      '#type' => 'checkbox',
# Line 159  function textlinkads_admin_settings() { Line 172  function textlinkads_admin_settings() {
172      '#size' => 8,      '#size' => 8,
173      '#maxlength' => 7,      '#maxlength' => 7,
174      '#default_value' =>  variable_get('textlinkads_bg_color', '#ffffff'),      '#default_value' =>  variable_get('textlinkads_bg_color', '#ffffff'),
175      '#suffix' => '<a href="#" onclick="cp2.select(document.getElementById(\'edit-textlinkads_bg_color\'),\'bg_color_picker\');return false;" id="bg_color_picker" name="bg_color_picker">Pick Color</a>',      '#suffix' => '<a href="#" onclick="cp2.select(document.getElementById(\'edit-textlinkads-bg-color\'),\'bg_color_picker\');return false;" id="bg_color_picker" name="bg_color_picker">Pick Color</a>',
176      );      );
177    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_no_bg'] = array(    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_no_bg'] = array(
178      '#type' => 'checkbox',      '#type' => 'checkbox',
# Line 173  function textlinkads_admin_settings() { Line 186  function textlinkads_admin_settings() {
186      '#size' => 8,      '#size' => 8,
187      '#maxlength' => 7,      '#maxlength' => 7,
188      '#default_value' =>  variable_get('textlinkads_link_color', '#0000ff'),      '#default_value' =>  variable_get('textlinkads_link_color', '#0000ff'),
189      '#suffix' => '<a href="#" onclick="cp2.select(document.getElementById(\'edit-textlinkads_link_color\'),\'link_color_picker\');return false;" id="link_color_picker" name="link_color_picker">Pick Color</a>',      '#suffix' => '<a href="#" onclick="cp2.select(document.getElementById(\'edit-textlinkads-link-color\'),\'link_color_picker\');return false;" id="link_color_picker" name="link_color_picker">Pick Color</a>',
190      );      );
191    
192    $form['textlinkads_themer']['textlinkads_preview'] = array('#type' => 'fieldset', '#title' => t('Example'));    $form['textlinkads_themer']['textlinkads_preview'] = array('#type' => 'fieldset', '#title' => t('Example'));
# Line 208  function textlinkads_stats_page() { Line 221  function textlinkads_stats_page() {
221    }    }
222  }  }
223    
224  function textlinkads_stats_page_form() {  function textlinkads_stats_page_form($form_state) {
225    $form['textlinkads_password'] = array(    $form['textlinkads_password'] = array(
226      '#type'       => 'password',      '#type'       => 'password',
227      '#title'      => t('Password'),      '#title'      => t('Password'),
# Line 219  function textlinkads_stats_page_form() { Line 232  function textlinkads_stats_page_form() {
232      '#type'  => 'value',      '#type'  => 'value',
233      '#value' => variable_get('textlinkads_website_xml_key', ''),      '#value' => variable_get('textlinkads_website_xml_key', ''),
234      );      );
235    $form['op'] = array(    $form['values']['op'] = array(
236      '#type'  => 'submit',      '#type'  => 'submit',
237      '#value' => t('Submit')      '#value' => t('Submit Settings')
238      );      );
239    $form['#base'] = 'textlinkads_stats_page';    $form['#submit'][] = 'textlinkads_stats_page_submit';
240      $form['#validate'][] = 'textlinkads_stats_page_validate';
241    return $form;    return $form;
242  }  }
243    
244  function textlinkads_stats_page_validate($form_id, &$form_values) {  function textlinkads_stats_page_validate($form, &$form_state) {
245    if (!$form_values['textlinkads_password'] && !$_SESSION['textlinkads_password']) {    if (!$form_state['values']['textlinkads_password'] && !$_SESSION['textlinkads_password']) {
246      form_set_error('textlinkads_password', t('Please enter your password'));      form_set_error('textlinkads_password', t('Please enter your password'));
247      return;      return;
248    }    }
249    $_SESSION['textlinkads_xml'] = file_get_contents('http://www.text-link-ads.com/publisher_stats_xml.php?xml_key='    $_SESSION['textlinkads_xml'] = file_get_contents('http://www.text-link-ads.com/publisher_stats_xml.php?xml_key='
250      . $form_values['textlinkads_xml_key']      . $form_state['values']['textlinkads_xml_key']
251      . '&password='      .'&password='
252      . ($_SESSION['textlinkads_password'] ? $_SESSION['textlinkads_password'] : $_SESSION['textlinkads_password'] = md5($form_values['textlinkads_password'])));      . ($_SESSION['textlinkads_password'] ? $_SESSION['textlinkads_password'] : $_SESSION['textlinkads_password'] = md5($form_state['values']['textlinkads_password'])));
253    
254    if ((strpos('<?xml version="1.0" ?>', $_SESSION['textlinkads_xml']) !== 0) && (strpos('invalid password', strtolower($_SESSION['textlinkads_xml'])) !== false)) {    if ((strpos('<?xml version="1.0" ?>', $_SESSION['textlinkads_xml']) !== 0) && (strpos('invalid password', strtolower($_SESSION['textlinkads_xml'])) !== false)) {
255      drupal_set_message(t('Invalid password'), 'error');      drupal_set_message(t('Invalid password'), 'error');
# Line 244  function textlinkads_stats_page_validate Line 257  function textlinkads_stats_page_validate
257    }    }
258  }  }
259    
260  function textlinkads_stats_page_submit($form_id, $form_values) {  function textlinkads_stats_page_submit($form, $form_state) {
261    if (!form_get_errors() && $_SESSION['textlinkads_password']) {    if (!form_get_errors() && $_SESSION['textlinkads_password']) {
262      textlinkads_stats_page_show();      textlinkads_stats_page_show();
263    }    }
# Line 278  function theme_textlinkads_ads($links) { Line 291  function theme_textlinkads_ads($links) {
291    $no_border = variable_get('textlinkads_no_border', 0);    $no_border = variable_get('textlinkads_no_border', 0);
292    $no_bg = variable_get('textlinkads_no_bg', 0);    $no_bg = variable_get('textlinkads_no_bg', 0);
293    
294    $output =  "<table style='width: 100%; margin: 5px auto;border: " . ($no_border ? 'none' : "1px solid $border_color") .  "; border-spacing: 0px;background: " . ($no_bg ? 'transparent' : $bg_color). ";' cellpadding='5' cellspacing='0'><tbody>";    $output =  '<table style="width: 100%; margin: 5px auto;border: '. ($no_border ? 'none' : "1px solid $border_color") .'; border-spacing: 0px;background: '. ($no_bg ? 'transparent' : $bg_color) .';" cellpadding="5" cellspacing="0"><tbody>';
295    
296    while (count($links) > 0) {    while (count($links) > 0) {
297      $output .= "<tr>";      $output .= "<tr>";
# Line 300  function theme_textlinkads_ads($links) { Line 313  function theme_textlinkads_ads($links) {
313    
314  function theme_textlinkads_stats($stats_data) {  function theme_textlinkads_stats($stats_data) {
315    $last_update = format_date(variable_get('textlinkads_last_update', 0), 'custom', 'Y-m-d G:i:s') .    $last_update = format_date(variable_get('textlinkads_last_update', 0), 'custom', 'Y-m-d G:i:s') .
316      ' ' . l('(Update now)', 'textlinkads/update_now');      ' '. l(t('Update now'), 'textlinkads/update_now');
317    $header = array('', '');    $header = array('', '');
318    $rows[] = array("domain:", $stats_data['WEBSITE']['STATS']['DOMAIN']);    $rows[] = array("domain:", $stats_data['WEBSITE']['STATS']['DOMAIN']);
319    $rows[] = array("description:", $stats_data['WEBSITE']['STATS']['DESCRIPTION']);    $rows[] = array("description:", $stats_data['WEBSITE']['STATS']['DESCRIPTION']);
# Line 331  function theme_textlinkads_stats($stats_ Line 344  function theme_textlinkads_stats($stats_
344  function theme_textlinkads_themer_colors($form) {  function theme_textlinkads_themer_colors($form) {
345    
346    $output .= '<table>';    $output .= '<table>';
347    $output .= '<tr><td>'  . drupal_render($form['textlinkads_border_color']) . '</td><td>' . drupal_render($form['textlinkads_no_border']) . '</td></tr>';    $output .= '<tr><td>'. drupal_render($form['textlinkads_border_color']) .'</td><td>'. drupal_render($form['textlinkads_no_border']) .'</td></tr>';
348    $output .= '<tr><td>' . drupal_render($form['textlinkads_bg_color']). '</td><td>' . drupal_render($form['textlinkads_no_bg']) . '</td></tr>';    $output .= '<tr><td>'. drupal_render($form['textlinkads_bg_color']) .'</td><td>'. drupal_render($form['textlinkads_no_bg']) .'</td></tr>';
349    $output .= '</table>';    $output .= '</table>';
350    $output .= drupal_render($form);    $output .= drupal_render($form);
351    
# Line 346  function theme_textlinkads_themer_colors Line 359  function theme_textlinkads_themer_colors
359   */   */
360  function textlinkads_check_update() {  function textlinkads_check_update() {
361    $CONNECTION_TIMEOUT = 10;    $CONNECTION_TIMEOUT = 10;
362    $url = 'http://www.text-link-ads.com/xml.php?inventory_key=' . check_plain(variable_get(textlinkads_website_xml_key, ''))    $url = 'http://www.text-link-ads.com/xml.php?inventory_key='. check_plain(variable_get(textlinkads_website_xml_key, ''))
363      . '&referer=' . urlencode($_SERVER['REQUEST_URI'])      .'&referer='. urlencode(request_uri())
364      . '&user_agent=' . urlencode($_SERVER['HTTP_USER_AGENT'])      .'&user_agent='. urlencode($_SERVER['HTTP_USER_AGENT'])
365      . '&drupal_module_version=' . urlencode(TEXTLINKADS_VERSION);      .'&drupal_module_version='. urlencode(TEXTLINKADS_VERSION);
366    textlinkads_update_links($url, $CONNECTION_TIMEOUT);    textlinkads_update_links($url, $CONNECTION_TIMEOUT);
367  }  }
368    
# Line 369  function textlinkads_update_links($url, Line 382  function textlinkads_update_links($url,
382        if (!is_array($links)) {        if (!is_array($links)) {
383          /* When no ads for site, $data looks like this:          /* When no ads for site, $data looks like this:
384               <?xml version="1.0" ?> <Links> </Links>               <?xml version="1.0" ?> <Links> </Links>
385             And $links = ' '             And $links = ' '
386             Subsequent code assumes we have an array - when no ads available,             Subsequent code assumes we have an array - when no ads available,
387             $links is a string containing only spaces.  So, let's force             $links is a string containing only spaces.  So, let's force
388             $links to be an array so the code will work.             $links to be an array so the code will work.
389          */          */
390          $links = array();          $links = array();
391        }        }
392      }      }
393      foreach ($links as $key => $values) {      foreach ($links as $key => $values) {
# Line 409  function textlinkads_next_rss_ad() { Line 422  function textlinkads_next_rss_ad() {
422   * @return Array   * @return Array
423   */   */
424  function textlinkads_get_links($type = 'text') {  function textlinkads_get_links($type = 'text') {
425    
426    $links = array();    $links = array();
427    $limit = ($type == 'text') ? variable_get('textlinkads_total', 4) : variable_get('feed_default_items', 10);    $limit = ($type == 'text') ? variable_get('textlinkads_total', 4) : variable_get('feed_default_items', 10);
428    $where = ($type == 'text') ? 'text IS NOT NULL && beforetext IS NOT NULL && aftertext IS NOT NULL' : 'rsstext IS NOT NULL';    $where = ($type == 'text') ? 'text IS NOT NULL && beforetext IS NOT NULL && aftertext IS NOT NULL' : 'rsstext IS NOT NULL';
429    $result = db_query("SELECT * FROM {textlinkads}  WHERE $where LIMIT %d", $limit);    $result = db_query("SELECT * FROM {textlinkads}  WHERE $where LIMIT %d", $limit);
430    while ($row = db_fetch_array($result)) {    while ($row = db_fetch_array($result)) {
431    
432      $links[] = $row;      $links[] = $row;
433    }    }
434    
435    return $links;    return $links;
436  }  }
437    
# Line 499  class xml2array { Line 515  class xml2array {
515    
516    
517  function textlinkads_get_js() {  function textlinkads_get_js() {
518    $path = TEXTLINKADS_MODULE_PATH;    $path = drupal_get_path('module', 'textlinkads');
519    $default_font_size = variable_get('textlinkads_font', 12);    $default_font_size = variable_get('textlinkads_font', 12);
520    $default_rows = variable_get('textlinkads_rows', 4);    $default_rows = variable_get('textlinkads_rows', 4);
521    $default_total_number = variable_get('textlinkads_total', 4);    $default_total_number = variable_get('textlinkads_total', 4);
# Line 509  function textlinkads_get_js() { Line 525  function textlinkads_get_js() {
525    $default_no_border = variable_get('textlinkads_no_border', 0);    $default_no_border = variable_get('textlinkads_no_border', 0);
526    $default_no_bg = variable_get('textlinkads_no_bg', 0);    $default_no_bg = variable_get('textlinkads_no_bg', 0);
527    $js =<<<__END__    $js =<<<__END__
528  <script type="text/javascript" src="$path/colorpicker2.js"></script>  <script type="text/javascript" src="/$path/colorpicker2.js"></script>
529  <script type="text/javascript">//<![CDATA[  <script type="text/javascript">//<![CDATA[
530  var cp2 = new ColorPicker();  var cp2 = new ColorPicker();
531  var table_total_ads = $default_total_number;  var table_total_ads = $default_total_number;
# Line 524  var example_link = 'Example Link'; Line 540  var example_link = 'Example Link';
540  var link_color_txt = 'link_color';  var link_color_txt = 'link_color';
541  //]]>  //]]>
542  </script>  </script>
543  <script type="text/javascript" src="$path/textlinkads.js"></script>  <script type="text/javascript" src="/$path/textlinkads.js"></script>
544    
545  __END__;  __END__;
546    return $js;    return $js;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.2