This page last changed on Nov 04, 2007 by pburney.

In general, the Global Lab codebase is a model-view-controller with front-controller pattern. Most site traffic is directed to the file called "application" which includes "foundation.php" which includes the various libraries ("sassy" for website templating, "mystery" for database connectivity), and the "front-controller.php" file. The "front-controller.php" determines which of the page controllers (in the controllers folder) to include. The site navigation is defined in XML files in the "configuration/navigation" directory. Most of the site text strings are in files in the "configuration/lang" directory and are accessed using the gl_get_string function.

Database access

You must use the mystery_select/insert/delete queries to communicate with the databases because they perform the proper error checking. You simply provide a query with parameters represented by ? and then an array full of parameters to replace those ?.

Debugging

All errors for the system are logged to an error file in the /web/logs directory. Do not generate errors. If you're taking a shortcut like relying on PHP to initialize an unset variable to an empty string, prefix the call with an @ symbol to avoid generating the error.

If you're debugging locally, you use trigger_error($message, E_USER_WARNING) to log something to the file, or use the mystery_print_r function to print out a variable recursively to the screen.

Code Style

All functions should be prefixed with a "gl_" to avoid conflicting with functions defined by other libraries (since PHP doesn't support namespaces).

Code should use tabs and NOT spaces. It should be saved in UTF-8 format to support multiple languages easily. Function names should separate multiple words using lowercase and underscores, NOT CamelCase. Curly braces should be used even when not technically necessary. Always use single quotes for quoting strings, not double quotes unless necessary for interpolation (i.e., use "\r\n" to get a CRLF newline).

Example:


function gl_special_function($param1, $param2 = '') {

     if ($some_variable == 'something') {

             gl_do_something_now($param1);        

     } else {

              trigger_error('An error occurred: ' . $param2);

     }

}

JavaScript

We're currently using both the YUI and jQuery JavaScript frameworks. jQuery is much simpler to use and should be used in preference to YUI for future client side work.

CSS

Our base CSS is the YUI reset-fonts-grids.css. The reset gets rid of the default styling for the content. The fonts part standardizes the rendering of font sizes (always use percentages for specifying font sizes. There is a "cheat sheet" at the top of the main.css file. The
grids part specifies a standard grid for layout. This grid is used for the main GL site layout.

Document generated by Confluence on Jan 27, 2014 16:42