|
| 1 | +# ZnetDK 4 Module theme chooser |
| 2 | +Allows the ZnetDK 4 Mobile application to be displayed with a dark theme. |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +## FEATURES |
| 7 | +This module add a "Theme" button to the User Panel. |
| 8 | +When clicked, a modal dialog is displayed to apply the dark theme or to come |
| 9 | +back to the light theme. |
| 10 | +The favorite theme is saved in database for the logged in user. |
| 11 | + |
| 12 | +## REQUIREMENTS |
| 13 | +- [ZnetDK 4 Mobile](/../../../znetdk4mobile) version 3.2 or higher, |
| 14 | +- A **MySQL** database is configured to store the application data, |
| 15 | +- **PHP version 7.4** or higher, |
| 16 | +- Authentication is enabled |
| 17 | +([`CFG_AUTHENT_REQUIRED`](https://mobile.znetdk.fr/settings#z4m-settings-auth-required) |
| 18 | +is `TRUE` in the App's |
| 19 | +[`config.php`](/../../../znetdk4mobile/blob/master/applications/default/app/config.php)). |
| 20 | + |
| 21 | +## INSTALLATION |
| 22 | +1. Copy module's code in the `./engine/modules/z4m_themechooser/` subdirectory, |
| 23 | +2. Edit the App's [`config.php`](/../../../znetdk4mobile/blob/master/applications/default/app/config.php) |
| 24 | +located in the [`./applications/default/app/`](/../../../znetdk4mobile/tree/master/applications/default/app/) subfolder and set the path or URL of your dark theme CSS stylesheet to the `MOD_Z4M_THEMECHOOSER_CSS_DARK_THEME` PHP constant. |
| 25 | +If the app logo to be displayed for dark theme is different from the one for light theme, also set the path of your light and dark logos to the `MOD_Z4M_THEMECHOOSER_LOGO_LIGHT_THEME` and `MOD_Z4M_THEMECHOOSER_LOGO_DARK_THEME` PHP constants. |
| 26 | +For example: |
| 27 | +```php |
| 28 | +define('MOD_Z4M_THEMECHOOSER_CSS_DARK_THEME', 'applications/'.ZNETDK_APP_NAME.'/public/css/theme-dark.css'); |
| 29 | +// Optional: the paths of the light and dark logos |
| 30 | +define('MOD_Z4M_THEMECHOOSER_LOGO_LIGHT_THEME', 'applications/'.ZNETDK_APP_NAME.'/public/images/logo-light.png'); |
| 31 | +define('MOD_Z4M_THEMECHOOSER_LOGO_DARK_THEME', 'applications/'.ZNETDK_APP_NAME.'/public/images/logo-dark.png'); |
| 32 | +``` |
| 33 | +3. In option, If the app logo to be displayed for dark theme is different from the one for light theme, |
| 34 | + edit the [`locale.php`](/../../../znetdk4mobile/blob/master/applications/default/app/lang/locale.php) script of your application |
| 35 | + and set the `LC_HEAD_IMG_LOGO` PHP constant to the path of the dark logo if dark theme is to be displayed. |
| 36 | +For example: |
| 37 | +```php |
| 38 | +/* Heading images */ |
| 39 | +use z4m_themechooser\mod\controller\Users; |
| 40 | +if (Users::getUserTheme() === MOD_Z4M_THEMECHOOSER_CSS_DARK_THEME) { |
| 41 | + define('LC_HEAD_IMG_LOGO', MOD_Z4M_THEMECHOOSER_LOGO_DARK_THEME); |
| 42 | +} else { |
| 43 | + define('LC_HEAD_IMG_LOGO', MOD_Z4M_THEMECHOOSER_LOGO_LIGHT_THEME); |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +## TRANSLATIONS |
| 48 | +This module is translated in **French**, **English** and **Spanish** languages. |
| 49 | +To translate this module in another language or change the standard |
| 50 | +translations: |
| 51 | +1. Copy in the clipboard the PHP constants declared within the |
| 52 | +[`locale_en.php`](mod/lang/locale_en.php) script of the module, |
| 53 | +2. Paste them from the clipboard within the |
| 54 | +[`locale.php`](/../../../znetdk4mobile/blob/master/applications/default/app/lang/locale.php) script of your application, |
| 55 | +3. Finally, translate each text associated with these PHP constants into your own language. |
| 56 | + |
| 57 | +## ISSUES |
| 58 | +The `zdk_user_themes` SQL table is created automatically by the module |
| 59 | +when the user's favorite theme is read or saved for the first time. |
| 60 | +If the MySQL user declared through the |
| 61 | +[`CFG_SQL_APPL_USR`](https://mobile.znetdk.fr/settings#z4m-settings-db-user) |
| 62 | +PHP constant does not have `CREATE` privilege, the module can't create the |
| 63 | +required SQL table. |
| 64 | +In this case, you can create the `zdk_user_themes` SQL table by importing |
| 65 | +in MySQL or phpMyAdmin the script |
| 66 | +[`z4m_themechooser.sql`](mod/sql/z4m_themechooser.sql) provided by the module. |
| 67 | + |
| 68 | +## CHANGE LOG |
| 69 | +See [CHANGELOG.md](CHANGELOG.md) file. |
| 70 | + |
| 71 | +## CONTRIBUTING |
| 72 | +Your contribution to the **ZnetDK 4 Mobile** project is welcome. Please refer to the [CONTRIBUTING.md](https://github.com/pascal-martinez/znetdk4mobile/blob/master/CONTRIBUTING.md) file. |
0 commit comments