/[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.2.1, Wed Oct 3 17:07:21 2007 UTC revision 1.5.2.2, Mon Nov 19 18:08:21 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  /**  /**
4   *  Support multiple inventory keys per site   *  Support multiple inventory keys per site
5   *  1.  Multiple blocks? (with a key per block) - let drupal block visibility system manage visibility?   *  1.  Multiple blocks? (with a key per block) - let drupal block visibility system manage visibility?
6   *   *
7   *  2. Database changes - store inventory key?   *  2. Database changes - store inventory key?
8   *  3. Cron changes   *  3. Cron changes
9   *  4. Settings changes   *  4. Settings changes
10   *     Inventory key(s), path mach pattern?   *     Inventory key(s), path mach pattern?
11   *     Module will provide block per key   *     Module will provide block per key
12   */   */
13    
14  define('TEXTLINKADS_VERSION', '$Id: textlinkads.module,v 1.5 2007/02/10 04:32:46 kbahey Exp $');  define('TEXTLINKADS_VERSION', '$Id: textlinkads.module,v 1.5.2.1 2007/10/03 17:07:21 greggles Exp $');
15  define('TEXTLINKADS_MODULE_PATH', drupal_get_path('module', 'textlinkads'));  define('TEXTLINKADS_MODULE_PATH', drupal_get_path('module', 'textlinkads'));
16    
17  function textlinkads_help($section) {  function textlinkads_help($section) {
# Line 98  function textlinkads_block($op = 'list', Line 98  function textlinkads_block($op = 'list',
98        for ($i = 0; $i < $nblocks; $i++) {        for ($i = 0; $i < $nblocks; $i++) {
99          $blocks[$i]['info'] = t('TLA Block for key= !key', array('!key'=>$keys[$i]));          $blocks[$i]['info'] = t('TLA Block for key= !key', array('!key'=>$keys[$i]));
100        }        }
101    
102        return $blocks;        return $blocks;
103      case 'view':      case 'view':
104        $block['subject'] = t(variable_get('textlinkads_ad_block_title', t('Advertisements')));        $block['subject'] = t(variable_get('textlinkads_ad_block_title', t('Advertisements')));
# Line 129  function textlinkads_admin_settings() { Line 130  function textlinkads_admin_settings() {
130      '#description' => t('Enter a heading for the Ad block. It is alright to leave it blank.'),      '#description' => t('Enter a heading for the Ad block. It is alright to leave it blank.'),
131    );    );
132    
   drupal_set_html_head(textlinkads_get_js());  
133    $total_options = drupal_map_assoc(array(4, 6, 8, 10));    $total_options = drupal_map_assoc(array(4, 6, 8, 10));
134    $row_options = drupal_map_assoc(array(1, 2, 3, 4, 8, 10));    $row_options = drupal_map_assoc(array(1, 2, 3, 4, 8, 10));
135    $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 161  function textlinkads_admin_settings() { Line 161  function textlinkads_admin_settings() {
161      '#size' => 8,      '#size' => 8,
162      '#maxlength' => 7,      '#maxlength' => 7,
163      '#default_value' => variable_get('textlinkads_border_color', '#000000'),      '#default_value' => variable_get('textlinkads_border_color', '#000000'),
     '#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>',  
164      );      );
165    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_no_border'] = array(    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_no_border'] = array(
166      '#type' => 'checkbox',      '#type' => 'checkbox',
167      '#title' => t('No Border'),      '#title' => t('No Border'),
168      '#default_value' => variable_get('textlinkads_no_border', 0),      '#default_value' => variable_get('textlinkads_no_border', 0),
     '#attributes' => array('onclick' => 'update_border_color()')  
169      );      );
170    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_bg_color'] = array(    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_bg_color'] = array(
171      '#type' => 'textfield',      '#type' => 'textfield',
# Line 175  function textlinkads_admin_settings() { Line 173  function textlinkads_admin_settings() {
173      '#size' => 8,      '#size' => 8,
174      '#maxlength' => 7,      '#maxlength' => 7,
175      '#default_value' =>  variable_get('textlinkads_bg_color', '#ffffff'),      '#default_value' =>  variable_get('textlinkads_bg_color', '#ffffff'),
     '#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',
179      '#title' => t('Transparent Background'),      '#title' => t('Transparent Background'),
180      '#default_value' => variable_get('textlinkads_no_bg', 0),      '#default_value' => variable_get('textlinkads_no_bg', 0),
     '#attributes' => array('onclick' => 'update_bg_color()')  
181      );      );
182    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_link_color'] = array(    $form['textlinkads_themer']['textlinkads_colors']['textlinkads_link_color'] = array(
183      '#type' => 'textfield',      '#type' => 'textfield',
# Line 189  function textlinkads_admin_settings() { Line 185  function textlinkads_admin_settings() {
185      '#size' => 8,      '#size' => 8,
186      '#maxlength' => 7,      '#maxlength' => 7,
187      '#default_value' =>  variable_get('textlinkads_link_color', '#0000ff'),      '#default_value' =>  variable_get('textlinkads_link_color', '#0000ff'),
     '#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>',  
188      );      );
189    
190    $form['textlinkads_themer']['textlinkads_preview'] = array('#type' => 'fieldset', '#title' => t('Example'));    $form['textlinkads_themer']['textlinkads_preview'] = array(
191        '#type' => 'fieldset',
192        '#title' => t('Preview'),
193        '#collapsible' => true,
194        '#collapsed' => false,
195      );
196    $form['textlinkads_themer']['textlinkads_preview']['preview_div'] = array('#value' => '<div id="preview"></div><script type="text/javascript">cp2.writeDiv();</script>');    $form['textlinkads_themer']['textlinkads_preview']['preview_div'] = array('#value' => '<div id="preview"></div><script type="text/javascript">cp2.writeDiv();</script>');
197      $block = (object) textlinkads_block('view');
198      $block->module = 'tlasettings';
199      $block->delta = 0;
200      $form['textlinkads_themer']['textlinkads_preview']['block'] = array(
201        '#value' => theme('block', $block),
202      );
203    return system_settings_form($form);    return system_settings_form($form);
204  }  }
205    
# Line 333  function theme_textlinkads_stats($stats_ Line 338  function theme_textlinkads_stats($stats_
338    
339    if (!empty($stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK'])) {    if (!empty($stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK'])) {
340      $rows = array();      $rows = array();
341      $output .= t('<h3>Currently Active Links:</h3>');      $output .= '<h3>'. t('Currently Active Links:'). '</h3>';
342      if (!$stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK']['URL'] && is_array($stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK'])) {      if (!$stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK']['URL'] && is_array($stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK'])) {
343        foreach ($stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK'] as $activelink) {        foreach ($stats_data['WEBSITE']['ACTIVELINKS']['ACTIVELINK'] as $activelink) {
344          $rows[] = array("<a href=\"$activelink[URL]\">$activelink[TEXT]</a>", "<b>({$activelink[CURRENT_MONTHS_EARNINGS]})</b>");          $rows[] = array("<a href=\"$activelink[URL]\">$activelink[TEXT]</a>", "<b>({$activelink[CURRENT_MONTHS_EARNINGS]})</b>");
# Line 403  function textlinkads_update_links($url, Line 408  function textlinkads_update_links($url,
408        if (!is_array($links)) {        if (!is_array($links)) {
409          /* When no ads for site, $data looks like this:          /* When no ads for site, $data looks like this:
410               <?xml version="1.0" ?> <Links> </Links>               <?xml version="1.0" ?> <Links> </Links>
411             And $links = ' '             And $links = ' '
412             Subsequent code assumes we have an array - when no ads available,             Subsequent code assumes we have an array - when no ads available,
413             $links is a string containing only spaces.  So, let's force             $links is a string containing only spaces.  So, let's force
414             $links to be an array so the code will work.             $links to be an array so the code will work.
415          */          */
416          $links = array();          $links = array();
417        }        }
418      }      }
419      foreach ($links as $key => $values) {      foreach ($links as $key => $values) {
# Line 516  class xml2array { Line 521  class xml2array {
521     }     }
522    
523     function correctentries($dataarray){     function correctentries($dataarray){
524       if (is_array($dataarray)){       if (is_array($dataarray)) {
525         $keys =  array_keys($dataarray);         $keys = array_keys($dataarray);
526         if (count($keys)== 1 && is_int($keys[0])){         if (count($keys)== 1 && is_int($keys[0])) {
527           $tmp = $dataarray[0];           $tmp = $dataarray[0];
528           unset($dataarray[0]);           unset($dataarray[0]);
529           $dataarray = $tmp;           $dataarray = $tmp;
530         }         }
531         $keys2 = array_keys($dataarray);         $keys2 = array_keys($dataarray);
532         foreach($keys2 as $key){         foreach ($keys2 as $key) {
533           $tmp2 = $dataarray[$key];           $tmp2 = $dataarray[$key];
534           unset($dataarray[$key]);           unset($dataarray[$key]);
535           $dataarray[$key] = $this->correctentries($tmp2);           $dataarray[$key] = $this->correctentries($tmp2);
# Line 533  class xml2array { Line 538  class xml2array {
538       }       }
539       return $dataarray;       return $dataarray;
540     }     }
 }  
   
   
 function textlinkads_get_js() {  
   $path = TEXTLINKADS_MODULE_PATH;  
   $default_font_size = variable_get('textlinkads_font', 12);  
   $default_rows = variable_get('textlinkads_rows', 4);  
   $default_total_number = variable_get('textlinkads_total', 4);  
   $default_link_color = variable_get('textlinkads_link_color', '#0000ff');  
   $default_bg_color = variable_get('textlinkads_bg_color', '#0000ff');  
   $default_border_color = variable_get('textlinkads_border_color', '#0000ff');  
   $default_no_border = variable_get('textlinkads_no_border', 0);  
   $default_no_bg = variable_get('textlinkads_no_bg', 0);  
   $js =<<<__END__  
 <script type="text/javascript" src="$path/colorpicker2.js"></script>  
 <script type="text/javascript">//<![CDATA[  
 var cp2 = new ColorPicker();  
 var table_total_ads = $default_total_number;  
 var table_rows = $default_rows;  
 var font_size = $default_font_size;  
 var link_color = '$default_link_color';  
 var bg_color = '$default_bg_color';  
 var border_color = '$default_border_color';  
 var no_border = $default_no_border;  
 var no_bg = $default_no_bg;  
 var example_link = 'Example Link';  
 var link_color_txt = 'link_color';  
 //]]>  
 </script>  
 <script type="text/javascript" src="$path/textlinkads.js"></script>  
   
 __END__;  
   return $js;  
541  }  }

Legend:
Removed from v.1.5.2.1  
changed lines
  Added in v.1.5.2.2

  ViewVC Help
Powered by ViewVC 1.1.2