59.2. The index.cgi Program

Because most of the graphical customization done by this theme occurs in the theme.pl script, its replacement index.cgi program does not differ much from the standard index.cgi in the top-level Webmin directory. The biggest difference is that it does not output any special index page heading or image. Instead, it just gets the list of modules available to the current user with get_available_module_infos and uses it to build a table of icons in the current category. Because the theme's theme_header function also calls this function, the list may already be in the global @msc_modules variable. Theme CGI programs execute in the “original” directory instead of the directory they are really in, therefore the index.cgi program in the MSC theme can use the line require './web-lib.pl';.

It is possible to create quite a different theme just by replacing index.cgi, without the need for a theme's function file. The standard Caldera theme has an index.cgi script that actually generates a frame set, in which the top frame displays categories and modules, and the bottom shows actual pages within modules. It is possible for a theme to include CGI programs that do not override any real program, and are used only as part of the theme's user interface. For example, the index_top.cgi program that the Caldera theme uses to render the top frame. Again, such programs are run in the corresponding real directory, not in the theme's subdirectory.

The MSC theme's index.cgi and theme.pl scripts all make use of %text and the text function to get messages to display to the user, instead of hard coding them into the Perl code. All of the messages come from the appropriate file in Webmin's top-level lang directory. If you are creating your own theme that overrides any CGI program or function, the same thing should be done to take advantage of the existing translations into many languages that Webmin already includes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.0.216