More great references. I have used some of the design patterns in the past, most the singleton, but I take a closer look at these before I proceed. Thanks.
I didn't mention it before, but the development is in php 5.1, mySQL 5 and smarty. Stored Procedures are used for just about all database access.
BTW, the defines aren't used outside the class. They are only used so that I can visually inspect the results. Reading
public static $ConservationTypes = array (
MAT_ARCHIVAL => array ( ALPHARAG_100_PERCENT_COTTON,ALPHARAG_ARTCARE ),
MAT_CONSERVATION => array ( SELECT ),
MAT_DECORATIVE => array ( PAPERMAT )
);
is a lot easier than
public static $ConservationTypes = array (
1 => array ( 1,2 ),
2 => array ( 44),
3 => array ( 66 )
);
Will never be used outside the class. I expect to change to product set of mats with some frequency so I won't be using them anywhere outside the class.
The following is a reduced version of the generated class (class.Mat.php) as it exists right now. Everything, including the comments are generated via a script. There is a lot more data and methods than shown.
<?php
// Conservation Types
define("MAT_ARCHIVAL",1);
define("MAT_CONSERVATION",2);
define("MAT_DECORATIVE",3);
// Manufacturers
define("BAINBRIDGE",1);
define("CRESECENT",2);
define("LARSON-JUHL",3);
// Mat Thickness
define("MAT_4_PLY",4);
define("MAT_6_PLY",6);
define("MAT_8_PLY",8);
// Mat Size
define("MAT_32X40",1);
define("MAT_40X60",2);
// Mat Types
define("MAT_ALPHARAG_100_PERCENT_COTTON",1);
define("MAT_ALPHARAG_ARTCARE",3);
define("MAT_SELECT",44);
define("MAT_PAPERMAT",66);
class Mat
{
public static $ConservationTypes = array (
MAT_ARCHIVAL => array ( ALPHARAG_100_PERCENT_COTTON,ALPHARAG_ARTCARE ),
MAT_CONSERVATION => array ( SELECT ),
MAT_DECORATIVE => array ( PAPERMAT )
);
public static $MatGroups = array (
ALPHARAG_100_PERCENT_COTTON => array ( "B8605","B8606","B8607","B8614"),
ALPHARAG_ARTCARE => array ( "B8634","B863412P","B8634L","B8640","B86408P","B8640L","B8641","B8642"),
SELECT => array ( "C89500","C89501","C89502","C89505","C89506","C89507","C89508","C89510","C89511"),
PAPERMAT => array ( "C1000","C1001","C1002","C1007","C1008","C1009","C1013","C1014","C1015",)
);
public static $Mat = array (
"B8605" => array ( "ffffff",MAT_32X40,8.17,"B8605",1,"White"),
"B8605" => array ( "ffffff",MAT_32X40,8.17,"B8605",1,"White"),
"B8606" => array ( "FFF4DA",MAT_32X40,8.17,"B8606",1,"Ivory"),
... more mats
"B8606" => array ( "FFF4DA",MAT_32X40,8.17,"B8606",1,"Ivory"),
"B8607" => array ( "ffffff",MAT_32X40,18.14,"B8607",1,"White"),
"B8607L" => array ( "ffffff",MAT_40X60,18.14,"B8607",1,"White")
);
public static function GetMatDescription ( $MatNo )
{
if ( array_key_exists ( $MatNo, self::$Mat) )
return self::$Mat [ $MatNo ] [ 4 ];
}
}
?>
Still a lot to do.
For example, lines like
return self::$Mat [ $MatNo ] [ 4 ];
will be replaced with an appropriate define like
return self::$Mat [ $MatNo ] [ COL_ DESCRIPTION ];