ZnetDK 4 Mobile

Forum

Questions and answers

If you need help about ZnetDK for Mobile, please post your questions on the SOURCEFORGE Discussion page of ZnetDK by clicking the button below.

Topics

Code Snippets: Uploading files from your Application
Sun, 13 Nov 2022 13:00:26

Hello,

The ZnetDK 4 Mobile website was updated this week with new code snippets for Uploading files from your Application.
See the step-by-step procedure to add this functionality to the ZnetDK 4 Mobile Starter application.

Hoping you'll enjoy,

Pascal
ZnetDK developer.

ZnetDK 4 Mobile v2.7 is released
Thu, 18 Aug 2022 21:44:15

Hello,

The new version 2.7 of ZnetDK is released and includes the following changes and bug fixes:

  • CHANGE: input fields are now surrounded by a red border in case of form validation error.
  • CHANGE: new jQuery events triggered before (beforeshow) and after (aftershow) displaying a modal dialog. If the beforeshow event handler returns false, the modal dialog is not displayed.
  • CHANGE: server-side errors are now displayed using the HTML5 JS Validation API (setCustomValidity method) when an input field value is incorrect.
  • CHANGE: the message displayed after the user changes their password is now a "snackbar" type message rather than a message in a blue panel.
  • CHANGE: the message displayed after editing a user's information or deleting a user is now a "snackbar" type message rather than a message in a blue panel.
  • CHANGE: new "My user rights" button added to the user panel to display the user profiles assigned to the connected user and to indicate whether she or he has a full menu access or not.
  • CHANGE: when 'Remember me' is checked on the login form, the user's login name is stored in the browser's local storage and is pre-populated on subsequent displays of the login form.
  • CHANGE: new "Installation" and "Uninstallation" buttons added to the user panel in order to help users to install the Application on their devices and to uninstall it. The modal dialogs shown when clicking these new buttons can also be displayed by calling the two following methods: znetdkMobile.install.showInstallView() and znetdkMobile.install.showUninstallView().
  • CHANGE: new CFG_MOBILE_INSTALL_MESSAGE_DISPLAY_AUTO parameter to enable or disable automatic display of a message to install the application (Add 2 Home Screen). Set to TRUE by default, this value can be changed to FALSE in the config.php script of the application. This message can also be displayed on demand by calling the znetdkMobile.install.showInstallableMessage() method.
  • CHANGE: new znetdkMobile.install.isAppInstallable() and znetdkMobile.install.isAppInstalled() methods respectively to know if the application is installable and if it is already installed.
  • CHANGE: new viewName and onViewLoaded optional parameters added to the znetdkMobile.modal.make() method in order to load in Ajax the modal dialog from the specified ZnetDK view before instantiating it. If the modal dialog already exists in the DOM, it is not loaded again when the method is called next times.
  • CHANGE: new znetdkMobile.serviceWorker.isRegistered property that is set to true once the service worker registration has succeeded.
  • CHANGE: new znetdkMobile.browser.doPhoneCall() method to dial the specified phone number on cell phone.
  • CHANGE: new znetdkMobile.browser.sendSMS() method to open the screen for sending an SMS and pre-fill phone number and message from the specified values passed in parameters.
  • CHANGE: special characters are now allowed by default when entering a new password for app authentication (see CFG_CHECK_PWD_VALIDITY and LC_MSG_ERR_PASSWORD_BADLENGTH PHP constants for customization purpose).
  • CHANGE: new $includeArchived parameter (set to TRUE by default) added to the \UserManager::getUsersHavingProfile() method. When set to FALSE, archived users are excluded from the returned users.
  • CHANGE: new znetdkMobile.list.beforeInsertRowCallback property to define a custom function to call each time a row is inserted in a list. This function has one parameter which contains the data to display for the row. This data can be modified within the function before displaying the row. This callback function can be useful to format data before row insertion.
  • CHANGE: for optimization purpose, AJAX requests are no longer sent by a znetdkMobile.autocomplete input field when the previously entered keyword does not match any suggestions.
  • CHANGE: for performance purpose, suggestions returned by AJAX requests when entering a keyword in a znetdkMobile.autocomplete input field can be cached in memory to reduce network traffic. To enable caching, set znetdkMobile.autocomplete.maxNumberOfCachedItems to a value greater than zero (set to zero by default). To clear the cache once a suggestion is selected, change the value znetdkMobile.autocomplete.cacheLifetime to 'selection' ('page' is set by default, meaning that cache is kept until user leaves the application).
  • BUG FIXING: when calling the DAO::store() method with an empty row id value (i.e. '') and the $emptyValuesToNull parameter is FALSE (default case), then the SQL statement generated is no longer an UPDATE but an INSERT instead.
  • BUG FIXING: for optimization purpose, the user profile list displayed for each user in the user list (menu Authorizations | Users) is no longer created by querying profiles in SQL for each user (now, only one SQL query is executed for all displayed users).
  • BUG FIXING: multiples clicks are prevented on anchor and button elements of the application (disabling during 500 ms).
  • BUG FIXING: messages displayed through the znetdkMobile.messages.add() method were not hidden after the user logged out.
  • BUG FIXING: the first parameter named $loginName is renamed to $userId for the \UserManager::getUserProfiles() method because the expected parameter value was the user internal identifier.
  • BUG FIXING: Javascript error displayed in web browser console on service worker registration when the App's URL is redirected: "The script resource is behind a redirect, which is disallowed.".
  • BUG FIXING: user profiles were displayed twice when the number of defined profiles exceeded 20 profiles.
  • BUG FIXING: when activating the "Users" tab from the "Profiles" tab, the user list was not reloaded when applying "Enabled", "Disabled" or "Archived" filter and the profile list was reloaded instead.
  • BUG FIXING: ajax requests could be executed twice after the user's session expired if a JS error occurred while executing them from the queue.
  • BUG FIXING: the login name was not displayed in the login field after reloading of the application once session was expired.
  • BUG FIXING: JS error message "TypeError: Cannot read properties of undefined (reading 'replace')" was displayed when the rendering callback function passed to the znetdkMobile.autocomplete.make() method did not returned a string value.
  • BUG FIXING: JS error message displayed in web browser console about znetdkMobile.log.e$() function that is not defined when a JS error is detected after a view loading through the znetdkMobile.ajax.loadView() method (issue in minification of mobile-min.js version 2.6).

Pascal,
ZnetDK developer

Input auto-complete dans un formulaire
Fri, 03 Jun 2022 20:54:29

Bonjour,

Vous pouvez vous inspirer de l'exemple d'application Autocomplete publiée sur la page Code Snippets.

La fonction de rappel (voir le paramètre onSelect de la méthode znetdk.autocomplete.make() dans la documentation en ligne de l'API JS) à la sélection d'une suggestion est l'endroit qui convient pour charger dynamiquement le contenu de votre liste déroulante via un appel Ajax en utilisant la méthode znetdkMobile.ajax.request() (voir documentation en ligne de l'API JS).

Bien à vous
Pascal

ZnetDK 4 Mobile v2.6 is released
Fri, 03 Jun 2022 14:15:11

Hello,

The new version 2.6 of ZnetDK is released and includes the following changes and bug fixes:

  • CHANGE: downloaded documents (photos, pdf, etc.) are now stored in cache by the service worker if the cache=true GET parameter is added to the download url.
  • CHANGE: new ZnetDK \General::reducePictureSize() method that resizes a JPEG or PNG picture by specifying a maximum width and height.
  • CHANGE: new CFG_APPLICATION_VERSION parameter to specify the current application's version (integer value, 1 by default). When this version is set into the config.php of the application, the client-side application is automatically reloaded on user's session expiration if the application version on the server-side is higher than the one currently loaded in the user's web browser.
  • CHANGE: new \Convert::binaryToBase64Url() ZnetDK method to convert a binary file content to base64 URL.
  • CHANGE: new \Convert::base64UrlToBinary() ZnetDK method to convert a base64 URL to binary file content.
  • CHANGE: new \Request::setTrimedCharacters() to specify the characters to trim when retrieving the sanitized value of a request parameter. By default, the trimed characters are " \n\r\t\v\x00". This method can be useful to preserve the newline characters of the beginning and the end of a text.
  • CHANGE: new CFG_REQUEST_VARIABLE_FILTERING_LEVEL parameter to specify the filtering level applied by default when reading HTTP request variables by calling the\Request() getter method (i.e $request->my_var). Value 'HIGH' is set by default (PHP filter_var() function is applied with FILTER_SANITIZE_STRING filter and FILTER_FLAG_NO_ENCODE_QUOTES option). Other allowed value is 'LOW' (PHP strip_tags() function is applied and the string '<=' is preserved if exists in the text to filter).
  • CHANGE: new \Request::setVariableFilteringLevel() to change the default value set through the CFG_REQUEST_VARIABLE_FILTERING_LEVEL parameter. Allowed parameters are 'LOW' and 'HIGH'.
  • CHANGE: Flash Of Unstyled Content (FOUC) is now prevented on application loading.
  • CHANGE: jQuery upgrade from version 3.5.1 to version 3.6.0 (see CFG_MOBILE_JQUERY_JS PHP constant).
  • CHANGE: the znetdkMobile.setInputValue() method now allows to check multiple checkboxes having the same name (generally ended with double brackets, for example "mycheckboxes[]"). The values of the checkboxes to check are passed in parameter of the method as an array.
  • CHANGE: the znetdkMobile.getInputValue() method now allows to retrieve as a JS array, the selected values for a SELECT HTML element set with the multiple property.
  • BUG FIXING: jQuery syntax error calling znetdkMobile.getInputValue() method when the input name passed in parameter contains "bracket" symbols.
  • BUG FIXING: when more than 20 users were declared in the application, the list of users (view 'z4musers.php') was not properly paginated (same users were displayed several times).

Pascal,
ZnetDK developer

Input auto-complete dans un formulaire
Wed, 09 Feb 2022 23:00:48

Bonsoir,
J’ai besoin d’aide sur une action que je veux effectuer avec ZnetDK Mobile.
Dans ma boite de dialogue d’enregistrement, j’utilise une balise select mais il se fait que le nombre de produit est trop élevé et ça prend du temps pour trouver un produit. Alors j’ai pensé à mettre dans le modal, un input auto-complete qui remplira un autre input avec le ID du produit lorsqu’un des labels proposés sera sélectionné.
Merci pour votre aide.

Comment aller d'une page à l'autre
Tue, 25 Jan 2022 22:33:16

Bonjour,
J'ai testé et ça marche exactement comme je voulais.
Merci Bien.

Comment aller d'une page à l'autre
Mon, 24 Jan 2022 22:30:39

Bonjour,

L'application de démarrage ZnetDK 4 Mobile est configurée par défaut pour être une application à page unique (Single Page Application).

Cela signifie que la page principale de l'application (unique) n'est jamais rechargée lorsque l'utilisateur réalise une action. Le contenu de la page affichée dans le navigateur (le DOM) est complété de données ou d'éléments HTML supplémentaires au fur et à mesure que l'utilisateur accède à de nouvelles vues de l'application.

Pour votre exemple de navigation depuis une liste de pays vers une liste des villes correspondantes au clic d'un pays, il n'existe pas de solution prête à l'emploi dans ZnetDK.
Néanmoins, pour répondre à ce besoin, voici par exemple comment je procéderais (il s'agit d'une solution possible parmi beaucoup d'autres) :

1) Déclarer 2 vues dans le script menu.php de l'application : une vue mycountryview pour afficher les pays (menu Pays) et une vue mycityview pour afficher les villes (menu Villes).

<?php
/* Définition menu.php */
namespace app;
class Menu implements \iMenu {
    static public function initAppMenuItems() {
        \MenuManager::addMenuItem(NULL, 'mycountryview', 'Pays', 'fa-globe');
        \MenuManager::addMenuItem(NULL, 'mycityview', 'Villes', 'fa-map-marker');
    }
 }

2) Ensuite, depuis la vue Pays (mycountryview.php), coder un gestionnaire d'événements répondant au clic d'une ligne de la liste des pays.
Dans ce gestionnaire, mémoriser l'identifiant du pays correspondant à la ligne cliquée et demander l'affichage de la vue Villes (méthode znetdkMobile.content.displayView()).

<!-- Vue mycountryview.php -->
<ul id="countrylist" class="w3-ul w3-hide" data-zdk-load="mycontroller:countries">
    <li><a href="{{country_id}}">{{country_name}}</a></li>
</ul>
<script>
    console.log('** mycountryview **');
    znetdkMobile.list.make('#countrylist');
    $('#countrylist').on('click', 'a', function(event){
        event.preventDefault();
        // Clicked Country is memorized
        var countryId = $(this).attr('href');
        $('#countrylist').data('selected-country-id', countryId);
        // The city view is displayed
        znetdkMobile.content.displayView('mycityview');
    });
</script>

3) Dans la vue Villes (mycityview.php), après initialisation en JS de la liste des villes (méthode znetdkMobile.list.make()), personnaliser la fonction de rappel beforeSearchRequestCallback pour passer en paramètre POST (country_id) de la recherche de villes, l'identifiant du pays mémorisé à l'étape 2.

<!-- Vue mycityview.php -->
<ul id="citylist" class="w3-ul w3-hide" data-zdk-load="mycontroller:cities">
    <li>{{city_name}}</li>
</ul>
<script>
    console.log('** mycityview **');
    var myCityList = znetdkMobile.list.make('#citylist');
    myCityList.beforeSearchRequestCallback = function(requestData) {
        var countryId = $('#countrylist').data('selected-country-id');
        requestData.country_id = countryId;        
    };    
</script>

4) Dans le contrôleur en charge de retourner la liste des villes, lire le paramètre POST (country_id) et ne retourner que les villes correspondantes.

<?php
/* Contrôleur mycontroller.php */
namespace app\controller;
class MyController extends \AppController {
    static protected function action_countries() {

        $countries = [
            ['country_id' => 'fr', 'country_name' => 'France'],
            ['country_id' => 'uk', 'country_name' => 'Royaume-uni'],
            ['country_id' => 'es', 'country_name' => 'Espagne'],
            ['country_id' => 'it', 'country_name' => 'Italie'],
        ];
        $response = new \Response();
        $response->rows = $countries;
        $response->total = count($countries);
        return $response;
    }

    static protected function action_cities() {        
        $allCities = [
            ['country_id' => 'fr', 'city_id' => 'fr1',  'city_name' => 'Paris'],
            ['country_id' => 'fr', 'city_id' => 'fr2',  'city_name' => 'Lyon'],
            ['country_id' => 'fr', 'city_id' => 'fr3',  'city_name' => 'Marseille'],
            ['country_id' => 'uk', 'city_id' => 'uk1',  'city_name' => 'London'],
            ['country_id' => 'uk', 'city_id' => 'uk2',  'city_name' => 'Manchester'],
            ['country_id' => 'uk', 'city_id' => 'uk3',  'city_name' => 'Glasgow'],
            ['country_id' => 'es', 'city_id' => 'es1',  'city_name' => 'Madrid'],
            ['country_id' => 'es', 'city_id' => 'es2',  'city_name' => 'Barcelone'],
            ['country_id' => 'es', 'city_id' => 'es3',  'city_name' => 'Grenade']
        ];
        $cities = [];
        $request = new \Request();
        if ($request->country_id !== NULL) {
            foreach ($allCities as $city) {
                if ($city['country_id'] === $request->country_id) {
                    $cities[] = $city;
                }
            }
        } else {
            $cities = $allCities;
        }
        $response = new \Response();
        $response->rows = $cities;
        $response->total = count($cities);
        return $response;
    }
}

En espérant vous avoir aidé.

Pascal MARTINEZ
ZnetDK developer

Comment aller d'une page à l'autre
Sun, 23 Jan 2022 07:48:29

Bonjour,
Je viens de commencer avec ZnetDk et j'ai du mal à aller d'une page à l'autre.
Par exemple: J'ai une liste de pays sur une page et en clickant sur un items pays, je retrouve la liste des villes associées à ce pays.
Cordialement.

Code Snippets: Showing your geolocation with OpenStreetMap
Sun, 09 Jan 2022 21:59:03

Hello,

The ZnetDK 4 Mobile website was updated this week with new code snippets for Showing your geolocation with OpenStreetMap.
See the step-by-step procedure to add this functionality to the ZnetDK 4 Mobile Starter application.

Hoping you'll enjoy,

Pascal
ZnetDK developer.

Code Snippets: Sending email with PHPMailer
Fri, 15 Oct 2021 16:41:23

Hello,

The ZnetDK 4 Mobile website was updated this week with new code snippets for Sending email with PHPMailer.
See the step-by-step procedure to add this functionality to the ZnetDK 4 Mobile Starter application.

Hoping you'll enjoy,

Pascal
ZnetDK developer.