[horde] Patches for virtual hosting with multiple themes per VH

Diego Rivera lrivera at racsa.co.cr
Mon Mar 10 20:52:28 PST 2003


Hey all,

Here's two patches for y'all to look over and improve upon (which I'm
sure you'll all do given that it's me writing them ;) ).  I also
included the files in case anyone wants to use them as-is.

The first one (css) uses $_SERVER['HTTP_HOST'] to determine which
html.php file to load, doing fallback to other files as needed.  This is
to help sites with virtual hosting set up multiple looks and feels (for
ALL horde apps AFAICT) depending on the name the horde app(s) is (are)
hit with.

The second one allows you to set up Horde, and force the initial choice
of a language when none other has been chosen (i.e., force initial
display in spanish), but allows the language preference to be changed. 
This is good for sites that have english software (i.e. US version of
Windows), but are generally NOT english-speaking.

The one that requires more explanation is the first one, so here goes:

When the css.php page is rendered, the virtual host's name is grabbed
from $_SERVER['HTTP_HOST'] (please advise if this is the correct place
to get it from, and if it's authoritative for the request).  Then, a
list of possible "html.php" files is done following this algorithm:

$file_array = array();
if ( $virtual_host_name is not an ip-address )
{
    $part_array = explode( '.', $virtual_host_name );
    while ( ! empty( $part_array ) )
    {
        array_push( implode( '.', $part_array ) . '-html.php' );
        array_shift( $part_array );
    }
}
else
{
    array_push( $file_array, $virtual-host-name . "-html.php" );
}
// Finally, add the two default files
array_push( "html.php" );
array_push( "html.php.dist" );

Once that's done, whenever an include is to be made to an 'html.php'
file, the list is traversed, and the first one that exists is used. 
This happens for both the global (horde/config/html.php) file as well as
the app-specific file (horde/imp/config/html.php, for example).  The
ip-based file is added for completeness (read: just-in-case).

Using this it's possible to have host-wide, domain-wide and tld-wide
look and feel configurations for complex sistes.

I see the following room for immediate improvement (I might even get
around to doing this myself):

Allow "inheritance": load ALL existing files in the reverse order (
i.e., first defaults, then tld, then domain, then host...).  This would
allow the replacement or addition of values to take place in subsequent
loads.  Doing this would allow us to have something like "I want the
same look and feel as domain.com, but only THIS particular color
changed".

Granted, this is low priority and cosmetic, but it can facilitate
maintenance and display configuration for large sites (like the one I'm
working on now), ISP's or hosters.

There's obviously TONS MORE room for improvement, but I'll let you guys
chew on it and see what comes out!  ;)  That's the OSS way!

Best

-- 
Diego Rivera <lrivera at racsa.co.cr>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: css.php.patch.bz2
Type: application/x-bzip
Size: 950 bytes
Desc: not available
Url : http://lists.horde.org/archives/horde/attachments/20030310/3232137a/css.php.patch-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lang.php.patch.bz2
Type: application/x-bzip
Size: 356 bytes
Desc: not available
Url : http://lists.horde.org/archives/horde/attachments/20030310/3232137a/lang.php.patch-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: horde-files.tar.bz2
Type: application/x-bzip
Size: 7878 bytes
Desc: not available
Url : http://lists.horde.org/archives/horde/attachments/20030310/3232137a/horde-files.tar-0002.bin


More information about the horde mailing list