- Snippet body:
- /*
- load - Loads the selected class file, initializes the class, calls main() method using $mode.
- Parameters
- $class = PHP class file relative to includes/classes/ -- NOTE: Do NOT include .php
- ALSO NOTE: The class name should be identical to the file name.
- $mode = The mode to run; this allows the same class file to be used for multiple pages if needed.
- (Optional) Default: main
- NOTE: all classes must have a main() method, as well as a "main" mode to default to!
- Return - Returns the class in variable $class
- */
- function load($class, $mode = 'main')
- {
- $class_file = $phpbb_root_path . 'includes/' . $class . '.' . $phpEx;
- // File does not exist; we end the script with a nice little error message
- {
- return;
- }
- else // File exists, so we move on.
- {
- @include($class_file); // Include the file
- // See if class exists in the included class file.
- // Because it should be the same as the file name, we can just use the class file name provided.
- {
- return false;
- }
- else // Class exists
- {
- $class = new $class;
- $class->main($mode); // Call the main() method using the $mode provided by the user
- return $class; // Return the class object
- }
- }
- }