Controllers
Predefined controllers
The WebGear Development Platform comes with a few predefined controllers out of the box. That happens so that you have a base to start from, but also to help you in developing your own applications.
The "Default" controller
As its name implies, this is the default system controller and its Index action will be called by default when accessing your base application URL. You will see what the Index action does in the next section, Examples.
For now, just keep in mind the fact that this is where all the action takes place in a default installation. If you installed the platform into YOUR_DOCUMENT_ROOT/your_application_name/, and you access http://yourwebsite/your_application_name/, the Index action of this controller will be called.
The "Helpers" controller
This controller provides some helper actions, directly accesible via URL. Unlike a regular controller, this one does not parse template files. Instead, output is generated (or not) from within its methods (actions).
An example of its usage is serving as an AJAX request callback function. An exception is made from the rule here, but only so that you have access to all the resources in a regular controller, even though it doesn't do anything useful alone.
void Helpers_Controller->LoadJSDefsAction([array params = array()])
This method will help you when writing your Javascript code, if it is included into your template. You can include it like this:
<script type="text/javascript" src="<?php echo WEBSITE_URL . 'Helpers/LoadJSDefs/'; ?>"></script>
After including that line into your template's header file, you will be able to write scripts independent of their location. This script will export all the URL constants from the includes/config/defs.php as global variables in Javascript. So, after including the file, you will be able to use the constant WEBSITE_URL (and all the other _URL suffixed constants) in Javascript, as you would use it in your controller or template file from PHP.
The "PageNotFound" controller
This controller only has one action, the Index action, and will only be called if you're trying to access an invalid controller (or an invalid/non-existing controller action). If you want this page to take place of the default "Page not found" error page of Apache for example, you will need to place a rule into your .htaccess file that instructs the web server to call this action if a page is not found.
Also, this controller overrides the default render method defined in the controller blueprint, so that it will parse its own complete HTML template file (which is templates/PageNotFound/Index.html).