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

Diff of /contributions/modules/weight/weight.module

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

revision 1.17.2.8 by nancyw, Sat Jan 24 17:29:29 2009 UTC revision 1.17.2.9 by nancyw, Tue Jan 27 16:44:27 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: weight.module,v 1.17.2.7 2009/01/24 16:14:33 nancyw Exp $  // $Id: weight.module,v 1.17.2.8 2009/01/24 17:29:29 nancyw Exp $
3  /**  /**
4   * @file   * @file
5   * This module uses the sticky column of the node table   * This module uses the sticky column of the node table
# Line 124  function weight_nodeapi(&$node, $op) { Line 124  function weight_nodeapi(&$node, $op) {
124    
125        // If the admin wants to use the menu weight, see if there is one.        // If the admin wants to use the menu weight, see if there is one.
126        if (variable_get('weight_use_menu', FALSE)) {        if (variable_get('weight_use_menu', FALSE)) {
127          $node->node_weight = isset($node->menu['title']) ? $node->menu['weight'] : $node->node_weight;          $node->node_weight = (isset($node->menu['title']) && !empty($node->menu['title'])) ? $node->menu['weight'] : $node->node_weight;
128        }        }
129    
130        // here we're 'encoding' weight into the sticky value for the database        // here we're 'encoding' weight into the sticky value for the database
# Line 188  function weight_form_alter($form_id, &$f Line 188  function weight_form_alter($form_id, &$f
188        foreach ($form['operations'] as $nid => $title) {        foreach ($form['operations'] as $nid => $title) {
189          // only add weight selector if weight is enabled for this node type          // only add weight selector if weight is enabled for this node type
190          if (in_array($form['name'][$nid]['#value'], $weight_node_type_names) ) {          if (in_array($form['name'][$nid]['#value'], $weight_node_type_names) ) {
191            $form['operations'][$nid]['weight_selector']['#value'] =  weight_node_selector($nid);            $selector = weight_node_selector($nid);
192              $form['operations'][$nid]['weight_selector']['#value'] =  $selector['selector'];
193              $form['status'][$nid]['#value'] .=  $selector['status'];
194          }          }
195        }        }
196      }      }
# Line 293  function weight_settings_form() { Line 295  function weight_settings_form() {
295      '#type' => 'select',      '#type' => 'select',
296      '#title' => t('Node Weight Range'),      '#title' => t('Node Weight Range'),
297      '#default_value' => variable_get('weight_range', 20),      '#default_value' => variable_get('weight_range', 20),
298      '#options' => array(5 => 5, 10 => 10, 20 => 20, 30 => 30, 40 => 40),      '#options' => array(5 => 5, 10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60, 70=> 70, 80 => 80, 90 => 90),
299      '#description' => t('<p>This will be the +/- range for node weight.</p>'),      '#description' => t('<p>This will be the +/- range for node weight.</p>'),
300      );      );
301    
# Line 392  function weight_node_selector($nid) { Line 394  function weight_node_selector($nid) {
394    $weight_selector = preg_replace("/(value='$weight')/", "$1 selected='selected'", $weight_selector);    $weight_selector = preg_replace("/(value='$weight')/", "$1 selected='selected'", $weight_selector);
395    $weight_selector = preg_replace("/\[NID\]/", $nid, $weight_selector);    $weight_selector = preg_replace("/\[NID\]/", $nid, $weight_selector);
396    $weight_selector = '<div class="weight-selector">'. $weight_selector .'</div>';    $weight_selector = '<div class="weight-selector">'. $weight_selector .'</div>';
397    return $weight_selector;    $status = NULL;
398      $status .= $node->sticky ? '<br />'. t('sticky') : NULL;
399      $status .= $node->promote ? '<br />'. t('promoted') : NULL;
400      $status .= $node->translate ? '<br />'. t('translate') : NULL;
401      $status .= $node->moderate ? '<br />'. t('moderated') : NULL;
402      return array('selector' => $weight_selector, 'status' => $status);
403  }  }
404    
405  // ajax callback for weight manager page  // ajax callback for weight manager page
# Line 400  function _change_weight($nid, $weight) { Line 407  function _change_weight($nid, $weight) {
407    // Doing it this way preserves the revision information.    // Doing it this way preserves the revision information.
408    $node = node_load($nid);    $node = node_load($nid);
409    $node->node_weight = $weight;    $node->node_weight = $weight;
410      node_submit($node);
   _weight2encoded_sticky($node);  
   
411    node_save($node);    node_save($node);
412  }  }
413    

Legend:
Removed from v.1.17.2.8  
changed lines
  Added in v.1.17.2.9

  ViewVC Help
Powered by ViewVC 1.1.6