Styles can be set to RELATIVE positions. This class is very useful to apply predefined styles
to ANY data (any number of rows and columns).
The positions are given by position "windrose"-mnomics like 'N' (north), 'NW' (north-west) etc.
This class is used in conjunction with the
Bs_HtmlTable.
(With the Bs_HtmlTable.class.php you are 'only' able to set styles and attributes to absolute positions.)
There is an online version of the
styles editor
to create and manage windrose styles.
|
ALL |
|
C |
|
DD |
|
DU |
|
N |
|
W |
|
S |
|
E |
|
NW |
|
SW |
|
SE |
|
NE |
|
ZR_0 |
|
ZR_1 |
|
ZC_0 |
|
ZC_1 |
|
|
|
Now what if 2 cell definitions exist for the same cell? For example there is a definition of
"ALL" and one for "N" (north row). The later definition overwrites the previous ones, except if
it's set to "transparent", then the definitions get "merged".
Example:
We have some data saved in a comma-separated-values style file. We read that in using the
Bs_CsvUtil class. Instead, the data could come from a db table or from anywhere you like.
CSV Data:
;1997;1998;1999;2000;2001;2002;2003
us;460;480;520;510;525;532;550
ca;120;125;130;90;95;92;115
uk;160;175;210;195;200;198;220
de;190;230;245;232;210;190;180
fr;140;142;143;165;162;152;160
ch;50;60;55;62;53;57;63
Then we have defined some styles. We can use the
styles editor
to simplify this task.
Styles:
[style]
ALL = color:black; weight:normal; font-size:12px; font-style:normal;
font-family:Verdana,Arial; border-bottom:thin solid #58A29E;
ZC_1 = background-color:white;
ZC_0 = background-color:#DBEFEB;
E = background-color:white; border-right:thin solid #58A29E;
W = background-color:#54BA99; border-left:thin solid #58A29E;
N = color:white; background-color:#58A29E; font-weight:bold;
Here is the PHP code to put this together:
PHP Code:
<?php
//include the needed blueshoes classes
require_once($APP['path']['core'] . 'util/Bs_CsvUtil.class.php');
require_once($APP['path']['core'] . 'html/table/Bs_HtmlTable.class.php');
require_once($APP['path']['core'] . 'html/table/Bs_HtmlTableWindrose.class.php');
//read in the csv data
$csv =& new Bs_CsvUtil;
$data = $csv->csvFileToArray($APP['path']['toolbox'] . 'html/table/windroseEditor/example.csv');
//read in the windrose style
$htmlWindroseObj =& new Bs_HtmlTableWindrose();
$htmlWindroseObj->read($APP['path']['toolbox'] . 'html/table/windroseEditor/styles/details.style');
//put it together and render the table
$tbl =& new Bs_HtmlTable($data);
$tbl->setWindroseStyle(&$htmlWindroseObj);
$tbl->setTableAttr(array('cellspacing'=>'0', 'cellpadding'=>'0'));
$tbl->setGlobalTdAttr(array('align'=>'left', 'valign'=>'top'));
echo $tbl->renderTable();
?>
And finally the output:
|
1997 |
1998 |
1999 |
2000 |
2001 |
2002 |
2003 |
us |
460 |
480 |
520 |
510 |
525 |
532 |
550 |
ca |
120 |
125 |
130 |
90 |
95 |
92 |
115 |
uk |
160 |
175 |
210 |
195 |
200 |
198 |
220 |
de |
190 |
230 |
245 |
232 |
210 |
190 |
180 |
fr |
140 |
142 |
143 |
165 |
162 |
152 |
160 |
ch |
50 |
60 |
55 |
62 |
53 |
57 |
63 |