My PHP Generator
My PHP Generator
User's guide
Table of Contents
Foreword 0
II Getting started 11
1 How to...................................................................................................................................
connect to MySQL 13
2 Projects
................................................................................................................................... 17
3 Command
...................................................................................................................................
line options 18
4 Report...................................................................................................................................
sending 19
5 Shortcut
...................................................................................................................................
keys 20
6 Deployment
................................................................................................................................... 21
IV Page Management 27
1 Root level
...................................................................................................................................
pages 28
2 Detail ...................................................................................................................................
pages 31
V Page Editor 33
1 Columns
................................................................................................................................... 35
Lookup settings .......................................................................................................................................................... 37
View controls.......................................................................................................................................................... 41
Text ......................................................................................................................................................... 42
DateTime ......................................................................................................................................................... 44
Checkbox ......................................................................................................................................................... 45
File download
......................................................................................................................................................... 46
Image ......................................................................................................................................................... 47
External File
......................................................................................................................................................... 48
External Image
......................................................................................................................................................... 49
External Audio
......................................................................................................................................................... 50
External Video
......................................................................................................................................................... 51
Embedded.........................................................................................................................................................
Video 53
Edit controls .......................................................................................................................................................... 54
Text ......................................................................................................................................................... 56
Combo box......................................................................................................................................................... 58
Radio group ......................................................................................................................................................... 60
Autocomplete.........................................................................................................................................................
editor 62
Multi-level autocomplete
.........................................................................................................................................................
editor 63
Check box......................................................................................................................................................... 70
Check box.........................................................................................................................................................
group 71
Multiple select
......................................................................................................................................................... 72
DateTime ......................................................................................................................................................... 73
Time ......................................................................................................................................................... 74
Spin edit ......................................................................................................................................................... 74
Range edit......................................................................................................................................................... 75
Color edit ......................................................................................................................................................... 76
Mask edit ......................................................................................................................................................... 77
Text area ......................................................................................................................................................... 78
Html Wysiwyg......................................................................................................................................................... 79
Password ......................................................................................................................................................... 81
File upload......................................................................................................................................................... 81
Image upload......................................................................................................................................................... 82
Upload file.........................................................................................................................................................
to folder 84
Upload image.........................................................................................................................................................
to folder 85
2 String ...................................................................................................................................
templates 88
3 Master-Detail
...................................................................................................................................
Presentations 89
4 Events................................................................................................................................... 95
Application-level
..........................................................................................................................................................
(global) Events 95
OnBeforePageExecute
......................................................................................................................................................... 97
OnAfterLogin
......................................................................................................................................................... 97
OnBeforeLogout
......................................................................................................................................................... 97
OnPreparePage
......................................................................................................................................................... 98
OnCustomHTMLHeader
......................................................................................................................................................... 98
OnGetCustomTemplate
......................................................................................................................................................... 99
OnBeforeInsertRecord
......................................................................................................................................................... 107
OnBeforeUpdateRecord
......................................................................................................................................................... 107
OnBeforeDeleteRecord
......................................................................................................................................................... 108
OnAfterInsertRecord
......................................................................................................................................................... 108
OnAfterUpdateRecord
......................................................................................................................................................... 109
OnAfterDeleteRecord
......................................................................................................................................................... 110
OnGetFieldValue
......................................................................................................................................................... 111
OnGetCustomExportOptions
......................................................................................................................................................... 111
OnCustomizePageList
......................................................................................................................................................... 112
OnGetCustomPagePermissions
......................................................................................................................................................... 113
Client Side Page
..........................................................................................................................................................
Events 113
OnBeforePageLoad
......................................................................................................................................................... 114
OnAfterPageLoad
......................................................................................................................................................... 114
OnInsertFormValidate
......................................................................................................................................................... 115
OnEditFormValidate
......................................................................................................................................................... 115
OnInsertFormEditorValueChanged
......................................................................................................................................................... 116
OnEditFormEditorValueChanged
......................................................................................................................................................... 118
OnInsertFormLoaded
......................................................................................................................................................... 120
OnEditFormLoaded
......................................................................................................................................................... 121
Server Side Page
..........................................................................................................................................................
Events 122
OnBeforePageExecute
......................................................................................................................................................... 123
OnPreparePage
......................................................................................................................................................... 123
OnPageLoaded
......................................................................................................................................................... 124
II
III PHP Generator for MySQL Help
OnCustomRenderColumn
......................................................................................................................................................... 125
OnCustomRenderPrintColumn
......................................................................................................................................................... 128
OnCustomRenderExportColumn
......................................................................................................................................................... 128
OnCustomHTMLHeader
......................................................................................................................................................... 128
OnExtendedCustomDrawRow
......................................................................................................................................................... 129
OnCustomRenderTotals
......................................................................................................................................................... 132
OnGetCustomTemplate
......................................................................................................................................................... 133
OnCustomDrawRow
......................................................................................................................................................... 141
OnAfterInsertRecord
......................................................................................................................................................... 142
OnAfterUpdateRecord
......................................................................................................................................................... 142
OnAfterDeleteRecord
......................................................................................................................................................... 143
OnBeforeInsertRecord
......................................................................................................................................................... 144
OnBeforeUpdateRecord
......................................................................................................................................................... 145
OnBeforeDeleteRecord
......................................................................................................................................................... 145
OnGetFieldValue
......................................................................................................................................................... 146
OnGetCustomExportOptions
......................................................................................................................................................... 146
OnPrepareFilterBuilder
......................................................................................................................................................... 147
OnPrepareColumnFilter
......................................................................................................................................................... 148
OnGetCustomFormLayout
......................................................................................................................................................... 149
OnGetCustomColumnGroup
......................................................................................................................................................... 150
OnCustomCompareValues
......................................................................................................................................................... 151
OnGetCustomUploadFileName
......................................................................................................................................................... 152
OnGetCustomPagePermissions
......................................................................................................................................................... 153
OnGetCustomRecordPermissions
......................................................................................................................................................... 153
Using Variables
.......................................................................................................................................................... 155
5 Filter................................................................................................................................... 157
6 Charts
................................................................................................................................... 158
Data Query .......................................................................................................................................................... 158
Common options
.......................................................................................................................................................... 160
Advanced options
.......................................................................................................................................................... 160
7 Page...................................................................................................................................
Properties 162
Common properties
.......................................................................................................................................................... 163
RSS options .......................................................................................................................................................... 167
Abilities .......................................................................................................................................................... 167
Export and Print
.......................................................................................................................................................... 170
Options .......................................................................................................................................................... 172
8 Data ...................................................................................................................................
Partitioning 176
9 Data ...................................................................................................................................
Validation 179
4 User ...................................................................................................................................
JavaScript 202
5 Custom
...................................................................................................................................
templates 203
IV
V PHP Generator for MySQL Help
getCaption......................................................................................................................................................... 247
clear ......................................................................................................................................................... 247
Radio group .......................................................................................................................................................... 248
addItem ......................................................................................................................................................... 248
removeItem......................................................................................................................................................... 249
getItemCount
......................................................................................................................................................... 251
getCaption......................................................................................................................................................... 251
clear ......................................................................................................................................................... 251
Checkbox group
..........................................................................................................................................................
and Multiple select 252
addItem ......................................................................................................................................................... 252
removeItem......................................................................................................................................................... 253
getItemCount
......................................................................................................................................................... 254
clear ......................................................................................................................................................... 255
2 Server
...................................................................................................................................
Side API 257
class Page .......................................................................................................................................................... 257
GetEnvVar......................................................................................................................................................... 257
GetConnection
......................................................................................................................................................... 257
class Application
.......................................................................................................................................................... 258
IsGETValueSet
......................................................................................................................................................... 258
GetGETValue
......................................................................................................................................................... 258
IsPOSTValueSet
......................................................................................................................................................... 259
GetPOSTValue
......................................................................................................................................................... 259
IsLoggedInAsAdmin
......................................................................................................................................................... 259
class EngConnection
.......................................................................................................................................................... 259
ExecScalarSQL
......................................................................................................................................................... 260
ExecSQL......................................................................................................................................................... 260
ExecQueryToArray
......................................................................................................................................................... 260
class PermissionSet
.......................................................................................................................................................... 260
Global functions
.......................................................................................................................................................... 261
GetApplication
......................................................................................................................................................... 261
sendMailMessage
......................................................................................................................................................... 261
createConnection
......................................................................................................................................................... 262
3 Style...................................................................................................................................
sheets internals 264
Index 296
VI
1 PHP Generator for MySQL Help
Key features:
· Master-detail presentations 89
· 25 color themes
· Event-driven content management 95
Almost all features provided by PHP Generator for MySQL can be seen in action in our
Feature Demo, Security Demo, and other demo applications. We would highly recommend
you to take a look at them as this can save you hours of work when developing your
own websites.
Server environment
1.2 Installation
To install PHP Generator for MySQL on your PC:
· download the PHP Generator for MySQL distribution package from the download page
at our site;
· run setup.exe from the local folder and follow the instructions of the installation
wizard;
· find the PHP Generator for MySQL shortcut in the corresponding program group of
the Windows Start menu after the installation is completed.
You can select licensing options and register PHP Generator for MySQL at its on-line
order page. It is possible to purchase on-line, by fax, mail, toll-free phone call, or place
a purchase order. We send the software activation key by email within 24 hours after
completion of the order process. If you have not received the activation key within this
period, please contact our sales department.
All our products and bundles are shipped with 12 months of free upgrades (minor and
major ones) or with 36 months of free upgrades for a quite small additional fee. After this
period you may renew your license for the next 12(36) months with a 50% discount.
PHP Generator for MySQL has a free 30-day trial. Upon purchasing the product you
confirm that you have tested it and you are completely satisfied with its current version.
To obtain technical support, please visit the appropriate section on our website or
contact us by email to [email protected].
· License grant. SQL Maestro Group grants you a license to use one copy of the
version of this SOFTWARE on any single hardware product for as many licenses as you
purchase. "You" means a company, an entity or an individual. "Use" means storing,
loading, installing, executing or displaying the SOFTWARE. You may not modify the
SOFTWARE or disable any licensing or control features of the SOFTWARE except as an
intended part of the SOFTWARE's programming features. This license is not
transferable to any other company, entity or individual. You may not publish any
registration information (serial numbers, registration keys, etc.) or pass it to any other
company, entity or individual.
· Ownership. The SOFTWARE is owned and copyrighted by SQL Maestro Group. Your
license confers no title or ownership of the SOFTWARE and should not be construed as
a sale of any rights for the SOFTWARE.
· Copyright. The SOFTWARE is protected by the United States copyright law and
international treaty provisions. You acknowledge that no title to the intellectual
property in the SOFTWARE is transferred to you. You further acknowledge that title
and full ownership rights to the SOFTWARE will remain the exclusive property of SQL
Maestro Group and you will not acquire any rights to the SOFTWARE except as
expressly set forth in this license. You agree that any copies of the SOFTWARE will
contain the same proprietary notices which appear on and in the SOFTWARE.
· replace existing version of the UNREGISTERED SOFTWARE installation package with the
new package immediately after a new version of the SOFTWARE is released by SQL
Maestro Group, or
· delete an obsolete version of the UNREGISTERED SOFTWARE installation package
immediately upon written email notice by SQL Maestro Group.
A registered copy of the SOFTWARE ("REGISTERED SOFTWARE") allows you to use the
SOFTWARE only on a single computer and only by a single user at a time. If you wish to
use the SOFTWARE for more than one user, you will need a separate license for each
individual user. You are allowed to make one copy of the REGISTERED SOFTWARE for
back-up purposes.
· Reverse engineering. You affirm that you will not attempt to reverse compile,
modify, translate, or disassemble the SOFTWARE in whole or in part.
· Unauthorized use. You may not use, copy, rent, lease, sell, modify, decompile,
disassemble, otherwise reverse engineer, or transfer the SOFTWARE except as
provided in this agreement. Any such unauthorized use shall result in immediate and
· No other warranties. SQL Maestro Group does not warrant that the SOFTWARE is
error-free. SQL Maestro Group disclaims all other warranties with respect to the
SOFTWARE, either express or implied, including but not limited to implied warranties of
merchantability, fitness for a particular purpose and noninfringement of third party
rights. Some jurisdictions do not allow the exclusion of implied warranties or limitations
on how long an implied warranty may last, or the exclusion or limitation of incidental or
consequential damages, so the above given limitations or exclusions may not apply to
you. This warranty gives you specific legal rights and you may also have other rights
which vary from jurisdiction to jurisdiction.
· Limited warranty. This SOFTWARE is provided on an "AS IS" basis. SQL Maestro
Group disclaims all warranties relating to this SOFTWARE, whether expressed or
implied, including but not limited to any implied warranties of merchantability or fitness
for a particular purpose. Neither SQL Maestro Group nor anyone else who has been
involved in the creation, production, or delivery of this SOFTWARE shall be liable for
any indirect, consequential, or incidental damages arising out of the use or inability to
use such SOFTWARE, even if SQL Maestro Group has been advised of the possibility of
such damages or claims. The person using the SOFTWARE bears all risk as to the
quality and performance of the SOFTWARE.
· Severability. In the event of invalidity of any provision of this license, the parties
agree that such invalidity shall not affect the validity of the remaining portions of this
license.
· No liability for consequential damages. In no event shall SQL Maestro Group or its
suppliers be liable to you for any consequential, special, incidental or indirect damages
of any kind arising out of the delivery, performance or use of the SOFTWARE, even if
SQL Maestro Group has been advised of the possibility of such damages. In no event
will SQL Maestro Group's liability for any claim, whether in contract, tort or any other
theory of liability, exceed the license fee paid by you, if any.
· Entire agreement. This is the entire agreement between you and SQL Maestro Group
which supersedes any prior agreement or understanding, whether written or oral,
relating to the subject matter of this license.
· Reserved rights. All rights not expressly granted here are reserved to SQL Maestro
Group.
The company was founded in 2002 as an essential partner for every business that is
trying to harness the explosive growth in corporate data. SQL Maestro Group employs an
international team concentrating their efforts on cutting-edge DBA tools development.
The slogan of our company is The Shortest Path to SQL. It is aimed to denote that we
set to create easy-to-use products meant for those who appreciate comfort, friendly
program interface and support when working with SQL servers.
At present, our company offers a series of Windows GUI admin tools for SQL
management, control and development of the following servers: MySQL, Microsoft SQL
Server, PostgreSQL, Oracle, SQL Anywhere, DB2, SQLite, Firebird, and MaxDB. We
also produce universal tools to be used for administering any database engine accessible
via ODBC driver or OLE DB provider. Such products may be the clear-cut decision for
those who constantly work with several database servers.
The software products are constantly optimized for the latest server versions support.
2 Getting started
In general, all you need to create your own feature rich data-driven web application is
to complete the following simple steps (in fact, only first two steps are mandatory):
· Connect to the database 13 you want to work with through the web;
· Specify datasources 22 for web pages;
· Customize web pages 27 to be created;
· Set additional generation options 228 such as webpages appearance 195 and
interface language 226 ;
· Specify security settings 205 to protect your data from an unauthorized access.
PHP Generator for MySQL allows you to save and restore all the options set during a
session. All the session parameters may be saved and loaded to/from a project file.
Loaded settings may be edited if necessary. To run a wizard with a project, follow
More... > Load Project on the first wizard step and enter the name of the project file,
recently used projects are also available from this popup menu. Find out more about
PHP Generator for MySQL allows you to connect to MySQL databases directly, or via
Secure SHell (SSH) tunnel or HTTP tunnel.
· Direct connection
It is the most natural and the most preferable connection mode. Use it each time it is
possible. Most of hosting companies allow direct connections to databases. However in
most cases you have to go to your control panel and add your home/office computer
IP address or domain name to the Access List - list of IP addresses allowed accessing
from outside. More information.
Host
The host name of the MySQL server.
Port number
The TCP/IP port to use (default MySQL port is 3306).
User name
The username used to connect to MySQL.
Password
The password for the user account on server.
2. Follow the Configure SSH options link to open the SSH Options window.
3. Check Connect through the Secure Shell (SSH) tunnel and complete the
following fields:
Host name
Specify the host name or IP of your site. Note, that MySQL host name
always should be set relatively to the SSH server. For example, if both of
MySQL and SSH servers are located on the same computer, you should
specify localhost as Host name instead of server's external host name or IP
address.
Port number
Enter the port number for the SSH server.
4. Enter valid User name for the remote server and select the Authentication
method and set corresponding credentials.
Password-based
Set the password corresponding to the specified user.
Key-based
Specify the path to the Private key file with the corresponding Passphrase to
log in to the remote server. PHP Generator for MySQL accepts keys in ssh.
com or OpenSSH formats. To convert a private key from PuTTY's format to
one of the formats supported by our software, use the PuTTYgen utility that
Keyboard interactive
Keyboard authentication is the advanced form of password authentication,
aimed specifically at the human operator as a client. During keyboard
authentication zero or more prompts (questions) is presented to the user.
The user should give the answer to each prompt (question). The number and
contents of the questions are virtually not limited, so certain types of
automated logins are also possible.
1. Upload the connection PHP script to your website. The installation folder, usually C:
\Program Files\SQL Maestro Group\PHP Generator for MySQL, contains two scripts:
mysqli_tunnel.php and mysql_tunnel.php. We would recommend you to use the
mysqli_tunnel.php script always if possible as it operates through the MySQLi PHP
extension (available since PHP 5) while mysql_tunnel.php uses the original MySQL PHP
API that is deprecated as of PHP 5.5.
4. In case using of a proxy server use Configure tunnelling options to open the HTTP
tunnelling options window and specify your proxy server connection parameters and
HTTP authentication.
Note: You are actually connecting to your database through the PHP script on the
server, so in most cases the host/server name is "localhost" unless the target database
server is not installed on the same computer as the Web server.
2.2 Projects
PHP Generator for MySQL allows you to save and restore all the options set during a
session. You need not to specify all options each time you work with the application
anew; instead you can load all settings from a project and change them if necessary.
Projects are very useful when working with PHP Generator. If you will close the
application without saving a project, all carefully adjusted settings will be lost. To set
the same options next time, you'll need to repeat the process step by step again while
with a project all the session parameters can be restored in a few mouse clicks.
To create a project, configure datasources and click More > Save Project at any next
step (Ctrl+S) or More > Save Project as... (Ctrl+Shift+S). All the settings you have
made will be saved to a file.
To restore previously saved settings from a project, click More > Load Project at the
first wizard step. Recently used projects are available from the More > Recent Projects
popup menu.
Examples
The examples below assume that you are entering the command lines in the PHP
Generator for MySQL program directory. Don't forget to enclose all paths and filenames
containing spaces in quotes.
Check the corresponding options to include project file, schema, and specified number of
the table records, add the problem description and click Send record to get the prepared
report in your default email client. In case you have no browser installed save the
prepared report to a file with the corresponding option and send it manually to
[email protected] as email attachment.
2.6 Deployment
Applications created by PHP Generator use the Smarty library. Smarty is a template
engine for PHP, facilitating the separation of presentation (HTML/CSS) from application
logic. Smarty compiles copies of the templates as PHP scripts. Compilation happens once
when each template is first invoked, and then the compiled versions are used from that
point forward. The compiled templates are stored under the templates_c directory which
must be accessible for writing by Smarty.
To upload a ready web application to your web hosting, you need to have the following
conditions.
· If the new and the live web applications were created by the same version of
PHP Generator for MySQL, just copy to the remote server all .php files from the
root directory of the generated application and the custom_templates folder (if
you customized one or more templates 133 in this project).
· If the new and the live web applications were created by different versions of
PHP Generator for MySQL, copy all files from the output directory to the
corresponding folder of the remote server and then empty the templates_c
directory.
We recommend you to use a file synchronization software. Any such tool compares and
synchronizes the output directory and the corresponding folder on your web hosting
quickly and can significantly simplify the deployment process. One thing you have to do
is to exclude the template_c directory from the synchronization process.
3 Configuring datasources
PHP Generator for MySQL creates webpages aimed at interaction with MySQL tables,
views, and queries throw the web. Each webpage contains a grid with data of according
datasource supplied with abilities to view, edit, filter, sort, delete, and others.
Adding queries
To add a query, type the query text in the Query editor 25 or load it from .sql file with
More > Load query from file... Moreover you can use queries stored a single .qrp file
(query repository). This feature may be extremely useful if you need to share a set of
the same queries between several different projects. To save/load queries to/from a
single file, use More > Save all queries as repository / Load query repository items from
the More button menu accordingly.
Invalid queries
The wizard automatically validates objects and displays names of invalid queries in red.
The basic rules of queries usage in PHP Generator projects are covered in the
corresponding topic 25 .
Primary keys
The wizard automatically inspects all data objects for unique identifiers that are
necessary for add, edit, and delete operations. It marks objects without primary key
constraints with No key columns label and asks a confirmation 277 on moving to the next
step. It's recommended to specify a single column or a set of columns that uniquely
identifies each record in the view/query to expedite the work of the generated
application. It's optional but preferable.
By default, each script has settings defined by the application options 266 . Of course,
you can change them later, but it's useful to setup the generation rules in accordance
with settings of the most webpages to reduce further adjustments.
select * from
(
QUERY_TEXT_YOU_ENTERED
) an_alias
This happens because the software uses similar queries for internal needs. In case such
SQL expression is not valid, the wizard marks the query as invalid and displays its name
in red.
To meet this requirement, make sure that all the columns in the result dataset have
unique aliases. For example, the following query works fine itself, but returns a dataset
with two columns named id:
SELECT
table1.*,
table2.*
FROM table1, table2
WHERE table1.id = table2.id;
This is the reason the wizard marks this query as invalid. To solve the problem, provide
these columns with unique aliases:
SELECT
table1.id as table1_id,
table2.id as table2_id
FROM table1, table2
WHERE table1.id = table2.id;
Example
Assume that we have the following SELECT statement:
SELECT
id,
first_name,
last_name
FROM customer
WHERE last_name LIKE 'A%'
To create an updatable dataset based on this query, INSERT, UPDATE and DELETE
statements can be specified as follows:
INSERT INTO
customer
VALUES (:id, :first_name, :last_name);
UPDATE customer
SET id = :id,
first_name = :first_name,
last_name = :last_name
WHERE id = :OLD_id;
4 Page Management
This step of the wizard displays the list of the webpages to be created. It allows you to
customize the pages as well as manage master/detail views and define the structure of
the application menu.
The working area of the step is divided into two main sections: root level pages 28 (i.e.
pages that can be included into the site menu) and detail pages 31 that are covered in
the appropriate topics.
The Setup project options to configure default page settings link at the bottom of the
step working area opens the Project Options 181 dialog where you can setup application-
level settings as well as specify default options for generated pages.
All cells in the list are editable i.e. it is possible to edit the value of any cell directly in
the list. To do so, just select the cell and click the left mouse button or the F2 key. All
these values can be also set in the Page Properties 162 dialog.
Edit
Opens Page Editor 33 for the selected page.
Properties
Provides quick access to the Page Properties 162 dialog which is also can be invoked in
Page Editor 33 .
Reorder
Allows you to reorder the pages in the site menu.
Refresh
Refreshes the database schema. If a new column detected in a page data source, PHP
Generator for MySQL asks you whether you want to include that column into the page.
The behavior can be changed in the Application Options 275 dialog.
Groups
Invokes a modal dialog that allows you to manage top-level site menu groups. To include
a page into a group, click a cell in the Group column and select the desired group in the
drop-down list.
Add
Allows you quickly add a page without necessity to return to the previous step. Also
using commands from this button's drop down list allows you to add two or more pages
based on the same data source.
Copy
Clones the selected page. Settings you want to copy can be customized in the dialog
window.
Remove
Removes the selected page from the list and website.
More
This button provides access to additional page management commands as described
below.
Assign settings
Copies all or certain page settings from the current page to selected pages based on the
same data source.
Add
Adds a new detail page located at the same level as the selected page.
Add Child
Adds a child page for the selected detail page. This command allows you to create a
detail page at any level of nesting.
Edit
Opens Page Editor 33 for the selected page.
Properties
Provides quick access to the Page Properties 162 dialog which is also can be invoked in
Page Editor 33 .
Link Editor
Opens a dialog window that allows you to edit link conditions between master and detail
pages. This dialog is also invoked when you add a new detail page with Add or Add
Child commands.
Copy
Clones the selected page. Settings you want to copy can be customized in the dialog
window.
Remove
Removes the selected page from the list and website.
More
This button provides access to additional page management commands as described
below.
Reorder
Allows you to change the order of detail pages.
5 Page Editor
Columns 35
Use this tab to specify which columns will be displayed on the result web page and
corresponding forms, their captions, which controls will be used for certain columns on
Insert and Edit forms, lookup options and more.
Details 89
Use this tab to adjust the page detail presentations and setup detail pages properties.
Events 95
Set here the fragments of PHP code to be executed before or after a record was added,
edited, deleted, etc.
Filter 157
Use this tab to reduce the number of records available at the generated page.
Charts 158
Use this tab to equip the web page with interactive charts.
Use the Page Properties 162 window to setup common page properties such as view/edit/
delete/filter/export abilities, pagination options, page header, and more.
The Data Partitioning 176 wizard allows you to create a custom pagination i.e. split the
records on the generated page by a specified criteria.
To reorder columns, click the Reorder columns... button and set the new order in the
opened window. Check the corresponding boxes to apply this order to necessary
presentations. The order of columns within Page Editor is changed accordingly if the new
order is applied to all presentations and remains unchanged if a different column order is
specified for two or more presentations.
5.1 Columns
The Columns tab of Page Editor allows you to customize the way column data is
displayed for all the available presentations (like List, Edit, Insert, etc). Details are
covered below.
Common
Properties specified in this section are applied to all presentations.
Caption
Allows you to specify the caption for the column. To provide different captions for
different presentations, click the ellipsis button and specify the appropriate values.
Use lookup
Turn this checkbox ON and set the appropriate options to enable displaying of lookup
values 37 instead of the "real" values stored in this column. For example, if a column
stores country IDs, you can use this option to display country names instead of their IDs
(assuming that there is a table that stores the ID/name combination for each country).
By default, PHP Generator for MySQL enables lookups for columns linked by a foreign key
with a single column from another table (if the Setup lookups by foreign key option 275
option is enabled).
View 41
Use this section to specify the way column values are displayed on List, View, Print,
Export, and Compare pages.
List
Here you can specify some options that are applied only for the List view.
Minimal visibility
PHP Generator for MySQL provides you with an ability to generate responsive pages that
look beautiful on any device from a mobile phone up to an extra-large desktop. This
option allows you to select the minimum resolution of devices the column will be visible
at. Live Demo.
Totals
This option allows you to enable a grid footer to display summaries (Sum, Average,
Count, etc) for the selected column. Live Demo.
Edit/Insert 54
Allows you to select a control to be used for the selected column in Edit and Insert
forms and customize the control's properties.
Filter Builder
Here you can specify operators that will be allowed for the selected column in the Filter
Builder dialog.
In data input forms the following editors can be used for lookup controls: Autocomplete
62 (default option), Radio Group 60 , and Combobox 58 . Here are some
recommendations:
· for lookup data sources containing a few (usually no more than 5-7) values, all editors
can be used.
· for lookup data sources containing no more than 15-20 values, both Autocomplete 62
and Combobox 58 editors can be used.
· for lookup data sources containing 20+ values, the Autocomplete 62 editor is
recommended.
By default, PHP Generator for MySQL enables an Autocomplete 62 editor for a column
linked by a foreign key with a single column from another table (if Setup lookups by
foreign key option 275 is enabled).
Example 1
To enable a lookup editor with a list of USA cities (the corresponding value of
"country_id" is 103) named like Da*, specify the following condition: country_id = 103
AND city LIKE 'Da%'
Example 2
Suppose we have a table that contains a column 'owner' with owner information. To set
a lookup editor with the list of values owned by the current user, specify the filter
NB. The Filter Condition property cannot be used to implement dependent lookups or
another similar logic. Only pre-defined variables and constant expressions are allowed.
Example
Suppose we have three tables: 'employee' with a list of office employees, 'job' with
employees' job titles and salaries, and 'department' with a list of office departments.
To enable a lookup editor for the 'HEAD_DEPT' field of the 'department' table
representing first name, last name, and job title of the employee, follow the steps above
with the following query text:
SELECT
e.EMP_NO as ID,
CONCAT(e.FIRST_NAME, ' ', e.LAST_NAME, ', ', j.JOB_TITLE) as FULL_NAME
FROM employee e,
job j
WHERE e.JOB_CODE = j.JOB_CODE
By default, PHP Generator for MySQL creates lookup editors described above for columns
based on enumeration data types.
Display properties
Select the control to be used to represent column data from the drop-down list.
Available controls are as follows:
· Text 42
· DateTime 44
· Checkbox 45
· File download 46
· Image 47
· External File 48
· External Image 49
· External Audio 50
· External Video 51
· Embedded video 53
To set the format to be applied to the column data such as text alignment, image size,
and so on, use the dialog opened by the ellipsis button. By default, the format is the
same as it is set at the Project options 276 .
Along with available formatting options you can specify any property you want using the
Custom attributes option. This option allows you to specify the content of standard
HTML style tag applied to the column data.
The Null Label property allows you to customize the representation of NULL values at
the column level.
Display as hyperlink
To represent the column's data as hyperlink, check the Display as hyperlink option and
specify the HREF Template 88 . Target controls where the new document is displayed
when a user follows the link.
Header hint
Use this field to specify the the column caption's hint. By default, it is a comment to the
table/view column.
5.1.2.1 Text
The most popular type of data representation when data is represented "as is" with
minimum modifications. All fields represented on the picture below are displayed as text.
Max length
Use this option to specify the maximum number of symbols to be displayed on the
generated webpage. In case the length of stored text is longer, this text will be cropped
and the more link will be added after the allowed number of symbols. The full text will be
displayed in a popup window on putting mouse over the more link or in a separate
window on clicking this link. Use application options 275 to specify the default max length
of text fields.
Use the Allow HTML and Word wrapping checkboxes to set whether HTML tags will be
applied to the stored data and whether word wrapping will be allowed.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
Set the Format options to be applied to the column data depending of data type
(Number, Percent, String, Currency).
5.1.2.2 DateTime
Use this type of representation to display date and time in convenient format.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
5.1.2.3 Checkbox
Use this control to display column values as checkboxes. This type of representation is
used for columns storing BOOLEAN, BIT(1), TINYINT(1), or INTEGER data. PHP Generator
for MySQL provides you with the following types of the control appearance.
· Images
· Text values
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
This control allows you to represent BLOB data stored in the database as download links.
For files stored outside of the database the External File 48 control should be used. If the
Setup binary fields as image 275 option is turned ON, the Image 47 control will be
automatically selected for all the BLOB columns.
Use the Additional options to specify templates 88 of file names and content type
(optional) to be used for binary files on download and enable the Force downloading
option to force browser to download files, instead of open them in the browser.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
5.1.2.5 Image
This control allows you to represent BLOB data stored in the database as images. For
images stored outside of the database the External Image 49 control should be used. If
the Setup binary fields as image 275 option is turned ON, this control will be automatically
selected for all the BLOB columns.
The Additional attributes allows you to manipulate the size of represented images: to
resize them to a specified height or width. To change image sizes, the appropriate PHP
extension is required. You can also specify a template 88 to be used for image hints to
be shown when the mouse passes on an image.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
This control is intended for representing links to external files. For files stored in the
database the File download 46 control should be used.
Hint template
The value of this property is displayed as the value of the title attribute of the
corresponding web element at the generated page. You can use column names enclosed
in percents (like %column_name%) to include the value(s) of the corresponding fields
into the hint.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
This control is intended for displaying images stored in external files. For images stored in
the database the Image 47 control should be used.
Live examples
You can see this control in action at Column Types and Image Galleries pages in the
Feature Showcase demo. Other examples are available at Arenas and Roster pages in
the NBA demo (the last page also learns how to display images stored at an external
website).
Hint template
The value of this property is displayed as the value of the title attribute of the
corresponding web element at the generated page. You can use column names enclosed
in percents (like %column_name%) to include the value(s) of the corresponding fields
into the hint.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
Is thumbnail
Defines whether this image is a thumbnail for another image. If this property is checked,
you should specify the original image field name and, optionally, its prefix and suffix that
are handled exactly as Source prefix and Source suffix properties described above.
5.1.2.8 External Audio
This control is intended for displaying and playing audio files with the standard html5
audio player.
Hint template
The value of this property is displayed as the value of the title attribute of the
corresponding web element at the generated page. You can use column names enclosed
in percents (like %column_name%) to include the value(s) of the corresponding fields
into the hint.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
This control is intended for displaying and playing raw (for example, locally stored) video
files. For videos stored on a video hosting service like YouTube or Vimeo the Embedded
Video 53 control should be used.
Hint template
The value of this property is displayed as the value of the title attribute of the
corresponding web element at the generated page. You can use column names enclosed
in percents (like %column_name%) to include the value(s) of the corresponding fields
into the hint.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
This control allows you to embed a video stored on a video hosting service like YouTube
or Vimeo into the page (for videos stored in external files the External Video 51 control
should be used). It is represented as a thumbnail of the video or as a play button (for
low screen resolutions). Clicking the thumbnail or the button opens a modal window and
starts playing the video.
Align
Allows you to specify the alignment of the control. Possible values are Default, Left,
Right, and Center.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Null label
This property allows you to define how NULL values are represented for this column. By
default the value of this property corresponds to the one defined at the project level.
You can specify a custom value for a certain column (for example, "Not selected", "Not
available" "Not supported", etc.) if necessary.
Edit properties
Use this drop-down list to select a control to be used for this column on Edit and Insert
pages. Available controls are:
· Text 56
· Combo box 58
· Radio group 60
· Autocomplete editor 62
· Check box 70
· Multiple Select 72
· DateTime 73
· Time 74
· Spin edit 74
· Range edit 75
· Color edit 76
· Mask edit 77
· Text area 78
· Html Wysiwyg 79
· Password 81
· File Upload 81 , Image Upload 82 , Upload File to Folder 84 , Upload Image to Folder
85
Read only
Use this option to make the control readonly. A readonly input field cannot be modified
(however, a user can tab to it, highlight it, and copy the text from it). Readonly form
elements will get passed to the form processor.
Visible
This option defines whether the control will be visible on the generated page. An invisible
element stays in its original position and size.
Enabled
Use this option to specify whether the control will be enabled on the generated page.
Turn it OFF to disable the control. Disabled input elements in a form will not be
submitted.
Required
Check the Required box if the field is mandatory. Required columns are marked by red
asterisk. When a user tries to submit a form with an empty required field, data will not
be submitted and an error message will be shown.
PHP Generator for MySQL allows you to check for correctness of input data on the client
side on two scopes:
· The input value is validated when a user leaves the control. For this purpose,
specify the suitable Client validator.
Range The generated script validates if number is between the
largest and smallest values.
Length The script validates if the length of text is between the min
length and the max length.
range
Email The script makes the element require a valid email.
Credit card The script makes the element require a credit card number.
Number The script makes the element require a decimal number.
URL The script makes the element require a valid URL.
Digits The script makes the element require digits only.
Regular You can also specify your regular expression for data
expression validation. Such expression is a pattern and every character
entered in a form field is matched against that pattern – the
form can only be submitted if the pattern and the user-input
matches.
· The input values are validated when a user clicks the Save button. This may be
useful to check the compatibility of input data. For this purpose, use the
OnInsertFormValidate 115 and OnEditFormValidate 115 client side events. These
events occur before submitting of an insert and edit forms and allow you to detect
errors on the client side before the form is submitted to the server to avoid the
round trip of information necessary for server-side validation.
Default value
This option allows you to set the expected value of an input field with string templates
88 . You can use such environment variables as %CURRENT_DATETIME%, %
5.1.3.1 Text
Select this control to create a single-line input field for entering text.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Max length
Use this field to restrict the number of symbols of the value that can be entered.
Placeholder
Use this field to set a short hint that describes the expected value of an input field (e.g.
a sample value or a short description of the expected format). The placeholder is
displayed in the input field before the user enters a value.
Use Prefix and Suffix to create prepended and appended inputs allowing for simple
punctuation or units to be paired with an input. For example, if you need to indicate a
field is asking for money, use the prepend with a $ sign. Other examples include @ with
a username (a la Twitter.com's settings pages) and "+1" for phone number inputs.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
HTML filter
Use it to strip unwanted HTML tags and attributes from user input. By default all tags
and attributes are stripped out, so you have to define allowed items explicitly.
Settings on the screenshot above are to allow the <a> tag (optionally with the href
attribute as well as the <strong> and <h1> tags. All other tags and attributes will be
removed from the user input.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Value
Use this field to fill the combobox with more convenient values instead of stored ones.
For this purpose use the Value list window or enter them manually as pairs
allowed_value=value_to_be_represented separated by commas (Example: 1=One,
2=Two).
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Select this control to let the visitor select one option from a set of alternatives. If more
options are to be allowed at the same time you should use check boxes 71 instead.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Values
You can specify values to be represented as radio group values instead of stored ones.
For this purpose use the dialog opened by the ellipsis button, or add them manually as
pairs allowed_value=value_to_be_represented separated by commas (Example: 1=One,
2=Two).
Display mode
Use the drop-down list to select whether the radio group will be represented on the
same column (Stacked) or on the same line (Inline).
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Select this control to create a combination of a single-line editable textbox and a drop-
down list filtered according to values entered in the textbox. It is recommended to use
this editor type as lookup editor to work with a big number of records. Live Demo.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Allow clear
Turn it ON to allow end users to clear the selected value using special button.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Formatting functions
Use these functions to format search results and the selection. For example, it is
possible to use fonts, colors, images, and so on. All you need is to specify two functions
in JavaScript each of which accepts the current item as a parameter and returns the
HTML code to represent search results and the selected item accordingly. In the
example below search results are displayed in italic and the selected item is displayed in
bold.
formatResult function:
return '<i>' + item.text + '</i>';
formatSelection function:
return '<b>' + item.text + '</b>';
Select this control to create cascading combo boxes to get greater control over data
input, and to make things easier for the user. Multi-level autocomplete editor is a series
of 2 or more combo boxes in which each combo box is filtered according to the previous
combo box. The number of levels is not limited. Live Demo.
Note: regardless of the number of levels the result of the multi-level editor is only a
single value.
The picture below demonstrates two-level and three-level autocomplete editors. On the
first figure, the City combo box is populated on the fly with city names that correspond
to the currently selected country from the Country combo box. On the second figure, to
specify an address a user needs to select a country, then select a city from a combo
box populated with names of cities located in the selected country, and after that he
can select an address from the list of addresses related to the currently selected city.
To create cascading combo boxes with any number of levels, use the same technique as
described below.
Levels
Use this tab to select tables to be used for additional combo boxes, specify captions for
these combo boxes, and columns which data will be displayed in the drop-down lists.
Place tables in the reverse order of logical priority. In the example of three-levels editor
we used Country, City, Address, and Customer tables. Customer is the source table for
the generated webpage. Pay attention that the data entry order would be Country, City
and then Address; which by data hierarchy standards is backwards. So we need to add
Address first, then specify City and after that Country.
The Filter Condition property allows you to restrict number of displayed values.
Variables like %CURRENT_USER_ID% are allowed.
Example
Let's consider how to implement a three-level editor. Suppose we have the following
tables:
1. Open the editor of the page based on the Customer table, select the Address_id
column, and specify its lookup properties 37 . If you have a foreign key relationship and
the Setup lookup by foreign key 275 option is enabled, these properties are set
automatically.
2. Select Multi-level autocomplete editor as edit control and click the ellipsis button to
open the Edit properties dialog
3. As we've written above, the tables for additional combo boxes are placed in the
reverse order of logical priority. The data entry order would be Country, City and then
Address, so we need to add Address first, then specify City and after that Country. To
add a new level for the control, click Add level and specify options of the Add filter
dialog as follows:
Click OK in the Edit properties window to save all settings and return to the Page Editor.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Allow clear
Turn it ON to allow end users to clear the selected value using special button.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Formatting functions
Use these functions to format search results and the selection. For example, it is
possible to use fonts, colors, images, and so on. All you need is to specify two functions
in JavaScript each of which accepts the current item as a parameter and returns the
HTML code to represent search results and the selected item accordingly. Formatting
functions can be specified at the level basis. The screenshot below is from our demo
application:
Select this control to let the user to make a binary choice. This type of editor is
automatically selected for boolean and bit(1) columns.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Select this control to provide the user with the ability to select multiple items. You can
also use the Multiple select 72 control for this purpose. Live Demo.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Values
You can separate values to be represented in the control and values stored in the
database. For this purpose use the dialog opened by the ellipsis button and enter the
values you need, or add them manually as pairs stored_value=value_to_be_represented
separated by commas (Example: 1=One, 2=Two).
Display mode
Use the drop-down list to select whether the check box group will be represented on the
same column (Stacked) or on the same line (Inline).
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Select this control to provide the user with the ability to select multiple items. It
provides the same functionality as Checkbox Group 72 (i.e. allows you to select multiple
options for a single field) but looks much different and requires less space in the forms.
Live Demo.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Values
You can separate values to be represented in the control and values stored in the
database. For this purpose use the dialog opened by the ellipsis button and enter the
values you need, or add them manually as pairs stored_value=value_to_be_represented
separated by commas (Example: 1=One, 2=Two).
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
5.1.3.9 DateTime
Select this control to let the user to enter date time values with datepicker, a
combination of an interactive calendar and a single-line editable textbox.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
By default, the format of the column's data is the same as it is set at the Project
options 276 . To use another Date time format, uncheck the Default format option and
select it from the corresponding field to setup a format to be applied to the input value.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
5.1.3.10 Time
Select this control to let the user to enter time values in a single-line editable textbox
provided by a spinner helping to quickly change the editor's value as well as to reset its
value to the current time.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
5.1.3.11 Spin edit
Select this control to create a single-line input field allowing users to edit numeric values
with ease. The editor consists of an edit region and one pairs of spin buttons which can
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Step specifies the legal number intervals for the input field. When an end-user presses a
spin button, the value is incremented or decremented by this amount. The default value
is 1.
To limit end-user input to a specified range, turn ON the Use constraints option and
define the editor's minimum and maximum allowed values.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
The range input (so-called slider) is useful for imprecise number input. It is possible to
indicate the allowed range of values in the appropriate dialog window (default values are
0 and 100 for bottom and top limits accordingly).
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Step specifies the legal number intervals for the input field. When an end-user presses a
spin button, the value is incremented or decremented by this amount. The default value
is 1.
To limit end-user input to a specified range, turn ON the Use constraints option and
define the editor's minimum and maximum allowed values.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
5.1.3.13 Color edit
Use this control to edit values of columns storing HTML color codes with a native-
browser Color Picker (it is assumed that a string data type is used for storing such
values in the database).
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
5.1.3.14 Mask edit
Use this control to define an edit box that limits the user to a specific format (dates,
phone numbers, etc) and accepts only valid characters.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Mask
A mask is defined by a format made up of mask literals and mask definitions. Any
character not in the definitions list below is considered a mask literal. Mask literals will be
automatically entered for the user as they type and will not be able to be removed by
the user. The following mask definitions are predefined:
Example
To define an edit box for telephone numbers, specify the following string as the mask of
the editor.
999-999-9999
In this case the created data entry field accepts only numeric input and if a user then
tries to enter a letter in this edit box, the application will not accept it.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
5.1.3.15 Text area
Use this control to provide the Edit form with a multi-line text input control. A text area
can hold an unlimited number of characters, and the text renders in a fixed-width font
(usually Courier).
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
The size of a text area can be specified by the Column count and Row count values.
Placeholder
Use this field to set a short hint that describes the expected value of an input field (e.g.
a sample value or a short description of the expected format). The placeholder is
displayed in the input field before the user enters a value.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
HTML filter
Use it to strip unwanted HTML tags and attributes from user input. By default all tags
and attributes are stripped out, so you have to define allowed items explicitly.
Settings on the screenshot above are to allow the <a> tag (optionally with the href
attribute as well as the <strong> and <h1> tags. All other tags and attributes will be
removed from the user input.
Select WYSIWYG (What You See Is What You Get) editor to provide users with an
ability to directly manipulate the layout of a HTML data stored in the column, without
having to type or remember names of layout commands.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
HTML filter
Use it to strip unwanted HTML tags and attributes from user input. By default all tags
and attributes are stripped out, so you have to define allowed items explicitly.
Settings on the screenshot above are to allow the <a> tag (optionally with the href
attribute as well as the <strong> and <h1> tags. All other tags and attributes will be
removed from the user input.
5.1.3.17 Password
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Use this control to allow users to upload binary files to the database. To store files
externally, use the Upload File to Folder 84 control.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
You can save the type, name and size of uploaded files to table columns (optional).
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Use this control to allow users to upload images to the database. To store images
externally, use the Upload Image to Folder 85 control.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
You can save the type, name and size of uploaded files to table columns (optional).
Example
To allow uploading images which size is not greater than 200Kb, width is not greater
than 600px and height is not greater than 400px and to save the original file names to
the file_name column, specify the Edit properties as follows:
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Use this control to allow users to upload external files. To files stored in the database,
use the File Upload 81 control.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
The value of this property defines which file types are displayed in the dialog invoked by
pressing the Choose File button. The drop down list contains pre-defined values for
some common cases.
Folder to upload
Use this field to specify the folder to be used to store the uploaded files.
Check the Generate random file name option to save uploaded files with random
names or specify the File name template 88 to be used for file name generation.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Use this control to allow users to upload external images 48 . To images stored in the
database, use the Image Upload 82 control.
Max width
Use this property to restrict the maximum width of the editor (this means that in any
screen resolution editor's width will be less or equal then the property value). Can be
specified in any units supported by web browsers e.g. 300px, 25em, 50%, etc.
Folder to upload
Use this field to specify the folder to be used to store the uploaded files.
Check the Generate random file name option to save uploaded files with random
names or specify the File name template 88 to be used for file name generation.
Enable the Generate thumbnail option to save reduced-size versions of the uploaded
files along with these files. By default thumbnails are saved in the same folder where full
size images are saved. The names of thumbnails are 'field name'_'uploaded_file_name'.
You can also specify another Folder to upload and File name template.
To set the size of thumbnails, select Resize type (Fit by width, Fit by height) and
specify the height or width correspondingly.
Inline styles
Use this field to set formatting options to be used inside the <style> tag of the element.
For example, to set the font color and the background color for a control, place the
following string to Inline styles:
Custom attributes
This property allows you to add simple metadata to individual elements, largely for the
purpose of providing information to make JavaScript functions easier. Such attributes
can be later handled in client-side events. For example, to add several custom attributes
to an editor, enter the following string into the Custom attributes edit box:
It is recommended to prefix all custom attributes with data- to keep the result document
compatible with the HTML5 requirements.
Examples:
1. Suppose a table 'team' stores various info about NBA teams. The table has 'caption'
column with such data:
maverics
cavaliers
2. Suppose there is a table 'employee' storing employee info. The table has 'first_name'
and 'last_name' columns with such data:
Forest Gump
Sara Connor
You can also create nested master-detail presentations when you can see the "details
of details". On the picture below the webpage with a list of continents is represented.
For any continent all the corresponding countries may be browsed with a single click and
at the same time it is possible to see cities of a certain country.
First 20 detail records can be previewed without opening a separate page. To see all the
detail records, click the Full view link above the detail data grid. Alternatively you can
access a detail page using the drop-down list on the right of the plus button.
Automatic creation
If tables are linked with a foreign key and the Setup details by foreign key 275 option is
enabled, the first-level detail pages are created automatically.
Manual creation
If tables are NOT linked with a foreign key or the Setup details by foreign key 275 option
is disabled, you can create detail pages manually as described below. The same
technique is applied for creating nested detail pages.
1. At the Page Management step of the wizard select a root-level page 28 you want to
create a detail page for or (for creating a nested detail page) select a detail page 31
in the corresponding list.
2. Click the Add... button on the right of the detail page list to open Link Editor.
3. Select a detail data source (table, view, or query) and columns from the Master field
and Detail field lists. Click Add to add a link condition (you can specify multiple
columns from each list for a single link). Click Remove to delete a field pair.
5.4 Events
PHP Generator for MySQL allows you to supply the generated applications with an
additional functionality with the help of event handlers. Event handlers are fragments of
PHP/Javascript code executed at the appointed time. This feature provides you with
wide opportunities: for example, you can equip webpages with tracking of user activity,
completely redesign any of generated pages, supply the application with the power of
third-part libraries, etc.
All events supported by PHP Generator for MySQL may be divided by the scope the
events are fired on (possible options are all generated webpages (global events) or a
certain webpage (page-specific events)); and by the side the event handlers are
executed on: the webserver (written on PHP) or browsers (written on Javascript).
To temporarily disable an event, use the corresponding checkbox at the Events tab of
the according Page Editor 33 (for Page events) or the Project Options 181 (for Global
events).
· OnBeforePageExecute 97
· OnAfterLogin 97
· OnBeforeLogout 97
· OnPreparePage 98
· OnGetCustomTemplate 99
· OnCustomHTMLHeader 98
· OnBeforeUpdateRecord 107
· OnBeforeInsertRecord 107
· OnBeforeDeleteRecord 108
· OnAfterUpdateRecord 109
· OnAfterInsertRecord 108
· OnAfterDeleteRecord 110
· OnGetFieldValue 111
· OnGetCustomExportOptions 111
· OnCustomizePageList 112
· OnGetCustomPagePermissions 113
To specify a handler for a global event, switch to the Events tab of the Project options
181 dialog and double click the appropriate line in the grid.
5.4.1.1 OnBeforePageExecute
This event occurs before other events are declared and allow to create global objects,
declare functions, and include third-party libraries. This helps you to define a snapshot
of PHP code that will be included into all the pages.
Signature:
function OnBeforePageExecute()
Example:
In our Schema Browser demo project all the code implementing database filter,
formatting and highlighting SQL code we entered in the schema_browser_utlis.php file.
The following code is used to include it to into all application web pages.
include_once 'schema_browser_utils.php';
5.4.1.2 OnAfterLogin
This event occurs after a user is successfully logged in into the application.
Signature:
function OnAfterLogin ($userName, $connection, $canLogin, $errorMessage)
Parameters:
$userName The name of the logged user.
$connection An instance of the EngConnection class 259 .
$canLogin Specifies whether a user can login (true by default). You can set
the value of this parameter to false to disable login even for a user
who provided valid credentials.
$errorMessage A message to be displayed when valid credentials are provided, but
$canLogin == false.
Example
Among other things this event can be used for tracking the user activity. The code
snippet below inserts a new record containing user name and the login time into the 'log'
table.
5.4.1.3 OnBeforeLogout
This event occurs just before a user logged out from the application by pressing the
Logout button or when the inactivity timeout 225 is reached.
Signature:
function OnBeforeLogout ($userName, $connection)
Parameters:
$userName The name of the logged user.
Example
Among other things this event can be used for tracking the user activity. The code
snippet below inserts a new record containing user name and the action into the
'activity_log' table.
$connection->ExecSQL(
"INSERT INTO activity_log (user_name, action) values ('{$userName}', 'logout')"
);
5.4.1.4 OnPreparePage
This piece of code is a method of the Page class that is called at the end of the
constructor. It allows you to customize all members of the class.
Signature:
function OnPreparePage()
Parameters:
This method has no parameters.
Example
The following code hides the update_date_time column from the data grid and Single
Record View form as well as the status column from Edit and Insert forms from all users
except ones who have the Admin privilege for the current page.
if (!GetApplication()->IsLoggedInAsAdmin()) {
$updateDateTimeColumnName = 'update_date_time';
$column = $this->GetGrid()->getSingleRecordViewColumn($updateDateTimeColumnName);
if ($column) {
$column->setVisible(false);
}
$column = $this->GetGrid()->getViewColumn($updateDateTimeColumnName);
if ($column) {
$column->setVisible(false);
}
$statusColumnName = 'status';
$column = $this->GetGrid()->getEditColumn($statusColumnName);
if ($column) {
$column->setVisible(false);
}
$column = $this->GetGrid()->getInsertColumn($statusColumnName);
if ($column) {
$column->setVisible(false);
}
}
5.4.1.5 OnCustomHTMLHeader
This event occurs when generating the HEAD section of the page. It allows you to
define the contents of the HEAD section (like meta tags or favicon) for all pages of the
generated website.
Signature:
function OnCustomHTMLHeader ($page, &$customHTMLHeaderText)
Parameters:
$page An instance of the Page class 257 declared in
components/page.php.
$customHtmlHeaderText The text block to be added to the head section of all
created pages.
Example:
To add a new title and a favicon to all webpages of the generated application, place the
following code to the event body.
5.4.1.6 OnGetCustomTemplate
This event allows you to customize almost any part of the generated application using
an own template instead of the default one.
Signature:
function OnGetCustomTemplate ($part, $mode, &$result, &$params)
Parameters:
$part The part of the page to be affected by the template.
$mode The current state of the webpage the template to be used.
$result The path to the file to be used as template according to the
components/templates/custom_templates folder.
$params An associative array of additional parameters you want to assign
to the template.
PHP Generator uses Smarty 2.0 as template language. If you are not familiar with web
template engines, you might want to start here.
The simplest way to create a new template is to modify an existing one (it is much
easier than create a new template "from scratch"). Use the table below to select the
template corresponding to the necessary state of page and page part. Custom template
files should be uploaded to the 'components/templates/custom_templates' directory.
This folder should be created by the user of PHP Generator and its content is not
changing during the further PHP Generator sessions.
The following table shows how to customize common pages used in the generated
applications.
forms/form.tpl PagePart::VerticalGrid
Edit form (editors area) PageMode::EditForm
forms/form.tpl PagePart::VerticalGrid
Insert form (editors area) PageMode::InsertForm
compare/grid.tpl PagePart::Grid
Record comparison page PageMode::Compare
forms/page_form.tpl PagePart::VerticalGrid
Edit (separate page) PageMode::Edit
forms/page_form.tpl PagePart::VerticalGrid
Insert (separate page) PageMode::Insert
forms/modal_form.tpl PagePart::VerticalGrid
Edit (modal dialog) PageMode::ModalEdit
forms/modal_form.tpl PagePart::VerticalGrid
Insert (modal dialog) PageMode::ModalInsert
view/record_card_view.tpl PagePart::VerticalGrid
View (modal dialog) PageMode::ModalView
forms/inline_form.tpl PagePart::VerticalGrid
Edit (inline form) PageMode::InlineEdit
forms/inline_form.tpl PagePart::VerticalGrid
Insert (inline form) PageMode::InlineInsert
print/page.tpl PagePart::PrintLayout
webpage
PageMode::PrintAll
layout
print/grid.tpl PagePart::Grid
Print table grid PageMode::PrintAll
print/detail_page.tpl PagePart::PrintLayout
detail page PageMode::PrintDetailPage
print/page.tpl PagePart::PrintLayout
webpage
PageMode::PrintOneRecord
Print layout
Single
Record view/print_grid.tpl PagePart::Grid
table grid PageMode::PrintOneRecord
login_page.tpl PagePart::LoginPage
Login page
login_control.tpl PagePart::LoginControl
Login control
home_page.tpl PagePart::HomePage
Home page
navigation.tpl PagePart::Navigation
Navigation
The following table shows how to customize user registration and password recovering
pages. These parameters can be used only for the project-level version of this event.
registration_page.tpl PagePart::RegistrationPage
Registration Page
registration_form.tpl PagePart::RegistrationForm
Registration Form
recovering_password_page. PagePart::
Password Recovery tpl PasswordRecovery
Page
reset_password_page.tpl PagePart::ResetPassword
Reset Password Page
resend_verification_page.tpl PagePart::
Resend Verification ResendVerification
Email Page
The following table shows how to customize emails sent to users 213 on registration and
password recovering. These parameters can be used only for the project-level version of
this event.
user_verification_subject PagePart::Mail
Verification email
.tpl PageMode::
subject
MailVerificationSubject
user_verification_body. PagePart::Mail
Verification email
tpl PageMode::MailVerificationBody
body
recovering_password_sub PagePart::Mail
Password reset email
ject.tpl PageMode::
subject
MailRecoveringPasswordSubject
recovering_password_bo PagePart::Mail
Password reset email
dy.tpl PageMode::
body
MailRecoveringPasswordBody
To instruct PHP Generator to use a customized template file for a certain webpage,
specify the following code in the page's OnGetCustomTemplate event handler (of course
you should replace YourPart and YourMode to the appropriate values from the table
above).
Example 1:
Suppose we need to use components/templates/custom_templates/staff_edit.tpl file as
a template for the edit form of a webpage.
Now we can compare the result webpages without using this event and with the enabled
one:
Example 2:
A single event handler can be used to customize multiple templates:
Example 3
This example shows how to fill a SELECT input with names of all MySQL databases
available at the server.
$queryResult = array();
$this->GetConnection()->ExecQueryToArray('SHOW DATABASES', $queryResult);
<select name="database">
{foreach from=$databaseNames item=database}
<option value="{$database}">{$database}</option>
{/foreach}
</select>
Example 4
This example shows the use of the superglobal $_GET array values in a custom template.
<div>
<h4>I am a custom template with a custom variable $custom_var. Its value
{if !isset($custom_var)}
still undefined
{else}
= {$custom_var}
{/if}.
</h4>
</div>
Example 4
Let's see the login form customization used in our NBA online demo.
if ($part == PagePart::LoginPage) {
$result = 'login_page.tpl';
}
<h2>Logins</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>admin</td>
<td>admin</td>
<td>Can modify any record at any page and manage other users.</td>
</tr>
<tr>
<td>lakers</td>
<td>lakers</td>
<td>Can modify team info, home games and players for LA Lakers.</td>
</tr>
<tr>
<td>boston</td>
<td>boston</td>
<td>The same for the Boston Celtics team.</td>
</tr>
<tr>
<td>game_manager</td>
<td>game</td>
<td>Can access only game list. Can modify any game.</td>
</tr>
</tbody>
</table>
Example 5
The example below is used in our NBA demo application to customize the template used
to export a single record to PDF.
5.4.1.7 OnBeforeInsertRecord
This event occurs when the Insert command is executed, and before the actual
insertion.
Signature:
function OnBeforeInsertRecord ($page, &$rowData, &$cancel, &$message,
&$messageDisplayTime, $tableName)
Parameters:
$page An instance of the Page 257 class declared in components/
page.php.
$rowData The associative array of values that corresponds to the
currently processed row.
$cancel The value indicating whether the operation should be
canceled.
$message The message string that is displayed after the operation is
completed (or canceled).
$messageDisplayTime A time interval (in seconds) after which the message will
disappear automatically. Default value is 0 (the message will
not disappear).
$tableName The name of processed table.
Example:
if (!(allowDataEditing())) {
$cancel = true;
$message = 'The application is running in read-only mode.';
}
5.4.1.8 OnBeforeUpdateRecord
This event occurs when the Update command is executed, and before the actual
update.
Signature:
function OnBeforeUpdateRecord ($page, $oldRowData, &$rowData, &$cancel, &$message,
&$messageDisplayTime, $tableName)
Parameters:
$page An instance of the Page 257 class declared in components/
page.php.
$oldRowData The associative array of old (previous) values of the
currently processed row.
$rowData The associative array of values that corresponds to the
currently processed row.
$cancel The value indicating whether the operation should be
canceled.
$message The message string that is displayed after the operation is
completed (or canceled).
$messageDisplayTime A time interval (in seconds) after which the message will
disappear automatically. Default value is 0 (the message will
not disappear).
$tableName The name of processed table.
Example:
if (!(allowDataEditing())) {
$cancel = true;
$message = 'The application is running in read-only mode.';
}
5.4.1.9 OnBeforeDeleteRecord
This event occurs when the Delete command is executed, and before the actual
deletion.
Signature:
function OnBeforeDeleteRecord ($page, &$rowData, &$cancel, &$message,
&$messageDisplayTime, $tableName)
Parameters:
$page An instance of the Page 257 class declared in components/
page.php.
$rowData The associative array of values that corresponds to the
currently processed row.
$cancel The value indicating whether the operation should be
canceled.
$message The message string that is displayed after the operation is
completed (or canceled).
$messageDisplayTime A time interval (in seconds) after which the message will
disappear automatically. Default value is 0 (the message will
not disappear).
$tableName The name of processed table.
Example:
if (!(allowDataEditing())) {
$cancel = true;
$message = 'The application is running in read-only mode.';
}
5.4.1.10 OnAfterInsertRecord
This event occurs when the Insert command is executed, and after the actual insertion.
Signature:
function OnAfterInsertRecord ($page, $rowData, $tableName,
&$success, &$message, &$messageDisplayTime)
Parameters:
$page An instance of the Page 257 class.
$rowData The associative array of values that corresponds to the
currently processed row.
$tableName The name of processed table.
$success Indicates whether the last data manipulation statement was
successful or not.
$message A message to be displayed to a user. If the statement
completed successfully, the value of this parameter is equal to
empty string. If the statement failed, the value of this
parameter contains the error message that came from the
database server.
$messageDisplayTi A time interval (in seconds) after which the message will
me disappear automatically. Default value is 0 (the message will
not disappear).
Success messages are displayed in green while error messages are displayed in red.
Example
if ($success) {
$message = 'Record processed successfully.';
}
else {
$message = '<p>Something wrong happened. ' .
'<a class="alert-link" href="mailto:[email protected]">' .
'Contact developers</a> for more info.</p>';
}
5.4.1.11 OnAfterUpdateRecord
This event occurs when the Update command is executed, and after the actual update.
Signature:
function OnAfterUpdateRecord ($page, $oldRowData, $rowData, $tableName,
&$success, &$message, &$messageDisplayTime)
Parameters:
$page An instance of the Page 257 class.
$oldRowData The associative array of old (previous) values of the currently
processed row.
$rowData The associative array of values that corresponds to the
currently processed row.
$tableName The name of processed table.
$success Indicates whether the last data manipulation statement was
successful or not.
Success messages are displayed in green while error messages are displayed in red.
Example
if ($success) {
$message = 'Record processed successfully.';
}
else {
$message = '<p>Something wrong happened. ' .
'<a class="alert-link" href="mailto:[email protected]">' .
'Contact developers</a> for more info.</p>';
}
5.4.1.12 OnAfterDeleteRecord
This event occurs when the Delete command is executed, and after the actual deletion.
Signature:
function OnAfterDeleteRecord ($page, $rowData, $tableName,
&$success, &$message, &$messageDisplayTime)
Parameters:
$page An instance of the Page 257 class.
$rowData The associative array of values that corresponds to the
currently processed row.
$tableName The name of processed table.
$success Indicates whether the last data manipulation statement was
successful or not.
$message A message to be displayed to a user. If the statement
completed successfully, the value of this parameter is equal to
empty string. If the statement failed, the value of this
parameter contains the error message that came from the
database server.
$messageDisplayTi A time interval (in seconds) after which the message will
me disappear automatically. Default value is 0 (the message will
not disappear).
Success messages are displayed in green while error messages are displayed in red.
Example
if ($success) {
$message = 'Record processed successfully.';
}
else {
$message = '<p>Something wrong happened. ' .
'<a class="alert-link" href="mailto:[email protected]">' .
'Contact developers</a> for more info.</p>';
}
5.4.1.13 OnGetFieldValue
This event occurs on displaying a value of a field. It allows you to replace the actual
value of a field to your own.
Signature:
function OnGetFieldValue ($fieldName, &$value, $tableName)
Parameters:
$fieldName The name of currently processed field.
$value The actual value of the field. Can be changed to another value.
$tableName The name of currently processed table.
Example
This example shows how this event can be used for implementing a very simple
transparent encryption based on the str_rot13 PHP function.
if ($fieldName == 'private_data') {
$value = str_rot13($value);
}
Since the call of this function for an encrypted expression returns the original string, we
can define OnBeforeInsertRecord 144 and OnBeforeUpdateRecord 145 event handlers as
follows:
$rowData['private_data'] = str_rot13($rowData['private_data']);
This is just an example. We would recommend that you use more cryptographically
strong algorithms to encrypt your important data.
5.4.1.14 OnGetCustomExportOptions
This event fires on exporting data from a database to a file. It allows you to customize
some advanced export settings.
Signature:
function OnGetCustomExportOptions ($Page page, $exportType, $rowData, &$options)
Parameters:
$page An instance of the Page 257 class.
$exportType The type of the result file. Possible values are "csv", "xls", "doc",
"pdf", "xml".
$rowData An associative array of values that corresponds to the currently
processed row (for exporting a single row). NULL if a record list is
exported.
$options An associative array of options passed to the export engine (see
below).
Export to PDF
orientation Page orientation. Possible values are "P" (portrait orientation) or
"L" (landscape orientation). Default value is "P".
size Size of the page. Possible values are A0 - A10, B0 - B10, C0 -
C10, 4A0, 2A0, RA0 - RA4, SRA0 - SRA4, Letter, Legal, Executive,
Folio, Demy, Royal, A (type A paperback 111x178mm), B (type B
paperback 128x198mm). Default value is A4.
Export to Excel
engine The engine to be used on data export. Possible values are
"template" (template-based export) and "phpexcel" (to create
native .xls files). Default value is "template".
Example
This example shows how to customize the result file name according to row values. If a
record list is exported, the file name is set to list.pdf (list.xml, list.xls, etc).
5.4.1.15 OnCustomizePageList
This event allows you to add new groups and items to the application menu (both top-
side and sidebar).
Signature:
function OnCustomizePageList($page, $pageList)
Parameters:
$page An instance of the CommonPage class that corresponds currently
processed page.
$pageList An instance of the PageList class.
Example
This example shows how to add a new group with a couple of links.
$pageList->addGroup('External links');
$pageList->addPage(new PageLink('Home Site', 'http://www.mysite.com',
'Vist my site', false, false, 'External links'));
$pageList->addPage(new PageLink('Get Support', 'http://www.mysite.com/support/',
'Get support for this application', false, false, 'External links'));
5.4.1.16 OnGetCustomPagePermissions
Signature:
function OnGetCustomPagePermissions($page, &$permissions, &$handled)
Parameters:
$page An instance of the Page 257 class.
$permissions Permissions to be applied to the page. An instance of the
PermissionSet 260 class.
$handled A parameter to indicate whether the new permissions should be
applied. Set $handled to true to apply the changes.
Example
This example shows how to implement a simple role-based permission model. Our goal is
to ensure that only site admins and members of the Sales role can add, remove and edit
records displayed on this page.
Client Side API 231 provided by PHP Generator for MySQL. The complete list of currently
available client-side events is as follows.
· OnBeforePageLoad 114
· OnAfterPageLoad 114
· OnInsertFormValidate 115
· OnEditFormValidate 115
· OnInsertFormEditorValueChanged 116
· OnEditFormEditorValueChanged 118
· OnInsertFormLoaded 120
· OnEditFormLoaded 121
5.4.2.1 OnBeforePageLoad
This event occurs before page loading. It allows you to declare functions and global
variables. Use the event to include one or several files of a third-party library into the
generated pages.
Example:
To get the details of the first master record expanded on opening of a certain page of
the generated application, define the expandFirstDetail function within the
OnBeforePageLoad event handler as follows:
function expandFirstDetail() {
if ($('table.pgui-grid').data('grid-class')){
var grid = $('table.pgui-grid').data('grid-class');
var $row = $('table.pgui-grid tr.pg-row').first();
grid.expandDetails($row);
return true;
}
else {
setTimeout(expandFirstDetail, 100);
}
}
This function then should be called within the OnAfterPageLoad 114 event handler.
5.4.2.2 OnAfterPageLoad
This event occurs after page has been fully rendered. It does not get triggered until all
assets such as images have been completely received and DOM hierarchy has been fully
constructed.
Example:
To get details of the first record expanded on the webpage opening, specify Javascript
code as follows:
$('a.expand-details').on("click", function() {
setTimeout(highlightWinLossRows, 3000);
});
It is also possible to specify the function above within the OnBeforePageLoad 114 event
handler. In this case the OnAfterPageload event handler should contain only the function
call:
expandFirstDetail();
5.4.2.3 OnInsertFormValidate
This event occurs before submitting of an insert form. It allows you to detect errors on
the client side before the form is submitted to the server to avoid the round trip of
information necessary for server-side validation.
Signature:
function OnInsertFormValidate (fieldValues, errorInfo)
Parameters:
fieldValues An associative array of values containing user input.
errorInfo The object that provides interface (the SetMessage method) to set
a validation error message.
Example 1:
The code below demonstrates the verification of the percent number on the record
inserting.
Example 2:
The following code is used in the NBA demo project to ensure that home and away
teams are different for an inserted game:
if (fieldValues['home_team_id'] == fieldValues['away_team_id'])
{
errorInfo.SetMessage('"Home" and "Away" must be different');
return false;
}
5.4.2.4 OnEditFormValidate
This event occurs before submitting an edit form. It allows you to detect errors on the
client before the form is submitted to the server to avoid the round trip of information
necessary for server-side validation.
Signature:
function OnEditFormValidate (fieldValues, errorInfo)
Parameters:
fieldValues An associative array of values containing the user input.
Example 1:
To validate the 'percents' value and show a warning message in case of erroneous input,
use the following code:
Example 2:
The following code is used in the NBA demo project to ensure that home and away
teams are different for an edited game:
if (fieldValues['home_team_id'] == fieldValues['away_team_id'])
{
errorInfo.SetMessage('"Home" and "Away" must be different');
return false;
}
5.4.2.5 OnInsertFormEditorValueChanged
Signature:
function OnInsertFormEditorValueChanged (sender, editors)
Parameters:
sender A control whose value has been changed.
editors An associative array of form controls.
The examples below show how this method can be used in the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 event
handlers.
Example 1:
The code below allows you to select a college only for players from U.S. (see this in
action). See how it looks on the webpage at the screen below.
console.log(sender);
if (sender.getFieldName() == 'country_id')
{
console.log(sender.getValue());
editors['college_id'].enabled(sender.getValue() == 1);
if (sender.getValue() != 1) {
editors['college_id'].setValue(null);
$('#college_id_edit').next().show();
}
else
$('#college_id_edit').next().hide();
Example 2:
Another example from the insert and edit forms of the Players page (see this in action).
This piece of code allows you to select player number only if a player's team is already
selected (in other words, players who do not belong to a team cannot have numbers).
if (sender.getFieldName() == 'current_team_id')
{
if (sender.getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
$('#current_number_edit').next().show();
}
else
{
editors['current_number'].enabled(true);
$('#current_number_edit').next().hide();
}
}
5.4.2.6 OnEditFormEditorValueChanged
Signature:
function OnEditFormEditorValueChanged(sender, editor)
Parameters:
sender A control whose value has been changed.
editors An associative array of form controls.
The examples below show how this method can be used in the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 event
handlers.
Example 1:
The code below allows you to select a college only for players from U.S. (see this in
action). See how it looks on the webpage at the screen below.
console.log(sender);
if (sender.getFieldName() == 'country_id')
{
console.log(sender.getValue());
editors['college_id'].enabled(sender.getValue() == 1);
if (sender.getValue() != 1) {
editors['college_id'].setValue(null);
$('#college_id_edit').next().show();
}
else
$('#college_id_edit').next().hide();
Example 2:
Another example from the insert and edit forms of the Players page (see this in action).
This piece of code allows you to select player number only if a player's team is already
selected (in other words, players who do not belong to a team cannot have numbers).
if (sender.getFieldName() == 'current_team_id')
{
if (sender.getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
$('#current_number_edit').next().show();
}
else
{
editors['current_number'].enabled(true);
$('#current_number_edit').next().hide();
}
}
5.4.2.7 OnInsertFormLoaded
Signature:
function OnInsertFormLoaded(editor)
Parameters:
editors An associative array of form controls.
Example:
This piece of code targets two things:
1) Player number is cleared and the appropriate control becomes disabled for players
that do not belong to a team.
if (editors['current_team_id'].getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
}
else
editors['current_number'].enabled(true);
2) Player's college is cleared and the appropriate control becomes disabled if player's
country is not USA (country code == 1). The inline hint describes the reason of the
disabling.
editors['college_id'].enabled(editors['country_id'].getValue() == 1);
addInlineHint('college_id', 'College can be selected only for players from USA.')
if (editors['country_id'].getValue() != 1)
editors['college_id'].setValue(null);
5.4.2.8 OnEditFormLoaded
Signature:
function OnEditFormLoaded(editor)
Parameters:
editors An associative array of form controls.
Example:
This piece of code targets two things:
1) Player number is cleared and the appropriate control becomes disabled for players
that do not belong to a team.
if (editors['current_team_id'].getValue() == '') {
editors['current_number'].setValue('');
editors['current_number'].setEnabled(false);
}
else {
editors['current_number'].setEnabled(true);
}
2) Player's college is cleared and the appropriate control becomes disabled if player's
country is not USA (country code == 1).
editors['college_id'].setEnabled(editors['country_id'].getValue() == 1);
if (editors['country_id'].getValue() != 1)
editors['college_id'].setValue(null);
· OnBeforePageExecute 123
· OnPreparePage 123
· OnCustomRenderColumn 125
· OnCustomRenderPrintColumn 128
· OnCustomRenderExportColumn 128
· OnCustomHTMLHeader 128
· OnExtendedCustomDrawRow 129
· OnCustomRenderTotals 132
· OnGetCustomTemplate 133
· OnCustomDrawRow 141
· OnAfterUpdateRecord 142
· OnAfterDeleteRecord 143
· OnAfterInsertRecord 142
· OnBeforeUpdateRecord 145
· OnBeforeDeleteRecord 145
· OnBeforeInsertRecord 144
· OnGetFieldValue 146
· OnGetCustomExportOptions 146
· OnPrepareFilterBuilder 147
· OnPrepareColumnFilter 148
· OnGetCustomFormLayout 149
· OnGetCustomColumnGroup 150
· OnCustomCompareValues 151
· OnGetCustomUploadFileName 152
· OnGetCustomPagePermissions 153
· OnGetCustomRecordPermissions 153
5.4.3.1 OnBeforePageExecute
This event handler contains PHP code to be included into the page. This code is
executed only once and intended to create global objects, declare functions, include
third-party libraries, and so on.
Example
Suppose we decided to implement a syntax highlighting using the GeSHi library
somewhere in the generated application. To implement such a feature, we need (among
other things) to include the main library file into the generated scripts, so the event
handler should be specified as follows:
include_once '../geshi/geshi.php';
5.4.3.2 OnPreparePage
This piece of code is a method of the Page class that is called at the end of the
constructor. It allows you to customize all members of the class.
Signature:
function OnPreparePage()
Parameters:
This method has no parameters.
Example
The following code hides the update_date_time column from the data grid and Single
Record View form as well as the status column from Edit and Insert forms from all users
except ones who have the Admin privilege for the current page.
if (!GetApplication()->IsLoggedInAsAdmin()) {
$updateDateTimeColumnName = 'update_date_time';
$column = $this->GetGrid()->getSingleRecordViewColumn($updateDateTimeColumnName);
if ($column) {
$column->setVisible(false);
}
$column = $this->GetGrid()->getViewColumn($updateDateTimeColumnName);
if ($column) {
$column->setVisible(false);
}
$statusColumnName = 'status';
$column = $this->GetGrid()->getEditColumn($statusColumnName);
if ($column) {
$column->setVisible(false);
}
$column = $this->GetGrid()->getInsertColumn($statusColumnName);
if ($column) {
$column->setVisible(false);
}
}
5.4.3.3 OnPageLoaded
This event occurs after the page is completely loaded from the server. It allows you, for
example, to add additional filters to the dataset.
Signature:
function OnPageLoaded()
Parameters:
This method has no parameters.
Example 1
The following code is used in our Schema Browser Demo to filter database objects
belonging to the selected database:
applyDatasetFilter($this->dataset);
Example 2
The following code is used in our Feature Demo to filter countries according to the
values selected in the form:
// default values
$minLifeExpectancy = 40;
$maxLifeExpectancy = 90;
5.4.3.4 OnCustomRenderColumn
This event occurs before column rendering and allows you to completely replace the cell
content. It is an extremely useful event for conditional rendering or embedding third-
party components to extend standard functionality.
Signature:
function OnCustomRenderColumn ($fieldName, $fieldData, $rowData,
&$customText, &$handled)
Parameters:
$fieldName The field name for the currently processed cell.
$fieldData The data of currently processed cell.
$rowData The associative array of values that corresponds to the currently
processed row.
$customText A string to replace the original cell content.
$handled A parameter to indicate whether the event handler takes effect.
Set $handled to true to apply the new content.
Example 1:
Suppose a table 'employee' has a column storing data about the employee's sex in that
way that '1' corresponds to male and '2' to female. Our goal is to represent the
employees sex as 'M' and 'F' for men and women accordingly. To do so, you could
specify the OnCustomRenderColumn event handler as follows:
if ($fieldName == 'sex') {
$customText = $rowData['sex'] == 1 ? 'M' : 'F';
$handled = true;
Example 2:
The code below is used in our demo project to show the number of overtime periods
played in the game.
if ($fieldName == 'overtime_count') {
if ($fieldData > 0)
$customText = $fieldData . ' OT';
else
$customText = '-';
$handled = true;
}
The screenshot demonstrates the result of this event fired on the Games webpage.
Example 3:
The code below is used in our demo project to add flag images to the "Country" column.
if ($fieldName == 'current_team_id')
{
if (!isset($fieldData))
{
$customText = 'Free agent';
$handled = true;
}
}
elseif ($fieldName == 'country_id')
{
$countriesPics = array (
1 => 'us',
2 => 'fr',
3 => 'br',
4 => 'it',
6 => 'sp',
8 => 'ar',
11 => 'li',
15 => 'ru',
18 => 'gr',
20 => 'ge'
);
$customText =
'<div style="width: 80px; text-align: left;">' .
'<img src="countries/'.$countriesPics[$rowData['country_id']].'.png">' .
' ' . $fieldData .
'</div>';
$handled = true;
}
Example 4
This example demonstrates the applying of the syntax highlighting provided by the Geshi
library. We use this library to highlight SQL syntax in strings stored in the 'Body' column.
if ($fieldName == 'Body') {
$source = $rowData['Body'];
$language = 'sql';
$formatted_sql = SqlFormatter::format($source, false);
$geshi = new GeSHi($formatted_sql, $language);
$customText = '<div align="left">'.$geshi->parse_code().'</div>';
$handled = true;
}
5.4.3.5 OnCustomRenderPrintColumn
This event occurs before column rendering on the print page and allows you to replace
cell content. It is an extremely useful for conditional rendering or embedding third-party
components to extend standard functionality.
Signature:
function OnCustomRenderPrintColumn ($fieldName, $fieldData, $rowData,
&$customText, &$handled)
Parameters:
$fieldName The field name of currently processed cell.
$fieldData The data of currently processed cell.
$rowData The associative array of values that corresponds to the currently
processed row.
$customText A string to replace the original cell content.
$handled A parameter to indicate whether the event handler executed. Set
$handled to true in the event handler to apply new content.
5.4.3.6 OnCustomRenderExportColumn
This event occurs before column rendering into Word, Excel, etc. and allows you to
replace cell content. It is an extremely useful event for conditional rendering.
Signature:
function OnCustomRenderExportColumn ($fieldName, $fieldData, $rowData,
&$customText, &$handled)
Parameters:
$fieldName The field name of currently processed cell.
$fieldData The data of currently processed cell.
$rowData The associative array of values that corresponds to the currently
processed row.
$customText A string to replace the original cell content.
$handled A parameter to indicate whether the event handler executed. Set
$handled to true in the event handler to apply new content.
5.4.3.7 OnCustomHTMLHeader
This event occurs when the head section of the page is generating. Use it to provide
additional information for the HEAD section of the page (such as keywords, author, or
description).
Signature:
function OnCustomHTMLHeader ($page, &$customHtmlHeaderText)
Parameters:
$page An instance of the Page class declared in components/
page.php
$customHtmlHeaderText A string to place into the head section
Example:
The following code demonstrates how to use this event to add metadata to the
generated webpage.
5.4.3.8 OnExtendedCustomDrawRow
This event occurs when rendering a grid row and allows you to change the row and/or
cell styles directly. It is an extremely useful event for conditional formatting such as
changing font color, font styles, row background color, cell background color, etc. The
specified styles and classes are applied to <tr> and <td> tags accordingly.
Signature:
function OnExtendedCustomDrawRow ($rowData, &$rowCellStyles, &$rowStyles,
&$rowClasses, &$cellClasses)
Parameters:
$rowData The associative array of values that corresponds to the currently
processed row.
$rowCellStyles The associative array of styles. Each field name is associated
with its style string.
$rowStyles Use this string to modify styles of a whole row.
$rowClasses Use this string to add a class to a whole row.
$cellClasses The associative array of cell classes.
This event (as well as the OnCustomDrawRow 141 one) is used for conditional formatting.
The only difference between these two events is that OnCustomDrawRow has a more
understandable parameter list while OnExtendedCustomDrawRow provides more flexible
abilities.
Example 1:
The code below is used in our online demo to display the winning team and the losing
team scores according to the current theme.
The 'win-score' and 'loss-score' classes are defined in User-defined styles as follows:
.base-score {
font-size: 1.4em;
font-weight: bold;
}
.win-score {
&:extend(.base-score);
color: @brand-danger;
}
.loss-score {
&:extend(.base-score);
}
The screenshot below demonstrates the result of the event fired on the Game list
webpage in Cyborg Bootswatch theme for Bootstrap.
The next one shows the result of the event fired on this webpage in Facebook
Bootswatch theme.
Example 2
The code below is used in our online demo to highlight fields representing player's height
depending on the value.
$height = $rowData['height'];
if ($height > 200)
$cellClass = 'tall';
elseif ($height > 185)
$cellClass = 'medium-height';
else
$cellClass = 'undersized';
$cellClasses ['height'] = $cellClass;
The 'undersized', 'medium-height', and 'tall' classes are defined in User Defined Styles as
follows:
@height-color: @state-warning-bg;
.undersized {
background-color: lighten(@height-color, 10%);
}
.medium-height {
background-color: @height-color;
}
.tall {
background-color: darken(@height-color, 10%);
}
The screenshot below demonstrates the result of the event fired on the Game list
webpage in Journal Bootswatch theme for Bootstrap.
The next one shows the result of the event fired on this webpage in Superhero
Bootswatch theme.
5.4.3.9 OnCustomRenderTotals
This event occurs before total values rendering and allows you to replace the default
total footer content. To use it, enable the grid footer in the View properties 41 of the
corresponding column.
Signature:
function OnCustomRenderTotals ($totalValue, $aggregate, $columnName,
&$customText, &$handled)
Parameters:
$totalValue The value of currently processed total.
$aggregate The string representation of total aggregate ('AVG', 'SUM', 'MIN',
'MAX', 'COUNT').
$columnName The column name of currently processed total.
$customText A string to replace the total cell content.
$handled A parameter to indicate whether the event handler executed. Set
$handled to true in the event handler to apply new content.
Example 1:
The code below changes the caption of the 'amount' column footer and gives it strong
importance.
if ($columnName == 'amount')
{
$customText = '<strong>Total: $' . $totalValue . '</strong>';
$handled = true;
}
This picture demonstrates the difference between a webpage generated with default
footer and a webpage with the OnCuStomRenderTotals event specified in this way:
Example 2:
The code below is used in our online demo on the 'Teams' page to display the year of
foundation of the oldest team on the page in more convenient form.
if ($columnName == 'year_founded') {
$customText = 'MIN: ' . intval(str_replace(',', '', $totalValue));
$handled = true;
}
5.4.3.10 OnGetCustomTemplate
This event allows you to customize almost any part of the generated application using
an own template instead of the default one.
Signature:
function OnGetCustomTemplate ($part, $mode, &$result, &$params)
Parameters:
$part The part of the page to be affected by the template.
$mode The current state of the webpage the template to be used.
$result The path to the file to be used as template according to the
components/templates/custom_templates folder.
$params An associative array of additional parameters you want to assign
to the template.
PHP Generator uses Smarty 2.0 as template language. If you are not familiar with web
template engines, you might want to start here.
application.
The simplest way to create a new template is to modify an existing one (it is much
easier than create a new template "from scratch"). Use the table below to select the
template corresponding to the necessary state of page and page part. Custom template
files should be uploaded to the 'components/templates/custom_templates' directory.
This folder should be created by the user of PHP Generator and its content is not
changing during the further PHP Generator sessions.
The following table shows how to customize common pages used in the generated
applications.
forms/form.tpl PagePart::VerticalGrid
Edit form (editors area) PageMode::EditForm
forms/form.tpl PagePart::VerticalGrid
Insert form (editors area) PageMode::InsertForm
compare/grid.tpl PagePart::Grid
Record comparison page PageMode::Compare
forms/page_form.tpl PagePart::VerticalGrid
Edit (separate page) PageMode::Edit
forms/page_form.tpl PagePart::VerticalGrid
Insert (separate page) PageMode::Insert
forms/modal_form.tpl PagePart::VerticalGrid
Edit (modal dialog) PageMode::ModalEdit
forms/modal_form.tpl PagePart::VerticalGrid
Insert (modal dialog) PageMode::ModalInsert
view/record_card_view.tpl PagePart::VerticalGrid
View (modal dialog) PageMode::ModalView
forms/inline_form.tpl PagePart::VerticalGrid
Edit (inline form) PageMode::InlineEdit
forms/inline_form.tpl PagePart::VerticalGrid
Insert (inline form) PageMode::InlineInsert
print/page.tpl PagePart::PrintLayout
webpage
PageMode::PrintAll
layout
print/grid.tpl PagePart::Grid
Print table grid PageMode::PrintAll
print/detail_page.tpl PagePart::PrintLayout
detail page PageMode::PrintDetailPage
view/print_grid.tpl PagePart::Grid
table grid PageMode::PrintOneRecord
login_page.tpl PagePart::LoginPage
Login page
login_control.tpl PagePart::LoginControl
Login control
home_page.tpl PagePart::HomePage
Home page
navigation.tpl PagePart::Navigation
Navigation
The following table shows how to customize user registration and password recovering
pages. These parameters can be used only for the project-level version of this event.
registration_page.tpl PagePart::RegistrationPage
Registration Page
registration_form.tpl PagePart::RegistrationForm
Registration Form
recovering_password_page. PagePart::
Password Recovery tpl PasswordRecovery
Page
reset_password_page.tpl PagePart::ResetPassword
Reset Password Page
resend_verification_page.tpl PagePart::
Resend Verification ResendVerification
Email Page
The following table shows how to customize emails sent to users 213 on registration and
password recovering. These parameters can be used only for the project-level version of
this event.
user_verification_subject PagePart::Mail
Verification email
.tpl PageMode::
subject
MailVerificationSubject
user_verification_body. PagePart::Mail
Verification email
tpl PageMode::MailVerificationBody
body
recovering_password_sub PagePart::Mail
Password reset email
ject.tpl PageMode::
subject
MailRecoveringPasswordSubject
recovering_password_bo PagePart::Mail
Password reset email
dy.tpl PageMode::
body
MailRecoveringPasswordBody
To instruct PHP Generator to use a customized template file for a certain webpage,
specify the following code in the page's OnGetCustomTemplate event handler (of course
you should replace YourPart and YourMode to the appropriate values from the table
above).
Example 1:
Suppose we need to use components/templates/custom_templates/staff_edit.tpl file as
a template for the edit form of a webpage.
Now we can compare the result webpages without using this event and with the enabled
one:
Example 2:
A single event handler can be used to customize multiple templates:
Example 3
This example shows how to fill a SELECT input with names of all MySQL databases
available at the server.
$queryResult = array();
$this->GetConnection()->ExecQueryToArray('SHOW DATABASES', $queryResult);
<select name="database">
{foreach from=$databaseNames item=database}
<option value="{$database}">{$database}</option>
{/foreach}
</select>
Example 4
This example shows the use of the superglobal $_GET array values in a custom template.
<div>
<h4>I am a custom template with a custom variable $custom_var. Its value
{if !isset($custom_var)}
still undefined
{else}
= {$custom_var}
{/if}.
</h4>
</div>
Example 4
Let's see the login form customization used in our NBA online demo.
if ($part == PagePart::LoginPage) {
$result = 'login_page.tpl';
}
<h2>Logins</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>admin</td>
<td>admin</td>
<td>Can modify any record at any page and manage other users.</td>
</tr>
<tr>
<td>lakers</td>
<td>lakers</td>
<td>Can modify team info, home games and players for LA Lakers.</td>
</tr>
<tr>
<td>boston</td>
<td>boston</td>
<td>The same for the Boston Celtics team.</td>
</tr>
<tr>
<td>game_manager</td>
<td>game</td>
<td>Can access only game list. Can modify any game.</td>
</tr>
</tbody>
</table>
Example 5
The example below is used in our NBA demo application to customize the template used
to export a single record to PDF.
5.4.3.11 OnCustomDrawRow
This event occurs on rendering a grid row. It is an extremely useful event for conditional
formatting such as changing font color, font styles, row background color, cell
background color, etc. This event (as well as the OnExtendedCustomDrawRow 129 one) is
used for conditional formatting. The only difference between these two events is that
OnCustomDrawRow has a more understandable parameter list while
OnExtendedCustomDrawRow provides more flexible abilities.
Signature:
function OnCustomDrawRow ($rowData, &$cellFontColor, &$cellFontSize, &$cellBgColor,
&$cellItalicAttr, &$cellBoldAttr)
Parameters:
$rowData The associative array of values that corresponds to the currently
processed row.
$cellFontColor The parameter allows to set a font color for selected fields.
$cellFontSize The parameter defines a font size of selected data.
$cellBgColor The parameter allows to set a background color of fields.
$cellItalicAttr Set the parameter to true to represent text in cursive font.
$cellBoldAttr Set the parameter to true to use bold font.
NB. $rowData array keys should contain the real column names in the data source
(table, view, or query). Don't use column captions instead!
Example 1:
Suppose we need to create a webpage with list of customers with addresses
represented in cursive. This column in the data source is named 'address_id' and the
column's caption is "Address".
$cellItalicAttr['address_id'] = true;
Example 2:
In the example below we need to display winning team score in red and losing team
score in black; moreover, both scores should be in bold and displayed by a 16pt font.
$cellFontSize['home_team_score'] = '16pt';
$cellBoldAttr['home_team_score'] = true;
$cellFontSize['away_team_score'] = '16pt';
$cellBoldAttr['away_team_score'] = true;
5.4.3.12 OnAfterInsertRecord
This event occurs when the Insert command is executed, and after the actual insertion.
Signature:
function OnAfterInsertRecord ($page, $rowData, $tableName,
&$success, &$message, &$messageDisplayTime)
Parameters:
$page An instance of the Page 257 class.
$rowData The associative array of values that corresponds to the
currently processed row.
$tableName The name of processed table.
$success Indicates whether the last data manipulation statement was
successful or not.
$message A message to be displayed to a user. If the statement
completed successfully, the value of this parameter is equal to
empty string. If the statement failed, the value of this
parameter contains the error message that came from the
database server.
$messageDisplayTi A time interval (in seconds) after which the message will
me disappear automatically. Default value is 0 (the message will
not disappear).
Success messages are displayed in green while error messages are displayed in red.
Example
if ($success) {
$message = 'Record processed successfully.';
}
else {
$message = '<p>Something wrong happened. ' .
'<a class="alert-link" href="mailto:[email protected]">' .
'Contact developers</a> for more info.</p>';
}
5.4.3.13 OnAfterUpdateRecord
This event occurs when the Update command is executed, and after the actual update.
Signature:
function OnAfterUpdateRecord ($page, $oldRowData, $rowData, $tableName,
&$success, &$message, &$messageDisplayTime)
Parameters:
$page An instance of the Page 257 class.
$oldRowData The associative array of old (previous) values of the currently
processed row.
$rowData The associative array of values that corresponds to the
currently processed row.
$tableName The name of processed table.
$success Indicates whether the last data manipulation statement was
successful or not.
$message A message to be displayed to a user. If the statement
completed successfully, the value of this parameter is equal to
empty string. If the statement failed, the value of this
parameter contains the error message that came from the
database server.
$messageDisplayTim A time interval (in seconds) after which the message will
e disappear automatically. Default value is 0 (the message will
not disappear).
Success messages are displayed in green while error messages are displayed in red.
Example
if ($success) {
$message = 'Record processed successfully.';
}
else {
$message = '<p>Something wrong happened. ' .
'<a class="alert-link" href="mailto:[email protected]">' .
'Contact developers</a> for more info.</p>';
}
5.4.3.14 OnAfterDeleteRecord
This event occurs when the Delete command is executed, and after the actual deletion.
Signature:
function OnAfterDeleteRecord ($page, $rowData, $tableName,
&$success, &$message, &$messageDisplayTime)
Parameters:
$page An instance of the Page 257 class.
$rowData The associative array of values that corresponds to the
currently processed row.
$tableName The name of processed table.
$success Indicates whether the last data manipulation statement was
successful or not.
$message A message to be displayed to a user. If the statement
completed successfully, the value of this parameter is equal to
empty string. If the statement failed, the value of this
parameter contains the error message that came from the
database server.
$messageDisplayTi A time interval (in seconds) after which the message will
me disappear automatically. Default value is 0 (the message will
not disappear).
Success messages are displayed in green while error messages are displayed in red.
Example
if ($success) {
$message = 'Record processed successfully.';
}
else {
$message = '<p>Something wrong happened. ' .
'<a class="alert-link" href="mailto:[email protected]">' .
'Contact developers</a> for more info.</p>';
}
5.4.3.15 OnBeforeInsertRecord
This event occurs when the Insert command is executed, and before the actual
insertion.
Signature:
function OnBeforeInsertRecord ($page, &$rowData, &$cancel, &$message,
&$messageDisplayTime, $tableName)
Parameters:
$page An instance of the Page 257 class declared in components/
page.php.
$rowData The associative array of values that corresponds to the
currently processed row.
$cancel The value indicating whether the operation should be
canceled.
$message The message string that is displayed after the operation is
completed (or canceled).
$messageDisplayTime A time interval (in seconds) after which the message will
disappear automatically. Default value is 0 (the message will
not disappear).
$tableName The name of processed table.
Example:
if (!(allowDataEditing())) {
$cancel = true;
$message = 'The application is running in read-only mode.';
}
5.4.3.16 OnBeforeUpdateRecord
This event occurs when the Update command is executed, and before the actual
update.
Signature:
function OnBeforeUpdateRecord ($page, $oldRowData, &$rowData, &$cancel, &$message,
&$messageDisplayTime, $tableName)
Parameters:
$page An instance of the Page 257 class declared in components/
page.php.
$oldRowData The associative array of old (previous) values of the
currently processed row.
$rowData The associative array of values that corresponds to the
currently processed row.
$cancel The value indicating whether the operation should be
canceled.
$message The message string that is displayed after the operation is
completed (or canceled).
$messageDisplayTime A time interval (in seconds) after which the message will
disappear automatically. Default value is 0 (the message will
not disappear).
$tableName The name of processed table.
Example:
if (!(allowDataEditing())) {
$cancel = true;
$message = 'The application is running in read-only mode.';
}
5.4.3.17 OnBeforeDeleteRecord
This event occurs when the Delete command is executed, and before the actual
deletion.
Signature:
function OnBeforeDeleteRecord ($page, &$rowData, &$cancel, &$message,
&$messageDisplayTime, $tableName)
Parameters:
$page An instance of the Page 257 class declared in components/
page.php.
$rowData The associative array of values that corresponds to the
currently processed row.
$cancel The value indicating whether the operation should be
canceled.
$message The message string that is displayed after the operation is
completed (or canceled).
$messageDisplayTime A time interval (in seconds) after which the message will
disappear automatically. Default value is 0 (the message will
not disappear).
$tableName The name of processed table.
Example:
if (!(allowDataEditing())) {
$cancel = true;
$message = 'The application is running in read-only mode.';
}
5.4.3.18 OnGetFieldValue
This event occurs on displaying a value of a field. It allows you to replace the actual
value of a field to your own.
Signature:
function OnGetFieldValue ($fieldName, &$value, $tableName)
Parameters:
$fieldName The name of currently processed field.
$value The actual value of the field. Can be changed to another value.
$tableName The name of currently processed table.
Example
This example shows how this event can be used for implementing a very simple
transparent encryption based on the str_rot13 PHP function.
if ($fieldName == 'private_data') {
$value = str_rot13($value);
}
Since the call of this function for an encrypted expression returns the original string, we
can define OnBeforeInsertRecord 144 and OnBeforeUpdateRecord 145 event handlers as
follows:
$rowData['private_data'] = str_rot13($rowData['private_data']);
This is just an example. We would recommend that you use more cryptographically
strong algorithms to encrypt your important data.
5.4.3.19 OnGetCustomExportOptions
This event fires on exporting data from a database to a file. It allows you to customize
some advanced export settings.
Signature:
function OnGetCustomExportOptions ($Page page, $exportType, $rowData, &$options)
Parameters:
$page An instance of the Page 257 class.
$exportType The type of the result file. Possible values are "csv", "xls", "doc",
"pdf", "xml".
$rowData An associative array of values that corresponds to the currently
processed row (for exporting a single row). NULL if a record list is
exported.
$options An associative array of options passed to the export engine (see
below).
Export to PDF
orientation Page orientation. Possible values are "P" (portrait orientation) or
"L" (landscape orientation). Default value is "P".
size Size of the page. Possible values are A0 - A10, B0 - B10, C0 -
C10, 4A0, 2A0, RA0 - RA4, SRA0 - SRA4, Letter, Legal, Executive,
Folio, Demy, Royal, A (type A paperback 111x178mm), B (type B
paperback 128x198mm). Default value is A4.
Export to Excel
engine The engine to be used on data export. Possible values are
"template" (template-based export) and "phpexcel" (to create
native .xls files). Default value is "template".
Example
This example shows how to customize the result file name according to row values. If a
record list is exported, the file name is set to list.pdf (list.xml, list.xls, etc).
5.4.3.20 OnPrepareFilterBuilder
This event allows you to setup initial condition for the Filter Builder tool.
Signature:
function OnPrepareFilterBuilder(FilterBuilder $filterBuilder,
FixedKeysArray $columns)
Parameters:
$filterBuilder An instance of the FilterBuilder class.
$columns An associative array of columns available in the tool.
Example
This example shows how to setup initial value for Filter Builder (available live in the
Feature Demo).
5.4.3.21 OnPrepareColumnFilter
Signature:
function OnPrepareColumnFilter ($columnFilter)
Parameters:
$columnFilter An instance of the ColumnFilter class.
Example 1
This example shows how to setup a column filter as a list of custom values.
$columnFilter->setOptionsFor(
'rating',
array(
"Less than 3" => FilterCondition::lessThan(3),
"4-5" => FilterCondition::between(4, 5),
"6-7" => FilterCondition::between(6, 7),
"7-8" => FilterCondition::between(7, 8),
"Higher than 8" => FilterCondition::greaterThan(8)
),
false // no default values
);
Example 2
This example shows how to group custom values.
$columnFilter->setOptionsFor(
'runtime',
array(
'Shorter than 90 min' => FilterCondition::lessThan(90),
'90 - 180 min' => FilterGroup::orX(
array(
'90-120 min' => FilterCondition::between(90, 120),
'120-150 min' => FilterCondition::between(120, 150),
'150-180 min' => FilterCondition::between(150, 180)
)
),
'Longer than 180 min' => FilterCondition::greaterThan(180)
),
false // no default values
);
Example 3
This example shows how to add custom values to default ones.
$columnFilter->setOptionsFor('release_date',
array(
'2010s' => FilterCondition::between('2010-01-01', '2019-12-31'),
'2000s' => FilterCondition::between('2000-01-01', '2009-12-31')
),
true // add default values (this parameter can be omitted)
);
5.4.3.22 OnGetCustomFormLayout
This event allows you to customize the layout for View, Edit, and Insert forms. Live
Demo. Video Tutorial.
Signature:
function OnGetCustomFormLayout($mode, FixedKeysArray $columns,
FormLayout $layout)
Parameters
$mode The form mode. Possible values are "edit", "inline_edit",
"insert", "inline_insert", and "view".
$columns The associative array of columns displayed in the form.
$layout An instance of the FormLayout class.
Layout structure
The layout has the following hierarchical structure: layout -> groups -> rows ->
columns. This means you can add groups to the layout, rows to groups, and columns to
rows.
Layout mode
By default all forms are horizontal i.e. the control label is placed on the left of the editor
(for vertical forms the label is placed on the top of the editor). To create a vertical
form, use the following call:
$layout->setMode(FormLayoutMode::VERTICAL);
Adding a group
To add a new group to the layout, use the addGroup method of the FormLayout class:
This function returns an instance of the FormLayoutGroup class that can be later used
to add rows to the new group (see below). Width is provided in relative units, possible
values are integers from 1 to 12.
function addRow();
This function has no parameters and returns an instance of the FormLayoutRow class
that can be later used to add controls to the new row (see below).
This function also returns an instance of the FormLayoutRow class to allow method
chaining. Here $column is an element of the $columns array and $inputWidth and
$labelWidth are relative widths of the editor and its label accordingly ($labelWidth can
be used only for horizontal forms).
Examples
All the examples below can be seen live in our Feature Demo.
Example 1
This example shows how to create a simple group with 2 rows and 2 controls in each
row (all controls have equal width):
$displayGroup = $layout->addGroup('Display');
$displayGroup->addRow()
->addCol($columns['display_type'], 6)
->addCol($columns['display_size'], 6);
$displayGroup->addRow()
->addCol($columns['display_resolution_x'], 6)
->addCol($columns['display_resolution_y'], 6);
Example 2
This example shows how to create a group and place 3 editors in the same row:
Example 3
This example shows how it is possible to place 2 groups in a row:
5.4.3.23 OnGetCustomColumnGroup
Signature:
function OnGetCustomColumnGroup(FixedKeysArray $columns,
ViewColumnGroup $columnGroup)
Parameters:
$columns The associative array of column headers.
$columnGroup The default (root) group. By default all column headers are
placed in this group.
Description
You can organize columns in logical groups and display them using multi-row header
representation. A column group is visually represented by a header displayed above the
headers of the columns it combines. Each group can contain data columns as well as
other groups.
Examples
All the examples below can be seen live in our Feature Demo.
Example 1
This example shows how to define an additional header for 3 columns:
Example 2
This example shows how to define nested column groups:
5.4.3.24 OnCustomCompareValues
This event allows you to define your own function for value comparison.
Signature:
Parameters:
$columnName The name of currently processed column.
$valueA The first value to compare.
$valueB The second value to compare.
$result The result of the comparison. Should be set to 0 if values are
equal and to a non-zero value otherwise.
Example
This example shows how to define an algorithm that considers two values to be equal if
their difference is less than or equal to 0.5.
5.4.3.25 OnGetCustomUploadFileName
This event allows you to customize the file name for files uploaded with Upload file to
folder 84 and Upload image to folder 85 editors.
Signature:
function OnGetCustomUploadFilename($fieldName, &$result, &$handled,
$originalFileName, $originalFileExtension, $fileSize)
Parameters:
$fieldName The name of currently processed column.
$rowData The associative array of values that corresponds to the
currently processed row.
$result The actual file name. Change the value of this parameter to
customize the filename.
$handled Indicate whether the event handler executed. Set $handled to
true in the event handler code to apply the changes.
$originalFileName The original file name
$originalFileExtension The original file extension
$fileSize The file size
Example
This example shows how to add current date and time to the uploaded filename.
5.4.3.26 OnGetCustomPagePermissions
Signature:
function OnGetCustomPagePermissions($page, &$permissions, &$handled)
Parameters:
$page An instance of the Page 257 class.
$permissions Permissions to be applied to the page. An instance of the
PermissionSet 260 class.
$handled A parameter to indicate whether the new permissions should be
applied. Set $handled to true to apply the changes.
Example
This example shows how to implement a simple role-based permission model. Our goal is
to ensure that only site admins and members of the Sales role can add, remove and edit
records displayed on this page.
5.4.3.27 OnGetCustomRecordPermissions
Signature:
Parameters:
$page An instance of the Page 257 class.
$usingCondition Any logical SQL expression. Rows for which the expression
returns true will be visible
$rowData The associative array of values that corresponds currently
processed row
$allowEdit If true, the user can edit values of the currently processed
row.
$allowDelete If true, the user can delete the currently processed row.
$mergeWithDefault Indicates whether custom permissions should be merged with
default ones 224 (if any). Default value is true.
$handled A parameter to indicate whether the new permissions should be
applied. Set $handled to true to apply the changes.
Example
Assume we have a small company with several sales departments. All users of our
application are sales managers, which work in one of these departments. Each such user
can work as an ordinary manager or as a head manager of the department. Our
challenge is to grant privileges in the following way:
- Ordinary managers must have full access to their own sales records except completed
ones. They should have no access to the sales made by other managers.
- Head managers must have full access to all sales records of the department. They
should have no access to sales of other departments.
// retrieving the ID of sales department and the status of the current user
$sql = "SELECT sales_department_id, is_head_manager " .
"FROM phpgen_users WHERE user_id = $userId";
$result = $page->GetConnection()->fetchAll($sql);
if (empty($result))
return;
$salesDepartmentId = $result[0]['sales_department_id'];
$isHeadManager = (boolean) $result[0]['is_head_manager'];
// Do not merge the new record permissions with default ones (true by default).
// We have to add this line, otherwise head managers will not be able to see
// sales made by other managers of the department.
$mergeWithDefault = false;
Example
The following example demonstrates how to use variables within the
OnBeforeInsertRecord 144 event handler.
$rowData['ip_address'] = $page->GetEnvVar('REMOTE_ADDR');
$userName = $page->GetEnvVar('CURRENT_USER_NAME');
if ($userName != 'admin')
$rowData['changed_by'] = $userName;
Within server-side page-level events it is also possible to use $this instead of $page.
5.5 Filter
To reduce the number of records available at the page, specify the Filter condition. This
condition corresponds to the WHERE clause of the query returned page data (you must
not add the WHERE keyword to beginning of the condition).
Example 1
There is a table with test questions of a Web programming course. To display only
questions of the 'Beginner' level (level_id = 2) concerning to PHP
(statement_language_id = 1), set the filter condition as follows:
Example 2
You can use subqueries in the filter expression. For example, to display the list of
channels that hosted even if a single game, specify the Filter condition as follows:
5.6 Charts
PHP Generator for MySQL allows you to visualize data on your website with feature-rich,
responsive, customizable, and interactive charts.
Live examples
You can find a number of examples in the Charts group of the Feature Demo. Some more
examples can be found at the Games, Players, and Teams page of the NBA Demo.
Key facts
To allow a chart to be sensitive to grid data, refer to the chart's parent page query
using the %source% placeholder.
Example 1
Assume we have the following table:
gbp_rate decimal(10,4),
chf_rate decimal(10,4),
cad_rate decimal(10,4),
aud_rate decimal(10,4),
/* Keys */
PRIMARY KEY (id)
);
Our goal is to create a chart that displays the USD course. As data are already grouped,
our query is very simple:
%source%
Then we should specify the exchange_rate column as domain column and all *_rate
columns as data columns.
Example 2
Suppose we have two tables department and employee defined as follows:
Our goal is to create a chart representing the total salary by departments on the
Department webpage. The following query returns the appropriate data:
SELECT
d.name as dep_name,
SUM(e.salary) AS total_salary
FROM
(%source%) d
INNER JOIN employee e ON (e.department_id = d.id)
GROUP BY
d.name
order by 2 desc
Then we should specify dep_name as the domain column and total_salary as a data
column.
Id
The unique identifier of the chart. Corresponds to the value of the id attribute of the
web element. Can contain letters, numbers, underscore, and hyphens.
Title
The chart title (to be displayed above the chart).
Type
The type for your chart. Allowed values are Column, Bar, Pie, Line, Area, and Geo.
Position
Select whether the chart is placed above or below the data grid.
Height
The height of the chart in pixels.
Width
The width of the chart in columns (from 1 to 12).
Visible
Allows to (temporarily) hide/show the chart.
Domain column
The column that specifies labels along the major axis of the chart. The Format property
is suitable for date and number columns and should be specified as a pattern (for
example, #,###,### or MMM d, yyyy).
Data columns
One or more columns to specify series data to render in the chart.
The key idea is that you can setup absolutely all the options that are available in the
Google chart library. All you need is to study the reference from Google and write a few
lines of PHP code to set property values.
The function that is invoked for each chart on the page is defined as follows:
Signature:
function OnPrepareChart(Chart $chart)
Parameters:
$chart An instance of the Chart class
getId() Returns the identifier of the chart (unique among all charts on a
page).
Example 1:
To set the value of the property propName, use the following syntax:
$chart->setOptions(array(
'propName' => 'Value',
));
To set the value of the property objectName.propName, use the following syntax:
$chart->setOptions(array(
'objectName' => array('propName' => 'value'),
));
Operating in the same way you can set any property provided by the library.
Example 2:
The following code is used in our demo application to customize the chart on the Players
page:
Example 3:
The following code is used in our demo application to customize charts on the Teams-
>Home games and Teams->Away games pages:
$options = array(
'colors' => array('#9ECC3C', '#CC3C3C'),
'titleTextStyle' => array('fontSize' => 14),
);
if ($chart->getId() === 'overall-win-loss') {
$chart->setOptions(array_merge($options, array(
'chartArea' => array('width' => '70%', 'height' => '70%', 'top' => '18%'),
'legend' => 'none',
)));
} else if ($chart->getId() === 'win-loss-by-month') {
$chart->setOptions(array_merge($options, array(
'vAxis' => array('format' => '0'),
)));
}
All properties are grouped in several tabs. By default, all property values defined at the
Abilities 167 , Export and Print 170 , and Options 172 tabs are set in accordance with the
corresponding values of project options 181 . To change this, uncheck the Use default
options box at the top of the tab and change the values.
· Common 163 tab represents page-specific properties i.e. properties that are unique
for each page.
· RSS 167 allows you to create an RSS feed based on the table.
· Abilities 167 tab allows you to specify operations (like View, Edit, Delete, etc) to be
Title
The title of the page.
Menu label
The text to be displayed in menus
View form title template, Edit form title template, Insert form title
The titles of View, Edit, and Insert forms accordingly. For View and Edit forms it is
possible to use field name tags in the title template, so you can easily change default
"Players" to a more user-friendly "Edit Tim Duncan profile".
Inline description
A text to be displayed at the top of the page. HTML tags are allowed.
Detailed description
If specified, the generated webpage is equipped with a button with a question mark on
the right side of the title bar of the page. This button opens a modal window with the
specified description. HTML tags are allowed.
Behavior
Options
File name
The name of generated .php file.If the file name extension is not specified, it will be
defined according to application output options 276 .
Default ordering
To set the default sort order of page data, use the Sort dialog opened by the ellipsis
button next to the Default ordering option. Specify the columns to sort by moving them
from the Available columns list to the Columns to sort list and specify which order for
each column you prefer.
The URL that provides the RSS feed for a page stored in the mypage.php file is as
follows:
http://www.mysite.com/mypage.php?operation=rss
Channel title
Defines the title of the channel.
Channel link
Defines the hyperlink to the channel.
Channel description
Describes the channel.
5.7.3 Abilities
This tab allows you to specify operations available for a certain page. By default values
of these options are set according to the corresponding values specified in the Project
Options 181 dialog. To change the abilities for a certain page, uncheck the Use default
options checkbox first. Click Reset to defaults to reset these options to their default
values defined at the project level.
Actions
View
Defines whether browsing a single record is available. Possible values are Disabled,
Separated Page (default value), and Modal window.
Edit
Defines whether data editing is available. ossible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Quick Edit
Defines whether the quick edit mode is available. Possible values are List and view (quick
editing is available in both data grid and single record view window), List only, View only,
and None.
Multi-edit
Defines whether mass data editing is available. Possible values are Disabled, Separated
Page (default value), and Modal window.
Insert
Defines whether data insertion is available. Possible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Copying
Defines whether data copying is available. Possible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Delete
Defines whether data deletion is available. Possible values are Enabled (default) and
Disabled.
Multi-delete
Defines whether multi deletion is available (user can delete multiple records at a time).
Possible values are Enabled (default) and Disabled.
Filtering
Quick search
Defines whether the Quick Search box is displayed. Possible values are Enabled (default)
and Disabled.
Filter Builder
Defines whether the Filter Builder tool is available. Possible values are Enabled (default)
and Disabled.
Column Filter
Defines whether the Column Filter tool is available. Possible values are Enabled (default)
and Disabled. It is also possible to enable/disable this feature at the column level.
Sorting
Sorting by click
Defines whether data can be sorted by click on a column header. Possible values are
Enabled (default) and Disabled.
Sorting by dialog
Defines whether the data sort dialog is available. Possible values are Enabled (default)
and Disabled.
Additional
Runtime Customization
Defines whether end user is able to customize such page properties as number of
records displayed on a page and a number of cards for each screen resolution. Possible
values are Enabled (default) and Disabled.
Records comparison
Defines whether the record comparison tool is available. Possible values are Enabled
(default) and Disabled.
Refresh
Defines whether the Refresh button is diaplyed. Possible values are Enabled (default)
and Disabled.
5.7.5 Options
This tab allows you to specify page options. By default values of these options are set
according to the corresponding values specified in the Project Options 181 dialog. To
change settings for a certain page, uncheck the Use default options checkbox first. Click
Reset to defaults to reset these options to their default values defined at the project
level.
Common
These options are applied for all generated pages.
Content encoding
The default option value is UTF-8 and you must have really good reasons to change it.
Page direction
Allows you to select between Left-to-right and Right-to-left page directions.
List
These options are applied for List views (both grid and card).
Page navigator
Allows you to specify the position of the navigational control(s) and the default number
of records displayed on the page. This value may be changed by application users in
runtime if the Runtime Customization option is enabled.
View mode
Select whether page data are displayed in a grid or as info cards. The end-user can
easily switch from the grid mode to the card one and vice versa using the Page Settings
dialog (if the Runtime Customization option is enabled).
Allows you to specify maximum number of cards displayed in a row for each screen
resolution. These values also can be changed by end-users if the Runtime Customization
option is enabled. Live Example.
Bordered table
Check this option to add borders on all sides of the table and cells. Live Example.
Condensed table
Turn this option 'ON' to make tables more compact by cutting cell padding in half. Live
Example.
Edit/Insert
These options are applied to data input forms.
To create a pagination by the film length, select Range partitioning at the first wizard
step, choose 'length' as partition expression and set the partitioning ranges as follows:
To get around such a situation, select Custom partitioning and define functions as
follows:
function GetPartitions($partitions)
{
$tmp = array();
$this->GetConnection()->ExecQueryToArray("
SELECT DISTINCT
left(c.last_name, 1) as first_letter
FROM customer c
ORDER BY first_letter", $tmp
);
foreach($tmp as $letter) {
$partitions[$letter['first_letter']] = $letter['first_letter'];
}
}
· Reducing the amount of traffic to and from your web server since the data
doesn't have to travel to the server before it gets checked (server-side data
validation). If an error is found in the data in the server-side validation, the error
must travel back to the user, who then corrects the problem and resubmits the
data. This back-and-forth traveling can eat up precious bandwidth.
· Saving processing time on the server by ensuring that data is clean and clear
before it gets to your database.
· Giving immediate feedback to your users since the processing is performed in their
browsers. The user doesn't have to wait for the data to travel to the server to
be checked and a response to be sent. They know immediately whether they
need to tweak the information they have entered.
PHP Generator for MySQL allows you to implement the client-side data validation on two
levels: when a user leaves a certain control and when a user submits a form.
This type of data validation means using PHP to verify that good values have been sent
to the script. Using server-side validation has pretty much the exact opposite pros and
cons of client-side development: it is more secure, works seamlessly with all browsers,
and allows to use session variables, but it does so at the cost of slightly higher server
load and slower feedback for users.
OnBeforeUpdateRecord 145
OnBeforeInsertRecord 144
6 Project Options
PHP Generator for MySQL allows you to specify default settings to be applied to each
generated webpage. By default, most of these options have the same values as the
application options 266 . To open this dialog window, follow the Setup project options to
configure default page settings link at the Page Managememt 27 wizard step
Page
This tab group allows you to define default settings for all pages of the website including
page appearance, operations to be available, exporting and printing options, and so on.
By default these settings are set in accordance with the Application options 266 .
Display formats
These tab fields allow to adjust the display data formats in the way you need. By
default these settings are set in accordance with the Application options 266 .
Events
This tab allows you to specify application-level events 95 .
6.1 Page
This tab allows you to specify default page options those can be later changed for a
certain page 172 .
Common
These options are applied for all generated pages.
Content encoding
The default option value is UTF-8 and you must have really good reasons to change it.
Page direction
Allows you to select between Left-to-right and Right-to-left page directions.
List
These options are applied for List views (both grid and card).
Page navigator
Allows you to specify the position of the navigational control(s) and the default number
of records displayed on the page. This value may be changed by application users in
runtime if the Runtime Customization option is enabled.
View mode
Select whether page data are displayed in a grid or as info cards. The end-user can
easily switch from the grid mode to the card one and vice versa using the Page Settings
dialog (if the Runtime Customization option is enabled).
Bordered table
Check this option to add borders on all sides of the table and cells. Live Example.
Condensed table
Turn this option 'ON' to make tables more compact by cutting cell padding in half. Live
Example.
Edit/Insert
These options are applied to data input forms.
6.1.1 Abilities
This tab allows you to specify default operation to be available for all pages. They can
be later changed for a certain page 167 .
Actions
View
Defines whether browsing a single record is available. Possible values are Disabled,
Separated Page (default value), and Modal window.
Edit
Defines whether data editing is available. ossible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Quick Edit
Defines whether the quick edit mode is available. Possible values are List and view (quick
editing is available in both data grid and single record view window), List only, View only,
and None.
Multi-edit
Defines whether mass data editing is available. Possible values are Disabled, Separated
Page (default value), and Modal window.
Insert
Defines whether data insertion is available. Possible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Copying
Defines whether data copying is available. Possible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Delete
Defines whether data deletion is available. Possible values are Enabled (default) and
Disabled.
Multi-delete
Defines whether multi deletion is available (user can delete multiple records at a time).
Possible values are Enabled (default) and Disabled.
Filtering
Quick search
Defines whether the Quick Search box is displayed. Possible values are Enabled (default)
and Disabled.
Filter Builder
Defines whether the Filter Builder tool is available. Possible values are Enabled (default)
and Disabled.
Column Filter
Defines whether the Column Filter tool is available. Possible values are Enabled (default)
and Disabled. It is also possible to enable/disable this feature at the column level.
Sorting
Sorting by click
Defines whether data can be sorted by click on a column header. Possible values are
Enabled (default) and Disabled.
Sorting by dialog
Defines whether the data sort dialog is available. Possible values are Enabled (default)
and Disabled.
Additional
Runtime Customization
Defines whether end user is able to customize such page properties as number of
records displayed on a page and a number of cards for each screen resolution. Possible
values are Enabled (default) and Disabled.
Records comparison
Defines whether the record comparison tool is available. Possible values are Enabled
(default) and Disabled.
Refresh
Defines whether the Refresh button is diaplyed. Possible values are Enabled (default)
and Disabled.
Menu mode
Defines the location of the application menu. Possible values are as Top-side drop-
down menu (the menu will be displayed on the top of each page), Sidebar menu (the
menu will be displayed on the left of each page), and None (no menu will be displayed
at all).
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 'On');
We would recommend you to turn this option ON in the development environment and
turn it OFF in the production environment.
Offline mode
Turn this option ON for websites running on web servers without an Internet connection.
Note that when this option is checked, you will not be able to use charts 158 and
embedded videos 53 in your application.
Events 95
Events are pieces of code that are run when an action is taken by the user. Such
events as OnBeforePageExecute 123 , OnCustomRenderColumn 125 , and OnCustomDrawRow
141 can be used to change the webpage appearance. Please find some examples of using
these and other events in our demo application and in the Resources section at the
product home page. Open the User Javascript 202 window to define functions to be called
from event handlers and other client-side code for your website.
To change default scheme settings according to your needs, click the Customize color
scheme button and modify the necessary variables within the opened window. To learn
more about the LESS syntax used in this window, please refer to the LESS manual.
The Preview window displays current appearance settings applied to a sample webpage.
Example: To add the header like one on the screen above, paste the following text in
the Header edit box:
<span class="navbar-brand">
<span>
<img src="mysql_logo.png" style="height: 44px; margin-top: -14px;">
</span>
</span>
<span class="navbar-brand">
<span class="hidden-xs"><strong>MySQL Schema Browser</strong></span>
</span>
To determine a selector to apply the styles for, use any available inspect HTML tools
such as default Firefox developer tools, Firebug, Chrome developer tools, Internet
Explorer developer tools, and so on. Among other things these tools allows you to view
the current element's attributes and applied styles and experiment with new ones.
Example 1
The code below is used in our online demo to display the winning team and the losing
team scores according to the current theme. The 'win-score' and 'loss-score' classes are
defined as follows:
.base-score {
font-size: 1.4em;
font-weight: bold;
}
.win-score {
&:extend(.base-score);
color: @brand-danger;
}
.loss-score {
&:extend(.base-score);
}
The screenshot below displays the Game list page in the Cyborg theme:
The next one shows the same page in the Facebook theme:
Example 2
To limit maximum width of Date and DateTime pickers in all Edit and Insert forms by
300 pixels, use the following rule:
div.pgui-date-time-edit {
max-width: 300px;
}
Example
Suppose we want to fill the content of 'title' control depending of the value selected as
'sex' on Insert and Edit forms. Of course we can define the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 with the
same code, but it's easier to define a function in the User Javascript window and call it
in these event handlers.
User Javascript:
if (sender.getFieldName() == 'sex')
{
fillRelatedTitles(sender, editors);
}
To change the webpage appearance with custom templates, follow these steps:
· Create a new template. Custom templates must be stored under the components/
templates/custom_templates folder which contents is not changing on re-generation
of the scripts. You must create this folder manually.
· Instruct PHP Generator to use this template for the selected webpage with the
OnGetCustomTemplate event.
· Customize the template according to your needs and preferences.
8 Security settings
Check the Enable security option to supply the generated application with a login page
to request user name and password when someone attempts to access your website.
PHP Generator for MySQL provides you with the following authorization types:
To create the administrator user, fill in the Administrator login and Administrator
password fields. Check the Enable guest access option to allow an anonymous user to
access the generated app without completing the authentication procedure. Turn ON
the Enable MD5 password encryption checkbox to store user passwords encrypted with
the MD5 algorithm (recommended).
To manage additional users, click the Edit additional users button, then use Add/Edit/
Remove buttons or the user grid's popup menu.
When creating/editing a user, provide its user name and password and check the
necessary options to grant application-level permissions to this user. To learn how to
specify page-level permissions, see the User permissions 220 section.
Table structure
The basic table structure is as follows. Some additional columns should be added for
support email-based features 213 .
To be able to log in to your website, you should create the first user (i.e. the first
record in this table) with the Admin privilege manually (for example, you can do it with
our MySQL Maestro). Don't forget that the password should be encrypted with the
algorithm you selected. Other users can be created online via the Administration Panel
that is generated automatically.
Customizing permissions
By default all users have the SELECT privilege granted at the application level via the
PUBLIC group. Open the Permission Manager 220 window to setup permission storage and/
or customize the permissions.
This function accepts an unencrypted password in the $password parameter and returns
the encrypted password in the $result parameter that is passed by reference.
This function accepts an unencrypted password entered by the user and an encrypted
password stored in the database. The $result parameter must be set to true if the
entered password has been verified successfully and to false otherwise. By default this
function encrypts the entered password with the OnEncryptPassword function call (see
above) and compares the result with the encrypted password, so you should define the
OnVerifyPassword function explicitly only if the default behavior is not suitable for your
needs.
Example
The example below shows how it is possible to use the PHP Native password hashing API
for encrypting and verifying the password.
Enable self-registration
If this option is turned ON, users can register in the generated application.
Events
A number of events help you to control user registration and password recovering
processes in the most flexible way possible. The following events are currently available:
· OnBeforeUserRegistration 214
· OnAfterUserRegistration 214
· OnPasswordResetRequest 215
· OnPasswordResetComplete 215
Signature:
function OnBeforeUserRegistration($username, $email, $password,
&$allowRegistration, &$errorMessage)
Parameters:
$username The name of the user.
$email The email of the user.
$password The password of the user.
$allowRegistration A parameter to indicate whether user registration is allowed. Set
$allowRegistration to false to reject the new user. Default value
is true.
$errorMessage A message to be displayed if $allowRegistration == false.
Example
The code snippet below demonstrates how to deny registrations for users with a
mailinator.com email address.
Signature:
function OnAfterUserRegistration ($userName, $email)
Parameters:
$userName The name of the user.
$email The email of the user.
Example
The code snippet below sends an email 261 to the site administrator when a new user is
registered.
Signature:
function OnPasswordResetRequest ($userName, $email)
Parameters:
$userName The name of the user.
$email The email of the user.
Example
The code snippet below shows how to add a record to a log table when a user
requested to reset his password.
$sqlTemplate =
"INSERT INTO user_log (username, action_type, action_time) " .
"VALUES ('%s', '%s', '%s')";
$connection->Connect();
$connection->ExecSQL($sql);
Signature:
function OnPasswordResetComplete ($userName, $email)
Parameters:
$userName The name of the user.
$email The email of the user.
Example
The code snippet below shows how to add a record to a log table when a user resets his
password.
$sqlTemplate =
"INSERT INTO user_log (username, action_type, action_time) " .
"VALUES ('%s', '%s', '%s')";
$connection->Connect();
$connection->ExecSQL($sql);
User permissions should also be managed with the server facilities (GRANT and REVOKE
statements). You can align user interface to real permissions granted at the server side
with the OnGetCustomPagePermissions 153 event.
Example:
To check that the password is equal to the user name and password contains 5 or more
symbols, place the following code to the body of the CheckUserIdentity function. This
condition means that the 'John/John' or 'John/Michael' pair will be declined while the
'Michael/Michael' or 'Gloria/Gloria' login/password combination will be accepted.
if ($username == $password)
$result = strlen($password) >= 5;
else
$result = false;
2. Permissions granted at the application level are automatically applied to all pages in
the application.
3. Page-level permissions are granted for each page individually. Effective user
permissions for a page are calculated as sum of permissions granted to the user at the
application and page levels i.e. permissions are cumulative.
5. You can enable the guest account in your application to allow any unauthorized user
access to your website. The privileges can be granted to guest just like any user in
the application. Note that PUBLIC privileges do not affect the guest privileges and vice
versa.
6. The following permissions can be granted: Select, Insert, Update, Delete, and Admin.
If a user has the Admin permission for a page, he/she can read, change, and delete all
the records of the page as well as add the new records and manage the page access
permissions via Admin Panel (if the table-based authorization 209 is used and
permissions are stored in a database table).
7. Exporting, Printing, and Comparison operations are available for everyone who has the
Select privilege.
8. The Copy operation is available for everyone who has the Insert privilege.
Hard-coded authorization
On using this kind of authorization, all users and their permissions are stored in
generated .php files, so it is necessary to re-generate the application to modify this
data. Use the checkboxes at the Permissions tab to grant/revoke the corresponding
application-level permissions to users specified at the Hard-coded authorization window
207 . To grant or revoke page-level permissions, use the Customize page level
permission... button.
Table-based authorization
On using this kind of authorization, user accounts are always stored in a database table
while permissions can be stored either in the generated files (as on using the hard-coded
authorization) or in a database table like user accounts (recommended). To choose
between these options, switch to the Storage tab and click the appropriate radio
button.
To store permissions in the database, you can use an existing table or create a new
one. On using this storage option, you can manage users and their permissions (both
application and page levels) without necessity of re-building your site via PHP Generator
for MySQL GUI as well as via the web-based Administration Panel.
To enable record-level security for a page, define a column that identifies the record
owner selecting the appropriate value from the drop down list in the Owner field name
column. Now all users are divided into two groups: the record owners, and the others.
Then grant privileges for each of these groups separately. Note the application and page
admins bypass record-level security, so they can access (and change) all the records.
Click the Set options for all button to specify owner field name and/or permissions for
all pages at once. Use the Reset settings button to clear all the settings made in this
window.
Live examples of using this feature can be found in the Security Demo.
You can customize record-level security for a certain page with the
OnGetCustomRecordPermissions 153 event.
Inactivity timeout is supported for all kinds of authorization. When the timeout is
reached, the OnBeforeLogout 97 event fires.
9 Interface language
By default a web application created with PHP Generator for MySQL has English interface
but it can be localized (i.e. translated) to any language. The text strings to be used in
the application's interface are stored in a localization file. To use a specific language,
select the corresponding file on the last wizard step. In case you use the same file on a
regular basis, it is recommended to specify it in the application output options 276 to
enable it by default.
lang.br.php Brazilian
lang.cs.php Czech
lang.de.php German
lang.dk.php Danish
lang.en.php English
lang.es.php Spanish
lang.fr.php French
lang.hu.php Hungarian
lang.it.php Italian
lang.nl.php Dutch
lang.pl.php Polish
lang.ru.php Russian
lang.se.php Swedish
lang.sk.php Slovak
lang.sl.php Slovenian
lang.sr.php Serbian
lang.tr.php Turkish
These files were sent to us by our customers and we are not responsible for their
quality. If none of these files is right for you, it is possible to customize the localization
as described below. We will be very appreciated if you send us your custom file to be
enjoyed by all the PHP Generator for MySQL users.
localization yourself. For this purpose get a localization file the clearest for you, enter/
correct necessary captions with any text editor, and save it in the UTF-8 encoding
(this is very important for the correct displaying of captions in a web browser).
Example
Suppose we need to create a web application in Esperanto. First we need to define the
localization file that is the clearest for us. In our case it is lang.en.php. Let's open the
file with a text editor (we prefer Notepad++), translate all captions to Esperanto, select
the UTF-8 encoding and save it as lang.eo.php (eo is the two-char language code for
Esperanto). All we need to do is select this file at the last wizard step and generate the
application. The result is shown below.
Access driver
There are several PHP drivers to communicate with database servers and PHP Generator
for MySQL allows you to select a driver to be used by the generated web application.
Note that the corresponding set of PHP functions should be available on your web
server. By default the driver is set in accordance with the application output options 276 .
Output directory
Generated files will be created in the output directory stored on your computer. To see
the result of the process, open any prepared .php file with any browser. Note, that to
run PHP code you need to have PHP and Apache installed or to run any portable web
server. To deploy ready web application to the Internet, copy the created directory to
your hosting 21 .
Generation options
To make the repeated generating process more fast, it's recommended to avoid
repeated copying of non-changeable system files stored in components,
database_engine, images, libs folders. These files must be rewritten only in case they
were generated by the former version of PHP Generator for MySQL.
11 Developer Reference
The following features and technologies allow you to develop applications with PHP
Generator for MySQL.
PHP Generator for MySQL provides you with a number of operations executed on the
client side. These functions may be used in client side events 113 . Find out the
description of available operations appropriate to each editor type:
· Combobox 243
· getValue 231
· setValue 233
· getEnabled 235
· setEnabled 235
· getReadonly 237
· setReadonly 237
· getVisible 237
· setVisible 238
· getRequired 238
· setRequired 238
· getState 238
· setState 239
· setHint 239
· getFieldName 239
11.1.1.1 getValue
Returns a value of a certain control (input, textarea, select, radio button, etc). To set a
control value, use the appropriate function 233 .
Signature:
function getValue()
The examples below show how this method can be used in the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 event
handlers.
Example 1:
The code below allows you to select a college only for players from U.S. (see this in
action). See how it looks on the webpage at the screen below.
console.log(sender);
if (sender.getFieldName() == 'country_id')
{
console.log(sender.getValue());
editors['college_id'].enabled(sender.getValue() == 1);
if (sender.getValue() != 1) {
editors['college_id'].setValue(null);
$('#college_id_edit').next().show();
}
else
$('#college_id_edit').next().hide();
Example 2:
Another example from the insert and edit forms of the Players page (see this in action).
This piece of code allows you to select player number only if a player's team is already
selected (in other words, players who do not belong to a team cannot have numbers).
if (sender.getFieldName() == 'current_team_id')
{
if (sender.getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
$('#current_number_edit').next().show();
}
else
{
editors['current_number'].enabled(true);
$('#current_number_edit').next().hide();
}
}
11.1.1.2 setValue
Sets the value of a certain control. To get a control value, use the appropriate function
231 .
Signature:
function setValue(value);
The examples below show how this method can be used in the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 event
handlers.
Example 1:
The code below allows you to select a college only for players from U.S. (see this in
action). See how it looks on the webpage at the screen below.
console.log(sender);
if (sender.getFieldName() == 'country_id')
{
console.log(sender.getValue());
editors['college_id'].enabled(sender.getValue() == 1);
if (sender.getValue() != 1) {
editors['college_id'].setValue(null);
$('#college_id_edit').next().show();
}
else
$('#college_id_edit').next().hide();
Example 2:
Another example from the insert and edit forms of the Players page (see this in action).
This piece of code allows you to select player number only if a player's team is already
selected (in other words, players who do not belong to a team cannot have numbers).
if (sender.getFieldName() == 'current_team_id')
{
if (sender.getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
$('#current_number_edit').next().show();
}
else
{
editors['current_number'].enabled(true);
$('#current_number_edit').next().hide();
}
}
11.1.1.3 getEnabled
Signature:
function getEnabled();
Example:
var editorState = editors['current_number'].getEnabled();
11.1.1.4 setEnabled
Sets a value specifying whether the control is enabled. True to enable the control; false
to disable it. Disabled input elements in a form will not be submitted.
Signature:
function setEnabled([true|false])
The examples below show how this method can be used in the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 event
handlers.
Example 1:
The code below allows you to select a college only for players from U.S. (see this in
action). See how it looks on the webpage at the screen below.
console.log(sender);
if (sender.getFieldName() == 'country_id')
{
console.log(sender.getValue());
editors['college_id'].enabled(sender.getValue() == 1);
if (sender.getValue() != 1) {
editors['college_id'].setValue(null);
$('#college_id_edit').next().show();
}
else
$('#college_id_edit').next().hide();
Example 2:
Another example from the insert and edit forms of the Players page (see this in action).
This piece of code allows you to select player number only if a player's team is already
selected (in other words, players who do not belong to a team cannot have numbers).
if (sender.getFieldName() == 'current_team_id')
{
if (sender.getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
$('#current_number_edit').next().show();
}
else
{
editors['current_number'].enabled(true);
$('#current_number_edit').next().hide();
}
}
11.1.1.5 getReadonly
Signature:
function getReadonly()
Example:
var editorState = editors['team'].getReadonly();
11.1.1.6 setReadonly
Sets a value specifying whether the control is readonly. A read-only input field cannot
be modified (however, a user can tab to it, highlight it, and copy the text from it). Form
elements with the readonly attribute set will get passed to the form processor.
Signature:
function setReadonly([true|false])
Example:
editors['team'].setReadonly(true);
11.1.1.7 getVisible
Signature:
function getVisible()
Example:
var editorState = editors['team'].getVisible();
11.1.1.8 setVisible
Sets a value specifying whether the control is visible. An invisible element stays in its
original position and size.
Signature:
function setVisible([true|false])
Example:
editors['team'].setVisible(true);
11.1.1.9 getRequired
Signature:
function getRequired()
Example:
var editorState = editors['team'].getRequired();
11.1.1.10 setRequired
Signature:
function setRequired([true|false])
Example:
11.1.1.11 getState
Signature:
function getRequired()
Returning value:
One of the following strings: 'normal', 'warning', 'error', or 'success'.
Example:
var editorState = editors['team'].getState();
11.1.1.12 setState
Signature:
function setState(['normal'|'warning'|'error'|'success'])
Example:
11.1.1.13 setHint
Signature:
function setHint(['Hint text'|null])
Example:
editors['field_name'].setHint('Hint text');
To clear a hint:
editors['field_name'].setHint(null);
11.1.1.14 getFieldName
Returns the name of the field in the database the editor corresponds to.
Signature:
function getFieldName()
The examples below show how this method can be used in the
OnInsertFormEditorValueChanged 116 and OnEditFormEditorValueChanged 118 event
handlers.
Example 1:
The code below allows you to select a college only for players from U.S. (see this in
action). See how it looks on the webpage at the screen below.
console.log(sender);
if (sender.getFieldName() == 'country_id')
{
console.log(sender.getValue());
editors['college_id'].enabled(sender.getValue() == 1);
if (sender.getValue() != 1) {
editors['college_id'].setValue(null);
$('#college_id_edit').next().show();
}
else
$('#college_id_edit').next().hide();
Example 2:
Another example from the insert and edit forms of the Players page (see this in action).
This piece of code allows you to select player number only if a player's team is already
selected (in other words, players who do not belong to a team cannot have numbers).
if (sender.getFieldName() == 'current_team_id')
{
if (sender.getValue() == '')
{
editors['current_number'].setValue('');
editors['current_number'].enabled(false);
$('#current_number_edit').next().show();
}
else
{
editors['current_number'].enabled(true);
$('#current_number_edit').next().hide();
}
}
· getPlaceholder 241
· setPlaceholder 241
11.1.2.1 getPlaceholder
Signature:
function getPlaceholder()
Example:
var placeholder = editors['user_name'].getPlaceholder();
11.1.2.2 setPlaceholder
Specifies a short hint that describes the expected value of an input field (e.g. a sample
value or a short description of the expected format). The short hint is displayed in the
input field before the user enters a value.
Signature:
function setPlaceholder(value)
Example:
To add a placeholder to an Insert form depending of the entered first name, place the
following strings to the OnInsertFormValueChanged.
if (editors['first_name'].getValue() == 'John')
{
editors['last_name'].setPlaceholder('Hi, John! Enter here your surname :).');
}
· getPlaceholder 242
· setPlaceholder 242
11.1.3.1 getPlaceholder
Signature:
function getPlaceholder()
Example:
var placeholder = editors['user_name'].getPlaceholder();
11.1.3.2 setPlaceholder
Specifies a short hint that describes the expected value of an input field (e.g. a sample
value or a short description of the expected format). The short hint is displayed in the
input field before the user enters a value.
Signature:
function setPlaceholder(value)
Example:
To add a placeholder to an Insert form depending of the entered first name, place the
following strings to the OnInsertFormValueChanged.
if (editors['first_name'].getValue() == 'John')
{
editors['last_name'].setPlaceholder('Hi, John! Enter here your surname :).');
}
11.1.4 Combobox
The following operations may be used to manipulate comboboxes on a form:
· addItem 243
· removeItem 245
· getItemCount 247
· getCaption 247
· clear 247
11.1.4.1 addItem
Signature:
function addItem(value, caption);
Example:
This example shows how we can manipulate combobox and radio group items depending
on the 'sex' value. Place the code in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 event handlers to change the 'Title' content
depending of the selected 'Sex' value.
11.1.4.2 removeItem
Signature:
function removeItem(value)
Example:
This example shows how we can manipulate combobox and radio group items depending
on the 'sex' value. Place the code in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 event handlers to change the 'Title' content
depending of the selected 'Sex' value.
11.1.4.3 getItemCount
Signature:
function getItemCount()
Example:
The following code populates the item_count variable with the number of combobox
elements.
11.1.4.4 getCaption
Signature:
function getCaption()
Let's see the difference between getValue() and getCaption() functions. Assume we we
have a Combobox editor with the following properties:
See also: addItem 243 , removeItem 245 , getItemCount 247 , clear 247
11.1.4.5 clear
Signature:
function clear()
Example:
The following code empties the 'title' control.
editors['title'].clear();
· addItem 248
· removeItem 249
· getItemCount 251
· getCaption 251
· clear 251
11.1.5.1 addItem
Signature:
function addItem(value, caption);
Example:
This example shows how we can manipulate combobox and radio group items depending
on the 'sex' value. Place the code in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 event handlers to change the 'Title' content
depending of the selected 'Sex' value.
11.1.5.2 removeItem
Signature:
function removeItem(value)
Example:
This example shows how we can manipulate combobox and radio group items depending
on the 'sex' value. Place the code in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 event handlers to change the 'Title' content
depending of the selected 'Sex' value.
11.1.5.3 getItemCount
Signature:
function getItemCount()
Example:
The following code populates the item_count variable with the number of combobox
elements.
11.1.5.4 getCaption
Signature:
function getCaption()
Let's see the difference between getValue() and getCaption() functions. Assume we we
have a Radio group editor with the following properties:
See also: addItem 248 , removeItem 249 , getItemCount 251 , clear 251
11.1.5.5 clear
Signature:
function clear()
Example:
The following code empties the 'title' control.
editors['title'].clear();
· addItem 252
· removeItem 253
· getItemCount 254
· clear 255
11.1.6.1 addItem
Signature:
function addItem(value, caption);
Example:
The code below placed in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 changes the content of the 'Clothes' checkbox group
depending of the selected season.
if (sender.getFieldName() == 'season')
{
var $item_count = editors['clothes'].getItemCount();
if ($item_count == 6)
{
if (sender.getValue() == 'Winter')
{
editors['clothes'].removeItem('Shorts');
editors['clothes'].removeItem('Sandals');
editors['clothes'].removeItem('Swimsuit');
}
else
{
editors['clothes'].removeItem('Coat');
editors['clothes'].removeItem('Boots');
editors['clothes'].removeItem('Cap');
}
}
else
{
editors['clothes'].clear();
if (sender.getValue() == 'Winter')
{
editors['clothes'].addItem('Coat','Coat');
editors['clothes'].addItem('Boots','Boots');
editors['clothes'].addItem('Cap','Cap');
}
else
{
editors['clothes'].addItem('Shorts','Shorts');
editors['clothes'].addItem('Sandals','Sandals');
editors['clothes'].addItem('Swimsuit','Swimsuit');
}
}
}
11.1.6.2 removeItem
Signature:
function removeItem(value)
Example:
The code below placed in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 changes the content of the 'Clothes' checkbox group
depending of the selected season.
if (sender.getFieldName() == 'season')
{
var $item_count = editors['clothes'].getItemCount();
if ($item_count == 6)
{
if (sender.getValue() == 'Winter')
{
editors['clothes'].removeItem('Shorts');
editors['clothes'].removeItem('Sandals');
editors['clothes'].removeItem('Swimsuit');
}
else
{
editors['clothes'].removeItem('Coat');
editors['clothes'].removeItem('Boots');
editors['clothes'].removeItem('Cap');
}
}
else
{
editors['clothes'].clear();
if (sender.getValue() == 'Winter')
{
editors['clothes'].addItem('Coat','Coat');
editors['clothes'].addItem('Boots','Boots');
editors['clothes'].addItem('Cap','Cap');
}
else
{
editors['clothes'].addItem('Shorts','Shorts');
editors['clothes'].addItem('Sandals','Sandals');
editors['clothes'].addItem('Swimsuit','Swimsuit');
}
}
}
11.1.6.3 getItemCount
Signature:
function getItemCount()
Example:
The code below placed in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 changes the content of the 'Clothes' checkbox group
depending of the selected season.
if (sender.getFieldName() == 'season')
{
var $item_count = editors['clothes'].getItemCount();
if ($item_count == 6)
{
if (sender.getValue() == 'Winter')
{
editors['clothes'].removeItem('Shorts');
editors['clothes'].removeItem('Sandals');
editors['clothes'].removeItem('Swimsuit');
}
else
{
editors['clothes'].removeItem('Coat');
editors['clothes'].removeItem('Boots');
editors['clothes'].removeItem('Cap');
}
}
else
{
editors['clothes'].clear();
if (sender.getValue() == 'Winter')
{
editors['clothes'].addItem('Coat','Coat');
editors['clothes'].addItem('Boots','Boots');
editors['clothes'].addItem('Cap','Cap');
}
else
{
editors['clothes'].addItem('Shorts','Shorts');
editors['clothes'].addItem('Sandals','Sandals');
editors['clothes'].addItem('Swimsuit','Swimsuit');
}
}
}
11.1.6.4 clear
Signature:
function clear()
Example:
The code below placed in the OnInsertFormEditorValueChanged 116 and
OnEditFormEditorValueChanged 118 changes the content of the 'Clothes' checkbox group
depending of the selected season.
if (sender.getFieldName() == 'season')
{
var $item_count = editors['clothes'].getItemCount();
if ($item_count == 6)
{
if (sender.getValue() == 'Winter')
{
editors['clothes'].removeItem('Shorts');
editors['clothes'].removeItem('Sandals');
editors['clothes'].removeItem('Swimsuit');
}
else
{
editors['clothes'].removeItem('Coat');
editors['clothes'].removeItem('Boots');
editors['clothes'].removeItem('Cap');
}
}
else
{
editors['clothes'].clear();
if (sender.getValue() == 'Winter')
{
editors['clothes'].addItem('Coat','Coat');
editors['clothes'].addItem('Boots','Boots');
editors['clothes'].addItem('Cap','Cap');
}
else
{
editors['clothes'].addItem('Shorts','Shorts');
editors['clothes'].addItem('Sandals','Sandals');
editors['clothes'].addItem('Swimsuit','Swimsuit');
}
}
}
· Page 257
· Application 258
· EngConnection 259
· GetEnvVar 257
· GetConnection 257
11.2.1.1 GetEnvVar
Signature:
function GetEnvVar($name)
Example:
The following example demonstrates how to use variables within the
OnBeforeInsertRecord 144 event handler.
$rowData['ip_address'] = $this->GetEnvVar('REMOTE_ADDR');
$userName = $this->GetEnvVar('CURRENT_USER_NAME');
if ($userName != 'admin')
$rowData['changed_by'] = $userName;
11.2.1.2 GetConnection
Returns the connection object (an instance of the EngConnection 259 class).
Signature:
function GetConnection()
Example:
To get the list of available databases, use the following code:
$queryResult = array();
$this->GetConnection()->ExecQueryToArray('SHOW DATABASES', $queryResult);
· IsGETValueSet 258
· GetGETValue 258
· IsPOSTValueSet 259
· GetPOSTValue 259
· IsLoggedInAsAdmin 259
11.2.2.1 IsGETValueSet
Signature:
function IsGETValueSet($paramName)
Example:
The code below checks if a $_GET parameter does exist and, if so, assigns its value to a
variable.
11.2.2.2 GetGETValue
Returns the value of a parameter named paramName from the superglobal $_GET array.
Signature:
function GetGETValue($name)
Example:
The code below checks if a $_GET parameter does exist and, if so, assigns its value to a
variable.
11.2.2.3 IsPOSTValueSet
Signature:
function IsPOSTValueSet($paramName)
The code below checks if a $_POST parameter does exist and, if so, assigns its value to
a variable.
11.2.2.4 GetPOSTValue
Returns the value of a parameter named paramName from the superglobal $_POST array.
Signature:
function GetPOSTValue($name)
The code below checks if a $_POST parameter does exist and, if so, assigns its value to
a variable.
11.2.2.5 IsLoggedInAsAdmin
Checks whether currently logged in user has admin permissions at the application level.
Signature:
function IsLoggedInAsAdmin()
Example
if (!GetApplication()->IsLoggedInAsAdmin()) {
// perform some actions for ordinal users
}
· ExecScalarSQL 260
· ExecSQL 260
· ExecQueryToArray 260
11.2.3.1 ExecScalarSQL
Signature:
function ExecScalarSQL($sql)
Example:
$one = $this->GetConnection()->ExecScalarSQL('SELECT 1');
11.2.3.2 ExecSQL
Signature:
function ExecSQL($sql)
Example:
$this->GetConnection()->ExecSQL('INSERT INTO ...');
11.2.3.3 ExecQueryToArray
Signature:
function ExecQueryToArray($sql, &$array)
Example:
$values = array();
$this->GetConnection()->ExecQueryToArray(
'SELECT 1 as a UNION SELECT 2 as a',
$values
);
Querying permissions
The following methods can be used to query the current state of a class instance. All
functions return Boolean.
Signature Description
hasViewGrant() Returns whether the current user can view records.
hasAddGrant() Returns whether the current user can add records.
hasEditGrant() Returns whether the current user can edit records.
hasDeleteGrant() Returns whether the current user can delete records.
hasAdminGrant() Returns whether the current user has admin privileges for
the current page.
Changing permissions
The following methods can be used to change the current state of a class instance. All
parameters are Boolean.
Signature Description
setViewGrant($value) Allows the current user to view records.
setAddGrant($value) Allows the current user to add records.
setEditGrant($value) Allows the current user to edit records.
setDeleteGrant($value) Allows the current user to delete records.
setAdminGrant($value) Grants the current user admin privileges
for the current page.
setGrants($view, $add, $edit, $delete) Sets all page permissions at once.
· GetApplication 261
11.2.5.1 GetApplication
Returns an instance of the Application 258 class. Actually it is implemented via the
Singleton pattern, so the same instance always will be returned.
Signature:
function GetApplication()
Example:
To check if the parameter custom_var is available, use the following code:
if (GetApplication()->IsGETValueSet('custom_var'))
// found
$params['custom_var'] = GetApplication()->GetGETValue('custom_var');
else
// not found. Assign a default value.
$params['custom_var'] = '5 (default)';
11.2.5.2 sendMailMessage
Sends an email message to specified recipients using project-level outgoing mail settings
192 .
Signature:
function sendMailMessage($recipients, $messageSubject, $messageBody,
$attachments = '', $cc = '', $bcc = '')
Parameters:
Name Data type Description Mandat
ory
$recipients string or A recipient or a list of recipients for the yes
array email message
$messageSubj string A subject of the email message yes
ect
$messageBod string A body of the email message. HTML is yes
y allowed.
$attachments string or An attachment or a list of attachments for no
array the email message
$cc string or A recipient or a list of recipients specified in no
array the CC field
$bcc string or A recipient or a list of recipients specified in no
array the BCC field
Example 1
This example demonstrates the simplest use of the function.
Example 2
This example demonstrates an advanced use of the function.
$messageSubject = 'Welcome!!!';
$messageBody = file_get_contents("external_data/mail_message_body.html");
$attachments =
array(
'external_data/files/example.pdf',
'external_data/images/example.png'
);
$cc = array('[email protected]', '[email protected]');
$bcc =
array(
'[email protected]' => 'Dougie Jones',
'[email protected]' => 'Bob Cooper',
'[email protected]' => 'Laura Horne'
);
11.2.5.3 createConnection
Signature:
function createConnection()
Example
The code snippet below shows how to add a record to a log table when a user resets his
password 215 .
$connection = createConnection();
$sqlTemplate =
"INSERT INTO user_log (username, action_type, action_time) " .
"VALUES ('%s', '%s', '%s')";
$connection->Connect();
$connection->ExecSQL 260 ($sql);
All .less files are stored in the components/assets/less folder of the output directory.
The main.less file references (directly or indirectly) all styles defined in other files and
subdirectories of this folder as well as user-defined styles, which are stored in
components/assets/less/user.less. Current color theme is defined in components/assets/
less/theme.less. When you click "Generate" in PHP Generator for MySQL, the software
automatically compiles main.less and saves the results to components/assets/css/main.
css.
dotless.compiler.exe -r -m full/path/to/main.less
12 Options
PHP Generator for MySQL allows you to customize the way it works within the Options
dialog. To open the dialog, use the More button and select Options at the drop-down
list.
The window allows you to customize the options grouped by the following sections:
· Application 266
General PHP Generator for MySQL options: generation rules, default page options,
and display data formats.
· Appearance 287
Customizing program interface - bars, trees, menus, etc.
It is a good idea to check through these settings before you start working with PHP
Generator for MySQL. You may be surprised at all the things you can adjust and
configure!
12.1 Application
The Application section allows you to customize common rules of PHP Generator for
MySQL behavior. The section consists of several tab; follow the links to find out more
about each of them.
· Page 266
· Output 276
12.1.1 Page
This tab allows you to specify default page options to be applied to all the generated
pages in all applications. These settings can be overwritten for a project as well as for a
certain page.
Common
These options are applied for all generated pages.
Content encoding
The default option value is UTF-8 and you must have really good reasons to change it.
Page direction
Allows you to select between Left-to-right and Right-to-left page directions.
List
These options are applied for List views (both grid and card).
Page navigator
Allows you to specify the position of the navigational control(s) and the default number
of records displayed on the page. This value may be changed by application users in
runtime if the Runtime Customization 272 option is enabled.
View mode
Select whether page data are displayed in a grid or as info cards. The end-user can
easily switch from the grid mode to the card one and vice versa using the Page Settings
dialog (if the Runtime Customization 272 option is enabled).
Bordered table
Check this option to add borders on all sides of the table and cells. Live Example.
Condensed table
Turn this option 'ON' to make tables more compact by cutting cell padding in half. Live
Example.
Edit/Insert
These options are applied to data input forms.
This tab allows you to specify default exporting and printing options to be available for all
the generated pages in all applications. These settings can be overwritten for a project as
well as for a certain page.
12.1.1.2 Abilities
This tab allows you to specify default operations to be available for all the generated
pages in all applications. These settings can be overwritten for a project as well as for a
certain page.
Actions
View
Defines whether browsing a single record is available. Possible values are Disabled,
Separated Page (default value), and Modal window.
Edit
Defines whether data editing is available. ossible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Quick Edit
Defines whether the quick edit mode is available. Possible values are List and view (quick
editing is available in both data grid and single record view window), List only, View only,
and None.
Multi-edit
Defines whether mass data editing is available. Possible values are Disabled, Separated
Page (default value), and Modal window.
Insert
Defines whether data insertion is available. Possible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Copying
Defines whether data copying is available. Possible values are Disabled, Separated Page
(default value), Inline mode, and Modal window.
Delete
Defines whether data deletion is available. Possible values are Enabled (default) and
Disabled.
Multi-delete
Defines whether multi deletion is available (user can delete multiple records at a time).
Possible values are Enabled (default) and Disabled.
Filtering
Quick search
Defines whether the Quick Search box is displayed. Possible values are Enabled (default)
and Disabled.
Filter Builder
Defines whether the Filter Builder tool is available. Possible values are Enabled (default)
and Disabled.
Column Filter
Defines whether the Column Filter tool is available. Possible values are Enabled (default)
and Disabled. It is also possible to enable/disable this feature at the column level.
Sorting
Sorting by click
Defines whether data can be sorted by click on a column header. Possible values are
Enabled (default) and Disabled.
Sorting by dialog
Defines whether the data sort dialog is available. Possible values are Enabled (default)
and Disabled.
Additional
Runtime Customization
Defines whether end user is able to customize such page properties as number of
records displayed on a page and a number of cards for each screen resolution. Possible
values are Enabled (default) and Disabled.
Records comparison
Defines whether the record comparison tool is available. Possible values are Enabled
(default) and Disabled.
Refresh
Defines whether the Refresh button is diaplyed. Possible values are Enabled (default)
and Disabled.
Specify here the Max visible length of text fields value. If the text length is greater than
this value, the residual text will be hidden under the More... link on the generated page.
Full text can be displayed in the special window in this case.
12.1.4 Output
Use this tab to specify default values for project output options 228 .
PHP Driver
There are several PHP drivers to communicate with database servers and PHP Generator
for MySQL allows you to select a driver to be used by the generated web application.
Note that the corresponding set of PHP functions should be available on your web
server.
Localization file
Use this field to define the interface language to be used for the generated application
by default. Find out more on applications localization at the corresponding page 226 .
You can also set here the output file extension and the default color scheme for the
generated pages.
12.1.5 Confirmations
This tab allows you to disable/enable application confirmations. Most of these options can
be also set directly from the corresponding confirmation dialogs.
· General 279
· Display 280
12.2.1 General
If the Auto indent option is checked, each new indention is the same as the previous
when editing SQL text.
Insert mode
If this option is checked, insert symbols mode is default on.
Tab Stops
Defines the tab length, used when editing text.
Undo Limit
12.2.2 Display
You can disable/enable the right text margin and the gutter of the editor area, set the
position of the right text margin as Right margin, and the Gutter width.
Use the Editor font and Font size to define the font used in all program editors and
viewers. The panel below displays the sample of the selected font.
You can enable/disable code folding in SQL editors and viewers and customize the colors
of its items.
12.3 Appearance
The Appearance section allows you to customize the application interface style to your
preferences.
Use the Scheme name box to select the interface scheme you prefer: Office XP style,
Windows XP native style, etc. You can create your own interface schemes by
customizing any visual options (Bars and menus, Trees and lists, Edit controls, Check
boxes, Buttons, etc.) and clicking the Save As button. All the customized options are
displayed on the sample panel.
· Buttons 291
· Splitters 294
The item allows you to select Bar style and menu animation from the corresponding
drop-down lists and to enable or disable such options as sunken border, F10 key for
opening menu, viewing full menus after delay, flat close buttons, gray-scale images.
12.3.5 Buttons
Use the Buttons item to customize PHP Generator for MySQL buttons. The tab allows
you to adjust the appearance of buttons and define sample buttons as well.
12.3.8 Splitters
Use the Splitters item to customize all PHP Generator for MySQL splitters according to
your preferences. Use the tab to select hot zone style (Windows XP task bar, Media
Player 8, Media Player 9, Simple or none) and specify the Hot zone drags a splitter
option.
Connection options 13
Index -D-
-A- Developer reference 230
Client Side API 231
Appearance Options Server Side API 257
Bar and menus 287 Style sheets internals 264
Buttons 291
Check boxes
Edit controls
290
289 -E-
Group boxes 293 Editor & Viewer Options
Page controls 292 Code Folding 285
Splitters 294 Code Insight 284
Trees and lists 288 Display 280
General 279
-V-
View Controls
External Audio 50
External File 48
External Image 49
External Video 51
-W-
Webpage appearance 195
Color Scheme 198
Color Scheme Customization 198
Custom CSS 200
Custom templates 203
Header and Footer 199
Using templates 203
Working with PHP Generator for MySQL
Adding queries 25
Advanced generation options 228
Configuring datasources 22
Deployment to the Internet 21
Localization 226
Output folder 228
Page Editor 33
Project Options 181
Security options 205
Selecting tables and views 24
Shared Options 192
Webpage appearance 195