function weight_nodeapi in Weight 5
Same name and namespace in other branches
- 6 weight.module \weight_nodeapi()
File
- ./
weight.module, line 116
Code
function weight_nodeapi(&$node, $op) {
switch ($op) {
case 'submit':
// non-weighted nodes have a weight of zero
if (is_null($node->node_weight)) {
$node->node_weight = 0;
}
// If the admin wants to use the menu weight, see if there is one.
if (variable_get('weight_use_menu', FALSE)) {
$node->node_weight = isset($node->menu['title']) && !empty($node->menu['title']) ? $node->menu['weight'] : $node->node_weight;
}
// here we're 'encoding' weight into the sticky value for the database
// stickiness is the inverse of weight
// - stickiness is sorted DESC while weight is sorted ASC so we invert
// the weight before saving... if sticky box is checked, add 100 to
// weight unweighted sticky nodes will have a value of 100
_weight2encoded_sticky($node);
break;
case 'load':
_encoded_sticky2weight($node);
break;
}
}