Mastering phpMyAdmin 3.3.x for Effective MySQL Management
上QQ阅读APP看书,第一时间看更新

Customizing general settings

This section describes settings that have an impact on many panels. These settings modify the appearance of titles in windows, of information icons, and how the list of tables is sorted. The whole visual style of all pages is controlled by the theme system, which is covered here altogether. This section also deals with how to restrict the list of databases seen by users.

Configuring the window title

When the navigation and main panels are displayed, the window's title changes to reflect which MySQL server, database, and table are active. phpMyAdmin also shows some information about the web server's hostname if $cfg['ShowHttpHostTitle'] is set to TRUE. What is displayed depends on another setting $cfg['SetHttpHostTitle']. If this setting is empty (as it is by default), the true web server's hostname appears in the title. We can put another string, such as "my Web server", and this will be shown instead of the true hostname.

Seeing the web server's hostname can come in handy when we have many phpMyAdmin windows open, thus being connected to more than one web server. Of course, each phpMyAdmin window can itself give access to many MySQL servers.

Configuring icons

When various warnings, errors, or information messages are displayed, they can be accompanied by an icon, if $cfg['ErrorIconic'] is set to TRUE. Another parameter, $cfg['ReplaceHelpImg'], when set to TRUE, displays a small icon containing a question mark at every place where documentation is available for a specific subject. These two parameters are set to TRUE by default.

Natural sort order for database and table names

Usually, computers sort items in lexical order, which gives the following results for a list of tables:

table1
table10
table2
table3

phpMyAdmin implements "natural sort order" by default, as specified by $cfg['NaturalOrder'] being TRUE. Thus, the database and table lists in the navigation and main panels are sorted as:

table1
table2
table3
table10

Creating site-specific headers and footers

Some users may want to display a company logo, a link to their company's helpdesk, or other information on the phpMyAdmin interface. In the main phpMyAdmin directory, for this purpose, we can create two scripts—config.header.inc.php and config.footer.inc.php. We can put our own PHP or XHTML code in these scripts, and it will appear either at the beginning (for header) or at the end (for footer) of the cookie login and the main panel pages.

For example, create a config.footer.inc.php script containing these lines:

<hr />
<em>All the information on this page is confidential.</em>

This would produce the intended message on all pages:

Creating site-specific headers and footers

Displaying MySQL documentation links

phpMyAdmin displays links to the MySQL documentation at various places on its interface. These links refer to the exact point in the official MySQL documentation to learn about a specific MySQL command. We can customize the location and manual type referred to, with the following configuration parameters:

$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman';
$cfg['MySQLManualType'] = 'viewable';

About the manual base, users who prefer to keep a copy of this documentation on a local server would specify a local link here. For the manual type, the most up-to-date possible values are explained as comments in config.inc.php.

Themes

A theme system is available in phpMyAdmin starting with version 2.6.0. The color parameters and the various icons are located in a directory structure under the themes subdirectory. For each available theme, there is a subdirectory named after the theme. It contains:

  • layout.inc.php for the theme parameters
  • css directory with the various CSS scripts
  • img directory containing any icons or other imagery (such as logos)
  • screen.png: A screenshot of this theme

The downloaded kit contains two themes, but there are more available at http://phpmyadmin.net/home_page/themes.php. Installing a new theme is just a matter of downloading the corresponding .zip file and extracting it under the themes subdirectory.

Note

In case someone would like to build a custom theme that contains JavaScript code, please note that some phpMyAdmin 3.3 pages are using the MooTools JavaScript library, and all phpMyAdmin 3.4 pages will be including the jQuery library.

Configuring themes

In config.inc.php, the $cfg['ThemePath'] parameter contains'themes' by default, indicating which subdirectory the required structure is located in. This can be changed to point to another directory where our company's specific phpMyAdmin themes are located.

The default chosen theme is specified in $cfg['ThemeDefault'], and is set to'original'. If no theme selection is available for users, this theme will be used.

The original subdirectory should never be deleted; phpMyAdmin relies on it for normal operations.

Selecting themes

On the home page, we can offer a theme selector to users. Setting $cfg['ThemeManager'] to TRUE (the default) shows the selector:

Selecting themes

To help choose a suitable theme, the Theme / Style link displays a panel containing screenshots of the available themes and a Get more themes link. We can then click on take it under the theme we want. The chosen theme is remembered in a cookie. By default, the remembered theme applies to all servers that we connect to. To make phpMyAdmin remember one theme per MySQL server, we set $cfg['ThemePerServer'] to TRUE.

Assigning colors using the color picker

Here is a feature—the custom color picker—that may seem frivolous but has its utility. We'll first discuss the how and then the why.

Located on the home page, the small rainbow icon gives access to a picker that controls the background color of both panels. The phpMyAdmin team merged the MooRainbow code from Djamil Legato (http://moorainbow.woolly-sheep.net) to offer this feature.

Assigning colors using the color picker

You can operate the picker in many ways—moving the slider, moving the mouse in the big square, or directly entering values into the fields. When you are done, you click on Select to clear the picker.

The purpose of this feature is to help users who are working simultaneously on many MySQL servers, and like to have visual clues about each server. Another possible scenario is a busy database administrator who takes calls from customers and opens many phpMyAdmin windows. He then assigns priorities by using the color picker, say red for top priority—you get the idea.

Sliders

You'll see on some pages, a small plus sign followed by a controlling label—either Options or Details. A click on the label opens a slider to reveal a section of the interface, which is believed to be less often used in day-to-day work. As some people prefer to immediately see the whole interface—at the expense of screen space—there is a configuration parameter that controls how the sliders are initially set:

$cfg['InitialSlidersState'] = 'closed';

The default value of closed means that sliders must be opened by clicking on the label; you might have guessed that the reverse value is open. A third value, disabled, can be used by slider-allergic users. This JavaScript feature comes from the MooTools library located at http://mootools.net.

Limiting URL lengths

Some web servers—for example, Internet Information Server (IIS)—have problems handling long URLs. As phpMyAdmin creates such URLs on the generated pages, we need a way to indicate when a link would be too long and should be replaced by a form with buttons. The $cfg['LinkLengthLimit'] directive acts as this limit, with a default value of 1000 which seems appropriate for such servers.

Restricting the list of databases

Sometimes it's useful to avoid showing, in the navigation panel, all the databases a user has access to. phpMyAdmin offers two ways of restricting this—only_db and hide_db.

To specify the list of what can be seen, the only_db parameter is used. It may contain a database name or a list of database names. Only these databases will be seen in the navigation panel:

$cfg['Servers'][$i]['only_db'] = 'payroll';
$cfg['Servers'][$i]['only_db'] = array('payroll', 'hr);

The database names can contain MySQL wildcard characters such as _ and %. These wildcard characters are described at http://dev.mysql.com/doc/refman/5.1/en/account-names.html. If an array is used to specify many databases, they will be displayed on the interface in the same order as they are listed in the array.

Another feature of only_db is that you can use it not to restrict the list, but instead to put emphasis on certain names that will be displayed on top of the list. Here, the myspecial database name will appear first, followed by all other names:

$cfg['Servers'][$i]['only_db'] = array('myspecial', '*');

We can also indicate which database names must be hidden with the hide_db parameter. It contains a regular expression (http://en.wikipedia.org/wiki/Regular_expression) representing what to exclude. If we do not want users to see any database whose name begins with secret, we should use:

$cfg['Servers'][$i]['hide_db'] = '^secret';

These parameters apply to all users for this server-specific configuration.

Note

These mechanisms do not replace the MySQL privilege system. Users' rights on other databases still apply, but they cannot use phpMyAdmin's navigation panel to reach their other databases or tables.