CobaltUI.php vs. pure UIFC

Posted by: mstauber Category: Development

There are two different way of creating Sausalito GUI pages. One is using CobaltUI.php, the other one is using pure UIFC instead. This article details why using CobaltUI.php is bad.

When the BlueOnyx code was overhauled to make it PHP-5.3 ready for BlueOnyx 5107R, I noticed that the 'base-dns' module had quite a few more issues than any other GUI module.

The source of the problem:

The module "base-dns.mod" uses an external library called CobaltUI.php, which typically is located here:


Usually our GUI pages use a method called UIFC to generate pages. CobaltUI.php adds a layer on top of that to simplify page generation, but this comes at the cost that some things simply don't work right anymore.

CobaltUI.php even pre-dates PHP-4 and although some attempts were made over the years to make it fully PHP-4 and PHP-5.1 to PHP-5.2 ready: Under PHP-5.3 it breaks hard in certain areas.

We are slowly but surely moving away from CobaltUI.php and code all new pages only in UIFC. In fact parts of base-dns.mod just got partially redone using proper UIFC methods to get around some broken bits and pices.

Some examples:

The ease of CobaltUI.php is easily show in examples.

1a) Creation of a text form field using CobaltUI.php 


1b) Creation of the same text form field using UIFC: 


2a) Creation of a pulldown menu using CobaltUI.php: 


2b) Creation of the same pulldown menu using UIFC: 


So you can easily see how and why CobaltUI.php can make it easier to create GUI pages.

But as also mentioned: Some things no longer work right anymore and this includes the function Alters() that CobaltUI.php uses to create pulldown menus. In UIFC we call them 'MultiChoice' instead.

Would it be desireable to fix CobaltUI.php so that we can continue to use it?

Not really.

Why? Simply put: CobaltUI.php is too unflexible and too watered down. There are quite a few things you cannot do just in CobaltUI.php alone and you can also hardly mix CobaltUI.php and UIFC code in the same GUI page without adding a lot of confusion.

So imagine someone started to code a new page using CobaltUI.php, because it was "good enough" for the initially intended purpose. Some months later, someone else wants to extend the original code by adding new stuff to it. But he needs pulldowns (or 'MultiChoice') for it, which CobaltUI.php no longer really supports at the present. Additionally the CobaltUI.php code doesn't really support usage of multiple tabs on the same page. So the initial choice of using CobaltUI.php will make the life of any code maintainer a hell of a lot more complicated if he ever wished to extend the existing code.

Even if Alters() from CobaltUI.php would still create working MultiChoice() output: The additional layer that CobaltUI.php puts on top of UIFC makes it hard for some of the more advanced features of the GUI to filter through all the way.

So in short: PLEASE DO NOT CODE NEW GUI PAGES in CobaltUI.php. Use UIFC instead!

Aug 29, 2011 Category: Development Posted by: mstauber
Next page: Features