Like other people, I also believe that using YAML or JSON can be done in a very simple way.
Just an example of an example JSON format for your data structure:
var settings = { 'site_background' : { 'subpanels' : { 'colour' : { 'plugins' : { 'colourchooser' : { 'tip' : "The background colour appears underneath the 'Background Image' (if set)-hover over the '?' around the colour chooser for extra tips on how to use it", 'element' : 'body', 'gradientenabled' : 'true', 'opts' : { 'closed' : 'true', 'advanced' : { 'tip' : "You can paste in your own generated gradient codes in here", 'checkbox' : true }//end advanced }//end Opts }//end colour chooser }//end plugins },//end colour sub panel 'pattern' : { 'plugins' : { 'patternselector' : { 'tip' : "Use the pattern selector to apply effects like moire or scan lines to your background image", 'element' : 'patimg' }//end patternselector }//end plugins }//end pattern sub panel }//end subpanels }//end site background };//end scope
You can use PHP functions like json_encode and json_decode to convert JSON ↔ PHP data. Using curly braces means that the elements are objects, and when replaced with [and] you got arrays ...
But also the PHP OOP approach can be used successfully, especially when using extensibility. You can have one main class of settings that has some default properties and, for example, magic __get and __set, and then you can implement many sub-classes of sub-settings that extend from this main class of settings.
shadyyx
source share