Application: Switch Board [SB] Version 0 beta [2006.5.2] Description: Allows for the dynamic generation of a page while enforcing for the seperation of model, view, control over multiple projects and directories. Original concept of this came from the FuseBox framework. Developer: Daniel Slaughter sb@thewlbl.com http://sb.thewlbl.com How to install: 1. Upload sb_master.php into your root. (This file is required to be in your root. If you do not wish this to be you may alter the sb_master.php file so that the $sb['absolute_path'] points to a different path. (not recomended)) 2. Upload the rest of the files/directories into your root or a sub-directory of your root. (The nice thing about SB is you may upload these same files into as many sub-directories as you wish and the framework all runs from the single sb_master.php file in your root) 3. If no errors are present from the following address then you appear to be in good shape: http://yoursite.com/?action=home.home OR http://yoursite.com/sub-directory/?action=home.home The short version of how it works: Take ?action=home.myPage (or index?action=home.myPage) for example. Your server looks at "home" and realizes that the control, model, and view folders it should look in are within that directory (the "home" directory). The following is then done in this order: 1. The sb_master.php file starts grabbing information. 2. Some global settings are made, nothing you need. 3. sb_settings.php in that directory runs. (it's ok if this is empty, don't delete it) 4. sb_switch.php in that directory runs. This lets you override or add to any of the directories' pages. 5. If there is a file named "myPage.php" in the "control" directory it is then run. 6. If there is a file named "myPage.php" in the "model" directory it is then run. 7. If there is a file named "myPage.php" in the "view" directory it is then run. 8. It checks to make sure some content was outputted from either the sb_switch.php or "myPage.php" in any of the directories (control, model, view). 9. The template page is now run and passed a variable called $sb['content'] that holds all of the content generated from the above sb_switch.php or "myPage.php" files. 10. The script ends execution. We can now change ?action=home.myPage to ?action=exampleCircuit.myPage2 which will display the information for "myPage2" found in the [basedirectory]/exampleCircuit/ just like "home" did (it's just a sub-directory of "home"). Something to know: The default page to be called when you access http://yoursite.com/ (your base) without the ?action= command is home.home If you call http://yoursite.com?action=home without the second .home then it assumes you want .home. This works good for circuits, for example: ?action=exampleCircuit looks better typed out then the assumed ?action=exampleCircuit.home. Original directory contents: [sb.zip index.php sb_master.php sb_settings.php sb_switch.php sb_template.php [control/ home.php] [model/ home.php] [view/ home.php] [exampleCircuit/ sb_settings.php sb_switch.php sb_template.php] [control/ home.php] [model/ home.php] [view/ home.php]] index.php: This file simply points to the sb_master.php sb_master.php: This file is the meat-and-potatoes of sb. It is only necessary to have one instance of this file in the root of your server. You should never have to edit this. sb_settings.php: This file holds any pre-conditions you wish to load in an individual directory's site. sb_switch.php This file should only be used for over-ridding your control/model/view directorys in the event of one of the following: 1. Redirecting: $sb['redirect'] = '?action=home.home'; 2. Disabling file access/loading: $sb['loadControl'] = false; $sb['loadModel'] = false; $sb['loadView'] = false; 3. Storing exit data/paths: $sb['exit']['VALUE'] = $_SERVER['PHP_SELF'] . '?action=home.login_post'; 4. Development debugging (you can also set thisis the path by using ?action=home.home&sb_debug=true): $sb['sb_debug'] = true; 5. Using a file path alias (say ?home.home is called, but you want to point to the files in ?exampleCircuit.asdf): $sb['circuit'] = 'exampleCircuit'; $sb['page'] = 'asdf'; 6. To stop the template from loading with only the content (works well with ajax): $sb['show_template'] = false sb_template.php: This file allows you to create any web-layout template you choose. Simply echo $sb['content'] to display the content generated by sb. home.php: This file is just an example of how SB works. You can call this file by going to an address like this: http://yoursitename/?action=home.home [control] This directory is called first from the sb_master.php file. Files stored in here should only contain commands that would alter existing files. Display to the screen should never be made. (example: database updates/inserts) [model] This directory is called second from the sb_master.php file. Files stored in here should only contain commands that will pull data. Display to the screen should never be made. (example: database [view] This directory is called third from the sb_master.php file. Files stored in here should not do any altering or storing of data. Display to the screen should ONLY be made in here. Have Fun, If you have any questions or feedback please contact: Daniel Slaughter sb@thewlbl.com All emails will be read!