if (is_object($anchor)) { $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), 'span'); } // the submit button $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n"; // set the focus Page::insert_script('$("#confirmed").focus();'); // the title of the table if (isset($item['title'])) { $context['text'] .= Skin::build_block($item['title'], 'title'); } // display the full text $context['text'] .= Skin::build_block($item['description'], 'description'); // execute the query string to build the table if (isset($item['query']) && $item['query']) { $context['text'] .= Tables::build($item['id'], 'sortable'); } // display the query string, if any if (isset($item['query']) && $item['query']) { $context['text'] .= BR . '<pre>' . $item['query'] . '</pre>' . BR . "\n"; } // details $details = array(); // information on uploader if (Surfer::is_member() && $item['edit_name']) { $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } // all details if ($details) { $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>' . "\n"; }
/** * render a dynamic table * * @param string the table content * @param string the variant, if any * @return string the rendered text **/ public static function render_dynamic_table($id, $variant = 'inline') { global $context; // refresh on every page load Cache::poison(); // get actual content include_once $context['path_to_root'] . 'tables/tables.php'; // use SIMILE Exhibit if ($variant == 'filter') { // load the SIMILE Exhibit javascript library in shared/global.php $context['javascript']['exhibit'] = TRUE; // load data $context['page_header'] .= "\n" . '<link href="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_json') . '" type="application/json" rel="exhibit/data" />'; // exhibit data in a table $text = '<div ex:role="exhibit-view" ex:viewClass="Exhibit.TabularView" ex:columns="' . Tables::build($id, 'json-labels') . '" ex:columnLabels="' . Tables::build($id, 'json-titles') . '" ex:border="0" ex:cellSpacing="0" ex:cellPadding="0" ex:showToolbox="true" ></div>' . "\n"; // allow for filtering $facets = '<div class="exhibit-facet">' . '<div class="exhibit-facet-header"><span class="exhibit-facet-header-title">' . i18n::s('Filter') . '</span></div>' . '<div class="exhibit-facet-body-frame" style="margin: 0 2px 1em 0;">' . '<div ex:role="facet" ex:facetClass="TextSearch" style="display: block;"></div>' . '</div></div>'; // facets from first columns $facets .= Tables::build($id, 'json-facets'); // filter and facets aside $context['components']['boxes'] .= $facets; // build sparkline } elseif ($variant == 'bars') { $text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=0⪆0.5" alt="" />'; // buid a Flash chart } elseif ($variant == 'chart') { // split parameters $attributes = preg_split("/\\s*,\\s*/", $id, 4); // set a default size if (!isset($attributes[1])) { $attributes[1] = 480; } if (!isset($attributes[2])) { $attributes[2] = 360; } // object attributes $width = $attributes[1]; $height = $attributes[2]; $flashvars = ''; if (isset($attributes[3])) { $flashvars = $attributes[3]; } // allow several charts to co-exist in the same page static $chart_index; if (!isset($chart_index)) { $chart_index = 1; } else { $chart_index++; } // get data in the suitable format $data = Tables::build($attributes[0], 'chart'); // load it through Javascript $url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/open-flash-chart.swf'; $text = '<div id="table_chart_' . $chart_index . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n"; Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "opaque";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "table_chart_' . $chart_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", {"get-data":"table_chart_' . $chart_index . '"}, params);' . "\n" . "\n" . 'var chart_data_' . $chart_index . ' = ' . trim(str_replace(array('<br />', "\n"), ' ', $data)) . ';' . "\n" . "\n" . 'function table_chart_' . $chart_index . '() {' . "\n" . ' return $.toJSON(chart_data_' . $chart_index . ');' . "\n" . '}' . "\n"); // build sparkline } elseif ($variant == 'line') { $text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=2&gap=0.0" alt="" />'; // we do the rendering ourselves } else { $text = Tables::build($id, $variant); } // put that into the web page return $text; }
include '../error.php'; // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_raw'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // display the table in CSV } else { // force the character set $context['charset'] = 'iso-8859-15'; // render actual table content $text = strip_tags(Tables::build($item['id'], 'raw')); // // transfer to the user agent // // handle the output correctly render_raw('text/csv; charset=' . $context['charset']); // suggest a download if (!headers_sent()) { $file_name = utf8::to_ascii(Skin::strip($item['title']) . '.csv'); Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"'); } // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download http::expire(1800); // strong validator $etag = '"' . md5($text) . '"'; // manage web cache
include '../error.php'; // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_xml'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // display the table in CSV } else { // force the character set $context['charset'] = 'iso-8859-15'; // render actual table content $text = Tables::build($id, 'xml'); // // transfer to the user agent // // handle the output correctly render_raw('text/xml; charset=' . $context['charset']); // suggest a download if (!headers_sent()) { $file_name = utf8::to_ascii(Skin::strip($item['title']) . '.xml'); Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"'); } // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download http::expire(1800); // strong validator $etag = '"' . md5($text) . '"'; // manage web cache
include '../error.php'; // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_json'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // display the table in CSV } else { // force the character set $context['charset'] = 'iso-8859-15'; // render actual table content $text = Tables::build($id, 'json'); // // transfer to the user agent // // handle the output correctly render_raw('text/json; charset=' . $context['charset']); // suggest a download if (!headers_sent()) { $file_name = utf8::to_ascii(Skin::strip($item['title']) . '.json'); Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"'); } // enable 3-minute caching (3*60 = 180), even through https, to help IE6 on download http::expire(180); // strong validator $etag = '"' . md5($text) . '"'; // manage web cache
if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!isset($item['id'])) { include '../error.php'; // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_png'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // build an image } else { // render actual table content $data = Tables::build($item['id'], 'column'); // reverse daata order $series = array_reverse(explode(',', $data)); // build a sparkline $sparkline = new sparkline(); $sparkline->build($series, $_REQUEST); // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download http::expire(1800); // the post-processing hook, then exit finalize_page(TRUE); } // render the normal skin in case of error render_skin();