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

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.

ZnetDK 4 Mobile v2.5 is released
Fri, 08 Oct 2021 14:38:09

Hello,

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

  • CHANGE: new \General::callRemoteAction() method usefull to invoke a controller action exposed as web service by a remote ZnetDK application.
  • CHANGE: new CFG_SQL_TRACE_ENABLED parameter which traces in the system log all SQL statements executed through the ZnetDK \DAO class.
  • CHANGE: new \UserSession::getUserId() method that returns the user ID of the connected user.
  • CHANGE: new zdk_user_pwd_resets SQL table for tracing reset password requests. The database schema can be upgraded for applications deployed in a previous version of ZnetDK by executing the following DDL statement:

CREATE TABLE `zdk_user_pwd_resets` (
`email` VARCHAR(100) NOT NULL COMMENT 'Email address',
`request_date_time` DATETIME NOT NULL COMMENT 'Request date time',
`reset_key` VARCHAR(100) NOT NULL COMMENT 'Reset key',
UNIQUE `email` (`email`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci
COMMENT = 'Password reset';

For any new applications, just download the znetdk-security-1.6.zip archive from the ZnetDK download page to install the security SQL tables corresponding to this version.

  • CHANGE: new CFG_FORGOT_PASSWORD_ENABLED parameter to display a link labeled 'Forgot password?' on the login form. When clicked, the ZnetDK 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 to the view/ folder of the application or a module.
  • CHANGE: new controller\ForgotPassword class in charge of displaying the forgotpassword.php view when the 'Forgot password?' link is clicked. In addition, the controller processes the requests for getting a new password and for resetting the user's password.
    This controller can be overloaded by the application or a module for customization purpose.
  • CHANGE: new CFG_FORGOT_PASSWORD_REQUEST_TRACE_ENABLED parameter to trace the
    requests for a new password to the ZnetDK system log file.
  • CHANGE: new 'Archived' user's status and new 'Status' datatable filter to limit display to users matching a given status ('Enabled', 'Disabled' or 'Archived'). An archived user is not allowed to log in to the application and can't request a new password through the 'Forgot password?' link.
  • CHANGE: the verification of the login name during authentication process is now case sensitive. This means that a user declared for example with the login name 'JohnDoe' can no longer log in if he enters 'JOHNdoe'.
  • BUG FIXING: the filename defined for the \Response::setFileToDownload() method was not properly displayed by the web browser when it contained accents.
  • BUG FIXING (for mobile only): when the znetdkMobile.setInputValue() method was called for a checkbox element with a non-empty value different than the one set for the checkbox element, it was not unchecked.
  • BUG FIXING: 'Remember me' checkbox state change event handler was incorrectly declared each time the login form was displayed for the user's session renewal.
  • BUG FIXING: focus wrongly applied to the show/hide password button instead of the password entry field.
  • BUG FIXING: error ENOTICE - Trying to access array offset on value of type null in profilemanager.php(126) when the user profile view (profile.php) was displayed in PHP 7.4.
  • BUG FIXING: the callback function specified for the znetdkMobile.messages.ask() method could be executed twice wrongly.
  • BUG FIXING: the Phone and Note labels of the z4musers.php view were not displayed in bold.
  • BUG FIXING: when the page header was hidden after calling the znetdkMobile.header.events.handleHideHeaderOnScroll() method, no extra space
    was longer added to the page's anchors through the inline #zdk-anchor-adjust CSS style (bug finally not fixed in version 2.4).

Pascal,
ZnetDK developer

Code Snippets: Multilingual Application
Sun, 09 May 2021 21:15:34

Hello,

The ZnetDK 4 Mobile website was updated this week with new code snippets for developping a Multilingual 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.