59.3. The theme_header Function

The theme_header function in theme.pl in the mscstyle3 directory effectively replaces the standard header function that almost all Webmin CGI programs call. Unlike the standard header, this one produces HTML for a list of module category icons at the top of most pages, allowing the user to easily switch to a different category. It also outputs HTML for a link to www.webmin.com, logout and feedback buttons, and the standard links like Module Index and Module Config. Finally, HTML is produced that puts the rest of the page inside the white table box that you can see on almost every page.

The table of categories is generated by calling get_available_module_infos, checking to see which categories actually exist, reading the file /etc/webmin/webmin.catnames to get alternate names, then displaying an icon and name made up of letter images for each. The theme has images for all of the standard categories, plus a special question mark image to be used if a nonstandard or user-defined category is found. Just generating a fixed table of standard categories will not work, as it is possible that the user only has access to modules in some of them.

Because the category titles may be in a different language that uses characters outside of the standard English alphabet, this theme includes images for every letter with ASCII codes between 32 and 255. Any other theme that uses letter images should do the same, so that it will work in non-English languages as well. For some languages (such as Chinese and Russian), it is impossible to create an image for every single character, due to the thousands that exist. The MSC theme checks the global variable $current_lang_info->{'titles'}, and if it is not set, produces plain text category labels instead.

When Webmin is in session authentication mode (determined by checking for the $main::session_id variable), a logout image button is added to the top-right corner of every page. If normal HTTP authentication is being used, however, this is replaced by a button for switching users, which links to a different CGI program. The old Webmin theme only has these links on the main menu. The code properly checks the $ENV{'SSL_USER'}, $ENV{'LOCAL_USER'}, and $ENV{'ANONYMOUS_USER'} environment variables, any of which, if set, indicates that no logout or switch button should appear.

Every page also has a feedback button in the top-right corner, unless $ENV{'ANONYMOUS_USER'} is set or the global or per-user configuration indicates that feedback is not allowed. This links to feedback_form.cgi with the current module name as a parameter, so that any feedback sent to it is automatically associated with the current module. This is a nice idea if you are writing your own theme.

Below the row of category icons are several small tabs for links like Module Index and Module Config. The theme_header function checks its parameters and $ENV variables to determine which ones to show, just like the standard header function does. The biggest difference is that no Webmin Index link is ever produced, as there is no need for it. The user can return to the module's category by just clicking on the appropriate icon at the top of any page.

Below any tabs comes the page title, supplied to the theme_header function as the first parameter. The MSC theme puts it in a small tab above the page body using only text, unlike the old Webmin theme that renders the title as a series of letter images.

Finally, the theme puts page content output by the CGI after header is called into a large box, by producing HTML tags to start a table. This is not done if the global variable $theme_no_table is set. Instead, the content will just be part of the page's body. CGI programs that slowly generate progressive output should set this variable, and themes that have their own custom theme_header function should honor it, if appropriate. Of course, if your theme doesn't use this kind of table for layout then the variable can be ignored.

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

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