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

Diff of /contributions/modules/taxonomy_ticker/taxonomy_ticker.module

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

revision 1.17, Sun Nov 5 16:55:11 2006 UTC revision 1.17.2.1, Fri Feb 8 20:06:32 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: taxonomy_ticker.module,v 1.16 2006/09/16 22:14:48 gjmjr Exp $  // $Id: taxonomy_ticker.module,v 1.20 2008/01/07 16:26:14 yrocq Exp $
3    
4    
5  /**  /**
6   * @taxonomy_ticker   * @file
7   * Enables user to use a ticker to display a type of content   * Enables user to use a ticker to display a type of content.
8   */   */
9    
10  /**  /**
# Line 17  function taxonomy_ticker_help($section) Line 18  function taxonomy_ticker_help($section)
18  }  }
19    
20  function taxonomy_ticker_contents() {  function taxonomy_ticker_contents() {
21    if (variable_get('taxonomy_ticker_direction', 0) == 0) {  // scrolling vertically    $tid    = variable_get("taxonomy_ticker_tid", array());
22      drupal_add_js(drupal_get_path('module', 'taxonomy_ticker') . '/taxonomy_ticker.js');  
23      drupal_add_css(drupal_get_path('module', 'taxonomy_ticker') .'/taxonomy_ticker.css');    if (count($tid))
24    } else {    {
25      drupal_add_js(drupal_get_path('module', 'taxonomy_ticker') . '/taxonomy_ticker_horizontally.js');      // Scrolling vertically.
26      drupal_add_css(drupal_get_path('module', 'taxonomy_ticker') .'/taxonomy_ticker_horizontally.css');      if (variable_get('taxonomy_ticker_direction', 0) == 0) {
27    }        drupal_add_js(drupal_get_path('module', 'taxonomy_ticker') .'/taxonomy_ticker.js');
28          drupal_add_css(drupal_get_path('module', 'taxonomy_ticker') .'/taxonomy_ticker.css');
   $tickerspeed = variable_get('taxonomy_ticker_speed', 8);  
   // removing the style tag from scrollPane breaks the scrolling functionality  
   $block = '<div id="scrollerClipper" style="z-index:'.$tickerspeed.'" onmouseover="pauseScroll();" onmouseout="reStartScroll();"><div id="outerscrollPane"><div id="scrollPane" style="position:relative; top:0px ; left:0px;">';  
   
   $type_q = ($type ? "n.type = '$type'" : 1);  
   $tid = variable_get("taxonomy_ticker_tid", 1);  
   foreach ($tid as $key => $val) {  
     $tid[$key] = "r.tid = '$val'";  
   }  
   if (!empty($tid)) $tids = "AND (" . join(" OR ", $tid) . ")";  
   
   $query = db_rewrite_sql("SELECT n.nid, n.title, n.type FROM {node} n LEFT JOIN {term_node} r ON r.nid = n.nid WHERE n.status = 1 " . $tids . " AND $type_q ORDER BY n.changed DESC");  
   
   $results = db_query_range($query, 0, variable_get('taxonomy_ticker_count', 5));  
   
   $block .= '<div id="firstscrollerContentItem"></div>';  
   while ( $result = db_fetch_object($results) ) {  
   
 /* The commented code that follows is an example of how to integrate taxonomy_ticker with  
  * a flexinode content-type, which could be used to show some html content instead of just  
  * displaying the title of the node... */  
 /*  
     $node = node_load(array('nid'=>$result->nid));  
     if ( $node->flexinode_2 != '' ) {  
       // $block .= "<div class=\"scrollerContentItem\"><p><a href=\"" . $node->flexinode_2 . "\">$result->title</a></p></div>";  
       $block .= "<div class=\"scrollerContentItem\"><p>$node->flexinode_2</p></div>";  
29      }      }
30      else {      else {
31  */        drupal_add_js(drupal_get_path('module', 'taxonomy_ticker') .'/taxonomy_ticker_horizontally.js');
32          drupal_add_css(drupal_get_path('module', 'taxonomy_ticker') .'/taxonomy_ticker_horizontally.css');
33        }
34    
35        $tickerspeed = variable_get('taxonomy_ticker_speed', 8);
36        // Removing the style tag from scrollPane breaks the scrolling functionality.
37        $block  = '<div id="scrollerClipper" style="z-index: '. $tickerspeed .'" onmouseover="pauseScroll();" onmouseout="reStartScroll();"><div id="outerscrollPane"><div id="scrollPane" style="position: relative; top: 0px; left: 0px;">';
38    
39        $type_q = ($type ? "n.type = '$type'" : 1);
40    
41        foreach ($tid as $key => $val) {
42          $tid[$key] = "r.tid = '$val'";
43        }
44        if (!empty($tid)) $tids = "AND (". join(" OR ", $tid) .")";
45    
46        $query = db_rewrite_sql("SELECT n.nid, n.title, n.type FROM {node} n LEFT JOIN {term_node} r ON r.nid = n.nid WHERE n.status = 1 ". $tids ." AND $type_q ORDER BY n.changed DESC");
47    
48        $results = db_query_range($query, 0, variable_get('taxonomy_ticker_count', 5));
49    
50        $block .= '<div id="firstscrollerContentItem"></div>';
51        while ($result = db_fetch_object($results)) {
52          /**
53           * The commented code that follows is an example of how to integrate taxonomy_ticker with
54           * a flexinode content-type, which could be used to show some html content instead of just
55           * displaying the title of the node.
56           */
57          /*
58          $node = node_load(array('nid'=>$result->nid));
59          if ( $node->flexinode_2 != '' ) {
60            // $block .= "<div class=\"scrollerContentItem\"><p><a href=\"" . $node->flexinode_2 . "\">$result->title</a></p></div>";
61            $block .= "<div class=\"scrollerContentItem\"><p>$node->flexinode_2</p></div>";
62          }
63          else {
64          */
65        if (variable_get('taxonomy_ticker_teaser', 0) == 1) {        if (variable_get('taxonomy_ticker_teaser', 0) == 1) {
66          $node = node_load(array('nid' => $result->nid));          $node = node_load(array('nid' => $result->nid));
67          $teaser = '<br/>' . $node->teaser;          $teaser = '<br/>'. $node->teaser;
68        } else $teaser = '';        }
69        $block .= '<div class="scrollerContentItem"><p>' . l($result->title, 'node/' . $result->nid) . $teaser . '</p></div>';        else $teaser = '';
70  /*        $block .= '<div class="scrollerContentItem"><p>'. l($result->title, 'node/'. $result->nid) . $teaser .'</p></div>';
71          /*
72          }
73          */
74      }      }
75  */  
76        $block .= '<div id="lastscrollerContentItem"></div>';
77        $block .= '<div style="clear: both"></div></div></div></div>';
78      }
79      else
80      {
81        $block='';
82    }    }
   
   $block .= '<div id="lastscrollerContentItem"></div>';  
   $block .= '<div style="clear:both"></div></div></div></div>';  
   
83    return $block;    return $block;
84  }  }
85    
86  function taxonomy_ticker_block($op = 'list', $delta = 0, $edit = array()) {  function taxonomy_ticker_block($op = 'list', $delta = 0, $edit = array()) {
87    switch($op) {    switch ($op) {
88      case 'list' :      case 'list':
89        $blocks[0]['info'] = t('A ticker block');        $blocks[0]['info'] = t('A ticker block');
90        return $blocks;        return $blocks;
91      case 'view' :  
92        case 'view':
93        $blocks["content"] = taxonomy_ticker_contents();        $blocks["content"] = taxonomy_ticker_contents();
94        $blocks["subject"] = t('Ticker');        $blocks["subject"] = t('Ticker');
95        return $blocks;        return $blocks;
# Line 84  function taxonomy_ticker_block($op = 'li Line 98  function taxonomy_ticker_block($op = 'li
98    
99  function taxonomy_ticker_menu($maycache) {  function taxonomy_ticker_menu($maycache) {
100    $items = array();    $items = array();
101    
102    if (!$may_cache) {    if (!$may_cache) {
103      $items[] = array(      $items[] = array(
104        'path' => 'admin/settings/taxonomy-ticker',        'path' => 'admin/settings/taxonomy-ticker',
# Line 96  function taxonomy_ticker_menu($maycache) Line 110  function taxonomy_ticker_menu($maycache)
110        'type' => MENU_NORMAL_ITEM,        'type' => MENU_NORMAL_ITEM,
111      );      );
112    }    }
113    
114    return $items;    return $items;
115  }  }
116    
117  function taxonomy_ticker_admin_settings() {  function taxonomy_ticker_admin_settings() {
   
118    $form['taxonomy_ticker_tid'] = array(    $form['taxonomy_ticker_tid'] = array(
119      '#type' => 'select',      '#type' => 'select',
120      '#title' => t('Terms'),      '#title' => t('Terms'),
121      '#default_value' => variable_get('taxonomy_ticker_tid', 1),      '#default_value' => variable_get('taxonomy_ticker_tid', array()),
122      '#options' => taxonomy_form_all(),      '#options' => taxonomy_form_all(),
123      '#description' => /* $description = */      '#description' => t('Take nodes associated to the selected terms.'),
124                           t('Take nodes associated to the selected terms.'),      '#extra' => 0,
125      '#extra' => /* $extra = */ 0,      '#multiple' => TRUE,
126      '#multiple' => /* $multiple = */ TRUE,      '#required' => TRUE,
     '#required' => /* $required = */ TRUE,  
127    );    );
128    
129    $form['taxonomy_ticker_count'] = array(    $form['taxonomy_ticker_count'] = array(
130      '#type' => 'textfield',      '#type' => 'textfield',
131      '#title' => t('Number of items'),      '#title' => t('Number of items'),
# Line 122  function taxonomy_ticker_admin_settings( Line 134  function taxonomy_ticker_admin_settings(
134      '#maxlength' => 3,      '#maxlength' => 3,
135      '#description' => t('The number of items to display in the ticker.'),      '#description' => t('The number of items to display in the ticker.'),
136    );    );
137    
138    $form['taxonomy_ticker_direction'] = array(    $form['taxonomy_ticker_direction'] = array(
139      '#type' => 'select',      '#type' => 'select',
140      '#title' => t('Direction of scroll'),      '#title' => t('Direction of scroll'),
# Line 130  function taxonomy_ticker_admin_settings( Line 142  function taxonomy_ticker_admin_settings(
142      '#options' => array(0 => t('Vertically'), 1 => t('Horizontally')),      '#options' => array(0 => t('Vertically'), 1 => t('Horizontally')),
143      '#description' => t('The direction in which the items scroll in the ticker.'),      '#description' => t('The direction in which the items scroll in the ticker.'),
144    );    );
145    
146    $form['taxonomy_ticker_speed'] = array(    $form['taxonomy_ticker_speed'] = array(
147      '#type' => 'select',      '#type' => 'select',
148      '#title' => t('Scroll Speed'),      '#title' => t('Scroll Speed'),
# Line 138  function taxonomy_ticker_admin_settings( Line 150  function taxonomy_ticker_admin_settings(
150      '#options' => array(1 => t('Super Fast'), 4 => t('Fast'), 8 => t('Standard'), 12 => t('Slow'), 16 => t('Super Slow')),      '#options' => array(1 => t('Super Fast'), 4 => t('Fast'), 8 => t('Standard'), 12 => t('Slow'), 16 => t('Super Slow')),
151      '#description' => t('The speed in which the items scroll in the ticker.'),      '#description' => t('The speed in which the items scroll in the ticker.'),
152    );    );
153    
154    $form['taxonomy_ticker_teaser'] = array(    $form['taxonomy_ticker_teaser'] = array(
155      '#type' => 'radios',      '#type' => 'radios',
156      '#title' => t('Include teaser'),      '#title' => t('Include teaser'),
# Line 146  function taxonomy_ticker_admin_settings( Line 158  function taxonomy_ticker_admin_settings(
158      '#options' => array(t('Disabled'), t('Enabled')),      '#options' => array(t('Disabled'), t('Enabled')),
159      '#description' => t('This option makes teasers appear under the titles (best used when scrolling vertically)'),      '#description' => t('This option makes teasers appear under the titles (best used when scrolling vertically)'),
160    );    );
161    
162    return system_settings_form($form);    return system_settings_form($form);
163  }  }
164    
165  ?>  
166    

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.17.2.1

  ViewVC Help
Powered by ViewVC 1.1.2