ZnetDK 4 Mobile

 Install the App?

Settings

Settings of the ZnetDK for Mobile Starter Web App

The Starter Web App shipped with ZnetDK For Mobile can be easily customized changing:
  • The global parameters in the INSTALL_DIR/applications/default/app/config.php script.
    Each parameter is set through a PHP constant prefixed by CFG_. For example: define('CFG_SESSION_TIMEOUT', 10);
  • The application labels in the INSTALL_DIR/applications/default/app/lang/locale.php script.
    These labels are also set through PHP constants prefixed by LC_. For example: define('LC_HEAD_TITLE', 'My App title');
  • The application Apache parameters in the INSTALL_DIR/.htaccess script.
    For example: ErrorDocument 403 /znetdk4m/index.php?control=httperror&action=403

Application labels and logo

Locale PHP Script: INSTALL_DIR/applications/default/app/lang/locale.php.

The PHP constants defined below can be modified to customize some labels and the navigation menu logo of your Web app.

PHP Constants

LC_PAGE_TITLE, LC_HEAD_TITLE, LC_FOOTER_LEFT, LC_FOOTER_CENTER, LC_FOOTER_RIGHT, LC_HEAD_IMG_LOGO

 Constant LC_PAGE_TITLE

TYPE String
DESCRIPTION Title displayed on the web browser tab.
DEFAULT VALUE 'ZnetDK 4 Mobile'

EXAMPLE

define('LC_PAGE_TITLE', 'My page title');

 Constant LC_HEAD_TITLE

TYPE String
DESCRIPTION Title displayed on the application header banner.
DEFAULT VALUE 'Starter App'

EXAMPLE

define('LC_HEAD_TITLE', 'My App title');

Database settings

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

The following parameters are required to connect your Web App to a MySQL database and so, query data through the \DAO and \SimpleDAO ZnetDK classes, both based on the PHP PDO class.

See Getting Started | Connecting to a database for more information.

PHP Constants

CFG_SQL_HOST, CFG_SQL_PORT, CFG_SQL_APPL_DB, CFG_SQL_APPL_USR, CFG_SQL_APPL_PWD, CFG_SQL_TRACE_ENABLED

 Constant CFG_SQL_HOST

TYPE String
DESCRIPTION Host name of the machine where the database MySQL is installed.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_SQL_HOST', 'localhost');

 Constant CFG_SQL_PORT

TYPE String
DESCRIPTION TCP/IP port number on which the SQL Server listens.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_SQL_PORT', '35105');

 Constant CFG_SQL_APPL_DB

TYPE String
DESCRIPTION Database which contains the tables specially created for the application.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_SQL_APPL_DB', 'mydatabase');

 Constant CFG_SQL_APPL_USR

TYPE String
DESCRIPTION User declared in the database of the application to access to the tables specially created for business needs.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_SQL_APPL_USR', 'myuser');

 Constant CFG_SQL_APPL_PWD

TYPE String
DESCRIPTION User's password declared in the database of the application.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_SQL_APPL_PWD', 'mypassword');

 Constant CFG_SQL_TRACE_ENABLED

TYPE Boolean
DESCRIPTION When set to TRUE, all SQL statements executed by the \DAO and \SimpleDAO classes are traced into the INSTALL_DIR/engine/log/system.log file.
DEFAULT VALUE FALSE
VERSION >= 2.5

EXAMPLE

define('CFG_SQL_TRACE_ENABLED', TRUE);

Authentication

To limit access to your application to only authorized users, authentication must first be enabled (see CFG_AUTHENT_REQUIRED PHP constant).

Next, authorized users can be declared via the User Management form.

In addition, user rights on menu items and data can be restricted by adding profiles through the Profile Management form (see Profile management and user rights).

PHP Constants

CFG_AUTHENT_REQUIRED, CFG_SESSION_DEFAULT_MODE, CFG_SESSION_SELECT_MODE, CFG_SESSION_TIMEOUT, CFG_DEFAULT_PWD_VALIDITY_PERIOD, CFG_CHECK_PWD_VALIDITY, CFG_FORGOT_PASSWORD_ENABLED, CFG_FORGOT_PASSWORD_REQUEST_TRACE_ENABLED CFG_APPLICATION_VERSION

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

Parameters to enable user authentication and configure the user session.

See Getting Started | Enabling user authentication for more information.

ZnetDK for Mobile authentication

 Constant CFG_AUTHENT_REQUIRED

TYPE Boolean
DESCRIPTION Is authentication required? When set to TRUE, a login page is displayed to authenticate users before they access the rest of the application.
DEFAULT VALUE FALSE

EXAMPLE

define('CFG_AUTHENT_REQUIRED', TRUE);

 Constant CFG_SESSION_DEFAULT_MODE

TYPE String
DESCRIPTION Specifies whether the user session expires or not.
When set to 'public', the user session expires after the time set for the CFG_SESSION_TIMEOUT parameter.
When set to 'private', the user session expires after a longer time according to the value set for the session.gc_maxlifetime parameter in the server php.ini file.
DEFAULT VALUE 'public'

EXAMPLE

define('CFG_SESSION_DEFAULT_MODE', 'public');

 Constant CFG_SESSION_SELECT_MODE

TYPE Boolean
DESCRIPTION Specifies if users can change the session expiration mode.
When set to TRUE, users are authorized to change the way their session expires when the login dialog is displayed by clicking or not the Remember me checkbox. When checked, the expiration mode is Private.
When set to FALSE, the user session expiration mode is imposed to users and it matches the one specified for the CFG_SESSION_DEFAULT_MODE parameter.
DEFAULT VALUE TRUE

EXAMPLE

define('CFG_SESSION_SELECT_MODE', FALSE);

 Constant CFG_SESSION_TIMEOUT

TYPE Integer
DESCRIPTION The user session timeout in minutes.
After a user inactivy beyond the specified duration, a login form is displayed to renew the user session.
This parameter is taken in account only if the CFG_SESSION_DEFAULT_MODE parameter is set to 'public'.
DEFAULT VALUE 10

EXAMPLE

define('CFG_SESSION_TIMEOUT', 5);

 Constant CFG_DEFAULT_PWD_VALIDITY_PERIOD

TYPE Integer
DESCRIPTION Default validity period in months of a user password before its expiration.
DEFAULT VALUE 6

EXAMPLE

define('CFG_DEFAULT_PWD_VALIDITY_PERIOD', 3);

 Constant CFG_CHECK_PWD_VALIDITY

TYPE String
DESCRIPTION Regular expression used to check the strength of a user password when it is first set or when it is renewed.
By default, a user password must be at least 8 characters long, must contain at least 1 uppercase letter, 1 lowercase letter, and 1 number.
Since version >= 2.7, the following special characters are also allowed by default: ! * + - / = . , ; : _ @ # ? % " ' $ &
DEFAULT VALUE '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d!*+.\-_\/;@#\?%\$&\'"=,:]{8,}$/'

EXAMPLE

define('CFG_CHECK_PWD_VALIDITY', '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{12,}$/');

 Constant CFG_FORGOT_PASSWORD_ENABLED

TYPE Boolean
DESCRIPTION Displays a 'Forgot your password?' anchor on the login form.

For security reasons, this anchor is only displayed if the user has succeeded in authenticating at least once on his terminal.

When clicked, the modal dialog corresponding to the view forgotpassword.php is shown to request a new password from a user email address (this view can be customized by copying it into the view folder of the application or a module).

To send emails to the user who has requested a new password, You need to add a custom app\controller\ForgotPassword class in your application (or mymodule\mod\controller\ForgotPassword in your own module) and implement the two following public static methods.

  • sendConfirmation($emailAddress, $confirmationUrl): this method is automatically called each time a user requests a new password by entering their email address. It is responsible for sending a message at the specified email address ($emailAddress parameter) asking the user for confirmation by clicking an hyperlink (the URL is given by the $confirmationUrl parameter) before sending a temporary password.

  • sendNewEmail($emailAddress, $tempPassword): this method is automatically called when a user confirms that he requests a new password by clicking on the link received by email. It is responsible for sending a temporary password (given through the $tempPassword parameter) at the specified email address ($emailAddress parameter).

Be sure the zdk_user_pwd_resets SQL table exists in the database (see Security SQL Tables).
For an example of sending emails with PHPMailer, please visit the section Sending email with PHPMailer on this website.

DEFAULT VALUE FALSE
VERSION >= 2.5
ZnetDK for Mobile forgot password link

ZnetDK for Mobile forgot password link

EXAMPLE 1: config.php, display of the Forgot your password? link

define('CFG_FORGOT_PASSWORD_ENABLED', TRUE);

EXAMPLE 2: forgotpassword.php, emails sent via a custom app/controller/ForgotPassword class

<?php
namespace app\controller;
/* PHP script named 'forgotpassword.php' installed into the following directory:
   'INSTALL_DIR/applications/default/controller/'
*/
/* PHPMailer is directly installed into the application */
use PHPMailer\PHPMailer\PHPMailer;
require 
'app/phpmailer/src/Exception.php';
require 
'app/phpmailer/src/PHPMailer.php';

class 
ForgotPassword extends \AppController {
    
/* Send email for confirmation */
    
static public function sendConfirmation($emailAddress$confirmationUrl) {
        
$subject 'Confirm your request for a new password';
        
$body "Hello<br>Confirm your request by clicking <a href=\"{$confirmationUrl}\">this link</a>.";
        if (!
self::sendMail($emailAddress$subject$htmlMessage)) {
            throw new \
Exception('Unable to send email for confirmation!');
        }
        return 
TRUE;
    }
    
/* Send password by email after confirmation */
    
static public function sendNewEmail($emailAddress$tempPassword) {
        
$subject 'Your new temporary password';
        
$body "Hello<br>Here is your temporary password: <b>{$tempPassword}</b>";
        if (!
self::sendMail($emailAddress$subject$htmlMessage)) {
            throw new \
Exception('Unable to send temporary password!');
        }
        return 
TRUE;
    }
    
/* Example of private sendMail method based on PHPMailer. Email is sent via PHP mail */
    
static private function sendMail($emailAddress$subject$htmlMessage) {
        
$mail = new PHPMailer();
        
$mail->setFrom('admin@example.com');
        
$mail->addAddress($emailAddress);
        
$mail->Subject $subject;
        
$mail->msgHTML($htmlMessage);
        return 
$mail->send();
    }
}
?>

 Constant CFG_FORGOT_PASSWORD_REQUEST_TRACE_ENABLED

TYPE Boolean
DESCRIPTION Traces in ZnetDK INSTALL_DIR/engine/log/system.log file the requests for a new password when the forgotten password feature is enabled (see CFG_FORGOT_PASSWORD_ENABLED parameter).
DEFAULT VALUE FALSE
VERSION >= 2.5

EXAMPLE

define('CFG_FORGOT_PASSWORD_REQUEST_TRACE_ENABLED', TRUE);

 Constant CFG_APPLICATION_VERSION

TYPE Integer
DESCRIPTION Set a version number for the application. This version is used to force application reloading in the web browser if the current application's version in the web browser is not the latest. This parameter is ignored if CFG_VIEW_PAGE_RELOAD is TRUE.
DEFAULT VALUE 1
VERSION >= 2.6

EXAMPLE

define('CFG_APPLICATION_VERSION', 2);

User management

ZnetDK includes in standard a dedicated view to manage the users authorized to access to the Web Application.

To manage users, the following requirements must be fulfilled:

  1. A menu item is defined in the menu.php of the application to access to the z4musers.php view (see procedure).
  2. The Web App is connected to a MySQL database (see procedure).
  3. The Security SQL tables for storing user authentication data must have been created in the database (see procedure).

To give access to users in the Web Application, follow the procedure Declaring the users.

User rights

Rights are generally granted to users though Profiles.

However, if no particular restriction applies to users, then no profile is required. Users must simply be declared with the Menu Access Full option checked.

Profile management and user rights

ZnetDK includes in standard a dedicated view to manage user profiles that can be assigned to users in order to restrict their rights in the Web Application.

To manage profiles, the following requirements must be fulfilled:

  1. A menu item is defined in the menu.php of the application to access to the z4mprofiles.php view (see procedure).
  2. The Web App is connected to a MySQL database (see procedure).
  3. The Security SQL tables for storing user authentication data must have been created in the database (see procedure).

A profile is generally created to restrict access to menu items in the application. In that case, the Menu Access Full option must be unchecked when assigning the profile to users.

It can also be defined to limit the visibility of the data when it is for some confidential, for example according to the department in the company in which the user works.

A profile can also be used to add specific functionalities to certain users or, on the contrary, to remove particularly sensitive functionalities.

When editing a user, one or several profiles can be assigned to him according to the rights we want to grant him.

The PHP API provides useful methods like \controller\Users::hasProfile() and \controller\Users::hasMenuItem() to grant specific rights to users programmatically based on their profiles and the menu items they have access to.

Edit profile in ZnetDK for Mobile
Edit user in ZnetDK for Mobile

User panel

The User panel is displayed when clicking the user icon on the App header.
Only authenticated users have access to the User panel (see CFG_AUTHENT_REQUIRED parameter).

The following screens are displayed when you click the corresponding User panel button.

Password screen

The Password screen allows authenticated users to change their login password if they wish. This screen is identical to the one displayed when the user's password has expired (see Password validity period).

My user rights screen

In version >= 2.7, the My user rights screen gives information about the user profiles assigned to the logged-in user. In addition, it indicates if user has a full access to the menu of the Application.

Installation screen

In version >= 2.7, the Installation screen helps users on PWA installation procedure on their mobile devices (see Easing installation for more information about Progressive Web Application).
This screen can also be displayed in JavaScript by calling the znetdkMobile.install.showInstallView JS API method.

Uninstallation screen

In version >= 2.7, the Uninstallation screen helps users on PWA uninstallation procedure on their mobile devices (see Easing installation for more information about Progressive Web Application).
This screen can also be displayed in JavaScript by calling the znetdkMobile.install.showUninstallView JS API method.

User panel in ZnetDK for Mobile

Password validity period

When a user logs into the application, if their password has expired (see Expire on entry field in the Edit a profile form), they are asked to renew it.

To renew their password, users have to enter the following informations:

  • Original password: this is the original password which has expired and needs to be changed.
  • New password: the new password which replaces the expired password.
  • Confirmation: the confirmation of the new password (the same than the one entered for the New password field).

Users can also renew their password before it has expired from the User panel.

To be changed, the new password must comply with the input rules defined through the CFG_CHECK_PWD_VALIDITY parameter.

Change password in ZnetDK for Mobile

User account Disabled or Archived

Users can't log in to the application if their account is Disabled or Archived (see Status radio buttons in the Edit a profile form).
Users are automatically Disabled when they enter the wrong password three times. Although disabled, they can request a new password by clicking on the Forgot password? link (see CFG_FORGOT_PASSWORD_ENABLED parameter).
Finally, when users are Archived, they can no longer log into the application or request a new password.

Application theming

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

Colors, font and logos can be customized through the parameters described below.

See Getting Started | Customizing the Starter Application for more information.

PHP Constants

CFG_MOBILE_W3CSS_THEME, CFG_MOBILE_CSS_FONT, CFG_MOBILE_CSS_FONT_FAMILY, CFG_MOBILE_FAVICON_CODE_FILENAME, CFG_MOBILE_FAVICON_DIR

 Constant CFG_MOBILE_W3CSS_THEME

TYPE String
DESCRIPTION Relative path or URL of the W3.CSS color theme stylesheet to enable for the web application.
By default, the built-in w3-theme-blue.css color theme is configured.

To configure a built-in W3.CSS color theme:

  1. Go to the W3.CSS Color Themes web page,
  2. Choose one theme among those proposed (for example w3-theme-blue-grey.css),
  3. And set its URL for the parameter (see EXAMPLE below).

To make and install your custom color theme:

  1. Go to the W3.CSS Color Generator web page,
  2. Generate your own theme,
  3. Download it,
  4. Next copy the theme's stylesheet (for example mytheme.css) into the INSTALL_DIR/applications/default/public/css directory.
  5. Finally, set its relative path for the parameter, set the value 'applications/'.ZNETDK_APP_NAME.'/public/css/mytheme.css').
DEFAULT VALUE 'resources/w3css/themes/w3-theme-blue.css'

EXAMPLE

define('CFG_MOBILE_W3CSS_THEME', 'https://www.w3schools.com/lib/w3-theme-blue-grey.css');

 Constant CFG_MOBILE_CSS_FONT

TYPE String
DESCRIPTION Relative path or URL of the CSS font file to include into the header of the mobile page layout.
DEFAULT VALUE 'resources/googlefonts/exo-v7-latin-regular.css'

EXAMPLE

define('CFG_MOBILE_CSS_FONT', 'https://fonts.googleapis.com/css?family=Poppins&display=swap');

 Constant CFG_MOBILE_CSS_FONT_FAMILY

TYPE String
DESCRIPTION The CSS font family to apply to the HTML elements for the mobile page layout.
This font family is set according to the font stylesheet set through the CFG_MOBILE_CSS_FONT parameter.
DEFAULT VALUE "'Exo', sans-serif"

EXAMPLE

define('CFG_MOBILE_CSS_FONT_FAMILY', "'Poppins', sans-serif");

 Constant CFG_MOBILE_FAVICON_CODE_FILENAME

TYPE String
DESCRIPTION Relative path of the favicon code template to include in the mobile page layout.
This parameter is to modify for customizing the favicon of the application. The custom favicon code template is generally stored into the INSTALL_DIR/applications/default/app/layout/ directory.

See Getting Started | The favicon logo for more information.

DEFAULT VALUE 'engine/core/layout/mobile_favicons.php'

EXAMPLE

define('CFG_MOBILE_FAVICON_CODE_FILENAME', 'applications/' . ZNETDK_APP_NAME . '/app/layout/mobile_favicons.php');

 Constant CFG_MOBILE_FAVICON_DIR

TYPE String
DESCRIPTION Relative path of the mobile page layout favicon files directory.
The favicon fileset is generally installed into the INSTALL_DIR/applications/default/public/images/favicons/ directory.

See Getting Started | The favicon logo for more information.

DEFAULT VALUE CFG_ZNETDK_IMG_DIR . '/favicons'

EXAMPLE

define('CFG_MOBILE_FAVICON_DIR', 'applications/' . ZNETDK_APP_NAME .'/public/images/favicons');

App extra CSS and JS libraries

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

Additional CSS stylesheets and JavaScript libraries can be loaded for extending the web application capabilities through the following parameters.

PHP Constants

 Constant CFG_APPLICATION_CSS

TYPE String
DESCRIPTION Relative path of the CSS stylesheet specially developed for the application.
The custom stylesheet is to install into INSTALL_DIR/applications/default/public/css/ directory.
Extra CDN CSS libraries can also be included in the application by specifying its URL (for example 'https://extracsslibrary.net/lib.css').
At last, several stylesheets can be set using a PHP serialized array as show in the EXAMPLE below.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_APPLICATION_CSS', serialize(array('applications/' . ZNETDK_APP_NAME . '/public/css/myscript.css', 'https://extracsslibrary.net/lib.css')));

 Constant CFG_APP_JS

TYPE String
DESCRIPTION Relative path of the JavaScript file specially developed for the application.
The custom JS library is to install into INSTALL_DIR/applications/default/public/js/ directory.
Extra CDN JS libraries can also be included in the application by specifying its URL (for example 'https://extrajslibrary.net/lib.js').
At last, several JS libraries can be set using a PHP serialized array as show in the EXAMPLE below.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_APP_JS', serialize(array('applications/' . ZNETDK_APP_NAME . '/public/js/myscript.js', 'https://extrajslibrary.net/lib.js')));

Language settings

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.
Locale PHP Script: INSTALL_DIR/applications/default/app/lang/locale.php

By default, the Starter App shipped with ZnetDK 4 Mobile is configured to be displayed in English (CFG_DEFAULT_LANGUAGE parameter set to 'en' in the config.php of the application).

The core features of ZnetDK are translated in English, French and Spanish.
To display your Web APP in French, set CFG_DEFAULT_LANGUAGE to 'fr'. For a display in Spanish, set CFG_DEFAULT_LANGUAGE to 'es'.

To translate your App into a language not translated in standard, for example in Portuguese:

  1. Copy the INSTALL_DIR/engine/core/lang/locale_en.php english core translation script into the INSTALL_DIR/applications/default/app/lang/ folder,
  2. Rename the copied locale_en.php script by changing the en filename suffix to the ISO 639-1 country code corresponding to your country, in this case to locale_pt.php.
  3. Edit the new locale_pt.php script and translate the PHP constant values in Portuguese.
  4. Edit the INSTALL_DIR/applications/default/app/config.php PHP script and change the value of the CFG_DEFAULT_LANGUAGE parameter from en to 'pt'.
  5. Refresh your Web App in your web browser; the title, the footer, the user and profil management features are now translated in Portuguese.

It is also possible to translate a view of the application directly into several languages.
For example, if a view is originally named myview.php with text displayed in English, then it might be suffixed with its language code (eg myview_en.php).
This view once translated into Spanish will be named myview_es.php and the one translated into French will be named myview_fr.php.
Thus, the view corresponding to the language to be displayed for the application will be chosen automatically by ZnetDK.

Finally, the display of the application can be set to a specific language by reloading it with the ?lang=<iso code> parameter added to its URL.
For example, to display the application in Spanish: https://mydomain/myapp?lang=es.

See on the Code Snippets page an example of Multilingual application.

PHP Constants

 Constant CFG_DEFAULT_LANGUAGE

TYPE String
DESCRIPTION Default language of the Application when the web browser language is not one the ZnetDK supported languages (English, French and Spanish). The language is set through a 2-character code in ISO 639-1, for example 'fr'.
DEFAULT VALUE 'en'

EXAMPLE

define('CFG_DEFAULT_LANGUAGE', 'es');

 Constant CFG_MULTI_LANG_ENABLED

TYPE Boolean
DESCRIPTION Is multilingual translation enabled for your application? When set to TRUE, the user can choose another display language.
DEFAULT VALUE FALSE

EXAMPLE

define('CFG_MULTI_LANG_ENABLED', TRUE);

Locale settings

Locale PHP Script: INSTALL_DIR/applications/default/app/lang/locale.php

The locale is used by ZnetDK to display dates and amounts formatted according to the user's language.

The locale can be set globally through the single LC_LOCALE_ALL PHP constant described below. However, this implies that the desired locale is installed on the web server.

Alternatively, the locale can be directly customized using the following PHP constants, independently of the locales installed on the web server: LC_LOCALE_DECIMAL_SEPARATOR, LC_LOCALE_THOUSANDS_SEPARATOR, LC_LOCALE_NUMBER_OF_DECIMALS, LC_LOCALE_CURRENCY_SYMBOL, LC_LOCALE_CURRENCY_SYMBOL_PRECEDE, LC_LOCALE_CURRENCY_SYMBOL_SEPARATE, LC_LOCALE_DATE_FORMAT, LC_LOCALE_CSV_SEPARATOR

PHP Constants

LC_LOCALE_ALL, LC_LOCALE_DECIMAL_SEPARATOR, LC_LOCALE_THOUSANDS_SEPARATOR, LC_LOCALE_NUMBER_OF_DECIMALS, LC_LOCALE_CURRENCY_SYMBOL, LC_LOCALE_CURRENCY_SYMBOL_PRECEDE, LC_LOCALE_CURRENCY_SYMBOL_SEPARATE, LC_LOCALE_DATE_FORMAT, LC_LOCALE_CSV_SEPARATOR

 Constant LC_LOCALE_ALL

TYPE String
DESCRIPTION Definition of the locale information to apply to the Web App.
The values are specified through a PHP serialized array.
A minimum of one locale must be specified (for example 'en_EN').
Extra locales can be specified in case the first locale entered is not installed on the web server. Under Linux, the locale -a command can be executed to get the installed locales.
The values set for LC_LOCALE_ALL are passed to the setlocale PHP function with LC_ALL as first parameter.
DEFAULT VALUES
  • For English language, serialize(array('en_US.UTF-8', 'English_United States.1252', 'en_US', 'english'))
  • For French language, serialize(array('fr_FR.UTF-8', 'French_France.1252', 'fr_FR', 'french'))
  • For Spanish language, serialize(array('es_ES.UTF-8', 'Spanish_Spain.1252', 'es_ES', 'spanish'))

EXAMPLE

define('LC_LOCALE_ALL', serialize(array('fr_FR', 'french', 'fr_FR.utf8')));

 Constant LC_LOCALE_DECIMAL_SEPARATOR

TYPE String
DESCRIPTION Decimal separator used for displaying amounts (',' or '.').
See the \Convert::toMoney() PHP method used to convert a float number to a formatted amount.
DEFAULT VALUE NULL

EXAMPLE

define('LC_LOCALE_DECIMAL_SEPARATOR', ',');

 Constant LC_LOCALE_THOUSANDS_SEPARATOR

TYPE String
DESCRIPTION Thousands separator used for displaying amounts ('.', ' ' or '').
See the \Convert::toMoney() PHP method used to convert a float number to a formatted amount.
DEFAULT VALUE NULL

EXAMPLE

define('LC_LOCALE_THOUSANDS_SEPARATOR', ' ');

 Constant LC_LOCALE_NUMBER_OF_DECIMALS

TYPE String
DESCRIPTION Number of decimal places used to display amounts (usually 2 decimal places).
See the \Convert::toMoney() PHP method used to convert a float number to a formatted amount.
DEFAULT VALUE NULL

EXAMPLE

define('LC_LOCALE_NUMBER_OF_DECIMALS', 2);

 Constant LC_LOCALE_CURRENCY_SYMBOL

TYPE String
DESCRIPTION The currency symbol used to display amounts (for example '€', '$', '£', ...).
See the \Convert::toMoney() PHP method used to convert a float number to a formatted amount.
DEFAULT VALUE NULL

EXAMPLE

define('LC_LOCALE_CURRENCY_SYMBOL', '€');

 Constant LC_LOCALE_CURRENCY_SYMBOL_PRECEDE

TYPE Boolean
DESCRIPTION Specifies whether the currency symbol is placed to the left of the amount (for example FALSE for euros, TRUE for US dollars).
See the \Convert::toMoney() PHP method used to convert a float number to a formatted amount.
DEFAULT VALUE NULL

EXAMPLE

define('LC_LOCALE_CURRENCY_SYMBOL_PRECEDE', FALSE);

 Constant LC_LOCALE_CURRENCY_SYMBOL_SEPARATE

TYPE String
DESCRIPTION The character used to separate the amount from its currency symbol (' ' or '').
See the \Convert::toMoney() PHP method used to convert a float number to a formatted amount.
DEFAULT VALUE NULL

EXAMPLE

define('LC_LOCALE_CURRENCY_SYMBOL_SEPARATE', ' ');

 Constant LC_LOCALE_DATE_FORMAT

TYPE String
DESCRIPTION
In ZnetDK version <= 2.7, the strftime date format used to display dates (for example '%Y-%m-%d').
In ZnetDK version >= 2.8, the DateTime::format() date format used to display dates (for example 'Y-m-d').
See the \Convert::W3CtoLocaleDate() PHP method used to convert an ISO date to a locale date.
DEFAULT VALUE NULL

EXAMPLE

<?php
// ZnetDK version <= 2.7
define('LC_LOCALE_DATE_FORMAT''%d-%m-%y');
// ZnetDK version >= 2.8
define('LC_LOCALE_DATE_FORMAT''d-m-y');

 Constant LC_LOCALE_CSV_SEPARATOR

TYPE String
DESCRIPTION The column separator used when a CSV file is downloaded from the Web App (';' or ',').
See \Response::setDataForCsv() PHP method for more information.
DEFAULT VALUE ';' or ',' according to the current display language (see Language settings).

EXAMPLE

define('LC_LOCALE_CSV_SEPARATOR', ';');

Views loading

By default, a view is loaded only once on demand, is not removed from the DOM (Document Object Model) when it is hidden, and therefore is not reloaded when it is displayed again on subsequent times.

This behaviour can be changed via the following PHP constants.

PHP Constants

 Constant CFG_VIEW_PRELOAD

TYPE Boolean
DESCRIPTION Loading of all views from the first access to the application.
When set to FALSE, views are loaded on demand as soon as the user accesses them.
Once loaded, the view is no longer loaded on subsequent accesses.
This parameter is not taken into account if the CFG_VIEW_PAGE_RELOAD parameter is set to TRUE.
DEFAULT VALUE FALSE

EXAMPLE

define('CFG_VIEW_PRELOAD', TRUE);

 Constant CFG_VIEW_PAGE_RELOAD

TYPE Boolean
DESCRIPTION Complete reloading of the application page each time a view is displayed by clicking on a navigation menu entry.
This loading mode is particularly suited for the publication of content with referencing by search engines.
This feature is only available if authentication is disabled for the application (CFG_AUTHENT_REQUIRED parameter set to FALSE).
DEFAULT VALUE FALSE

EXAMPLE

define('CFG_VIEW_PAGE_RELOAD', TRUE);

Stored documents

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

Pictures, documents and other files uploaded by users or generated by the Starter App can be stored within the INSTALL_DIR/applications/default/documents/ private directory whose absolute file path is accessible via the CFG_DOCUMENTS_DIR PHP constant described below.

PHP Constants

 Constant CFG_DOCUMENTS_DIR

TYPE String
DESCRIPTION Absolute path of the directory where are stored the electronic documents of the Starter App.
DEFAULT VALUE ZNETDK_APP_ROOT . DIRECTORY_SEPARATOR . 'documents'

EXAMPLE

define('CFG_DOCUMENTS_DIR', '/home/documents');

Web Services

Controller actions can be exposed as Web Services.

The POST method should be used to call a Web Service. The GET method is reserved for downloading files.

The web service is authenticated through Basic Authentication. A dedicated user is generally declared in the application to call a web service.

For example, to execute the MyController::action_dostuff() controller action of the Application deployed at https://mydomain.com/mydir/, with the user account wsuser to authenticate, submit via the POST method the following URL:

EXAMPLE

https://wsuser:password@mydomain.com/mydir/?control=mycontroller&action=dostuff&my_param=myvalue

See below for PHP constants to configure controller actions to expose as a web service.

PHP Constants

 Constant CFG_HTTP_BASIC_AUTHENTICATION_ENABLED

TYPE Boolean
DESCRIPTION Enables or disables the HTTP basic authentication method for executing a controller action as a web service.
DEFAULT VALUE FALSE

EXAMPLE

define('CFG_HTTP_BASIC_AUTHENTICATION_ENABLED', TRUE);

 Constant CFG_ACTIONS_ALLOWED_FOR_WEBSERVICE_USERS

TYPE String
DESCRIPTION Defines the controller actions that users can execute when they are authenticated by the HTTP basic authentication.
Controller actions are declared through a serialized array where each entry is a string starting by the the allowed user login name followed by a vertical bar (i.e |) and finally by the allowed controller action as a string separated by a colon character (i.e :).
When set to NULL (the default value), no action can be executed.
DEFAULT VALUE NULL

EXAMPLE

define('CFG_ACTIONS_ALLOWED_FOR_WEBSERVICE_USERS', serialize([
    'wsuser|mycontroller:dostuff',
    'wsuser|mycontroller:download'
]));

 Constant CFG_DOWNLOAD_AS_POST_REQUEST_ENABLED

TYPE Boolean
DESCRIPTION Enables or disables the ability to download a file from a HTTP POST request.
DEFAULT VALUE FALSE

EXAMPLE

define('CFG_DOWNLOAD_AS_POST_REQUEST_ENABLED', TRUE);

HTTP errors 403 and 404

Apache configuration file: INSTALL_DIR/.htaccess.

According to the directory where ZnetDK for mobile is installed, the HTTP Error 403 (access forbidden) and HTTP error 404 (page not found) must be handled properly by adjusting the Apache Web Server ErrorDocument parameter.

Then, if users attempt to access a page that does not exist or to which access is denied, then they will be automatically redirected to the dedicated ZnetDK HTTP error page.

The view displayed in case of HTTP errors is INSTALL_DIR/engine/core/view/httperror.php.
This view can be customized after having copied it into the INSTALL_DIR/applications/default/app/view/ folder.

Configuration scenarios

CASE 1: App deployed directly at http://mydomain/

In this case, ZnetDK is directly installed in the root directory of your Apache web server.

For example, your web root directory is /var/www/html/ and so the file path of the .htaccess file shipped with ZnetDK is /var/www/html/.htaccess.
Here is below the path to specify for the ErrorDocument statement in the ZnetDK's .htaccess file.

.htaccess (in web server root directory)

ErrorDocument 403 /index.php?control=httperror&action=403
ErrorDocument 404 /index.php?control=httperror&action=404

CASE 2: App deployed at http://mydomain/mysubdirectory/

In this second case, ZnetDK is installed in a subdirectory of the root directory of your Apache web server.

For example, your web root directory is /var/www/html/, the subdirectory is named mysubdirectory/ and so the file path of the .htaccess file shipped with ZnetDK is /var/www/html/mysubdirectory/.htaccess.
Here is below the path to specify for the ErrorDocument statement in the ZnetDK's .htaccess file.

.htaccess (in web server subdirectory)

ErrorDocument 403 /mysubdirectory/index.php?control=httperror&action=403
ErrorDocument 404 /mysubdirectory/index.php?control=httperror&action=404

Progressive Web App (PWA)

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

The ZnetDK 4 Mobile Starter Web application is natively configured to be a Progressive Web App.
A default service worker is started when loading the application.
The Starter Web App can be installed on devices with a web browser that supports A2HS feature like Chrome and Safari.

PHP Constants

 Constant CFG_MOBILE_SERVICE_WORKER_URL

TYPE String
DESCRIPTION Relative path of the Service Worker JavaScript file to launch (NULL to disable the service worker).
DEFAULT VALUE 'service-worker.js'

EXAMPLE

define('CFG_MOBILE_SERVICE_WORKER_URL', 'my-sw.js');

 Constant CFG_MOBILE_INSTALL_MESSAGE_DISPLAY_AUTO

TYPE Boolean
DESCRIPTION Enables automatic display of a message to install the application (add shortcut icon to device home screen).
DEFAULT VALUE TRUE
VERSION >= 2.7

EXAMPLE

define('CFG_MOBILE_INSTALL_MESSAGE_DISPLAY_AUTO', FALSE);

Miscellaneous

App configuration PHP Script: INSTALL_DIR/applications/default/app/config.php.

Additionnal application settings are described in this section.

PHP Constants

 Constant CFG_IS_IN_MAINTENANCE

TYPE Boolean
DESCRIPTION Specify if the application is in maintenance mode or not.
In maintnenance mode, access to the application is unavailable and the INSTALL_DIR/engine/core/view/maintenance.php core view is displayed to inform users that they have to wait until the end of the maintenance work.
The displayed message can be customized by setting the LC_MSG_ERR_MAINTENANCE PHP constant in the locale.php script of the application.
DEFAULT VALUE FALSE
VERSION >= 2.8

EXAMPLE

define('CFG_IS_IN_MAINTENANCE', TRUE);