'on',
'auth' => '',
'table_mod' => '',
'calc' => '0',
'row' => '',
'column' => '',
'dot' => '0',
// 'comma' => '',
// 'copy' => '',
);
$auth_chk = auth::check_auth();
foreach($edit_auth_pages as $key=>$val){
if (preg_match($key, $page) && $edit_auth){
$opt['edit'] = 'off';
if(! empty($auth_chk)){
$opt['edit'] = 'on';
}
}
}
// if(is_editable($page)){ }
$head_button = '';
$body = '';
$body_table = '';
$args = func_get_args();
$arg = array_pop($args);
foreach ($args as $opt_key) {
list($key, $val) = explode('=', strtolower($opt_key));
$opt[$key] = htmlspecialchars($val);
}
// if (PKWK_READONLY) {
if (auth::check_role('readonly') || is_freeze($page) ) {
$opt['edit'] = 'off';
}
// open or close
if ($opt['table_mod'] != 'off' && $opt['edit'] != 'off'){
if ($opt['table_mod'] == 'open' || $opt['table_mod'] == ''){
$image_png = 'close.png" width="11" height="11" alt="" title="close"';
$table_mod = 'close';
} else if ($opt['table_mod'] == 'close'){
$image_png = 'paraedit.png" width="9" height="9" alt="" title="open"';
$opt['edit'] = 'off';
$table_mod = 'open';
}
$head_button = '
<)b
$body .= "|";
}
$body .= "|h\n" . $body_table;
$body_table = '';
$table_header = 0;
} else {
$body .= $body_table;
$body_table = '';
}
if ( $opt['column'] == 'sum' || $opt['column'] == 'average' ) $column_sum_or_avg = 1;
if ( $table_end && $column_sum_or_avg){ //column
$cell_calc = '';
$body .= '|';
for ( $x = 1 ;$x < $cell_count_max ;$x++){
$cell_column = 0;
for ( $y = 1 ;$y < $line_count ;$y++){
$cell_column += $cells[$y][$x];
}
if ($opt['column'] == 'sum' ) {
$cell_calc = $cell_column;
} else if ($opt['column'] == 'average'){
$cell_calc = $cell_column / ( $line_count - 1);
}
$body .= 'RIGHT: ' . number_format((float) $cell_calc, $opt['dot'], '.', $comma) . '|';
}
$body .= $opt['edit'] == 'on' ? '|' : '';
$body .= "\n";
$table_end = 0;
}
$cell_format = 'RIGHT: '; //06.09.15 calc 0.2
$body .= $args_line . "\n";
}
}
return $head_button . convert_html($body);
}
function cell_func($matc_cell,$cells,$line_count,$cell_count,$cell)
{
$func_s = $func_r = array();
for ($i=0; $i< count($matc_cell[0]); $i++) {
// $func_chk = function_exists($matc_cell[1][$i]) ? TRUE : FALSE;
$func_name = "sum_r sum_c cell cell_ra avg_r avg_c count_r count_c max_r max_c min_r min_c";
if ( preg_match("/\b" . $matc_cell[1][$i] . "\b/i", $func_name ) ) {
$cell_func = call_user_func(strtolower($matc_cell[1][$i]),$matc_cell[2][$i],$matc_cell[3][$i],$cells,$line_count,$cell_count);
}
$func_s[$i] = '/\@' . $matc_cell[1][$i] . '\(' . $matc_cell[2][$i] . ',' . $matc_cell[3][$i] . '\)/';
$func_r[$i] = '' . $cell_func . '';
// $cell .= "func1: " . $matc_cell[1][$i]; //data test
// $cell .= ", func2: " . $matc_cell[2][$i];
// $cell .= ", func3: " . $matc_cell[3][$i];
}
$cell = preg_replace($func_s, $func_r, $cell);
return $cell;
// return $matc_cell[0][1];
}
function sum_r($start,$end,$cells,$line_count,$cell_count)
{
$cell_sum = 0;
for ( $x = $start;$x <= $end;$x++){
$cell_sum += $cells[$line_count][$x];
}
return $cell_sum;
}
function sum_c($start,$end,$cells,$line_count,$cell_count)
{
$cell_sum = 0;
for ( $x = $start;$x <= $end;$x++){
$cell_sum += $cells[$x][$cell_count];
}
return $cell_sum;
}
function cell($row,$column,$cells,$line_count,$cell_count)
{
$cell = $cells[$row][$column];
return $cell;
}
//rlative addrss
function cell_ra($row,$column,$cells,$line_count,$cell_count)
{
$cell = $cells[$line_count - $row][$cell_count - $column];
return $cell;
}
function avg_r($start,$end,$cells,$line_count,$cell_count)
{
$cell_sum = 0;
$sum_count = 0;
for ( $x = $start;$x <= $end;$x++){
$cell_sum += $cells[$line_count][$x];
if (is_numeric($cells[$line_count][$x])){
$sum_count++;
}
}
$cell_avg = ( $sum_count === 0 ) ? '' : $cell_sum / $sum_count;
return $cell_avg;
}
function avg_c($start,$end,$cells,$line_count,$cell_count)
{
$cell_sum = 0;
$sum_count = 0;
for ( $x = $start;$x <= $end;$x++){
$cell_sum += $cells[$x][$cell_count];
if (is_numeric($cells[$x][$cell_count])){
$sum_count++;
}
}
$cell_avg = ( $sum_count === 0 ) ? '' : $cell_sum / $sum_count;
return $cell_avg;
}
function count_r($start,$end,$cells,$line_count,$cell_count)
{
$count = 0;
for ( $x = $start;$x <= $end;$x++){
if (is_numeric($cells[$line_count][$x])){
$count++;
}
}
return $count;
}
function count_c($start,$end,$cells,$line_count,$cell_count)
{
$count = 0;
for ( $x = $start;$x <= $end;$x++){
if (is_numeric($cells[$x][$cell_count])){
$count++;
}
}
return $count;
}
function max_r($start,$end,$cells,$line_count,$cell_count)
{
$max_cell = $cells[$line_count][$start];
$start++;
for ( $x = $start;$x <= $end;$x++){
if ($max_cell < $cells[$line_count][$x]){
$max_cell = $cells[$line_count][$x];
}
}
return $max_cell;
}
function max_c($start,$end,$cells,$line_count,$cell_count)
{
$max_cell = $cells[$start][$cell_count];
$start++;
for ( $x = $start;$x <= $end;$x++){
if ($max_cell < $cells[$x][$cell_count]){
$max_cell = $cells[$x][$cell_count];
}
}
return $max_cell;
}
function min_r($start,$end,$cells,$line_count,$cell_count)
{
$min_cell = $cells[$line_count][$start];
$start++;
for ( $x = $start;$x <= $end;$x++){
if ($min_cell > $cells[$line_count][$x]){
$min_cell = $cells[$line_count][$x];
}
}
return $min_cell;
}
function min_c($start,$end,$cells,$line_count,$cell_count)
{
$min_cell = $cells[$start][$cell_count];
$start++;
for ( $x = $start;$x <= $end;$x++){
if ($min_cell > $cells[$x][$cell_count]){
$min_cell = $cells[$x][$cell_count];
}
}
return $min_cell;
}
function plugin_table_edit2_inline()
{
global $script, $vars, $edit_auth_pages;
$page = isset($vars['page']) ? $vars['page'] : '';
$r_page = rawurlencode($page);
$body = '';
$opt = array(
'edit_mod' => '',
'table_num' => '',
'line_count' => '',
);
$args = func_get_args();
foreach ($args as $opt_key) {
list($key, $val) = explode('=', strtolower($opt_key));
$opt[$key] = htmlspecialchars($val);
}
if ($opt['edit_mod'] == 'show' || $opt['edit_mod'] == 'tdshow'){
$image_png = 'paraedit.png" width="9" height="9" alt="" title="edit"';
} else if ($opt['edit_mod'] == 'tr' || $opt['edit_mod'] == 'td'){
$image_png = 'mini_add.png" width="8" height="8" alt="" title="addition"';
}
$body .= '$title, 'body'=>$body);
}
header('Location: ' . $script . '?' . rawurlencode($page) . '#' . "table_edit2_table_number$table_num"); //1.0 06.09.20
exit;
}
//table edit form
function table_edit_form($page, $_edit_mod, $table_num, $edit_count, $edit_cell, $table_sub_num, $table_header)
{
if ($_edit_mod == 'show'){
$line_name = ' line';
$edit_mod = 't_edit';
$x_count = 'line_count';
$y_count = 'cell_count';
} else if ($_edit_mod == 'tdshow'){
$line_name = " (sub number=" . $table_sub_num . ") column line";
$edit_mod = 't_edit_td';
$x_count = 'cell_count';
$y_count = 'line_count';
}
$body = '' . 'table=' . $table_num . $line_name . '=' . $edit_count . '
';
$body .= '
EOD;
return $body;
}
?>