Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fd11a29ce3
51
db_tables_search.php
Normal file
51
db_tables_search.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/common.lib.php';
|
||||
|
||||
$db = $_GET['db'];
|
||||
$table_term = $_GET['table'];
|
||||
$common_url_query = PMA_generate_common_url($GLOBALS['db']);
|
||||
$tables_full = PMA_getTableList($db);
|
||||
$tables_response = array();
|
||||
|
||||
foreach ($tables_full as $key => $table) {
|
||||
if (strpos($key, $table_term) !== FALSE) {
|
||||
$link = '<li class="ajax_table"><a class="tableicon" title="'
|
||||
. htmlspecialchars($link_title)
|
||||
. ': ' . htmlspecialchars($table['Comment'])
|
||||
. ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
|
||||
. ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
|
||||
. ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
|
||||
. $common_url_query
|
||||
. '&table=' . urlencode($table['Name'])
|
||||
. '&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
|
||||
. '" >';
|
||||
$attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
|
||||
if (PMA_Table::isView($table_db, $table['Name'])) {
|
||||
$link .= PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr);
|
||||
} else {
|
||||
$link .= PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr);
|
||||
}
|
||||
$link .= '</a>';
|
||||
// link for the table name itself
|
||||
$href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
|
||||
. $common_url_query . '&table='
|
||||
. urlencode($table['Name']) . '&pos=0';
|
||||
$link .= '<a href="' . $href . '" title="'
|
||||
. htmlspecialchars(
|
||||
PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
|
||||
. ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')'
|
||||
)
|
||||
. '" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
|
||||
// preserve spaces in table name
|
||||
. str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
|
||||
$link .= '</li>' . "\n";
|
||||
$table['line'] = $link;
|
||||
$tables_response[] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
PMA_ajaxResponse('', true, array('tables' => $tables_response));
|
||||
@ -160,6 +160,9 @@ function PMA_setCookie(name, value, expires, path, domain, secure)
|
||||
function fast_filter(value)
|
||||
{
|
||||
var lowercase_value = value.toLowerCase();
|
||||
var matches = 0;
|
||||
var db = $('#lightm_db').val();
|
||||
$('li.ajax_table').hide();
|
||||
$("#subel0 a[class!='tableicon']").each(function(idx, elem) {
|
||||
var $elem = $(elem);
|
||||
// .indexOf is case sensitive so convert to lowercase to compare
|
||||
@ -167,10 +170,28 @@ function fast_filter(value)
|
||||
$elem.parent().hide();
|
||||
} else {
|
||||
$elem.parents('li').show();
|
||||
matches = matches + 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (matches === 0) { //If no local matches search in all tables
|
||||
if (fast_filter.ajax_semaphore) { //If is true another request is running
|
||||
return;
|
||||
}
|
||||
fast_filter.ajax_semaphore = true;
|
||||
$.get('db_tables_search.php?db=' + db +'&table=' + lowercase_value, function(data) {
|
||||
var tables = data.tables;
|
||||
var l = tables.length;
|
||||
for(var i = 0; i < l; i++) {
|
||||
$('#subel0').append(tables[i].line);
|
||||
}
|
||||
fast_filter.ajax_semaphore = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fast_filter.ajax_semaphore = false; //If is true an Ajax request is running
|
||||
|
||||
/**
|
||||
* Clears fast filter.
|
||||
*/
|
||||
@ -223,8 +244,11 @@ $(function(){
|
||||
$('#fast_filter').focus();
|
||||
});
|
||||
|
||||
$('#fast_filter').keyup(function(evt) {
|
||||
$('#fast_filter').keyup(function(evt) {
|
||||
fast_filter($(this).val());
|
||||
if ($(this).val() == '') { //Hides added tables by search
|
||||
$('li.ajax_table').hide();
|
||||
}
|
||||
});
|
||||
|
||||
/* Jump to recent table */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user