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 <herve.suaudeau@parisdescartes.fr>
Tue, 22 Sep 2020 17:59:06 +0000 (19:59 +0200)
committerherve <herve.suaudeau@parisdescartes.fr>
Tue, 22 Sep 2020 17:59:06 +0000 (19:59 +0200)
admin/MonLabo-admin.php
admin/MonLabo-edit-members.php
changelog.txt
includes/MonLabo-generate-HTML.php
includes/MonLabo-lib.php
includes/MonLabo-translate.php
includes/constants.php

index 3a220a7..dc6f4e3 100644 (file)
@@ -255,6 +255,8 @@ class MonLabo_admin {
                if ( isset( $options0['MonLabo_uses_custom_texts_in_shortcodes'] ) && ( intval( $options0['MonLabo_uses_custom_texts_in_shortcodes'] ) === 1 ) ) {
                        $this->curent_settings_group='MonLabo_settings_group5';
                        $this->add_section( 'MonLabo_pluginPage_section_custom_persons_texts',    __( 'Affichage des personnels', 'mon-laboratoire' ), 'MonLaboPageCustomTexts' );
+                       $this->add_field( 'text_field',  'MonLabo_custom_text_Room_en', __( 'Bureau', 'mon-laboratoire' ).' (en/fr)' );
+                       $this->add_field( 'text_field',  'MonLabo_custom_text_Room_fr', '');
                        $this->add_field( 'text_field',  'MonLabo_custom_text_Personal_website_en',     __( 'Liens vers un site extérieur', 'mon-laboratoire' ).' (en/fr)' );
                        $this->add_field( 'text_field',  'MonLabo_custom_text_Personal_website_fr',     '' );
                        $this->add_field( 'text_field',  'MonLabo_custom_text_Team_leader_en',  __( 'Titre par défaut pour les chefs d\'équipe (en/fr/en pluriel/fr pluriel)', 'mon-laboratoire' ) );
@@ -517,7 +519,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' : '' )  .'">'.MonLaboLib::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::get_teamGroupName_pl().'</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 42641a9..f314934 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,  MonLaboLib::get_teamGroupName_pl(),
+               $retval .= generate_champ_formulaire_select_multiple( 'thematics', $all_thematics_name, false,  MonLabo_translate::get_teamGroupName_pl(),
                        get_MonLabo_Team_fields_comments( 'thematics' ), $thematics_name );
        }
        $retval .= '</fieldset>';
@@ -492,7 +492,7 @@ function edit_thematics_form() {
        $values = $thematics_name;
        $isMandatory = true;
 
-       $legend =  MonLaboLib::get_teamGroupName();
+       $legend =  MonLabo_translate::get_teamGroupName();
        $description = '';
        $onchange='changeThematic(this.value)';
 
index c40dbc0..efbcec8 100644 (file)
@@ -80,18 +80,16 @@ Remember, check_admin_referer alone is not bulletproof security. Do not rely on
 = 3.1 =
 ===> Suppression champs inutiles dans table Persons
 ===> Vérifier que la gestion des logos des équipes, unités et autre sont bien gérés.
-===> Permettre de créer une nouvelle page.
-===> mon-laboratoire.php a améliorer gestion CSS. TODO + ne pas mettre de Propriétés CSS vides.
-==> Rajout de room comme texte à traduire.
 ==> plusieurs adresses email dans un champs.
 * EVOL: A person can have several pages
 * CODE : Secure ajax code with a nonce to prevent unauthorized access
 * CODE : Secure all actions that accept POST with a nonce to prevent unauthorized access
 * BUG : Suppress php warnings that occur when creating new person, team, thematic or unit.
+* BUG : Suppress php warnings that occur when apparence fields in are empty in configuration interface.
 * BUG : Correct bad redirection of buttons for modifying teams, thematics or units in the admin tab "table view"
 * BUG: Bad alphabetic order of [members_list] with people that have accents in names. Order shoud be : E < É < F
 * DESIGN : Add logo U-Paris. Suppress UPEC (non contributive since V2.0)
-* ERGONOMY: Better configuration form for members WordPress address
+* NEW FUNC: Much better configuration form for members WordPress address
 * CODE : Suppress warnings if database is empty
 * CODE : Detect obsolete database
 * CODE : Correct few warnings with HTML standards
@@ -100,6 +98,8 @@ Remember, check_admin_referer alone is not bulletproof security. Do not rely on
 * BUG : In some server configuration, URL of default image for a person was wrong.
 * TEST: Tester en multisite WordPress
 * CODE : Improve unit test coverage (XXXXX tests)
+* NEW FUNC: Allows you to customize other shortcode texts ("Room", "Thematic" in team_panel).
+
 
 = 3.0.5 =
 (GIT tag v3.0.5)
index 58b5348..69ee90e 100644 (file)
@@ -685,7 +685,9 @@ class MonLabo_generate_HTML {
                        $list_to_display = Array(); //On range les items suivants dans un tableau
                        if ( $person_information->mail<>'' ) { $list_to_display[] = $MonLabo_generate_HTML->obsfuscate_email( $person_information->mail ); }
                        if ( $person_information->phone<>'' ) { $list_to_display[] = MonLaboLib::to_html( MonLaboLib::get_phone_with_prefix( $person_information->phone ) ); }
-                       if ( ( !$is_alumni ) && ( $person_information->room<>'' ) ) { $list_to_display[] = MonLaboLib::to_html( MonLabo_translate::translate( 'room', $language ) .' ' . $person_information->room ); }
+                       if ( ( !$is_alumni ) && ( !empty( $person_information->room ) ) ) {
+                               $list_to_display[] = MonLaboLib::to_html( MonLabo_translate::translate( 'room', $language ) .' ' . $person_information->room );
+                       }
                        $a_afficher .= implode( ', ', $list_to_display ); //On met des virgules entre chaque item
                        $a_afficher.= '</div></div>';
                }
index 77dee38..2b1d59d 100644 (file)
@@ -77,30 +77,6 @@ class MonLaboLib {
                return ( empty( $val ) ? NULL : $val );
        }
 
-
-       public static function  get_teamGroupName_pl() {
-               $options0 = get_option( 'MonLabo_settings_group0' );
-               switch ( get_locale() ) {
-                       case 'en_US':
-                       case 'en_GB':
-                               return $options0['MonLabo_teamGroupName_en_pl'];
-                       default:
-                               return $options0['MonLabo_teamGroupName_fr_pl'];
-               }
-       }
-
-       public static function  get_teamGroupName() {
-               $options0 = get_option( 'MonLabo_settings_group0' );
-               switch ( get_locale() ) {
-                       case 'en_US':
-                       case 'en_GB':
-                               return $options0['MonLabo_teamGroupName_en'];
-                       default:
-                               return $options0['MonLabo_teamGroupName_fr'];
-               }
-       }
-
-
        /**
         * Met en majuscules pour de l'affichage HTML
         */
index f4f21ad..bd9f4a9 100644 (file)
@@ -63,8 +63,6 @@ class MonLabo_translate {
 
        public static function translate( $sentence_to_translate, $language = '' ) {
                $translation_table = array(
-                       'Room' => array( 'en-US'=> 'room',
-                                                       'fr-FR'=> 'bureau' ),
                        'Nom' => array( 'en-US'=> 'Name',
                                                        'fr-FR'=> 'Nom' ),
                        'Equipe' => array(  'en-US'=> 'Group',
@@ -81,10 +79,6 @@ class MonLabo_translate {
                                                        'fr-FR'=> 'Ancienne fonction&nbsp;:' ),
                        'Until'    => array( 'en-US'=> 'Until',
                                                        'fr-FR'=> 'Jusqu\'en' ),
-                       'Thematic'         => array( 'en-US'=> 'Thematic',
-                                                       'fr-FR'=> 'Thématique' ),
-                       'Thematics'        => array( 'en-US'=> 'Thematics',
-                                                       'fr-FR'=> 'Thématiques' ),
                        'Supervised student'  => array( 'en-US'=> 'Student',
                                                          'fr-FR'=> 'Étudiant' ),
                        'Supervised students' => array( 'en-US'=> 'Students',
@@ -96,7 +90,7 @@ class MonLabo_translate {
                        'Statut'           => array( 'en-US'=> 'Status',
                                                        'fr-FR'=> 'Statut' ),
                        );
-               if ( '' === $language ) {
+               if ( empty( $language ) ) {
                        $language = get_locale();
                }
                switch ( $language ) {
@@ -119,6 +113,9 @@ 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 ) ) {
                        if ( $is_first_char_is_uppercase ) {
                                return ucfirst( $translation_table[ucfirst( $sentence_to_translate )][$language] );
@@ -126,16 +123,72 @@ class MonLabo_translate {
                                return lcfirst( $translation_table[ucfirst( $sentence_to_translate )][$language] );
                        }
                } else {
-                       $custom_text = MonLabo_translate::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;
+                       //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;
                        }
                }
        }
+
+       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 1f051b0..d1ffeb5 100644 (file)
@@ -65,6 +65,8 @@ France',
                ),
 
                'MonLabo_settings_group5' => array(
+                                                                                       'MonLabo_custom_text_Room_en'                                   => 'Room',
+                                                                                       'MonLabo_custom_text_Room_fr'                                   => 'Bureau',
                                                                                        'MonLabo_custom_text_Personal_website_en'          => 'Personal website',
                                                                                        'MonLabo_custom_text_Personal_website_fr'          => 'Site personnel',
                                                                                        'MonLabo_custom_text_Recent_Publications_en'    => 'Recent Publications',
@@ -89,7 +91,10 @@ France',
                                                                                        'MonLabo_custom_text_Member_fr'                          => 'Membre',
                                                                                        'MonLabo_custom_text_Members_en'                                => 'Members',
                                                                                        'MonLabo_custom_text_Members_fr'                                => 'Membres',
-
+                                                                                       'MonLabo_custom_text_Thematic_en'                               => 'Thematic',
+                                                                                       'MonLabo_custom_text_Thematic_fr'                               => 'Thématique',
+                                                                                       'MonLabo_custom_text_Thematics_en'                              => 'Thematics',
+                                                                                       'MonLabo_custom_text_Thematics_fr'                              => 'Thématiques',
                ),
 
        );