public static function getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false)
{
$sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
if ($tables === null) {
$tables = $GLOBALS['dbi']->getTablesFull($db, '', false, null, $limit_offset, $limit_count);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
}
}
if (count($tables) < 1) {
return $tables;
}
$default = array('Name' => '', 'Rows' => 0, 'Comment' => '', 'disp_name' => '');
$table_groups = array();
foreach ($tables as $table_name => $table) {
$table['Rows'] = self::_checkRowCount($db, $table);
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping'] && $sep && mb_strstr($table_name, $sep)) {
$parts = explode($sep, $table_name);
$group =& $table_groups;
$i = 0;
$group_name_full = '';
$parts_cnt = count($parts) - 1;
while ($i < $parts_cnt && $i < $GLOBALS['cfg']['NavigationTreeTableLevel']) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
if (!isset($group[$group_name])) {
$group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
$table = $group[$group_name];
$group[$group_name] = array();
$group[$group_name][$group_name] = $table;
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} else {
$group[$group_name]['tab' . $sep . 'count']++;
}
$group =& $group[$group_name];
$i++;
}
} else {
if (!isset($table_groups[$table_name])) {
$table_groups[$table_name] = array();
}
$group =& $table_groups;
}
$table['disp_name'] = $table['Name'];
$group[$table_name] = array_merge($default, $table);
}
return $table_groups;
}