Home | Using DataLoad | Macro Loads | Browser Control | Forms Playback | Scripting | Problems |
DataLoad provides "event handlers" where the PHP script code should be added. Each event handler is run when something happens in DataLoad, e.g. the file is opened or the load started. By adding PHP code to the appropriate event handler(s) the script writer can customise DataLoad as required. In general all PHP code should be entered in event handler functions. The only exceptions are global variables and the developer's own custom functions, both of which should be declared outside of the event handler functions.
The template PHP script DataLoad provides when you start a new script includes "stub functions" for each event handler. These are pre-created functions for each event but they do not contain any code. The developer should insert their code in these functions. The empty OnOpenFile event handler function is shown below as an example. Developers should replace the comment "//Insert code here..." with their PHP code.
//OnFileOpened - Called when the file is opened in DataLoad.
function OnOpenFile()
{//Use error_reporting() to control how warnings and errors are handled and reported.
//0 turns off all reporting while E_ALL | E_STRICT is the most verbose. There are a range of values between - see PHP documentation.
//The DataLoad php.ini defaults reporting to E_ALL | E_STRICT.
//error_reporting(0);//Insert code here...
}
The full list of event handlers available is shown below. Each event handler will have an equivalent function in the template PHP script.
Event Handler |
Description |
OnOpenFile | Called when the file containing the script is opened in DataLoad |
OnStartLoad | Called when the user runs a load and, for Macro loads, before the Macro starts. Code for loads where the PHP script loads the data, i.e. a Macro load is not used, will normally use this event. |
OnHeaderCell | Macro loads only. Called after a cell is processed in the header grid, if the header grid is used. Event function includes 2 parameters, $Col & $Row, that identify the cell processed, both of which start at 1 for the first cell. |
OnHeaderRow | Macro loads only. Called after the row is processed in the header grid, if the header grid is used. Event function includes 1 parameter, $Row, that identify the row processed and which starts at 1 for the first row. |
OnCell | Macro loads only. Called after a cell is processed in the main grid. Event function includes 2 parameters, $Col & $Row, that identify the cell processed, both of which start at 1 for the first cell. |
OnRow | Macro loads only. Called after a row is processed in the main grid. Event function includes 1 parameter, $Row, that identify the row processed and which starts at 1 for the first row. |
OnFooterCell | Macro loads only. Called after a cell is processed in the footer grid, if the footer grid is used. Event function includes 2 parameters, $Col & $Row, that identify the cell processed, both of which start at 1 for the first cell. |
OnFooterRow | Macro loads only. Called after the row is processed in the footer grid, if the footer grid is used. $Row. Event function includes 1 parameter, $Row, that identify the row processed and which starts at 1 for the first row. |
OnCompleteLoad | Macro loads only. Called when a Macro load is finished. |
OnSaveFile | Called when a DataLoad saves the current file. |
OnCloseFile | Called when the DataLoad file containing the script is closed. |
OnExitPHP | Called when the PHP script shuts down. Usually executed when the file is closed but also executed whenever the PHP script terminates if the reason for termination permits further processing. |