-
Notifications
You must be signed in to change notification settings - Fork 6
Code Structure
Description of Code Structure The code uses a URL router (ToroPHP) and template engine (Smarty). The way I've structured the code then is as follows:
All requests go through index.php and are then routed to a specific class / function as specified by the URL (e.g. '^/student/([a-zA-Z0-9_ ]+)/?$', 'regex', 'StudentHandler') Each of these classes is a controller which is derived from the parent class ToroHandler (e.g. see student.php) ToroHandler initializes a Smarty template object which is then used in the derived controllers via commands such as: $this->smarty->assign("username", USERNAME); // assigns a variable to be used in the template $this->smarty->display('assignment.html'); // displays a template All the templates are in ./templates/templates/ and Smarty automatically handles piecing these together with its template language URL's are initially rewritten with an htaccess file so that the server sees the request /paperless/student/Eric as /paperless/index.php/student/Eric Here are the URL's currently set up: / ---> main.php, IndexHandler List of students and assignments /student/student_name ---> student.php, StudentHandler List of assignments for given student /assignment/assignment_name ---> assignment.php, AssignmentHandler List of students for given assignment /code/student_name/assignment_name ---> code.php, CodeHandler Code / comment view for student assignment pair