| 1 |
<?php |
<?php |
| 2 |
// $Id: weight.module,v 1.23.2.6 2009/02/25 19:05:39 nancyw Exp $ |
// $Id: weight.module,v 1.23.2.7 2009/04/25 15:03:23 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 |
| 61 |
} |
} |
| 62 |
|
|
| 63 |
function weight_nodeapi(&$node, $op) { |
function weight_nodeapi(&$node, $op) { |
| 64 |
switch ($op) { |
$weight_node_types = variable_get('weight_node_types', array_flip(node_get_types('names'))); |
| 65 |
case 'presave': |
if (in_array($node->type, $weight_node_types)) { |
| 66 |
// Non-weighted nodes have a weight of zero. |
switch ($op) { |
| 67 |
if (is_null($node->node_weight)) { |
case 'presave': |
| 68 |
$node->node_weight = 0; |
// Non-weighted nodes have a weight of zero. |
| 69 |
} |
if (is_null($node->node_weight)) { |
| 70 |
|
$node->node_weight = 0; |
| 71 |
|
} |
| 72 |
|
|
| 73 |
// 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. |
| 74 |
if (variable_get('weight_use_menu', FALSE)) { |
if (variable_get('weight_use_menu', FALSE)) { |
| 75 |
$node->node_weight = (isset($node->menu['link_title']) && !empty($node->menu['link_title'])) ? $node->menu['weight'] : $node->node_weight; |
$node->node_weight = (isset($node->menu['link_title']) && !empty($node->menu['link_title'])) ? $node->menu['weight'] : $node->node_weight; |
| 76 |
} |
} |
| 77 |
|
|
| 78 |
// Encode weight into the sticky value for the database. |
// Encode weight into the sticky value for the database. |
| 79 |
_weight_encode($node); |
_weight_encode($node); |
| 80 |
break; |
break; |
| 81 |
|
|
| 82 |
case 'load': |
case 'load': |
| 83 |
_weight_decode($node); |
_weight_decode($node); |
| 84 |
break; |
break; |
| 85 |
|
} |
| 86 |
} |
} |
| 87 |
} |
} |
| 88 |
|
|