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

Diff of /contributions/modules/helptip/helptip.module

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

revision 1.9, Tue Dec 5 20:04:57 2006 UTC revision 1.10, Fri Dec 8 19:56:39 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: helptip.module,v 1.8 2006/11/04 18:58:24 yogadex Exp $  // $Id: helptip.module,v 1.9 2006/12/05 20:04:57 yogadex Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 40  function _helptip_num_blocks() { Line 40  function _helptip_num_blocks() {
40   */   */
41  function _helptip_get_block_settings($delta) {  function _helptip_get_block_settings($delta) {
42    $var_name = "helptip_block_".$delta."_settings";    $var_name = "helptip_block_".$delta."_settings";
43    $defaults = variable_get($var_name,    $defaults = array('how_many' => 1,
44                             array('how_many' => 1,                      'title' => '%title',
45                                   'title' => '%title')                      'min_weight' => -10,
46                             );                      'max_weight' => 10);
47    return $defaults;  
48      $settings = variable_get($var_name,
49                               array());
50      // array_merge ensures all defaults will be found.
51      return array_merge($defaults, $settings);
52  }  }
53    
54  /**  /**
# Line 59  function helptip_block($op = 'list', $de Line 63  function helptip_block($op = 'list', $de
63      return $blocks;      return $blocks;
64    }    }
65    else if ($op == 'configure') {    else if ($op == 'configure') {
66      $var_name = "helptip_block_".$delta."_settings";      $defaults = _helptip_get_block_settings($delta);
     $defaults = _helptip_get_block_settings($var_name);  
     $defaults = variable_get($var_name,  
                              array('how_many' => 1,  
                                    'title' => '%title')  
                              );  
67      $form[$var_name] = array('#tree' => true);      $form[$var_name] = array('#tree' => true);
68      $form[$var_name]['title'] =      $form[$var_name]['title'] =
69        array('#type' => 'textfield',        array('#type' => 'textfield',
# Line 82  function helptip_block($op = 'list', $de Line 81  function helptip_block($op = 'list', $de
81              '#maxlength' => 2,              '#maxlength' => 2,
82              '#description' => t('How many tips to display?  If more than one tip applies to the current page, more than one can be displayed.  Tips of equal weight will be displayed in random order.'),              '#description' => t('How many tips to display?  If more than one tip applies to the current page, more than one can be displayed.  Tips of equal weight will be displayed in random order.'),
83              );              );
84        $form[$var_name]['min_weight'] =
85          array('#type' => 'weight',
86                '#title' => t('Minimum Weight'),
87                '#default_value' => $defaults['min_weight'],
88                '#description' => t('Show only helptips with this weight or greater.  This allows you to define multiple helptip blocks, and position helptips on the page by their weight.'),
89          );
90        $form[$var_name]['max_weight'] =
91          array('#type' => 'weight',
92                '#title' => t('Maximum Weight'),
93                '#default_value' => $defaults['max_weight'],
94                '#description' => t('Show only helptips with this weight or less.  This allows you to define multiple helptip blocks, and position helptips on the page by their weight.'),
95          );
96      return $form;      return $form;
97    }    }
98    else if ($op == 'save') {    else if ($op == 'save') {
# Line 97  function helptip_block($op = 'list', $de Line 108  function helptip_block($op = 'list', $de
108      $paths = _helptip_get_current_paths();      $paths = _helptip_get_current_paths();
109      $path_clause = "('" . implode("' LIKE ht.path OR '", $paths) . "' LIKE ht.path)";      $path_clause = "('" . implode("' LIKE ht.path OR '", $paths) . "' LIKE ht.path)";
110      // use db_rewrite_sql for people with node_access modules      // use db_rewrite_sql for people with node_access modules
111      $result = db_query(db_rewrite_sql("SELECT ht.* FROM {node} n LEFT JOIN {helptip} ht ON ht.nid = n.nid LEFT JOIN {helptip_user_data} ht_hidden ON ht_hidden.uid=$user->uid AND ht_hidden.nid=n.nid AND ht_hidden.relation='hidden' WHERE n.status = 1 AND ht_hidden.relation IS NULL AND $path_clause ORDER BY ht.weight, RAND() LIMIT %d"),      $result = db_query(db_rewrite_sql("SELECT ht.* FROM {node} n LEFT JOIN {helptip} ht ON ht.nid = n.nid LEFT JOIN {helptip_user_data} ht_hidden ON ht_hidden.uid=$user->uid AND ht_hidden.nid=n.nid AND ht_hidden.relation='hidden' WHERE n.status = 1 AND ht_hidden.relation IS NULL AND $path_clause AND weight >= $settings[min_weight] AND weight <= $settings[max_weight] ORDER BY ht.weight, RAND() LIMIT %d"),
112                         $settings['how_many']);                         $settings['how_many']);
113      $block = array();      $block = array();
114      while ($data = db_fetch_object($result)) {      while ($data = db_fetch_object($result)) {
# Line 254  function helptip_form(&$node, &$param) { Line 265  function helptip_form(&$node, &$param) {
265    $form['helptip']['weight'] = array('#type' => 'weight',    $form['helptip']['weight'] = array('#type' => 'weight',
266                                       '#title' => t('Weight'),                                       '#title' => t('Weight'),
267                                       '#default_value' => $node->helptip->weight,                                       '#default_value' => $node->helptip->weight,
268                                       '#description' => t('When more than one help tip applies to a page, this controls the order in which they are displayed.'),                                       '#description' => t('When more than one help tip applies to a page, this controls the order in which they are displayed.  It may also determine in which block the helptip appears.'),
269                                       '#required' => false);                                       '#required' => false);
270    
271    $form['helptip']['settings'] = array('#tree' => true);    $form['helptip']['settings'] = array('#tree' => true);
# Line 355  function helptip_settings_form() { Line 366  function helptip_settings_form() {
366  function theme_helptip_body($node) {  function theme_helptip_body($node) {
367    $node->teaser = check_markup($node->teaser, $node->format, FALSE);    $node->teaser = check_markup($node->teaser, $node->format, FALSE);
368    $node->body = check_markup($node->body, $node->format, FALSE);    $node->body = check_markup($node->body, $node->format, FALSE);
369    return '<div class="helptip">'.$node->teaser.    return '<div class="helptip">' . $node->teaser .
370      theme('helptip_links', $node)."</div>\n";      theme('helptip_links', $node) . "</div>\n";
371  }  }
372    
373  /**  /**

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.2