'',
'graph_mod' => '',
'list_mod' => '',
'setting' => '',
'change' => '0',
'width' => '400',
'height' => '250',
'bg_color' => '666666',
'transparent' => '0',
'license' => '0',
);
$args = func_get_args();
foreach ($args as $opt_key) {
list($key, $val) = explode('=', strtolower($opt_key));
$opt[$key] = htmlspecialchars($val);
}
$page = isset($vars['page']) ? $vars['page'] : '';
if (! isset($number[$page])) $number[$page] = 1;
$count = $number[$page]++;
$r_page = rawurlencode($page);
$auth_chk = auth::check_auth();
foreach($edit_auth_pages as $key=>$val){
if (preg_match($key, $page) && $edit_auth){
if(! empty($auth_chk)){
} else {
if($opt['setting'] != 'on'){
$opt['setting'] = 'off';
}
}
}
}
$head_button = '';
// if (PKWK_READONLY || is_freeze($page) ) {
if (auth::check_role('readonly') || is_freeze($page) ) {
$opt['setting'] = 'off';
}
$change = $opt['change'];
$swf = SKIN_DIR . 'charts.swf';
$charts_library = SKIN_DIR . 'charts_library';
$php_source = $scripe . '?plugin=charts&refer=' . $r_page . '&chart_type=' . $opt['graph_mod']
. '&table_num=' . $opt['table_num'] . '&change=' . $change;
if (isset($opt['chart_transition'])){
$php_source .= '&chart_transition';
}
if (isset($opt['chart_value'])){
$php_source .= '&chart_value=' . $opt['chart_value'];
}
if (isset($opt['xml_read'])){
$php_source .= '&charts_num=' . $count . '&xml_read';
}
if ($opt['setting'] != 'off'){
if ( $opt['list_mod'] == 'open' ){
//graph list
$graph_type = array('line', 'column', 'stacked column', 'floating column',
'3d column', 'stacked 3d column', 'parallel 3d column',
'pie', '3d pie', 'bar', 'stacked bar', 'floating bar',
'area', 'stacked area', 'candlestick', 'scatter', 'polar',
);
foreach($graph_type as $type) {
if ($opt['graph_mod'] == $type){
$select_list .= "\n";
} else {
$select_list .= "\n";
}
}
$radio_chk[$opt['change']] = "checked";
$radio = " column\n";
$radio .= " row\n";
$head_button = <<
EOD;
// $head_button .= "\ncheck\n";
// open or close
$image_png = 'plus/close.png" width="11" height="11" alt="" title="list close"';
$list_mod = 'close';
} else if ($opt['list_mod'] == 'close' || $opt['list_mod'] == ''){
$image_png = 'plus/chart.png" width="9" height="10" alt="" title="list open"';
$opt['list_mod'] = 'off';
$list_mod = 'open';
}
$head_button .= ' ';
}
return $head_button . InsertChart( $swf, $charts_library, $php_source, $opt['width'], $opt['height'], $opt['bg_color'], $opt['transparent'], $opt['license']);
}
function InsertChart( $flash_file, $library_path, $php_source, $width, $height, $bg_color, $transparent, $license)
{
$php_source = urlencode($php_source);
$library_path = urlencode($library_path);
if($license != 0){
$license = "&license=$license";
} else {
$license = "";
}
if($transparent != 0){
$transparent_html = "\t\r\n";
$transparent_opt = "wmode=transparent";
} else {
$transparent_html = "";
$transparent_opt = "";
}
$html = <<
$transparent_html
EOD;
return $html;
}
function plugin_charts_action()
{
global $vars, $post, $script;
$line_count = 1;
$charts_num = $vars['charts_num'];
$page = $vars['refer'];
static $count = 0;
if ( isset($vars['chart_type']) ) {
$xml_source = "";
pkwk_common_headers();
header('Content-type: text/xml');
print '' . "\n";
if( isset($vars['xml_read'])){
$p_source = get_source($page);
$xml_line_count = 0;
foreach ($p_source as $source_line) {
if(preg_match('/^#([^\(\{]+)(?:\(([^\r]*)\))?(\{*)/', $source_line, $matches) && $matches[1] == 'charts') {
$charts_find = 1;
$count++;
$end_line = strlen($matches[3]);
}
if (preg_match('/^\}{' . $end_line . '}/', $source_line)) {
$charts_find = 0;
}
if( $count == $charts_num ){
if( $charts_find && $xml_line_count){
$xml_source .= $source_line;
}
$xml_line_count++;
}
}
}
print $xml = chart_xml($page, $vars, $xml_source);
exit;
}
// if (PKWK_READONLY) die_message( ('PKWK_READONLY prohibits editing') );
if (auth::check_role('readonly')) die_message('PKWK_READONLY prohibits editing');
if (! path_check($script,$_SERVER['HTTP_REFERER'])) return;
$args = get_source($page);
$source_s = '';
$notimestamp = (isset($vars['notimestamp'])) ? TRUE : FALSE;
if ($vars['list_mod'] == 'close'){
$search_r = array ('@list_mod=open@si');
$replace_r = array ('list_mod=close');
} else if ($vars['list_mod'] == 'open') {
$search_r = array ('@list_mod=close@si');
$replace_r = array ('list_mod=open');
}
foreach ($args as $args_line) {
// if (preg_match('/^#charts([^\(\{]+)(?:\(([^\r]*)\))?(\{*)/', $args_line, $matches)){
if(preg_match('/^#([^\(\{]+)(?:\(([^\r]*)\))?(\{*)/', $args_line, $matches) && $matches[1] == 'charts') {
$charts_find = 1;
$count++;
if( $line_count === 1 && $count == $charts_num ){
if(! preg_match('/(auth_check_off)/i',$matches[2])){
check_editable($page, true, true);
}
if ( isset($vars['list_mod']) ){ //list_mod
$notimestamp = TRUE;
if(preg_match('/(list_mod)/',$matches[2])){
$args_line = preg_replace($search_r, $replace_r, $args_line);
} else {
$args_line = "#charts(" . $matches[2] . ",list_mod=" . $vars['list_mod'] . ")" . $matches[3] . "\n";
}
}
if ( isset($vars['list']) ){ //list_mod
$notimestamp = TRUE;
if( preg_match('/(graph_mod)/', $matches[2] ) ){
$args_line = preg_replace( array ('@graph_mod=[^>]*?,@si'), array ('graph_mod=' . $vars['graph_mod'] . ','), $args_line);
} else {
$args_line = "#charts(" . "graph_mod=" . $vars['graph_mod'] . "," . $matches[2] . ")" . $matches[3] . "\n";
}
if( preg_match('/(change)/', $matches[2] ) ){
$args_line = preg_replace( array ('@change=\d@si'), array ('change=' . $vars['change']), $args_line);
} else {
$args_line = "#charts(" . $matches[2] . ",change=" . $vars['change'] . ")" . $matches[3] . "\n";
}
}
}
$end_line = strlen($matches[3]);
}
if (preg_match('/^\}{' . $end_line . '}/', $args_line)) {
$charts_find = 0;
}
$source_s .= $args_line;
}
if(isset($vars['list_mod']) || isset($vars['list'])){
page_write($page, $source_s, $notimestamp);
}
$post['refer'] = $page;
header('Location: ' . $script . '?' . rawurlencode($page) . '#' . "charts_number$charts_num");
exit;
}
function chart_xml( $page, $vars, $xml_source)
{
$chart_type = $vars['chart_type'];
$table_num = $vars['table_num'];
$change = $vars['change'];
$source = get_source($page);
$table_count = 1;
$table_chk = 0;
$line_count = 0;
foreach ($source as $s_line){
//table search
if ( preg_match('/^\|(.+)\|([hHfFcC]?)$/', $s_line, $match) ){
if ( $table_count == $table_num ){
if ( strtolower( $match[2] ) != 'c'){
$cells = explode("|", $match[1]);
$cell_count = 0;
foreach ($cells as $cell){
if( $line_count == 0 || $cell_count == 0 ){
$cell = "\t\t\t" . $cell . "\r\n";
} else {
$cell = "\t\t\t" . $cell . "\r\n";
}
if( $change ){
$chart[$cell_count][$line_count] = $cell;
} else {
$chart[$line_count][$cell_count] = $cell;
}
$cell_count++;
}
$line_count++;
}
}
$table_chk = 1;
} else {
if ( $table_chk ) {
$table_count++;
$table_chk = 0;
}
}
}
if ( $change ) {
$max_y = $line_count;
$max_x = $cell_count;
} else {
$max_x = $line_count;
$max_y = $cell_count;
}
// $max_x = count($chart);
// $max_y = count($chart[1]);
$xml = "\r\n";
$xml .= "\t" . $chart_type . "\r\n";
if ( isset($vars['chart_transition'])){
$xml .= "\t\r\n";
}
if ( isset($vars['chart_value'])){
$xml .= "\t\r\n";
}
// if ( isset($vars['draw_text'])){
// $xml .= "\t\r\n\t\tgraph\r\n\t";
// }
if ( isset($vars['xml_read'])){
$xml .= $xml_source;
}
$xml .= "\t\r\n";
for ( $x = 0; $x < $max_x;$x++){
$xml .= "\t\t\r\n";
for ( $y = 0; $y < $max_y;$y++){
$xml .= $chart[$x][$y];
}
$xml .= "\t\t
\r\n";
}
$xml .= "\t\r\n";
$xml .= "\r\n";
return $xml;
}
?>