Skip to content

Commit 6ec939d

Browse files
committedSep 16, 2014
#46 - algorithm for calculating splits to work with sample page / exposed filter (also needs code update in php fields)
1 parent c9e239d commit 6ec939d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎sites/all/modules/custom/kendra_wf/kendra_wf.module

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@
88
/**
99
* Called from a views PHP field
1010
*/
11-
function kendra_wf_calc_points_value($nid, &$static) {
11+
function kendra_wf_calc_points_value($nid, &$static, $start_p=0, $end_p=100) {
1212
//drupal_set_message($nid);
1313
$node = node_load($nid);
1414
$node_wrapper = entity_metadata_wrapper('node', $node);
1515

1616
// Get the total usage (target usage).
1717
$target_usage = $node_wrapper->field_cont_target_usage->value();
18+
19+
// Reduce start and end points so they are within the provided once.
20+
foreach ($target_usage as &$value) {
21+
if ($value['from'] < $start_p) {
22+
$value['from'] = $start_p;
23+
}
24+
if ($value['to'] > $end_p) {
25+
$value['to'] = $end_p;
26+
}
27+
}
28+
1829
$total_usage = _kendra_wf_calc_usage_value($target_usage);
1930
// Usage weight.
2031
$usage_weight = $node_wrapper->field_cont_usage_weight->value();

0 commit comments

Comments
 (0)