44
Customizing web pages
46
© 2010 SQL Maestro Group
Use the Reset and Reset all links of popup menu to setup detail pages properties
according to the generation
rules
.
4.1.3
Events
Event is a fragment of PHP/Javascript code executed before or after a record was
added, edited, or deleted, etc. Therefore events allow you to define some actions that
will be activated when certain conditions are met. All events are grouped into 2
categories: Client side events and Server side events. Client side events are written on
Javascript and executed by browsers while Server side events are written on PHP and
executed by webserver.
Working with events
To add/edit an event handler, select the necessary event in the list and double-click the
Code column or use Ctrl+Enter. Then type PHP code in the Event Editor window.
To temporarily disable/enable an event, select the appropriate line in the list and
uncheck/check the corresponding Enabled box.
Using variables
PHP Generator for MySQL supports some environment variables (such as
CURRENT_USER_ID, CURRENT_USER_NAME, UNIQUE_ID) in events. To obtain a complete
list of supported variables, uncomment the define('SHOW_VARIABLES', 1); line in the
generated settings.php file and open any generated web page. The following example
demonstrates how to use variables within the OnBeforeInsertRecord event.
Example:
$rowData['ip_address'] = $this->GetEnvVar('REMOTE_ADDR');
$userName = $this->GetEnvVar('CURRENT_USER_NAME');
if ($userName != 'admin')
$rowData['changed_by'] = $userName;
PHP Generator for MySQL supports the following events:
Client side events:
OnBeforePageLoad
Occurs before page loading. Allows you to declare
functions and global variables.
OnAfterPageLoad
Occurs after page has been fully rendered. This event
does not get triggered until all assets such as images
have been completely received and DOM hierarchy has
been fully constructed.
OnInsertFormValidate
Occurs before submitting the insert form. This allows
73