]> git.agnieray.net Git - galette.git/commitdiff
Rely on static methods rather than constants comparison
authorJohan Cwiklinski <johan@x-tnd.be>
Wed, 8 Nov 2023 04:32:13 +0000 (05:32 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Wed, 8 Nov 2023 04:44:09 +0000 (05:44 +0100)
Impacts:
- DEV mode
- DEMO mode
- GALETTE_SQL_DEBUG
- GALETTE_NIGHTLY

23 files changed:
galette/includes/dependencies.php
galette/includes/galette.inc.php
galette/includes/i18n.inc.php
galette/includes/main.inc.php
galette/lib/Galette/Controllers/Crud/DynamicFieldsController.php
galette/lib/Galette/Controllers/Crud/MailingsController.php
galette/lib/Galette/Controllers/GaletteController.php
galette/lib/Galette/Controllers/PluginsController.php
galette/lib/Galette/Core/Db.php
galette/lib/Galette/Core/Galette.php
galette/lib/Galette/Core/GaletteMail.php
galette/lib/Galette/Core/LightSlimApp.php
galette/lib/Galette/Core/Preferences.php
galette/lib/Galette/Core/SysInfos.php
galette/lib/Galette/IO/News.php
galette/templates/default/components/forms/picture.html.twig
galette/templates/default/elements/modes.html.twig
galette/templates/default/elements/navigation/navigation_topbar.html.twig
galette/templates/default/pages/500.html.twig
galette/templates/default/pages/desktop.html.twig
galette/templates/default/pages/mailing_form.html.twig
galette/templates/default/pages/plugins.html.twig
galette/templates/default/pages/preferences.html.twig

index 04c0f7efb1ff93cce4e53d1b5cd084a31aa45ab1..8a751a9c00e9fa16e7532549be5b55b00225e501 100644 (file)
@@ -72,14 +72,14 @@ $container->set('Slim\Views\Twig', function (ContainerInterface $c) {
         $templates,
         [
             'cache' => rtrim(GALETTE_CACHE_DIR, DIRECTORY_SEPARATOR),
-            'debug' => (GALETTE_MODE === \Galette\Core\Galette::MODE_DEV),
-            'strict_variables' => (GALETTE_MODE == \Galette\Core\Galette::MODE_DEV)
+            'debug' => \Galette\Core\Galette::isDebugEnabled(),
+            'strict_variables' => \Galette\Core\Galette::isDebugEnabled()
         ]
     );
 
     //Twig extensions
     $view->addExtension(new \Galette\Twig\CsrfExtension($c->get('csrf')));
-    if (GALETTE_MODE === \Galette\Core\Galette::MODE_DEV) {
+    if (\Galette\Core\Galette::isDebugEnabled()) {
         $view->addExtension(new \Twig\Extension\DebugExtension());
     }
     //End Twig extensions
index e8b59483700c7e1c0eb26bef858388f9abcf7186..5b5897e736262dc4c907e529abbb291aae54a7ce 100644 (file)
@@ -142,7 +142,7 @@ Analog::$format = "%s - %s - %s - %s\n";
 $galette_run_log = null;
 
 if (!defined('GALETTE_LOG_LVL')) {
-    if (GALETTE_MODE === 'DEV') {
+    if (\Galette\Core\Galette::isDebugEnabled()) {
         define('GALETTE_LOG_LVL', Analog::DEBUG);
     } elseif (defined('GALETTE_TESTS')) {
         define('GALETTE_LOG_LVL', Analog::NOTICE);
index 395e223181f3e63cff039b426664a604d323be8c..b1360a41b2f7d148101f7ec4109fd4a2c38501e6 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2003-2020 The Galette Team
+ * Copyright © 2003-2023 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -30,7 +30,7 @@
  * @author    Frédéric Jacquot <unknown@unknow.com>
  * @author    Georges Khaznadar (i18n using gettext) <unknown@unknow.com>
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2003-2020 The Galette Team
+ * @copyright 2003-2023 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.62
@@ -41,8 +41,7 @@ if (!defined('GALETTE_ROOT')) {
 }
 
 use Analog\Analog;
-use Laminas\Db\Sql\Expression;
-use Galette\Core\L10n;
+use Galette\Core\Galette;
 
 $i18n->updateEnv();
 global $language;
@@ -92,7 +91,7 @@ function _T($string, $domain = 'galette', $nt = true)
     if (!$trans) {
         $trans = $string;
 
-        if (GALETTE_MODE == 'DEV' && $nt === true) {
+        if (Galette::isDebugEnabled() && $nt === true) {
             $trans .= ' (not translated)';
         }
     }
@@ -145,7 +144,7 @@ function _Tn($singular, $plural, $count, $domain = 'galette', $nt = true)
     if (!$trans) {
         $trans = ($count > 1 ? $plural : $singular);
 
-        if (GALETTE_MODE == 'DEV' && $nt === true) {
+        if (Galette::isDebugEnabled() && $nt === true) {
             $trans .= ' (not translated)';
         }
     }
@@ -183,7 +182,7 @@ function _Tx($context, $string, $domain = 'galette', $nt = true)
     if (!$trans) {
         $trans = $ret;
 
-        if (GALETTE_MODE == 'DEV' && $nt === true) {
+        if (Galette::isDebugEnabled() && $nt === true) {
             $trans .= ' (not translated)';
         }
     }
@@ -236,7 +235,7 @@ function _Tnx($context, $singular, $plural, $count, $domain = 'galette', $nt = t
     if (!$trans) {
         $trans = $ret;
 
-        if (GALETTE_MODE == 'DEV' && $nt === true) {
+        if (Galette::isDebugEnabled() && $nt === true) {
             $trans .= ' (not translated)';
         }
     }
index 7f27eab445c1e01aa7bd51a34a6d958f476b81db..9ee31b98ef18e90331bcb28321f3c91ce90330f9 100644 (file)
@@ -227,7 +227,7 @@ $app->addRoutingMiddleware();
  * for middleware added after it.
  */
 $errorMiddleware = $app->addErrorMiddleware(
-    (GALETTE_MODE === 'DEV'),
+    Galette::isDebugEnabled(),
     true,
     true
 );
index 367d3138e0291e949e17d0ca690c1ec92bdadadd..f18495d7995b52942b89522dd10868ad3f19aeca 100644 (file)
@@ -36,6 +36,7 @@
 
 namespace Galette\Controllers\Crud;
 
+use Galette\Core\Galette;
 use Galette\IO\File;
 use Galette\Repository\DynamicFieldsSet;
 use Throwable;
@@ -132,7 +133,7 @@ class DynamicFieldsController extends CrudController
                 $e->getMessage(),
                 Analog::ERROR
             );
-            if (GALETTE_MODE == 'DEV') {
+            if (Galette::isDebugEnabled()) {
                 throw $e;
             }
             $error_detected[] = _T('An error occurred adding dynamic field :(');
@@ -478,7 +479,7 @@ class DynamicFieldsController extends CrudController
                 $e->getMessage(),
                 Analog::ERROR
             );
-            if (GALETTE_MODE == 'DEV') {
+            if (Galette::isDebugEnabled()) {
                 throw $e;
             }
             $error_detected[] = _T('An error occurred editing dynamic field :(');
index 457cdd8174aaf75ad1222a42743effe40bae085e..e7523c23fffb04ed210379b2c9075d878ae53b78 100644 (file)
@@ -97,7 +97,7 @@ class MailingsController extends CrudController
 
         if (
             $this->preferences->pref_mail_method == Mailing::METHOD_DISABLED
-            && !(GALETTE_MODE === Galette::MODE_DEMO)
+            && !Galette::isDemo()
         ) {
             $this->history->add(
                 _T("Trying to load mailing while email is disabled in preferences.")
@@ -249,7 +249,7 @@ class MailingsController extends CrudController
 
         if (
             $this->preferences->pref_mail_method == Mailing::METHOD_DISABLED
-            && !(GALETTE_MODE === Galette::MODE_DEMO)
+            && !Galette::isDemo()
         ) {
             $this->history->add(
                 _T("Trying to load mailing while email is disabled in preferences.")
index 43c6e73271a78365a48fc3e12fa14a10bcceae1f..ec8922a685dcfa9406389cb51137413806747e3c 100644 (file)
@@ -188,7 +188,7 @@ class GaletteController extends AbstractController
             'pref_card_vspace'      => 1
         );
 
-        if ($this->login->isSuperAdmin() && GALETTE_MODE !== Galette::MODE_DEMO) {
+        if ($this->login->isSuperAdmin() && !Galette::isDemo()) {
             $required['pref_admin_login'] = 1;
         }
 
@@ -295,7 +295,7 @@ class GaletteController extends AbstractController
                 $warning_detected = array_merge($warning_detected, $this->preferences->checkCardsSizes());
 
                 // picture upload
-                if (GALETTE_MODE !== Galette::MODE_DEMO && isset($_FILES['logo'])) {
+                if (!Galette::isDemo() && isset($_FILES['logo'])) {
                     if ($_FILES['logo']['error'] === UPLOAD_ERR_OK) {
                         if ($_FILES['logo']['tmp_name'] != '') {
                             if (is_uploaded_file($_FILES['logo']['tmp_name'])) {
@@ -318,7 +318,7 @@ class GaletteController extends AbstractController
                     }
                 }
 
-                if (GALETTE_MODE !== Galette::MODE_DEMO && isset($post['del_logo'])) {
+                if (!Galette::isDemo() && isset($post['del_logo'])) {
                     if (!$this->logo->delete()) {
                         $error_detected[] = _T("Delete failed");
                     } else {
@@ -327,7 +327,7 @@ class GaletteController extends AbstractController
                 }
 
                 // Card logo upload
-                if (GALETTE_MODE !== Galette::MODE_DEMO && isset($_FILES['card_logo'])) {
+                if (!Galette::isDemo() && isset($_FILES['card_logo'])) {
                     if ($_FILES['card_logo']['error'] === UPLOAD_ERR_OK) {
                         if ($_FILES['card_logo']['tmp_name'] != '') {
                             if (is_uploaded_file($_FILES['card_logo']['tmp_name'])) {
@@ -350,7 +350,7 @@ class GaletteController extends AbstractController
                     }
                 }
 
-                if (GALETTE_MODE !== Galette::MODE_DEMO && isset($post['del_card_logo'])) {
+                if (!Galette::isDemo() && isset($post['del_card_logo'])) {
                     if (!$this->print_logo->delete()) {
                         $error_detected[] = _T("Delete failed");
                     } else {
index 251ca11898de7ae36f6848c11c8c203276af8140..6354e7652b9541d372e18246941d8fabc9e3c6f6 100644 (file)
@@ -100,7 +100,7 @@ class PluginsController extends AbstractController
      */
     public function togglePlugin(Request $request, Response $response, string $action, string $module_id): Response
     {
-        if (GALETTE_MODE !== Galette::MODE_DEMO) {
+        if (!Galette::isDemo()) {
             $plugins = $this->plugins;
             $reload_plugins = false;
             if ($action == 'activate') {
@@ -163,7 +163,7 @@ class PluginsController extends AbstractController
      */
     public function initPluginDb(Request $request, Response $response, string $id): Response
     {
-        if (GALETTE_MODE === Galette::MODE_DEMO) {
+        if (Galette::isDemo()) {
             Analog::log(
                 'Trying to access plugin database initialization in DEMO mode.',
                 Analog::WARNING
index 7dbbfbce7ce0e46f6275eec6e83dbeffacde516b..52d2aa1b23cde01d50a903499e2dc26494005e0f 100644 (file)
@@ -236,7 +236,7 @@ class Db
      */
     public function checkDbVersion()
     {
-        if (GALETTE_MODE === 'DEV') {
+        if (Galette::isDebugEnabled()) {
             Analog::log(
                 'Database version not checked in DEV mode.',
                 Analog::INFO
@@ -983,7 +983,7 @@ class Db
      */
     protected function log($query)
     {
-        if (GALETTE_MODE == 'DEV' || defined('GALETTE_SQL_DEBUG')) {
+        if (Galette::isSqlDebugEnabled()) {
             $logfile = GALETTE_LOGS_PATH . 'galette_sql.log';
             file_put_contents($logfile, $query . "\n", FILE_APPEND);
         }
index c8dbb0000e40d57461a4f98b93291b36dc6feba4..d78183e06f1fa3663ca160445a4197186a195952 100644 (file)
@@ -68,7 +68,7 @@ class Galette
     {
         $galette_version = GALETTE_VERSION;
 
-        //used for both gith and nightly installs
+        //used for both git and nightly installs
         $version = str_replace('-dev', '-git', GALETTE_VERSION);
         if (strstr($version, '-git') === false) {
             $version .= '-git';
@@ -85,7 +85,7 @@ class Galette
                 $commitHash,
                 $commitDate->format(($time ? 'Y-m-d H:i:s T' : 'Y-m-d'))
             );
-        } elseif (GALETTE_NIGHTLY !== false) {
+        } elseif (static::isNightly()) {
             $galette_version = $version . '-' . GALETTE_NIGHTLY;
         }
         return $galette_version;
@@ -942,4 +942,44 @@ class Galette
         }
         return $actions;
     }
+
+    /**
+     * Is demonstration mode enabled
+     *
+     * @return bool
+     */
+    public static function isDemo(): bool
+    {
+        return GALETTE_MODE === static::MODE_DEMO;
+    }
+
+    /**
+     * Is debug mode enabled
+     *
+     * @return bool
+     */
+    public static function isDebugEnabled(): bool
+    {
+        return GALETTE_MODE === static::MODE_DEV;
+    }
+
+    /**
+     * Is SQL debug mode enabled
+     *
+     * @return bool
+     */
+    public static function isSqlDebugEnabled(): bool
+    {
+        return defined('GALETTE_SQL_DEBUG') || static::isDebugEnabled();
+    }
+
+    /**
+     * Is a nightly build
+     *
+     * @return bool
+     */
+    public static function isNightly(): bool
+    {
+        return GALETTE_NIGHTLY !== false;
+    }
 }
index c54741853bd61f5b5aa46cc1336b2239503d8b64..18517c8dd2b0b521df3755b566d480c2da49613c 100644 (file)
@@ -116,7 +116,7 @@ class GaletteMail
                 //if we want to send emails using a smtp server
                 $this->mail->IsSMTP();
                 // enables SMTP debug information
-                if (GALETTE_MODE == 'DEV') {
+                if (Galette::isDebugEnabled()) {
                     $this->mail->SMTPDebug = 4;
                     //cannot use a callable here; this prevents class to be serialized
                     //see https://bugs.galette.eu/issues/1468
index e50d51455bd2719ca678814cea63c0473b6081cd..7f9fd0b17ca32312abd87de5e72b8aa8cf35102b 100644 (file)
@@ -71,7 +71,7 @@ class LightSlimApp
         $builder->useAttributes(true);
         $builder->addDefinitions([
             'templates.path'                    => GALETTE_ROOT . GALETTE_THEME,
-            'settings.displayErrorDetails'      => (GALETTE_MODE === 'DEV'),
+            'settings.displayErrorDetails'      => Galette::isDebugEnabled(),
             'settings.addContentLengthHeader'   => false,
             'galette'                           => [
                 'mode'      => $this->mode,
index e3bedf85b93f8053f40dc121069b5d4d41e4ea07..e8ff0954143782a61a4880a44faa54cf7da4d6a1 100644 (file)
@@ -496,7 +496,7 @@ class Preferences
     public function check(array $values, Login $login)
     {
         $insert_values = array();
-        if ($login->isSuperAdmin() && GALETTE_MODE !== Galette::MODE_DEMO) {
+        if ($login->isSuperAdmin() && !Galette::isDemo()) {
             $this->required[] = 'pref_admin_login';
         }
 
@@ -512,7 +512,7 @@ class Preferences
         }
 
         //cleanup fields for demo
-        if (GALETTE_MODE == Galette::MODE_DEMO) {
+        if (Galette::isDemo()) {
             unset(
                 $insert_values['pref_admin_login'],
                 $insert_values['pref_admin_pass'],
@@ -522,7 +522,7 @@ class Preferences
 
         // missing relations
         if (
-            GALETTE_MODE !== Galette::MODE_DEMO
+            !Galette::isDemo()
             && isset($insert_values['pref_mail_method'])
         ) {
             if ($insert_values['pref_mail_method'] > GaletteMail::METHOD_DISABLED) {
@@ -596,7 +596,7 @@ class Preferences
             }
         }
 
-        if (GALETTE_MODE !== Galette::MODE_DEMO && isset($values['pref_admin_pass_check'])) {
+        if (!Galette::isDemo() && isset($values['pref_admin_pass_check'])) {
             // Check passwords. Hash will be done into the Preferences class
             if (strcmp($insert_values['pref_admin_pass'], $values['pref_admin_pass_check']) != 0) {
                 $this->errors[] = _T("Passwords mismatch");
@@ -674,7 +674,7 @@ class Preferences
                 }
                 break;
             case 'pref_admin_login':
-                if (GALETTE_MODE === Galette::MODE_DEMO) {
+                if (Galette::isDemo()) {
                     Analog::log(
                         'Trying to set superadmin login while in DEMO.',
                         Analog::WARNING
@@ -729,7 +729,7 @@ class Preferences
                 }
                 break;
             case 'pref_admin_pass':
-                if (GALETTE_MODE == Galette::MODE_DEMO) {
+                if (Galette::isDemo()) {
                     Analog::log(
                         'Trying to set superadmin pass while in DEMO.',
                         Analog::WARNING
@@ -799,7 +799,7 @@ class Preferences
 
             foreach (self::$defaults as $k => $v) {
                 if (
-                    GALETTE_MODE == Galette::MODE_DEMO
+                    Galette::isDemo()
                     && in_array($k, ['pref_admin_pass', 'pref_admin_login', 'pref_mail_method'])
                 ) {
                     continue;
@@ -970,7 +970,7 @@ class Preferences
 
         if (!in_array($name, $forbidden) && isset($this->prefs[$name])) {
             if (
-                GALETTE_MODE === Galette::MODE_DEMO
+                Galette::isDemo()
                 && $name == 'pref_mail_method'
             ) {
                 return GaletteMail::METHOD_DISABLED;
@@ -1071,7 +1071,7 @@ class Preferences
             || $name == 'pref_email_newadh'
             || $name == 'pref_email_reply_to'
         ) {
-            if (GALETTE_MODE === Galette::MODE_DEMO) {
+            if (Galette::isDemo()) {
                 Analog::log(
                     'Trying to set pref_email while in DEMO.',
                     Analog::WARNING
index abc48bf55fd784b2d3c32d7528e9d79a6f199e92..816b1adb75dc83e22fd7faf156451514f9a4c1d3 100644 (file)
@@ -65,7 +65,7 @@ class SysInfos
 
         $str = str_pad('Galette version:', 20, '.') . ' ' . \Galette\Core\Galette::gitVersion(true) . "\n";
 
-        if (GALETTE_MODE == \Galette\Core\Galette::MODE_DEMO) {
+        if (Galette::isDemo()) {
             $str .= $this->getPluginsInfo($plugins);
             return $str;
         }
index bab8414900deef867bf49bfe2461faa12e8e5037..009c6b8ee8f393833ab308c4e25aa11c50088120 100644 (file)
@@ -36,6 +36,7 @@
 
 namespace Galette\IO;
 
+use Galette\Core\Galette;
 use Throwable;
 use Analog\Analog;
 
@@ -76,7 +77,7 @@ class News
         $this->feed_url = $this->getFeedURL($url);
 
         //only if cache should be used
-        if ($nocache === false && GALETTE_MODE !== 'DEV') {
+        if ($nocache === false && !Galette::isDebugEnabled()) {
             if (!$this->checkCache()) {
                 $this->makeCache();
             } else {
index 71376ff6ab4846e9dee35422090e6829893bfc5c..176c3d821899723ca0e44c8705d5f38fedc3a307 100644 (file)
@@ -13,7 +13,7 @@
             <div class="description">
                 <div class="ui file action input">
                     <input id="photo_new" type="file" name="photo"/>
-                    <label for="photo_new" class="ui button{% if constant('GALETTE_MODE') == constant('\\Galette\\Core\\Galette::MODE_DEMO') %} disabled{% endif %}">
+                    <label for="photo_new" class="ui button{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled{% endif %}">
                         <i class="blue upload icon" aria-hidden="true"></i>
                         {% if member.hasPicture() == 1 %}{{ _T("Choose another file") }}{% else %}{{ _T("Choose a file") }}{% endif %}
                     </label>
index 3b43659f7949c8c9e0379749643d7b70b830a828..e7c3b9e0fc591c015e3b6a82cb5450da3ea74bbf 100644 (file)
@@ -4,7 +4,7 @@
         {{ _T("Superadmin") }}
     </span>
 {% endif %}
-{% if constant('GALETTE_MODE') == 'DEMO' %}
+{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
     <span class="tooltip ui orange icon circular label" title="{{ _T("This application runs under DEMO mode, all features may not be available.") }}">
         <i class="gamepad icon" aria-hidden="true"></i>
         {{ _T("Demonstration") }}
index baad7d588e9ffae99513a434b754536631f6b838..993b6e0171b2ad80b45a04f6e5de9f2d05742407 100644 (file)
@@ -30,7 +30,7 @@
                 ui: "dropdown"
         } %}
 
-        {% if constant('GALETTE_MODE') == 'DEMO' %}
+        {% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
             <div class="item">
                 {% include "elements/modes.html.twig" %}
             </div>
index 16b85e9f9410dea13ff8f7ed1a93b3b1744530f4..d33e2b53d5014ce1caaa6f59e9257e9d49654459 100644 (file)
@@ -38,7 +38,7 @@
         <h2 class="ui center aligned header">{{ _T("Application error") }}</h2>
     </div>
 
-    {% if login.isLogged() and login.isAdmin() or constant('GALETTE_MODE') == 'DEV' %}
+    {% if login.isLogged() and login.isAdmin() or callstatic('\\Galette\\Core\\Galette', 'isDebugEnabled') %}
         {{ _self.render_ex(exception) }}
     {% endif %}
 {% endblock %}
index 659a1ebefa21579b25a150151d955f018e22a948..e2f67fea6ee3777b2c158de9adf4222c3a22d6a0 100644 (file)
@@ -4,7 +4,7 @@
 
 {% block content %}
     <div class="ui grid">
-{% if not hide_telemetry and constant('GALETTE_MODE') != 'DEMO' %}
+{% if not hide_telemetry and not callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
         <div class="sixteen wide column">
             <div class="ui yellow message">
                 <div class="header">{{ _T("Help us know about you!") }}</div>
index b810e02d8e57d146240ec98f7bb778c88eab3baf..04da0b441fffeb00ffef96f3332318b6ed7ee20b 100644 (file)
@@ -1,7 +1,7 @@
 {% extends 'page.html.twig' %}
 
 {% block content %}
-{% if preferences.pref_mail_method == constant('Galette\\Core\\Mailing::METHOD_DISABLED') and constant('GALETTE_MODE') != 'DEMO' %}
+{% if preferences.pref_mail_method == constant('Galette\\Core\\Mailing::METHOD_DISABLED') and not callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
         <div id="errorbox" class="ui negative icon message">
             <i class="ban icon" aria-hidden="true"></i>
             <div class="content">
                         <i class="save green icon" aria-hidden="true"></i>
                         {{ _T("Save") }}
                     </button>
-                    <button type="submit" name="mailing_confirm" class="ui labeled icon button {% if constant('GALETTE_MODE') == 'DEMO' %} disabled" disabled="disabled{% endif %}">
+                    <button type="submit" name="mailing_confirm" class="ui labeled icon button {% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled" disabled="disabled{% endif %}">
                         <i class="rocket red icon" aria-hidden="true"></i>
                         {{ _T("Send") }}
                     </button>
                         <i class="backward icon" aria-hidden="true"></i>
                         {{ _T("Modifiy mailing") }}
                     </button>
-                    <button type="submit" name="mailing_confirm"{% if constant('GALETTE_MODE') == 'DEMO' %} class="ui labeled icon button disabled" disabled="disabled"{% else %} class="ui labeled icon button"{% endif %}>
+                    <button type="submit" name="mailing_confirm"{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} class="ui labeled icon button disabled" disabled="disabled"{% else %} class="ui labeled icon button"{% endif %}>
                         <i class="rocket icon" aria-hidden="true"></i>
                         {{ _T("Send") }}
                     </button>
 {% endblock %}
 
 {% block javascripts %}
-{% if (preferences.pref_mail_method != constant('Galette\\Core\\Mailing::METHOD_DISABLED') or constant('GALETTE_MODE') != 'DEMO') and mailing_saved is not defined %}
+{% if (preferences.pref_mail_method != constant('Galette\\Core\\Mailing::METHOD_DISABLED') or not callstatic('\\Galette\\Core\\Galette', 'isDemo')) and mailing_saved is not defined %}
     {% if mailing.current_step != constant('Galette\\Core\\Mailing::STEP_SENT') %}
 <script type="text/javascript">
     $(function() {
index d38d8bf4d202526020643f1c709ae721960ed616..72e1b5b8c88681dc19f25eb340cb6a460d0c5ec0 100644 (file)
@@ -98,7 +98,7 @@
 {% block javascripts %}
     <script type="text/javascript">
         $(function() {
-    {% if constant('GALETTE_MODE') == 'DEMO' %}
+    {% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
             $('.initdb, a.toggleActivation').click(function(){
                 {% include "elements/js/modal.js.twig" with {
                     modal_title_twig: _T("Application runs under demo mode. This functionnality is not enabled, sorry.")|e("js"),
index 3854de67005a9546571ea132cf76633f0ac34b6e..01700108f7278708705cafe3a2e70ea2153da0b3 100644 (file)
@@ -53,8 +53,8 @@
                             <div class="content">
                                 <div class="description">
                                     <div class="ui file action input">
-                                        <input type="file" name="logo" id="logo_picture"{% if constant('GALETTE_MODE') == constant('\\Galette\\Core\\Galette::MODE_DEMO') %} disabled="disabled"{% endif %}/>
-                                        <label for="logo_picture" class="ui button{% if constant('GALETTE_MODE') == constant('\\Galette\\Core\\Galette::MODE_DEMO') %} disabled{% endif %}">
+                                        <input type="file" name="logo" id="logo_picture"{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled="disabled"{% endif %}/>
+                                        <label for="logo_picture" class="ui button{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled{% endif %}">
                                             <i class="blue upload icon" aria-hidden="true"></i>
                                             {% if logo.isCustom() %}{{ _T("Choose another file") }}{% else %}{{ _T("Choose a file") }}{% endif %}
                                         </label>
             </div>
         </div>{# /tab segment #}
         <div class="ui{{ tab == 'mail' ? ' active' }} tab segment" data-tab="mail">
-    {% if constant('GALETTE_MODE') == constant('\\Galette\\Core\\Galette::MODE_DEMO') %}
+    {% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
             <div class="ui icon negative message">
                 <i class="ban icon" aria-hidden="true"></i>
                 <div class="content">
                             <div class="content">
                                 <div class="description">
                                     <div class="ui file action input">
-                                        <input type="file" name="card_logo" id="card_logo"{% if constant('GALETTE_MODE') == constant('Galette\\Core\\Galette::MODE_DEMO') %} disabled="disabled"{% endif %}/>
-                                        <label for="card_logo" class="ui button{% if constant('GALETTE_MODE') == constant('\\Galette\\Core\\Galette::MODE_DEMO') %} disabled{% endif %}">
+                                        <input type="file" name="card_logo" id="card_logo"{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled="disabled"{% endif %}/>
+                                        <label for="card_logo" class="ui button{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled{% endif %}">
                                             <i class="blue upload icon" aria-hidden="true"></i>
                                             {% if print_logo.isCustom() %}{{ _T("Choose another file") }}{% else %}{{ _T("Choose a file") }}{% endif %}
                                         </label>
 {% endif %}
 {% if login.isSuperAdmin() %}
         <div class="ui{{ tab == 'admin' ? ' active' }} tab red segment" data-tab="admin">
-    {% if constant('GALETTE_MODE') == constant('\\Galette\\Core\\Galette::MODE_DEMO') %}
+    {% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
                 <div class="ui icon negative message">
                     <i class="ban icon" aria-hidden="true"></i>
                     <div class="content">