Chapter 6. The User Interface Toolkit

Table of Contents

Introducing WacsUI
Including WacsUI support
WacsUI: DescribeHer
The whatshedoes function
The addkeyicons function
The Link Family
iconlink: WacsUI's Most Important Function
Using the thumblink function
Using the contentlink function
WacsUI: Other Functions
Conclusions

Introducing WacsUI

In this chapter, we're going to take a slightly different tack, we're going to just look at code segments you could choose to include within your application, primarily user interface components taken from the User Interface toolkit, WacsUI. This is not going to be an exhaustive review of what is available as that is covered in detail in the reference section, Chapter 9, WACS API: User Interface Module. Instead this is just a quick taster of just a few of the calls provided by the WacsUI toolkit.

So far we've been dealing with the various routines that are provided by the Core Wacs module - and these relate primarily to configuration parameters and security. There is a second module available for you to use called WacsUI, the WACS User Interface Toolkit. This concerns itself primarily with providing utility functions to ease the tasks of formatting and preparing data from the database into a form more suitable for use in web pages.

Including WacsUI support

To include support for the WACS User Interface (WacsUI) toolkit within your application, you need to add the following extra lines to your code, ideally just after the Wacs core module.

Example 6.1. WacsUI initialisation

require_once "wacsui.php";

$wacsui = new WacsUI;

and here's the perl dialect of the same activity...

use Wacs::WacsUI;
[Note]Note

NB: From Wacs 0.8.6, the WacsUI module now lives in a Wacs sub-directory and so needs to be called as Wacs::WacsUI instead of just WacsUI.

WacsUI: DescribeHer

The first function from WacsUI that we're going to look at is called describeher and it is designed to take the output of the very regemented values of the model attributes fields of the database and turn them into something much more readable. Although not implemented yet this provides a good mechanism for doing other translations or providing an attribute table rather than a textual description.

Example 6.2. Using WacsUI: describeher

print $wacsui->describeher( 
       array( 'hair'=>$results[4],
         'length'=>results[5],
         'titsize'=>results[6],
         'pussy'=>results[7],
         'race'=>results[8],
         'build'=>results[9],
         'height'=>results[10],
         'weight'=>results[11],
         'occupation'=>results[12]))."\n";

[Note]Note

We have to package up our parameter list as an array in order to pass it in Php; perl is somewhat simpler with a simple sequence of named parameters.

print describeher(
        hair=>$results[4],
        length=>$results[5],
        titsize=>$results[6],
        pussy=>$results[7],
        race=>$results[8],
        build=>$results[9],
        height=>$results[10],
        weight=>$results[11],
        occupation=>$results[12] )."\n";

The above example is based upon modifying the MySimple example program from in the second chapter (Chapter 2, Basics: Getting Started) to add the following extra fields into the query: mhair, mlength, mtitsize, mpussy, mrace, mbuild, mheight, mweight, moccupation after the mimage (with a comma of course) and before the from clause.

The whatshedoes function

As with the previous describeher, whatshedoes is designed to make a readable sentence from a number of fixed format database fields. In this case however, it's a little different as the values passed in are typically either Y for yes, or N for no, and they are translated to a text phrase based upon what they're value is. This also means that if you're using array subscripts to fetch the database field values you need to be careful about positioning. Give a yes to the wrong field and the error will not be as obvious - while blonde breasts would be easy to spot, the fact that each model who did masturbation scenes was listed as doing straight scenes would be less apparent.

For the purposes of this example, we're adding yet more fields to the select statement in the original MySimple program shown in the second chapter (Chapter 2, Basics: Getting Started). In this case msolo, mstraight, mlesbian, mfetish, mtoys, mmast and mother.

Example 6.3. Using WacsUI: whatshedoes

print $wacsui->whatshedoes(
	array( 'solo'=>$results[13],
	       'straight'=>$results[14],
	       'lesbian'=>$results[15],
	       'fetish'=>$results[16],
	       'toys'=>$results[17],
	       'masturbation'=>$results[18],
	       'other'=>$results[19] ) )."\n";

The same function works just the same in perl without the need for the array declaration wrapper:

print whatshedoes(
	solo=>$results[13],
	straight=>$results[14],
	lesbian=>$results[15],
	fetish=>$results[16],
	toys=>$results[17],
	masturbation=>$results[18],
	other=>$results[19])."\n";

The addkeyicons function

Both the models and sets schemas feature fields that contain a space seperated list of keywords that mark certain attributes found within that set. These can be quickly turned into a small HTML table of icons using the routine addkeyicons. The fields suitable for use with this are scatinfo from the sets table and mattributes from the models table. These are passed as the first attribute; the second being the displayed size of the icons which for the default icons would be a maximum of 48 x 48 pixels. The function is called simply with:

Example 6.4. Using AddKeyIcons

	addkeyicons( $results[16], 24, $dbhandle );

[Note]Note

In WACS 0.9.0 and later, addkeyicons should be passed a third parameter which is the handle to the current active database connection. The act of passing this allows the addkeyicons routine access to the attrib database table which contains the extended range of icons and the ability to add locally defined additional icons. Without this being supplied, any of the extended and locally defined icons will appear as a broken image.

[Warning]Warning

Where possible please update your existing code to pass the dbhandle parameter as well.