Add different CardSets for rendering of preferences.
[lhc/web/wiklou.git] / includes / CardSet.php
1 <?php
2 // CardSet is a widget for displaying a stack of cards, e.g. for
3 // user preferences. It is skinnable by overloading.
4 // Default CardSet uses fieldsets for the cards,
5 // the derived class TabbedCardSet uses JavaScript-based tabs
6 //
7 // Usage:
8 // First, create a CardSet using the constructor
9 // Then, add cards to it
10 // Finally Render to get the HTML
11
12 class CardSet {
13
14 /* private */ var $mLabels, // Array of card labels
15 $mBodies, // Array of card bodies
16 $mTitle; // Title of this stack
17
18 // Initialize an empty CardSet.
19 function CardSet( $title )
20 {
21 $this->mLabels = array();
22 $this->mBodies = array();
23 $this->mTitle = $title;
24 }
25
26 // Add a card to the set. The body of the card is expected to be
27 // HTML, not wikitext.
28 function addCard( $label, $body )
29 {
30 $this->mLabels[] = $label;
31 $this->mBodies[] = $body;
32 }
33
34 // Return the HTML of this CardSet
35 function renderToOutpage( &$out )
36 {
37 for ( $i=0; $i<count( $this->mLabels ); $i++ )
38 {
39 $s .= "<fieldset>\n<legend>" . $this->mLabels[$i] . "</legend>\n"
40 . $this->mBodies[$i] . "</fieldset>\n";
41 }
42
43 $out->addHTML( $s );
44 }
45
46 } // end of: class CardSet
47
48 ?>