diff --git a/swad_changelog.h b/swad_changelog.h index ac8d6db50..49debe55c 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.108.3 (2019-12-30)" +#define Log_PLATFORM_VERSION "SWAD 19.108.4 (2019-12-30)" #define CSS_FILE "swad19.101.5.css" #define JS_FILE "swad19.91.1.js" /* @@ -502,6 +502,7 @@ ps2pdf source.ps destination.pdf Version 19.10x: Dec 30, 2019 Map in country information. (? lines) Version 19.10x: Dec 30, 2019 Map in institution information. (? lines) + Version 19.108.4: Dec 30, 2019 Code refactoring related to printing messages. (249709 lines) Version 19.108.3: Dec 30, 2019 Code refactoring related to printing messages. (249725 lines) Version 19.108.2: Dec 30, 2019 Code refactoring related to printing messages. (249739 lines) Version 19.108.1: Dec 30, 2019 Code refactoring related to printing messages. (249746 lines) diff --git a/swad_institution.c b/swad_institution.c index a34f3d9a0..627584ac4 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -291,11 +291,11 @@ static void Ins_ListInstitutions (void) unsigned NumIns; /***** Begin box *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Institutions_of_COUNTRY_X, - Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); - Box_BoxBegin (NULL,Gbl.Title,Ins_PutIconsListingInstitutions, + Box_BoxBegin (NULL,Str_BuildStrMsg (Txt_Institutions_of_COUNTRY_X, + Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]), + Ins_PutIconsListingInstitutions, Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE); + Str_FreeStrMsg (); if (Gbl.Hierarchy.Cty.Inss.Num) // There are institutions in the current country { @@ -538,11 +538,11 @@ static void Ins_EditInstitutionsInternal (void) Hie_WriteMenuHierarchy (); /***** Begin box *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Institutions_of_COUNTRY_X, - Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); - Box_BoxBegin (NULL,Gbl.Title,Ins_PutIconsEditingInstitutions, + Box_BoxBegin (NULL,Str_BuildStrMsg (Txt_Institutions_of_COUNTRY_X, + Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]), + Ins_PutIconsEditingInstitutions, Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE); + Str_FreeStrMsg (); /***** Put a form to create a new institution *****/ Ins_PutFormToCreateInstitution (); diff --git a/swad_institution_config.c b/swad_institution_config.c index d08264180..e4279ab73 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -467,10 +467,10 @@ static void InsCfg_NumCtrs (void) HTM_TD_Begin ("class=\"LB\""); Frm_StartFormGoTo (ActSeeCtr); Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod); - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Centres_of_INSTITUTION_X, - Gbl.Hierarchy.Ins.ShrtName); - HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL); + HTM_BUTTON_SUBMIT_Begin (Str_BuildStrMsg (Txt_Centres_of_INSTITUTION_X, + Gbl.Hierarchy.Ins.ShrtName), + "BT_LINK DAT",NULL); + Str_FreeStrMsg (); HTM_Unsigned (Ctr_GetNumCtrsInIns (Gbl.Hierarchy.Ins.InsCod)); HTM_BUTTON_End (); Frm_EndForm (); diff --git a/swad_mail.c b/swad_mail.c index 47e557c07..22424a8f0 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -1308,10 +1308,10 @@ static void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe, /* Email confirmed? */ if (Confirmed) { - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Email_X_confirmed, - row[0]); - Ico_PutIcon ("check-circle.svg",Gbl.Title,"ICO16x16"); + Ico_PutIcon ("check-circle.svg", + Str_BuildStrMsg (Txt_Email_X_confirmed,row[0]), + "ICO16x16"); + Str_FreeStrMsg (); } /* Form to change user's email */ diff --git a/swad_match.c b/swad_match.c index 6d05ffbe9..d46b6e41c 100644 --- a/swad_match.c +++ b/swad_match.c @@ -3881,18 +3881,6 @@ static void Mch_DrawBarNumUsrs (unsigned NumRespondersAns,unsigned NumResponders unsigned i; unsigned BarWidth = 0; - /***** String with the number of users *****/ - if (NumRespondersQst) - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u (%u%% %s %u)", - NumRespondersAns, - (unsigned) ((((double) NumRespondersAns * 100.0) / (double) NumRespondersQst) + 0.5), - Txt_of_PART_OF_A_TOTAL,NumRespondersQst); - else - snprintf (Gbl.Title,sizeof (Gbl.Title), - "0 (0%% %s %u)", - Txt_of_PART_OF_A_TOTAL,NumRespondersQst); - /***** Start container *****/ HTM_DIV_Begin ("class=\"MCH_RESULT\""); @@ -3918,7 +3906,14 @@ static void Mch_DrawBarNumUsrs (unsigned NumRespondersAns,unsigned NumResponders HTM_TABLE_End (); /***** Write the number of users *****/ - HTM_Txt (Gbl.Title); + if (NumRespondersQst) + HTM_TxtF ("%u (%u%% %s %u)", + NumRespondersAns, + (unsigned) ((((double) NumRespondersAns * 100.0) / (double) NumRespondersQst) + 0.5), + Txt_of_PART_OF_A_TOTAL,NumRespondersQst); + else + HTM_TxtF ("0 (0%% %s %u)", + Txt_of_PART_OF_A_TOTAL,NumRespondersQst); /***** End container *****/ HTM_DIV_End (); diff --git a/swad_match_result.c b/swad_match_result.c index c80c1e90e..bffe6bd0e 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -176,10 +176,9 @@ void McR_ShowMyMchResultsInGam (void) false); // Do not put form to start new match /***** List my matches results in game *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Results_of_game_X, - Game.Title); - McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ShowResultsBegin (Str_BuildStrMsg (Txt_Results_of_game_X,Game.Title), + false); // Do not list games to select + Str_FreeStrMsg (); McR_ListMyMchResultsInGam (Game.GamCod); McR_ShowResultsEnd (); @@ -221,10 +220,9 @@ void McR_ShowMyMchResultsInMch (void) false); // Do not put form to start new match /***** List my matches results in match *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Results_of_match_X, - Match.Title); - McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ShowResultsBegin (Str_BuildStrMsg (Txt_Results_of_match_X,Match.Title), + false); // Do not list games to select + Str_FreeStrMsg (); McR_ListMyMchResultsInMch (Match.MchCod); McR_ShowResultsEnd (); @@ -322,10 +320,9 @@ void McR_ShowAllMchResultsInGam (void) false); // Do not put form to start new match /***** List matches results in game *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Results_of_game_X, - Game.Title); - McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ShowResultsBegin (Str_BuildStrMsg (Txt_Results_of_game_X,Game.Title), + false); // Do not list games to select + Str_FreeStrMsg (); McR_ListAllMchResultsInGam (Game.GamCod); McR_ShowResultsEnd (); @@ -408,10 +405,9 @@ void McR_ShowAllMchResultsInMch (void) false); // Do not put form to start new match /***** List matches results in match *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Results_of_match_X, - Match.Title); - McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ShowResultsBegin (Str_BuildStrMsg (Txt_Results_of_match_X,Match.Title), + false); // Do not list games to select + Str_FreeStrMsg (); McR_ListAllMchResultsInMch (Match.MchCod); McR_ShowResultsEnd (); diff --git a/swad_project.c b/swad_project.c index 38dd7bcac..d233f7e99 100644 --- a/swad_project.c +++ b/swad_project.c @@ -2059,12 +2059,11 @@ static void Prj_ShowOneProjectMembersWithARole (const struct Project *Prj, HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"PRJ_MEMBER_ICO\""); Gbl.Prjs.PrjCod = Prj->PrjCod; // Used to pass project code as a parameter - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Add_USERS, - Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]); Ico_PutContextualIconToAdd (ActionReqAddUsr[RoleInProject],NULL, Prj_PutCurrentParams, - Gbl.Title); + Str_BuildStrMsg (Txt_Add_USERS, + Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject])); + Str_FreeStrMsg (); HTM_TD_End (); HTM_TD_Begin ("class=\"PRJ_MEMBER_PHO\""); // Column for photo @@ -2461,10 +2460,9 @@ static void Prj_ReqRemUsrFromPrj (Prj_RoleInProject_t RoleInProject) Frm_StartForm (ActionRemUsr[RoleInProject]); Gbl.Prjs.PrjCod = Prj.PrjCod; Prj_PutCurrentParams (); - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Remove_USER_from_this_project, - Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject][Gbl.Usrs.Other.UsrDat.Sex]); - Btn_PutRemoveButton (Gbl.Title); + Btn_PutRemoveButton (Str_BuildStrMsg (Txt_Remove_USER_from_this_project, + Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject][Gbl.Usrs.Other.UsrDat.Sex])); + Str_FreeStrMsg (); Frm_EndForm (); /* End alert */ diff --git a/swad_report.c b/swad_report.c index e8a86e264..cded05dfd 100644 --- a/swad_report.c +++ b/swad_report.c @@ -158,11 +158,10 @@ void Rep_ReqMyUsageReport (void) Frm_StartForm (ActSeeMyUsgRep); /***** Begin box *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Report_of_use_of_PLATFORM, - Cfg_PLATFORM_SHORT_NAME); - Box_BoxBegin (NULL,Gbl.Title,NULL, + Box_BoxBegin (NULL,Str_BuildStrMsg (Txt_Report_of_use_of_PLATFORM, + Cfg_PLATFORM_SHORT_NAME),NULL, Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE); + Str_FreeStrMsg (); /***** Header *****/ Rep_TitleReport (NULL); // NULL means do not write date @@ -265,11 +264,10 @@ static void Rep_PutLinkToMyUsageReport (struct Rep_Report *Report) extern const char *Txt_This_link_will_remain_active_as_long_as_your_user_s_account_exists; /***** Begin box *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Report_of_use_of_PLATFORM, - Cfg_PLATFORM_SHORT_NAME); - Box_BoxBegin (NULL,Gbl.Title,NULL, + Box_BoxBegin (NULL,Str_BuildStrMsg (Txt_Report_of_use_of_PLATFORM, + Cfg_PLATFORM_SHORT_NAME),NULL, Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE); + Str_FreeStrMsg (); /***** Header *****/ Rep_TitleReport (&Report->CurrentTimeUTC); @@ -458,14 +456,11 @@ static void Rep_WriteHeader (const struct Rep_Report *Report) extern const char *Txt_Date; extern const char *Txt_Permalink; - /***** Start header *****/ + /***** Begin header *****/ fprintf (Gbl.F.Rep,"
"); - - /***** Main title *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Report_of_use_of_PLATFORM, - Cfg_PLATFORM_SHORT_NAME); - fprintf (Gbl.F.Rep,"

%s

",Gbl.Title); + fprintf (Gbl.F.Rep,"

"); + fprintf (Gbl.F.Rep,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME); + fprintf (Gbl.F.Rep,"

"); HTM_UL_Begin (NULL); /***** User *****/ @@ -1119,12 +1114,10 @@ static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role, if (NumCrss) { /* Heading row */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Hits_as_a_USER, - Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Me.UsrDat.Sex]); - fprintf (Gbl.F.Rep,"
  • %s:" - "
      ", - Gbl.Title); + fprintf (Gbl.F.Rep,"
    1. "); + fprintf (Gbl.F.Rep,Txt_Hits_as_a_USER, + Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Me.UsrDat.Sex]); + fprintf (Gbl.F.Rep,":
        "); /* Write courses */ for (NumCrs = 1; diff --git a/swad_statistic.c b/swad_statistic.c index 83f0f5c23..cca9e111e 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -230,11 +230,10 @@ void Sta_AskShowCrsHits (void) Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; /***** Begin box *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Statistics_of_visits_to_the_course_X, - Gbl.Hierarchy.Crs.ShrtName); - Box_BoxBegin (NULL,Gbl.Title,NULL, + Box_BoxBegin (NULL,Str_BuildStrMsg (Txt_Statistics_of_visits_to_the_course_X, + Gbl.Hierarchy.Crs.ShrtName),NULL, Hlp_ANALYTICS_Visits_visits_to_course,Box_NOT_CLOSABLE); + Str_FreeStrMsg (); /***** Show form to select the groups *****/ Grp_ShowFormToSelectSeveralGroups (NULL,Grp_MY_GROUPS); diff --git a/swad_syllabus.c b/swad_syllabus.c index 88999d70f..08b68470a 100644 --- a/swad_syllabus.c +++ b/swad_syllabus.c @@ -620,15 +620,14 @@ static void Syl_ShowRowSyllabus (unsigned NumItem, HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); if (Subtree.MovAllowed) { - snprintf (Gbl.Title,sizeof (Gbl.Title), - LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_up_X_and_its_subsections : - Txt_Move_up_X, - StrItemCod); Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActUp_IteSylLec : ActUp_IteSylPra, NULL,Syl_PutParamNumItem, "arrow-up.svg", - Gbl.Title); + Str_BuildStrMsg (LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_up_X_and_its_subsections : + Txt_Move_up_X, + StrItemCod)); + Str_FreeStrMsg (); } else Ico_PutIconOff ("arrow-up.svg",Txt_Movement_not_allowed); @@ -639,15 +638,14 @@ static void Syl_ShowRowSyllabus (unsigned NumItem, HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); if (Subtree.MovAllowed) { - snprintf (Gbl.Title,sizeof (Gbl.Title), - LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_down_X_and_its_subsections : - Txt_Move_down_X, - StrItemCod); Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActDwnIteSylLec : ActDwnIteSylPra, NULL,Syl_PutParamNumItem, "arrow-down.svg", - Gbl.Title); + Str_BuildStrMsg (LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_down_X_and_its_subsections : + Txt_Move_down_X, + StrItemCod)); + Str_FreeStrMsg (); } else Ico_PutIconOff ("arrow-down.svg",Txt_Movement_not_allowed); @@ -657,14 +655,13 @@ static void Syl_ShowRowSyllabus (unsigned NumItem, HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); if (Level > 1) { - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Increase_level_of_X, - StrItemCod); Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActRgtIteSylLec : - ActRgtIteSylPra, + ActRgtIteSylPra, NULL,Syl_PutParamNumItem, "arrow-left.svg", - Gbl.Title); + Str_BuildStrMsg (Txt_Increase_level_of_X, + StrItemCod)); + Str_FreeStrMsg (); } else Ico_PutIconOff ("arrow-left.svg",Txt_Movement_not_allowed); @@ -675,14 +672,13 @@ static void Syl_ShowRowSyllabus (unsigned NumItem, if (Level < LastLevel + 1 && Level < Syl_MAX_LEVELS_SYLLABUS) { - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Decrease_level_of_X, - StrItemCod); Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActLftIteSylLec : - ActLftIteSylPra, + ActLftIteSylPra, NULL,Syl_PutParamNumItem, "arrow-right.svg", - Gbl.Title); + Str_BuildStrMsg (Txt_Decrease_level_of_X, + StrItemCod)); + Str_FreeStrMsg (); } else Ico_PutIconOff ("arrow-right.svg",Txt_Movement_not_allowed); diff --git a/swad_test.c b/swad_test.c index 6c58358a5..31f731b24 100644 --- a/swad_test.c +++ b/swad_test.c @@ -1840,10 +1840,10 @@ static void Tst_PutIconEnable (long TagCod,const char *TagTxt) HTM_TD_Begin ("class=\"BM\""); Frm_StartForm (ActEnableTag); Par_PutHiddenParamLong (NULL,"TagCod",TagCod); - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Tag_X_not_allowed_Click_to_allow_it, - TagTxt); - Ico_PutIconLink ("eye-slash.svg",Gbl.Title); + Ico_PutIconLink ("eye-slash.svg", + Str_BuildStrMsg (Txt_Tag_X_not_allowed_Click_to_allow_it, + TagTxt)); + Str_FreeStrMsg (); Frm_EndForm (); HTM_TD_End (); } @@ -1859,10 +1859,10 @@ static void Tst_PutIconDisable (long TagCod,const char *TagTxt) HTM_TD_Begin ("class=\"BM\""); Frm_StartForm (ActDisableTag); Par_PutHiddenParamLong (NULL,"TagCod",TagCod); - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Tag_X_allowed_Click_to_disable_it, - TagTxt); - Ico_PutIconLink ("eye.svg",Gbl.Title); + Ico_PutIconLink ("eye.svg", + Str_BuildStrMsg (Txt_Tag_X_allowed_Click_to_disable_it, + TagTxt)); + Str_FreeStrMsg (); Frm_EndForm (); HTM_TD_End (); } diff --git a/swad_timeline.c b/swad_timeline.c index 14fb666b6..1d439106f 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -507,10 +507,10 @@ static void TL_ShowTimelineUsrHighlightingNot (long NotCod) TL_GET_RECENT_TIMELINE); /***** Show timeline *****/ - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Timeline_OF_A_USER, - Gbl.Usrs.Other.UsrDat.FirstName); - TL_ShowTimeline (Query,Gbl.Title,NotCod); + TL_ShowTimeline (Query,Str_BuildStrMsg (Txt_Timeline_OF_A_USER, + Gbl.Usrs.Other.UsrDat.FirstName), + NotCod); + Str_FreeStrMsg (); /***** Drop temporary tables *****/ TL_DropTemporaryTablesUsedToQueryTimeline (); @@ -3121,17 +3121,18 @@ static void TL_PutDisabledIconShare (unsigned NumShared) extern const char *Txt_TIMELINE_NOTE_Shared_by_X_USERS; extern const char *Txt_TIMELINE_NOTE_Not_shared_by_anyone; + /***** Disabled icon to share *****/ if (NumShared) + { snprintf (Gbl.Title,sizeof (Gbl.Title), Txt_TIMELINE_NOTE_Shared_by_X_USERS, NumShared); + Ico_PutDivIcon ("TL_ICO_DISABLED",TL_ICON_SHARE, + Gbl.Title); + } else - Str_Copy (Gbl.Title,Txt_TIMELINE_NOTE_Not_shared_by_anyone, - Lay_MAX_BYTES_TITLE); - - /***** Disabled icon to share *****/ - Ico_PutDivIcon ("TL_ICO_DISABLED", - TL_ICON_SHARE,Gbl.Title); + Ico_PutDivIcon ("TL_ICO_DISABLED",TL_ICON_SHARE, + Txt_TIMELINE_NOTE_Not_shared_by_anyone); } /*****************************************************************************/ @@ -3143,17 +3144,18 @@ static void TL_PutDisabledIconFav (unsigned NumFavs) extern const char *Txt_TIMELINE_NOTE_Favourited_by_X_USERS; extern const char *Txt_TIMELINE_NOTE_Not_favourited_by_anyone; + /***** Disabled icon to mark as favourite *****/ if (NumFavs) + { snprintf (Gbl.Title,sizeof (Gbl.Title), Txt_TIMELINE_NOTE_Favourited_by_X_USERS, NumFavs); + Ico_PutDivIcon ("TL_ICO_DISABLED",TL_ICON_FAV, + Gbl.Title); + } else - Str_Copy (Gbl.Title,Txt_TIMELINE_NOTE_Not_favourited_by_anyone, - Lay_MAX_BYTES_TITLE); - - /***** Disabled icon to mark as favourite *****/ - Ico_PutDivIcon ("TL_ICO_DISABLED", - TL_ICON_FAV,Gbl.Title); + Ico_PutDivIcon ("TL_ICO_DISABLED",TL_ICON_FAV, + Txt_TIMELINE_NOTE_Not_favourited_by_anyone); } /*****************************************************************************/