The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings MonLabo
Summary Activity Tracker Tasks Docs SCM Files Dokuwiki Continious Integration Listes Sympa

SCM Repository

authorHerve Suaudeau <herve.suaudeau@parisdescartes.fr>
Wed, 23 Sep 2020 07:27:21 +0000 (09:27 +0200)
committerHerve Suaudeau <herve.suaudeau@parisdescartes.fr>
Wed, 23 Sep 2020 07:27:21 +0000 (09:27 +0200)
admin/MonLabo-admin.php
admin/MonLabo-edit-members.php
includes/MonLabo-db.php
includes/MonLabo-translate.php
includes/constants.php
mon-laboratoire.php

index dc6f4e3..fda6455 100644 (file)
@@ -180,12 +180,13 @@ class MonLabo_admin {
                } else {
                        $dissableThematic=true;
                }
+               $this->curent_settings_group='MonLabo_settings_group5';
+               $this->add_field( 'text_field',  'MonLabo_custom_text_Thematic_fr',     '', $dissableThematic, __( 'Nom du regroupement en français (singulier).', 'mon-laboratoire' ) );
+               $this->add_field( 'text_field',  'MonLabo_custom_text_Thematics_fr', '', $dissableThematic, __( 'Nom du regroupement en français (pluriel).', 'mon-laboratoire' ) );
+               $this->add_field( 'text_field',  'MonLabo_custom_text_Thematic_en',     '', $dissableThematic, __( 'Nom du regroupement en anglais (singulier).', 'mon-laboratoire' ) );
+               $this->add_field( 'text_field',  'MonLabo_custom_text_Thematics_en', '', $dissableThematic, __( 'Nom du regroupement en anglais (pluriel).', 'mon-laboratoire' ) );
 
-               $this->add_field( 'text_field',  'MonLabo_teamGroupName_fr',    '', $dissableThematic, __( 'Nom du regroupement en français (singulier).', 'mon-laboratoire' ) );
-               $this->add_field( 'text_field',  'MonLabo_teamGroupName_fr_pl', '', $dissableThematic, __( 'Nom du regroupement en français (pluriel).', 'mon-laboratoire' ) );
-               $this->add_field( 'text_field',  'MonLabo_teamGroupName_en',    '', $dissableThematic, __( 'Nom du regroupement en anglais (singulier).', 'mon-laboratoire' ) );
-               $this->add_field( 'text_field',  'MonLabo_teamGroupName_en_pl', '', $dissableThematic, __( 'Nom du regroupement en anglais (pluriel).', 'mon-laboratoire' ) );
-
+               $this->curent_settings_group='MonLabo_settings_group0';
                $this->add_field( 'checkbox2',  'MonLabo_uses_unites',            __( 'Unités multiples', 'mon-laboratoire' ),                            $disableMembers, __( 'Pour une structure rassemblant plusieurs laboratoires.', 'mon-laboratoire' ) );
                $this->add_field( 'hidden',  'MonLabo_activated_version',          '', true );
                $this->add_section( 'MonLabo_pluginPage_section_fonctionalites2', __( 'Fonctions avancées', 'mon-laboratoire' ), 'MonLaboPageFunctionalities' );
@@ -519,7 +520,7 @@ function MonLabo_admin_edit_members_and_groups_render() {
        echo( '<a href="?page=MonLabo_edit_members_and_groups&tab=tab_one" class="nav-tab ' . ( $active_tab === 'tab_one' ? 'nav-tab-active' : '' )  .'">'.__( 'Personnels', 'mon-laboratoire' ).'</a>' );
        echo( '<a href="?page=MonLabo_edit_members_and_groups&tab=tab_two" class="nav-tab ' . ( $active_tab === 'tab_two' ? 'nav-tab-active' : '' )  .'">'.__( 'Équipes', 'mon-laboratoire' ).'</a>' );
        if ( isset( $options0['MonLabo_uses_thematiques'] ) && ( intval( $options0['MonLabo_uses_thematiques'] ) === 1 ) ) {
-               echo( '<a href="?page=MonLabo_edit_members_and_groups&tab=tab_three" class="nav-tab ' . ( $active_tab === 'tab_three' ? 'nav-tab-active' : '' )  .'">'.MonLabo_translate::get_teamGroupName_pl().'</a>' );
+               echo( '<a href="?page=MonLabo_edit_members_and_groups&tab=tab_three" class="nav-tab ' . ( $active_tab === 'tab_three' ? 'nav-tab-active' : '' )  .'">'.MonLabo_translate::translate( 'Thematics' ).'</a>' );
        }
        if ( isset( $options0['MonLabo_uses_unites'] ) && ( intval( $options0['MonLabo_uses_unites'] ) === 1 ) ) {
                echo( '<a href="?page=MonLabo_edit_members_and_groups&tab=tab_four" class="nav-tab ' . ( $active_tab === 'tab_four' ? 'nav-tab-active' : '' ) .'">'.__( 'Unités', 'mon-laboratoire' ).'</a>' );
index f314934..df0f8e9 100644 (file)
@@ -419,7 +419,7 @@ function edit_teams_form() {
        if ( isset( $options0['MonLabo_uses_thematiques'] ) && ( intval( $options0['MonLabo_uses_thematiques'] ) === 1 ) ) { //On n'affiche cette option que si l'on gère les thématiques
                $all_thematics_name = $MonLabo_access_data->get_thematics_name( 'fr' );
                $thematics_name = $MonLabo_access_data->get_thematics_name_for_a_team( $team_id, 'fr' );
-               $retval .= generate_champ_formulaire_select_multiple( 'thematics', $all_thematics_name, false,  MonLabo_translate::get_teamGroupName_pl(),
+               $retval .= generate_champ_formulaire_select_multiple( 'thematics', $all_thematics_name, false,  MonLabo_translate::translate( 'Thematics' ),
                        get_MonLabo_Team_fields_comments( 'thematics' ), $thematics_name );
        }
        $retval .= '</fieldset>';
@@ -492,7 +492,7 @@ function edit_thematics_form() {
        $values = $thematics_name;
        $isMandatory = true;
 
-       $legend =  MonLabo_translate::get_teamGroupName();
+       $legend =  MonLabo_translate::translate( 'Thematic' );
        $description = '';
        $onchange='changeThematic(this.value)';
 
index ea90700..2e78f07 100644 (file)
@@ -343,13 +343,41 @@ class MonLabo_db {
                        } else {
                                $plugin_version = floatval( $options0['MonLabo_activated_version'] );
                        }
-                       if ( ( $plugin_version < 2.8 ) ) {
-                               //$this->migrate_to_version_2_8();
+                       if ( ( $plugin_version < 3.1 ) ) {
+                               $this->migrate_to_version_3_1();
                        }
                        return $this;
                }
        }
 
+       public function migrate_to_version_3_1() {
+               /* Transfer options ;
+               MonLabo_settings_group0:MonLabo_teamGroupName_fr    --> MonLabo_settings_group5:MonLabo_custom_text_Thematic_fr
+               MonLabo_settings_group0:MonLabo_teamGroupName_fr_pl --> MonLabo_settings_group5:MonLabo_custom_text_Thematics_fr
+               MonLabo_settings_group0:MonLabo_teamGroupName_en    --> MonLabo_settings_group5:MonLabo_custom_text_Thematic_en
+               MonLabo_settings_group0:MonLabo_teamGroupName_en_pl --> MonLabo_settings_group5:MonLabo_custom_text_Thematics_en
+               */
+               $options0 = get_option( 'MonLabo_settings_group0' );
+               $options5 = get_option( 'MonLabo_settings_group5' );
+               if ( isset( $options0['MonLabo_teamGroupName_fr'] ) ) {
+                       $options5['MonLabo_custom_text_Thematic_fr'] =  $options0['MonLabo_teamGroupName_fr'];
+                       unset( $options0['MonLabo_teamGroupName_fr'] );
+               }
+               if ( isset( $options0['MonLabo_teamGroupName_fr_pl'] ) ) {
+                       $options5['MonLabo_custom_text_Thematics_fr'] =  $options0['MonLabo_teamGroupName_fr_pl'];
+                       unset( $options0['MonLabo_teamGroupName_fr_pl'] );
+               }
+               if ( isset( $options0['MonLabo_teamGroupName_en'] )  ) {
+                       $options5['MonLabo_custom_text_Thematic_en'] =  $options0['MonLabo_teamGroupName_en'];
+                       unset( $options0['MonLabo_teamGroupName_en'] );
+               }
+               if ( isset( $options0['MonLabo_teamGroupName_en_pl'] ) ) {
+                       $options5['MonLabo_custom_text_Thematics_en'] =  $options0['MonLabo_teamGroupName_en_pl'];
+                       unset( $options0['MonLabo_teamGroupName_en_pl'] );
+               }
+               update_option( 'MonLabo_settings_group0', $options0 );
+               update_option( 'MonLabo_settings_group5', $options5 );
+       }
 
        public function delete_options() {
                //Effacer les options
index bd9f4a9..4a5aef2 100644 (file)
@@ -114,81 +114,27 @@ class MonLabo_translate {
                //Test if first char is lowercase
                $is_first_char_is_uppercase = ctype_upper( substr( $sentence_to_translate, 0, 1 ) );
 
-               //Case 1 : translation is in $translation_table
-               //---------------------------------------------
                if ( array_key_exists( ucfirst( $sentence_to_translate ), $translation_table ) ) {
+                       //Case 1 : translation is in $translation_table
+                       //---------------------------------------------
                        if ( $is_first_char_is_uppercase ) {
                                return ucfirst( $translation_table[ucfirst( $sentence_to_translate )][$language] );
                        } else {
                                return lcfirst( $translation_table[ucfirst( $sentence_to_translate )][$language] );
                        }
                } else {
-                       //Case 2 : translation is about groupname
-                       //---------------------------------------
-                       switch ( ucfirst( $sentence_to_translate ) ) {
-                               /*case 'Thematic':
-                                       if ( $is_first_char_is_uppercase ) {
-                                               return ucfirst( self::get_teamGroupName( $language ) );
-                                       } else {
-                                               return lcfirst( self::get_teamGroupName( $language ) );
-                                       }
-                                       break;
-
-                               case 'Thematics':
-                                       if ( $is_first_char_is_uppercase ) {
-                                               return ucfirst( self::get_teamGroupName_pl( $language ) );
-                                       } else {
-                                               return lcfirst( self::get_teamGroupName_pl( $language ) );
-                                       }
-                                       break;
-*/
-                               //Case 3 : translation is a custom text
-                               //-------------------------------------
-                               default:
-                                       $custom_text = self::get_customizable_text( 'MonLabo_custom_text_'.str_replace( ' ', '_', ucfirst( $sentence_to_translate ) ), $language );
-                                       if ( !empty( $custom_text ) ) {
-                                               if ( $is_first_char_is_uppercase ) {
-                                                       return ucfirst( $custom_text );
-                                               } else {
-                                                       return lcfirst( $custom_text );
-                                               }
-                                       } else {
-                                               return $sentence_to_translate;
-                                       }
-                                       break;
+                       //Case 2 : translation is a custom text
+                       //-------------------------------------
+                       $custom_text = self::get_customizable_text( 'MonLabo_custom_text_'.str_replace( ' ', '_', ucfirst( $sentence_to_translate ) ), $language );
+                       if ( !empty( $custom_text ) ) {
+                               if ( $is_first_char_is_uppercase ) {
+                                       return ucfirst( $custom_text );
+                               } else {
+                                       return lcfirst( $custom_text );
+                               }
+                       } else {
+                               return $sentence_to_translate;
                        }
                }
        }
-
-       public static function  get_teamGroupName_pl( $language = NULL) {
-               return self::translate('Thematics', $language);
-               $options0 = get_option( 'MonLabo_settings_group0' );
-               if ( empty( $language ) ) {
-                       $language = get_locale();
-               }
-               switch ( $language ) {
-                       case 'en_US':
-                       case 'en_GB':
-                       case 'en-US':
-                               return $options0['MonLabo_teamGroupName_en_pl'];
-                       default:
-                               return $options0['MonLabo_teamGroupName_fr_pl'];
-               }
-       }
-
-       public static function  get_teamGroupName( $language = NULL ) {
-               return self::translate('Thematic', $language);
-               $options0 = get_option( 'MonLabo_settings_group0' );
-               if ( empty( $language ) ) {
-                       $language = get_locale();
-               }
-               switch ( $language ) {
-                       case 'en_US':
-                       case 'en_GB':
-                       case 'en-US':
-                               return $options0['MonLabo_teamGroupName_en'];
-                       default:
-                               return $options0['MonLabo_teamGroupName_fr'];
-               }
-       }
 }
index d1ffeb5..bbe6197 100644 (file)
@@ -13,10 +13,6 @@ function get_options_DEFAULT() {
                                                                                        'MonLabo_uses_custom_fields_for_staff'  => '0',
                                                                                        'MonLabo_uses_unites'                                   => '0',
                                                                                        'MonLabo_uses_thematiques'                              => '0',
-                                                                                       'MonLabo_teamGroupName_fr'                              => 'Thématique',
-                                                                                       'MonLabo_teamGroupName_fr_pl'                   => 'Thématiques',
-                                                                                       'MonLabo_teamGroupName_en'                              => 'Thematic',
-                                                                                       'MonLabo_teamGroupName_en_pl'                   => 'Thematics',
                ),
                'MonLabo_settings_group1' => array(
                                                                                        'MonLabo_nom'           => 'Centre de Neurophysique, Physiologie et Pathologie',
index 168e46d..e56eac6 100644 (file)
@@ -65,8 +65,7 @@ if ( !class_exists( 'MonLabo' ) ) {
 
                                //For development (not documented )
                                add_shortcode( 'dev_team_name', array( 'MonLabo_shortcodes', 'dev_team_name' ) );
-                               add_shortcode( 'dev_team_logo', array( 'MonLabo_shortcodes', 'dev_team_logo' ) );
-
+                               add_shortcode( 'dev_team_logo', array( 'MonLabo_shortcodes', 'dev_team_logo' ) );// OPTIMIZE:
                        }
 
                        // Shortcodes for publications