The general structure of the class file will be
<?php
include_once( "MatLists.php" ); // created dynamically via a script
class Mat
{
include "MatArrays.php"; // also created dynamically via a script
public static function GetMatDescription ( $MatNo )
{
if ( array_key_exists ( $MatNo, self::$Mat) )
return self::$Mat [ $MatNo ] [ 4 ];
}
.... more access functions
}
?>
which when expanded will look like
<?php
define("MAT_ARCHIVAL",1);
define("MAT_CONSERVATION",2);
define("MAT_DECORATIVE",3);
define("BAINBRIDGE",1);
define("CRESECENT",2);
define("MAT_4_PLY",4);
define("MAT_8_PLY",8);
define("MAT_12_PLY",12);
define("MAT_32X40",1);
define("MAT_40X60",2);
define("MAT_ALPHARAG_100%_COTTON",1);
define("MAT_ALPHARAG_NATURALS",2);
define("MAT_ALPHARAG_ARTCARE",3);
define("MAT_ALPHAMAT_ARTCARE_SOLIDS",4);
define("MAT_ALPHAMAT_ARTCARE_SPECIALTIES_PRECIOUS_METALS",5);
... and more definitions
class Mat
{
public static $ConservationTypes = array {
MAT_ARCHIVAL => array { ALPHARAG_100%_COTTON,ALPHAMAT_ARTCARE_SPECIALTIES_HERITAGE,ALPHAMAT_ARTCARE_SPECIALTIES_TRACES,ALPHAMAT_ARTCARE_SPECIALTIES_AMERICAN_CLASSICS,ALPHAMAT_ARTCARE_SPECIALTIES_CLASSICOS,ALPHAMAT_ARTCARE_SPECIALTIES_PARCHMENTS,ALPHAMAT_ARTCARE_SPECIALTIES_ALPHA_LINENS,ALPHAMAT_ARTCARE_WASHED_LINEN,ALPHAMAT_ARTCARE_LEATHER,ALPHAMAT_ARTCARE_DENIMS,ALPHAMAT_ARTCARE_COLOR_CORE,ALPHAMAT_ARTCARE_NEW_THREADS,ALPHAMAT_ARTCARE_SUEDE,ALPHAMAT_ARTCARE_EMBOSSED_SUEDE,ALPHAMAT_ARTCARE_GRASSCLOTH,ALPHAMAT_ARTCARE_RICE_PAPER,ALPHAMAT_ARTCARE_METTALIC_RICE_PAPER,ALPHAMAT_ARTCARE_SILKENS,ALPHAMAT_ARTCARE_TATAMI_SILKENS,ALPHAMAT_ARTCARE_RAW_SILKS,RAGMAT_MUSEUM_SOLIDS,RAGMAT,RAGMAT_ANTIQUARIAN,RAGMAT_SPECIALTIES,RAGMAT_NOIR_BLACK_CORE,ELIZABETH_DOW_COLLECTION,MICHAEL_GRAVES_COLLECTION,RAGMAT_INTAGLIO},
MAT_CONSERVATION => array { SELECT,SELECT_ULTIBLACKS,ACCENTS,ULTIBLACK_FLORENTINES,SELECT_PALAZZOS,SELECT_BELGIQUES,SELECT_ULTIBLACK_BELGIQUES,MOORMAN_SUEDES,BLACK_CORE_MOORMAN_SUEDES,MOORMAN_NATURAL_LINENS,MOORMAN_LINENS,MOORMAN_LEATHER},
MAT_DECORATIVE => array { PEBBLE_PAPER_MATS,PAPER_MATS,PAPERMAT_FORMALS,PAPERMAT_FORMALS_BLACK_CORE,BLACK_BY_BAINBRIDGE_PAPERMAT,INTERNATION_WHITECORE,CRESCENT_INTERNATION_WHITECORE_FAUX_METALLIC,CRESCENT_INTERNATION_WHITECORE_FAUX_MARBLE,CRESCENT_INTERNATION_WHITECORE_FAUX_MARBLE_BLACK_CORE,INTERNATION_WHITECORE_CLASSICS_FAUX_LEATHER,INTERNATION_WHITECORE_CLASSICS_LIBRARY_LEATHER,PAPERMAT,BRITECORES_PAPERMAT,_FLANNEL_PAPERMAT,LINI_PAPERMAT,SILKI_PAPERMAT,PARCHMENT_PAPERMAT,CRESCENT_DENIM_PAPERMAT,NEOCLASSICS_PAPERMAT,PRECIOUS_METALS_PAPERMAT,ANCIENTS_PAPERMAT,FLORENTINE_METTALICS_PAPERMAT,BLACK_CORE_PRECIOUS_METALS_PAPERMAT,BLACK_CORE_PAPERMAT,BLACK_CORE_FLANNEL_PAPERMAT}
};
public static $MatGroups = array {
ALPHARAG_100%_COTTON => array ( "B8605","B8606","B8607","B8614"},
ALPHARAG_NATURALS => array ( "B8626","B8627","B8628","B8629","B8689","B8690"},
...... more groups 80+ inall
BLACK_CORE_PRECIOUS_METALS_PAPERMAT => array ( "C63702","C63703","C63708","C63713"},
BLACK_CORE_FLANNEL_PAPERMAT => array ( "C63300","C63305","C63306","C63307","C63310","C63311"}
};
public static $Mat = array {
"B110" => array ( 1,3.43,"B110",1, "Off White & White Pebble"),
"B110L" => array ( 2,8.48,"B110L",1, "Off White & White Pebble"),
........ more mats - 2600 in all
"B4119L" => array ( 2,29.83,"B4119L",1, "Grappa"),
"B412" => array ( 1,3.92,"B412",1, "Tan"),
);
public static function GetMatDescription ( $MatNo )
{
if ( array_key_exists ( $MatNo, self::$Mat) )
return self::$Mat [ $MatNo ] [ MAT_DESCRIPTION_COLUMN ];
}
... more access functions
}
?>
Both of the include files are generated via a php script that will run daily via a cron job.The inclusion of first file MatLists.php, that includes defines generated from the db is not a problem as it is outside the class.
The file that I wish to include inside the class is the problem. I can't find (a lot of googling seems to say it can't be done) a way to do this.
I don't want to include the file outside the class. I prefer the structure of static class access as opposed to a bunch of global arrays.
Plan A, if anyone can offer any suggestions, is figure out a way to overcome the include restrictions inside a class.
Plan B, if I can't figure it out is to dynamically write the entire class, including all the functions dynamically.
I use the same thing in other portions of the site. There will be over 200K products on the site. The menus are all dynamic (sortof) and will be structured by most the most popular viewed products (top artists, top subjects, top art styles, top items, etc). They menus are created via a daily cron jobs that creates top viewed lists from the hits tables, which are incremented anytime an item is viewed, which then define the menus. These are also in a static class which has only data, so I write the entire class dynamically for this one.
Suggestions are welcome. Thanks in advance.