primo commit
This commit is contained in:
4
templates/tabulizer/calc/.htaccess
Normal file
4
templates/tabulizer/calc/.htaccess
Normal file
@ -0,0 +1,4 @@
|
||||
satisfy any
|
||||
order deny,allow
|
||||
deny from all
|
||||
|
||||
51
templates/tabulizer/calc/add.php
Normal file
51
templates/tabulizer/calc/add.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
class TabulizerCalcAdd {
|
||||
function calc($row_id, $column_id, $values, $custom_arg) {
|
||||
$sum = null;
|
||||
$count = 0;
|
||||
|
||||
if (!empty($values)) {
|
||||
$sum = 0;
|
||||
foreach ($values as $coord => $value) {
|
||||
if (!empty($custom_arg)) {
|
||||
list($value_row_id, $value_column_id) = explode(',',$coord);
|
||||
switch ($custom_arg) {
|
||||
case 'above':
|
||||
$id = intval($value_row_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'below':
|
||||
$id = intval($value_row_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
case 'left':
|
||||
$id = intval($value_column_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'right':
|
||||
$id = intval($value_column_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
default:
|
||||
// unknow case
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$value = TabulizerMath::getNumericValue($value);
|
||||
if (is_numeric($value)) {
|
||||
$sum += $value;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
return $sum;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
51
templates/tabulizer/calc/avg.php
Normal file
51
templates/tabulizer/calc/avg.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
class TabulizerCalcAvg {
|
||||
function calc($row_id, $column_id, $values, $custom_arg) {
|
||||
$sum = null;
|
||||
$count = 0;
|
||||
|
||||
if (!empty($values)) {
|
||||
$sum = 0;
|
||||
foreach ($values as $coord => $value) {
|
||||
if (!empty($custom_arg)) {
|
||||
list($value_row_id, $value_column_id) = explode(',',$coord);
|
||||
switch ($custom_arg) {
|
||||
case 'above':
|
||||
$id = intval($value_row_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'below':
|
||||
$id = intval($value_row_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
case 'left':
|
||||
$id = intval($value_column_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'right':
|
||||
$id = intval($value_column_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
default:
|
||||
// unknow case
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$value = TabulizerMath::getNumericValue($value);
|
||||
if (is_numeric($value)) {
|
||||
$sum += $value;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$value = ($sum / $count);
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
4
templates/tabulizer/calc/index.html
Normal file
4
templates/tabulizer/calc/index.html
Normal file
@ -0,0 +1,4 @@
|
||||
<html>
|
||||
<body bgcolor="#FFFFFF">
|
||||
</body>
|
||||
</html>
|
||||
50
templates/tabulizer/calc/max.php
Normal file
50
templates/tabulizer/calc/max.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class TabulizerCalcMax {
|
||||
function calc($row_id, $column_id, $values, $custom_arg) {
|
||||
$sum = null;
|
||||
$numeric_values = array();
|
||||
|
||||
if (!empty($values)) {
|
||||
$sum = 0;
|
||||
foreach ($values as $coord => $value) {
|
||||
if (!empty($custom_arg)) {
|
||||
list($value_row_id, $value_column_id) = explode(',',$coord);
|
||||
switch ($custom_arg) {
|
||||
case 'above':
|
||||
$id = intval($value_row_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'below':
|
||||
$id = intval($value_row_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
case 'left':
|
||||
$id = intval($value_column_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'right':
|
||||
$id = intval($value_column_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
default:
|
||||
// unknow case
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$value = TabulizerMath::getNumericValue($value);
|
||||
if (is_numeric($value)) {
|
||||
$numeric_values[] = $value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($numeric_values)) {
|
||||
$value = max($numeric_values);
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
52
templates/tabulizer/calc/med.php
Normal file
52
templates/tabulizer/calc/med.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class TabulizerCalcMed {
|
||||
function calc($row_id, $column_id, $values, $custom_arg) {
|
||||
$sum = null;
|
||||
$numeric_values = array();
|
||||
|
||||
if (!empty($values)) {
|
||||
$sum = 0;
|
||||
foreach ($values as $coord => $value) {
|
||||
if (!empty($custom_arg)) {
|
||||
list($value_row_id, $value_column_id) = explode(',',$coord);
|
||||
switch ($custom_arg) {
|
||||
case 'above':
|
||||
$id = intval($value_row_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'below':
|
||||
$id = intval($value_row_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
case 'left':
|
||||
$id = intval($value_column_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'right':
|
||||
$id = intval($value_column_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
default:
|
||||
// unknow case
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$value = TabulizerMath::getNumericValue($value);
|
||||
if (is_numeric($value)) {
|
||||
$numeric_values[] = $value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($numeric_values)) {
|
||||
sort($numeric_values, SORT_NUMERIC);
|
||||
$median_index = round(count($numeric_values) /2, 0, PHP_ROUND_HALF_DOWN);
|
||||
$value = $numeric_values[$median_index];
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
50
templates/tabulizer/calc/min.php
Normal file
50
templates/tabulizer/calc/min.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class TabulizerCalcMin {
|
||||
function calc($row_id, $column_id, $values, $custom_arg) {
|
||||
$sum = null;
|
||||
$numeric_values = array();
|
||||
|
||||
if (!empty($values)) {
|
||||
$sum = 0;
|
||||
foreach ($values as $coord => $value) {
|
||||
if (!empty($custom_arg)) {
|
||||
list($value_row_id, $value_column_id) = explode(',',$coord);
|
||||
switch ($custom_arg) {
|
||||
case 'above':
|
||||
$id = intval($value_row_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'below':
|
||||
$id = intval($value_row_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
case 'left':
|
||||
$id = intval($value_column_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'right':
|
||||
$id = intval($value_column_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
default:
|
||||
// unknow case
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$value = TabulizerMath::getNumericValue($value);
|
||||
if (is_numeric($value)) {
|
||||
$numeric_values[] = $value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($numeric_values)) {
|
||||
$value = min($numeric_values);
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
51
templates/tabulizer/calc/mul.php
Normal file
51
templates/tabulizer/calc/mul.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
class TabulizerCalcMul {
|
||||
function calc($row_id, $column_id, $values, $custom_arg) {
|
||||
$sum = null;
|
||||
$count = 0;
|
||||
|
||||
if (!empty($values)) {
|
||||
$sum = 1;
|
||||
foreach ($values as $coord => $value) {
|
||||
if (!empty($custom_arg)) {
|
||||
list($value_row_id, $value_column_id) = explode(',',$coord);
|
||||
switch ($custom_arg) {
|
||||
case 'above':
|
||||
$id = intval($value_row_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'below':
|
||||
$id = intval($value_row_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
case 'left':
|
||||
$id = intval($value_column_id);
|
||||
if ($id >= $row_id) continue 2;
|
||||
break;
|
||||
case 'right':
|
||||
$id = intval($value_column_id);
|
||||
if ($id <= $row_id) continue 2;
|
||||
break;
|
||||
default:
|
||||
// unknow case
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$value = TabulizerMath::getNumericValue($value);
|
||||
if (is_numeric($value)) {
|
||||
$sum *= $value;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
return $sum;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user