Patch by Leonardo Sápiras during the gsoc2010, plus some external edits based on Alexey reviews and mine.
} else if (isset($conf['use_xhtml_strict']) && $conf['use_xhtml_strict']) {
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd\">\n";
} else {
- echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd\">\n";
+ echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
}
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"{$lang['applocale']}\" lang=\"{$lang['applocale']}\"";
if (strcasecmp($lang['applangdir'], 'ltr') != 0) echo " dir=\"", htmlspecialchars($lang['applangdir']), "\"";
// (e.g. 7.3 )
$conf['help_base'] = 'http://www.postgresql.org/docs/%s/interactive/';
+ // Configuration for ajax scripts
+ // Time in seconds. If set to 0, refreshing data using ajax will be disabled (locks and activity pages)
+ $conf['ajax_refresh'] = 3;
+
/*****************************************
* Don't modify anything below this line *
*****************************************/
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
if (!isset($msg)) $msg = '';
+ $scripts = '';
function _highlight($string, $term) {
return str_replace($term, "<b>{$term}</b>", $string);
$misc->printTable($processes, $columns, $actions, $lang['strnodata']);
}
- /**
- * Show the existing table locks in the current database
- */
- function doLocks() {
- global $data, $misc;
- global $lang;
+ function currentLocks($isAjax = false) {
+ global $data, $misc, $lang;
// Get the info from the pg_locks view
$variables = $data->getLocks();
- $misc->printTrail('database');
- $misc->printTabs('database','locks');
-
$columns = array(
'namespace' => array(
'title' => $lang['strschema'],
if (!$data->hasVirtualTransactionId()) unset($columns['vxid']);
$actions = array();
-
$misc->printTable($variables, $columns, $actions, $lang['strnodata']);
+
+ if ($isAjax) exit;
+ }
+
+ /**
+ * Show the existing table locks in the current database
+ */
+ function doLocks() {
+ global $data, $misc;
+ global $lang;
+
+ $misc->printTrail('database');
+ $misc->printTabs('database','locks');
+
+ echo "<br /><a id=\"control\" href=\"\"><img src=\"".$misc->icon('Refresh')."\" alt=\"{$lang['strrefresh']}\" title=\"{$lang['strrefresh']}\"/> {$lang['strrefresh']}</a>";
+
+ echo "<div id=\"locks_block\" class=\"data_block\">";
+ currentLocks();
+ echo "</div>";
+
+ echo "<a href=\"#\" class=\"bottom_link\">".$lang['strgotoppage']."</a>";
}
/**
require('./admin.php');
+ /* shortcuts: these functions exit the script */
if ($action == 'tree') doTree();
-
- $misc->printHeader($lang['strschemas']);
+ if ($action == 'refresh_locks') currentLocks(true);
+
+ /* normal flow */
+ if ($action == 'locks') {
+ $scripts = "<script src=\"libraries/js/jquery.js\" type=\"text/javascript\"></script>";
+ $scripts .= "<script src=\"js/locks.js\" type=\"text/javascript\"></script>";
+
+ $refreshTime = $conf['ajax_refresh'] * 1000;
+
+ $scripts .= "<script type=\"text/javascript\">\n";
+ $scripts .= "var Database = {\n";
+ $scripts .= "ajax_time_refresh: {$refreshTime},\n";
+ $scripts .= "str_start: {text:'{$lang['strstart']}',icon: '". $misc->icon('Execute') ."'},\n";
+ $scripts .= "str_stop: {text:'{$lang['strstop']}',icon: '". $misc->icon('Stop') ."'},\n";
+ $scripts .= "server:'{$misc->href}',\n";
+ $scripts .= "};\n";
+ $scripts .= "</script>\n";
+ }
+
+ $misc->printHeader($lang['strdatabase'], $scripts);
$misc->printBody();
-
+
switch ($action) {
case 'find':
if (isset($_REQUEST['term'])) doFind(false);
}
$misc->printFooter();
-
?>
--- /dev/null
+$(document).ready(function() {
+
+ var timeid = null;
+ var controlLink = $('#control');
+
+ function refreshLocksTable() {
+ if (Database.ajax_time_refresh > 0) {
+ $.ajax({
+ type: 'GET',
+ dataType: 'html',
+ url: 'database.php?action=refresh_locks&' + Database.server,
+ timeout: Database.ajax_timeout - 100,
+ cache: false,
+ contentType: 'application/x-www-form-urlencoded',
+ success: function(html) {
+ $('#locks_block').html(html);
+ timeid = window.setTimeout(refreshLocksTable, Database.ajax_time_refresh)
+ }
+ });
+ }
+ }
+
+ controlLink.toggle(
+ function() {
+ timeid = window.setTimeout(refreshLocksTable, Database.ajax_time_refresh);
+ controlLink.html('<img src="'+ Database.str_stop.icon +'" alt="" /> '
+ + Database.str_stop.text);
+ },
+ function() {
+ window.clearInterval(timeid);
+ controlLink.html('<img src="'+ Database.str_start.icon +'" alt="" /> '
+ + Database.str_start.text
+ );
+ }
+ );
+
+ controlLink.click();
+});
$lang['strctype'] = 'Character Type';
$lang['strdefaultvalues'] = 'Default values';
$lang['strnewvalues'] = 'New values';
+ $lang['strstart'] = 'Start';
+ $lang['strstop'] = 'Stop';
+ $lang['strgotoppage'] = 'back to top';
// Admin
$lang['stradminondatabase'] = 'The following administrative tasks apply on the whole %s database.';
$lang['strselectall'] = 'Selecionar tudo';
$lang['strunselectall'] = 'Desmarcar tudo';
$lang['strlocale'] = 'Local';
+ $lang['strstart'] = 'Iniciar';
+ $lang['strstop'] = 'Parar';
+ $lang['strgotoppage'] = 'Topo da página';
// User-supplied SQL history
$lang['strhistory'] = 'Histórico';
$lang['strinstead'] = 'Fazer ao invés';
$lang['strwhen'] = 'Quando';
$lang['strformat'] = 'Formato';
+$lang['strstart'] = 'Iniciar';
+$lang['strstop'] = 'Parar';
+$lang['strgotoppage'] = 'Topo da página';
// Error handling
$lang['strdata'] = 'Data';
$lang['strctype'] = 'Character Type';
$lang['strdefaultvalues'] = 'Default values';
$lang['strnewvalues'] = 'New values';
+ $lang['strstart'] = 'Start';
+ $lang['strstop'] = 'Stop';
+ $lang['strgotoppage'] = 'back to top';
// Admin
$lang['stradminondatabase'] = 'The following administrative tasks apply on the whole %s database.';
$lang['strselectall'] = 'Selecionar tudo';
$lang['strunselectall'] = 'Desmarcar tudo';
$lang['strlocale'] = 'Local';
+ $lang['strstart'] = 'Iniciar';
+ $lang['strstop'] = 'Parar';
+ $lang['strgotoppage'] = 'Topo da página';
// User-supplied SQL history
$lang['strhistory'] = 'Histórico';
$lang['strinstead'] = 'Fazer ao invés';
$lang['strwhen'] = 'Quando';
$lang['strformat'] = 'Formato';
+$lang['strstart'] = 'Iniciar';
+$lang['strstop'] = 'Parar';
+$lang['strgotoppage'] = 'Topo da página';
// Error handling
$lang['strdata'] = 'Data';
}
.ac_values {width:100%}
.ac_field {border:1px solid #D9D95F}
+
+.bottom_link {
+ position: fixed;
+ bottom: 0;
+ right: 0;
+ padding: 5px;
+}