function testTableCount()
 {
     $GLOBALS['cfg']['Server']['extension'] = 'mysql';
     $GLOBALS['cfg']['Server']['host'] = 'localhost';
     $GLOBALS['cfg']['Server']['user'] = '******';
     $this->assertEquals(5, PMA_getTableCount('meddb'));
     $this->assertTrue(true);
 }
    /**
     * returns array with dbs grouped with extended infos
     *
     * @uses    $GLOBALS['PMA_List_Database']
     * @uses    $GLOBALS['cfgRelation']['commwork']
     * @uses    $cfg['ShowTooltip']
     * @uses    $cfg['LeftFrameDBTree']
     * @uses    $cfg['LeftFrameDBSeparator']
     * @uses    $cfg['ShowTooltipAliasDB']
     * @uses    PMA_getTableCount()
     * @uses    PMA_getDbComment()
     * @uses    is_array()
     * @uses    implode()
     * @uses    strstr()
     * @uses    explode()
     * @param   integer $offset
     * @param   integer $count
     * @return  array   db list
     */
    public function getGroupedDetails($offset, $count)
    {
        $dbgroups   = array();
        $parts      = array();

        if ($GLOBALS['cfg']['ShowTooltip']
          && $GLOBALS['cfgRelation']['commwork']) {
            $db_tooltips = PMA_getDbComments();
        }

        if (!$GLOBALS['cfg']['LeftFrameDBTree']) {
            $separators = array();
        } elseif (is_array($GLOBALS['cfg']['LeftFrameDBSeparator'])) {
            $separators = $GLOBALS['cfg']['LeftFrameDBSeparator'];
        } elseif (!empty($GLOBALS['cfg']['LeftFrameDBSeparator'])) {
            $separators = array($GLOBALS['cfg']['LeftFrameDBSeparator']);
        } else {
            $separators = array();
        }

        foreach ($this->getLimitedItems($offset, $count) as $key => $db) {
            // garvin: Get comments from PMA comments table
            $db_tooltip = '';

            if (isset($db_tooltips[$db])) {
                $db_tooltip = $db_tooltips[$db];
            }

            $pos = false;

            foreach($separators as $separator) {
                // use strpos instead of strrpos; it seems more common to
                // have the db name, the separator, then the rest which
                // might contain a separator
                // like dbname_the_rest
                $pos = strpos($db, $separator);

                if ($pos !== false) {
                    break;
                }
            }

            if ($pos !== false) {
                $group          = substr($db, 0, $pos);
                $disp_name_cut  = substr($db, $pos);
            } else {
                $group          = $db;
                $disp_name_cut  = $db;
            }

            $disp_name  = $db;
            if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
                $disp_name      = $db_tooltip;
                $disp_name_cut  = $db_tooltip;
                $db_tooltip     = $db;
            }

            $dbgroups[$group][$db] = array(
                'name'          => $db,
                'disp_name_cut' => $disp_name_cut,
                'disp_name'     => $disp_name,
                'comment'       => $db_tooltip,
            );

            if ($GLOBALS['cfg']['Server']['CountTables']) {
                $dbgroups[$group][$db]['num_tables'] = PMA_getTableCount($db);
            }
        } // end foreach ($GLOBALS['PMA_List_Database']->items as $db)
        return $dbgroups;
    }
Beispiel #3
0
    <h5 style="margin-top: 0px; margin-bottom: 10px;"><a class="item"
        href="<?php 
    echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query;
    ?>
"
        title="<?php 
    echo htmlspecialchars($db_tooltip);
    ?>
" >
    <?php 
    if ($GLOBALS['text_dir'] === 'rtl') {
        echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
    }
    echo htmlspecialchars($disp_name);
    if ($GLOBALS['text_dir'] === 'ltr') {
        echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
    }
    echo '</a></h5>';
    $table_list = PMA_getTableList($GLOBALS['db']);
    if (count($table_list) > 0) {
        PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
    } else {
        echo $GLOBALS['strNoTablesFound'];
    }
    unset($table_list);
} elseif ($GLOBALS['cfg']['LeftFrameLight']) {
    echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
} else {
    $common_url_query = PMA_generate_common_url();
    PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails());
}
Beispiel #4
0
    <p><a class="item"
        href="<?php 
    echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query;
    ?>
"
        title="<?php 
    echo htmlspecialchars($db_tooltip);
    ?>
" >
    <?php 
    if ($GLOBALS['text_dir'] === 'rtl') {
        echo ' <bdo dir="ltr">(' . PMA_getTableCount($db) . ')</bdo> ';
    }
    echo htmlspecialchars($disp_name);
    if ($GLOBALS['text_dir'] === 'ltr') {
        echo ' <bdo dir="ltr">(' . PMA_getTableCount($db) . ')</bdo> ';
    }
    echo '</a></p>';
    $table_list = PMA_getTableList($db);
    if (count($table_list) > 0) {
        PMA_displayTableList($table_list, true, '', $db);
    } else {
        echo $strNoTablesFound;
    }
    unset($table_list);
} elseif ($GLOBALS['cfg']['LeftFrameLight']) {
    echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
} else {
    $common_url_query = PMA_generate_common_url();
    PMA_displayDbList(PMA_getDbList());
}
Beispiel #5
0
$img_minus = PMA_Util::getImage('b_minus.png', '-', array('id' => 'el%dImg'));

$href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
    .' href="navigation.php?%s" target="_self">';

$element_counter = 0;


if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
    $table_list = PMA_Util::getTableList(
        $GLOBALS['db'],
        null,
        $tpos,
        $cfg['MaxTableList']
    );
    $table_count = PMA_getTableCount($GLOBALS['db']);

    // show selected databasename as link to DefaultTabDatabase-page
    // with table count in ()
    $common_url_query = PMA_generate_common_url($GLOBALS['db']);

    $db_tooltip = '';

    if ($GLOBALS['cfg']['ShowTooltip']
        && $GLOBALS['cfgRelation']['commwork']
    ) {
        $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
        if ($_db_tooltip) {
            $db_tooltip = $_db_tooltip;
        }
    }
Beispiel #6
0
/**
 * returns array with dbs grouped with extended infos
 *
 * @uses    $GLOBALS['dblist'] from PMA_availableDatabases()
 * @uses    $GLOBALS['num_dbs'] from PMA_availableDatabases()
 * @uses    $GLOBALS['cfgRelation']['commwork']
 * @uses    $GLOBALS['cfg']['ShowTooltip']
 * @uses    $GLOBALS['cfg']['LeftFrameDBTree']
 * @uses    $GLOBALS['cfg']['LeftFrameDBSeparator']
 * @uses    $GLOBALS['cfg']['ShowTooltipAliasDB']
 * @uses    PMA_availableDatabases()
 * @uses    PMA_getTableCount()
 * @uses    PMA_getComments()
 * @uses    PMA_availableDatabases()
 * @uses    is_array()
 * @uses    implode()
 * @uses    strstr()
 * @uses    explode()
 * @return  array   db list
 */
function PMA_getDbList()
{
    if (empty($GLOBALS['dblist'])) {
        PMA_availableDatabases();
    }
    $dblist = $GLOBALS['dblist'];
    $dbgroups = array();
    $parts = array();
    foreach ($dblist as $key => $db) {
        // garvin: Get comments from PMA comments table
        $db_tooltip = '';
        if ($GLOBALS['cfg']['ShowTooltip'] && $GLOBALS['cfgRelation']['commwork']) {
            $_db_tooltip = PMA_getComments($db);
            if (is_array($_db_tooltip)) {
                $db_tooltip = implode(' ', $_db_tooltip);
            }
        }
        if ($GLOBALS['cfg']['LeftFrameDBTree'] && $GLOBALS['cfg']['LeftFrameDBSeparator'] && strstr($db, $GLOBALS['cfg']['LeftFrameDBSeparator'])) {
            // use strpos instead of strrpos; it seems more common to
            // have the db name, the separator, then the rest which
            // might contain a separator
            // like dbname_the_rest
            $pos = strpos($db, $GLOBALS['cfg']['LeftFrameDBSeparator']);
            $group = substr($db, 0, $pos);
            $disp_name_cut = substr($db, $pos);
        } else {
            $group = $db;
            $disp_name_cut = $db;
        }
        $disp_name = $db;
        if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
            $disp_name = $db_tooltip;
            $disp_name_cut = $db_tooltip;
            $db_tooltip = $db;
        }
        $dbgroups[$group][$db] = array('name' => $db, 'disp_name_cut' => $disp_name_cut, 'disp_name' => $disp_name, 'comment' => $db_tooltip, 'num_tables' => PMA_getTableCount($db));
    }
    // end foreach ($dblist as $db)
    return $dbgroups;
}
Beispiel #7
0
    /**
     * This helps reducing the navi panel size; in the right panel,
     * user can find a navigator to page thru all tables.
     *
     * @todo instead of the 0 parameter, keep track of the
     *       offset in the list of tables ($_SESSION['userconf']['table_limit_offset'])
     *       and use PMA_listNavigator(); do not just check pos in REQUEST
     *       but add another hidden param to see if it's the pos of databases
     *       or the pos of tables. 
     */
    $table_list = PMA_getTableList($GLOBALS['db'], null, 0, $cfg['MaxTableList']);
    if (!empty($table_list)) {
        PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
        // hint user that the table list is larger, until the todo is done
        if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && PMA_getTableCount($GLOBALS['db']) > $GLOBALS['cfg']['MaxTableList']) {
            echo '&nbsp; ( 1 .. ', $GLOBALS['cfg']['MaxTableList'], ' / ', PMA_getTableCount($GLOBALS['db']), ' )';
        }
    } else {
        echo $GLOBALS['strNoTablesFound'];
    }
    unset($table_list);
} elseif ($GLOBALS['cfg']['LeftFrameLight']) {
    echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
} else {
    echo '<div id="databaseList">' . "\n";
    $_url_params = array('pos' => $pos);
    PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
    echo '</div>' . "\n";
    $common_url_query = PMA_generate_common_url();
    PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails($_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']), $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']);
}