From 8e0f43918109173ea2991712597a2f342e089ffc Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 10 Oct 2023 00:27:25 +0200 Subject: [PATCH] Version 23.31: Oct 10, 2023 Code refactoring in short and full names. --- swad_banner.c | 27 +++-------- swad_center.c | 56 +++++++---------------- swad_center_config.c | 26 +++++------ swad_changelog.h | 3 +- swad_country.c | 12 ++--- swad_course.c | 32 +++---------- swad_course_config.c | 12 ++--- swad_degree.c | 44 +++++------------- swad_degree_config.c | 12 ++--- swad_degree_type.c | 12 ++--- swad_department.c | 94 +++++++++++++++------------------------ swad_form.c | 38 ++++++++++++++++ swad_form.h | 6 +++ swad_group.c | 56 +++++++++++------------ swad_holiday.c | 54 +++++++++++----------- swad_institution.c | 32 +++---------- swad_institution_config.c | 12 ++--- swad_link.c | 28 +++--------- swad_place.c | 27 +++-------- swad_record.c | 66 +++++++++++++-------------- swad_room.c | 12 ++--- 21 files changed, 270 insertions(+), 391 deletions(-) diff --git a/swad_banner.c b/swad_banner.c index e0ced843..81a31bbf 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -383,9 +383,6 @@ void Ban_PutIconToViewBanners (void) static void Ban_ListBannersForEdition (struct Ban_Banners *Banners) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE]; static Act_Action_t ActionHideUnhide[HidVis_NUM_HIDDEN_VISIBLE] = { @@ -400,8 +397,7 @@ static void Ban_ListBannersForEdition (struct Ban_Banners *Banners) unsigned NumBan; struct Ban_Banner *Ban; char *Anchor = NULL; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; - Cns_ShrtOrFullName_t ShrtOrFullName; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); @@ -450,23 +446,10 @@ static void Ban_ListBannersForEdition (struct Ban_Banners *Banners) /* Banner short name and full name */ Name[Cns_SHRT_NAME] = Ban->ShrtName; Name[Cns_FULL_NAME] = Ban->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"CM\""); - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_Ban,Banners->BanCodToEdit); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_Ban,Banners->BanCodToEdit, + Name, + true); // Put form /* Banner image */ HTM_TD_Begin ("class=\"CM\""); diff --git a/swad_center.c b/swad_center.c index 7fb23275..3f5c587a 100644 --- a/swad_center.c +++ b/swad_center.c @@ -730,9 +730,6 @@ void Ctr_WriteSelectorOfCenter (void) static void Ctr_ListCentersForEdition (const struct Plc_Places *Places) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *Txt_Another_place; extern const char *Txt_CENTER_STATUS[Hie_NUM_STATUS_TXT]; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = @@ -743,15 +740,14 @@ static void Ctr_ListCentersForEdition (const struct Plc_Places *Places) unsigned NumCtr; struct Hie_Node *Ctr; unsigned NumPlc; - const struct Plc_Place *PlcInLst; + const struct Plc_Place *Plc; char WWW[Cns_MAX_BYTES_WWW + 1]; struct Usr_Data UsrDat; bool ICanEdit; unsigned NumDegs; unsigned NumUsrsCtr; unsigned NumUsrsInCrssOfCtr; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -825,12 +821,12 @@ static void Ctr_ListCentersForEdition (const struct Plc_Places *Places) NumPlc < Places->Num; NumPlc++) { - PlcInLst = &Places->Lst[NumPlc]; - HTM_OPTION (HTM_Type_LONG,&PlcInLst->PlcCod, - PlcInLst->PlcCod == Ctr->Specific.PlcCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Plc = &Places->Lst[NumPlc]; + HTM_OPTION (HTM_Type_LONG,&Plc->PlcCod, + Plc->PlcCod == Ctr->Specific.PlcCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",PlcInLst->ShrtName); + "%s",Plc->ShrtName); } HTM_SELECT_End (); Frm_EndForm (); @@ -846,28 +842,10 @@ static void Ctr_ListCentersForEdition (const struct Plc_Places *Places) /* Center short name and full name */ Name[Cns_SHRT_NAME] = Ctr->ShrtName; Name[Cns_FULL_NAME] = Ctr->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); - if (ICanEdit) - { - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_OthHie,Ctr->HieCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - } - else - HTM_Txt (Name[ShrtOrFullName]); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_OthHie,Ctr->HieCod, + Name, + ICanEdit); // Put form? /* Center WWW */ HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); @@ -1265,7 +1243,7 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places) extern const char *Txt_Another_place; Act_Action_t NextAction = ActUnk; unsigned NumPlc; - const struct Plc_Place *PlcInLst; + const struct Plc_Place *Plc; Cns_ShrtOrFullName_t ShrtOrFullName; char *Name[Cns_NUM_SHRT_FULL_NAMES] = { @@ -1319,12 +1297,12 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places) NumPlc < Places->Num; NumPlc++) { - PlcInLst = &Places->Lst[NumPlc]; - HTM_OPTION (HTM_Type_LONG,&PlcInLst->PlcCod, - PlcInLst->PlcCod == Ctr_EditingCtr->Specific.PlcCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Plc = &Places->Lst[NumPlc]; + HTM_OPTION (HTM_Type_LONG,&Plc->PlcCod, + Plc->PlcCod == Ctr_EditingCtr->Specific.PlcCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",PlcInLst->ShrtName); + "%s",Plc->ShrtName); } HTM_SELECT_End (); HTM_TD_End (); diff --git a/swad_center_config.c b/swad_center_config.c index 7bfd2a65..8def6339 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -536,7 +536,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) extern const char *Par_CodeStr[]; extern const char *Txt_Institution; unsigned NumIns; - const struct Hie_Node *InsInLst; + const struct Hie_Node *Ins; /***** Institution *****/ HTM_TR_Begin (NULL); @@ -563,12 +563,12 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) NumIns < Gbl.Hierarchy.List[Hie_CTY].Num; NumIns++) { - InsInLst = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; - HTM_OPTION (HTM_Type_LONG,&InsInLst->HieCod, - InsInLst->HieCod == Gbl.Hierarchy.Node[Hie_INS].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Ins = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; + HTM_OPTION (HTM_Type_LONG,&Ins->HieCod, + Ins->HieCod == Gbl.Hierarchy.Node[Hie_INS].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",InsInLst->ShrtName); + "%s",Ins->ShrtName); } HTM_SELECT_End (); Frm_EndForm (); @@ -635,7 +635,6 @@ static void CtrCfg_Place (bool PutForm) struct Plc_Places Places; struct Plc_Place Plc; unsigned NumPlc; - const struct Plc_Place *PlcInLst; /***** Reset places context *****/ Plc_ResetPlaces (&Places); @@ -665,20 +664,17 @@ static void CtrCfg_Place (bool PutForm) The_GetSuffix ()); HTM_OPTION (HTM_Type_STRING,"0", Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod == 0 ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, "%s",Txt_Another_place); for (NumPlc = 0; NumPlc < Places.Num; NumPlc++) - { - PlcInLst = &Places.Lst[NumPlc]; - HTM_OPTION (HTM_Type_LONG,&PlcInLst->PlcCod, - PlcInLst->PlcCod == Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod, + Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",PlcInLst->ShrtName); - } + "%s",Places.Lst[NumPlc].ShrtName); HTM_SELECT_End (); Frm_EndForm (); diff --git a/swad_changelog.h b/swad_changelog.h index 345ea06f..5b354dce 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -632,10 +632,11 @@ TODO: Francisco Javier Fern Me sale este error, no sé si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así? "can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod') */ -#define Log_PLATFORM_VERSION "SWAD 23.30 (2023-10-09)" +#define Log_PLATFORM_VERSION "SWAD 23.31 (2023-10-10)" #define CSS_FILE "swad23.25.2.css" #define JS_FILE "swad22.49.js" /* + Version 23.31: Oct 10, 2023 Code refactoring in short and full names. (336169 lines) Version 23.30: Oct 09, 2023 Code refactoring in short and full names. (336293 lines) Version 23.29: Oct 07, 2023 Code refactoring in short and full names. (336131 lines) Version 23.28: Oct 06, 2023 New file swad_constant.c. diff --git a/swad_country.c b/swad_country.c index 3cb14b44..e14668fc 100644 --- a/swad_country.c +++ b/swad_country.c @@ -846,7 +846,7 @@ void Cty_WriteSelectorOfCountry (void) { extern const char *Txt_Country; unsigned NumCty; - const struct Hie_Node *CtyInLst; + const struct Hie_Node *Cty; /***** Get list of countries *****/ Cty_GetBasicListOfCountries (); @@ -871,12 +871,12 @@ void Cty_WriteSelectorOfCountry (void) NumCty < Gbl.Hierarchy.List[Hie_SYS].Num; NumCty++) { - CtyInLst = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; - HTM_OPTION (HTM_Type_LONG,&CtyInLst->HieCod, - CtyInLst->HieCod == Gbl.Hierarchy.Node[Hie_CTY].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Cty = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; + HTM_OPTION (HTM_Type_LONG,&Cty->HieCod, + Cty->HieCod == Gbl.Hierarchy.Node[Hie_CTY].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",CtyInLst->FullName); + "%s",Cty->FullName); } /***** End selector of country *****/ diff --git a/swad_course.c b/swad_course.c index a73587f1..513f09e0 100644 --- a/swad_course.c +++ b/swad_course.c @@ -916,9 +916,6 @@ static void Crs_ListCoursesForEdition (void) static void Crs_ListCoursesOfAYearForEdition (unsigned Year) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_COURSE_STATUS[Hie_NUM_STATUS_TXT]; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = @@ -932,8 +929,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) struct Usr_Data UsrDat; bool ICanEdit; unsigned NumUsrs[Rol_NUM_ROLES]; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -1020,28 +1016,10 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) /* Course short name and full name */ Name[Cns_SHRT_NAME] = Crs->ShrtName; Name[Cns_FULL_NAME] = Crs->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); - if (ICanEdit) - { - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_OthHie,Crs->HieCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - } - else - HTM_Txt (Name[ShrtOrFullName]); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_OthHie,Crs->HieCod, + Name, + ICanEdit); // Put form? /* Current number of teachers in this course */ HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ()); diff --git a/swad_course_config.c b/swad_course_config.c index 116171c0..a8da8d32 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -198,7 +198,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm) extern const char *Par_CodeStr[]; extern const char *Txt_Degree; unsigned NumDeg; - const struct Hie_Node *DegInLst; + const struct Hie_Node *Deg; /***** Degree *****/ HTM_TR_Begin (NULL); @@ -225,12 +225,12 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm) NumDeg < Gbl.Hierarchy.List[Hie_CTR].Num; NumDeg++) { - DegInLst = &Gbl.Hierarchy.List[Hie_CTR].Lst[NumDeg]; - HTM_OPTION (HTM_Type_LONG,&DegInLst->HieCod, - DegInLst->HieCod == Gbl.Hierarchy.Node[Hie_DEG].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Deg = &Gbl.Hierarchy.List[Hie_CTR].Lst[NumDeg]; + HTM_OPTION (HTM_Type_LONG,&Deg->HieCod, + Deg->HieCod == Gbl.Hierarchy.Node[Hie_DEG].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",DegInLst->ShrtName); + "%s",Deg->ShrtName); } HTM_SELECT_End (); Frm_EndForm (); diff --git a/swad_degree.c b/swad_degree.c index 16746286..92f783bf 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -316,9 +316,6 @@ void Deg_ShowDegsOfCurrentCtr (void) static void Deg_ListDegreesForEdition (const struct DegTyp_DegTypes *DegTypes) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *Txt_DEGREE_STATUS[Hie_NUM_STATUS_TXT]; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = { @@ -334,8 +331,7 @@ static void Deg_ListDegreesForEdition (const struct DegTyp_DegTypes *DegTypes) bool ICanEdit; unsigned NumCrss; unsigned NumUsrsInCrssOfDeg; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -391,28 +387,10 @@ static void Deg_ListDegreesForEdition (const struct DegTyp_DegTypes *DegTypes) /* Degree short name and full name */ Name[Cns_SHRT_NAME] = Deg->ShrtName; Name[Cns_FULL_NAME] = Deg->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); - if (ICanEdit) - { - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_OthHie,Deg->HieCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - } - else - HTM_Txt (Name[ShrtOrFullName]); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_OthHie,Deg->HieCod, + Name, + ICanEdit); // Put form? /* Degree type */ HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); @@ -533,7 +511,7 @@ static void Deg_PutFormToCreateDegree (const struct DegTyp_DegTypes *DegTypes) extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; Act_Action_t NextAction = ActUnk; unsigned NumDegTyp; - struct DegTyp_DegreeType *DegTypInLst; + struct DegTyp_DegreeType *DegTyp; Cns_ShrtOrFullName_t ShrtOrFullName; char *Name[Cns_NUM_SHRT_FULL_NAMES] = { @@ -600,12 +578,12 @@ static void Deg_PutFormToCreateDegree (const struct DegTyp_DegTypes *DegTypes) NumDegTyp < DegTypes->Num; NumDegTyp++) { - DegTypInLst = &DegTypes->Lst[NumDegTyp]; - HTM_OPTION (HTM_Type_LONG,&DegTypInLst->DegTypCod, - DegTypInLst->DegTypCod == Deg_EditingDeg->Specific.TypCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + DegTyp = &DegTypes->Lst[NumDegTyp]; + HTM_OPTION (HTM_Type_LONG,&DegTyp->DegTypCod, + DegTyp->DegTypCod == Deg_EditingDeg->Specific.TypCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",DegTypInLst->DegTypName); + "%s",DegTyp->DegTypName); } HTM_SELECT_End (); HTM_TD_End (); diff --git a/swad_degree_config.c b/swad_degree_config.c index 67052f00..14bc3889 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -193,7 +193,7 @@ static void DegCfg_Center (bool PrintView,bool PutForm) extern const char *Par_CodeStr[]; extern const char *Txt_Center; unsigned NumCtr; - const struct Hie_Node *CtrInLst; + const struct Hie_Node *Ctr; /***** Center *****/ HTM_TR_Begin (NULL); @@ -220,12 +220,12 @@ static void DegCfg_Center (bool PrintView,bool PutForm) NumCtr < Gbl.Hierarchy.List[Hie_INS].Num; NumCtr++) { - CtrInLst = &Gbl.Hierarchy.List[Hie_INS].Lst[NumCtr]; - HTM_OPTION (HTM_Type_LONG,&CtrInLst->HieCod, - CtrInLst->HieCod == Gbl.Hierarchy.Node[Hie_CTR].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Ctr = &Gbl.Hierarchy.List[Hie_INS].Lst[NumCtr]; + HTM_OPTION (HTM_Type_LONG,&Ctr->HieCod, + Ctr->HieCod == Gbl.Hierarchy.Node[Hie_CTR].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",CtrInLst->ShrtName); + "%s",Ctr->ShrtName); } HTM_SELECT_End (); Frm_EndForm (); diff --git a/swad_degree_type.c b/swad_degree_type.c index 53fa2797..042043f3 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -105,7 +105,7 @@ void DegTyp_WriteSelectorDegreeTypes (long SelectedDegTypCod) extern const char *Txt_Any_type_of_degree; struct DegTyp_DegTypes DegTypes; unsigned NumDegTyp; - const struct DegTyp_DegreeType *DegTypInLst; + const struct DegTyp_DegreeType *DegTyp; /***** Form to select degree types *****/ /* Get list of degree types */ @@ -125,12 +125,12 @@ void DegTyp_WriteSelectorDegreeTypes (long SelectedDegTypCod) NumDegTyp < DegTypes.Num; NumDegTyp++) { - DegTypInLst = &DegTypes.Lst[NumDegTyp]; - HTM_OPTION (HTM_Type_LONG,&DegTypInLst->DegTypCod, - DegTypInLst->DegTypCod == SelectedDegTypCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + DegTyp = &DegTypes.Lst[NumDegTyp]; + HTM_OPTION (HTM_Type_LONG,&DegTyp->DegTypCod, + DegTyp->DegTypCod == SelectedDegTypCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",DegTypInLst->DegTypName); + "%s",DegTyp->DegTypName); } HTM_SELECT_End (); diff --git a/swad_department.c b/swad_department.c index fe9dc8a2..9bc9649a 100644 --- a/swad_department.c +++ b/swad_department.c @@ -464,9 +464,6 @@ static void Dpt_GetDepartmentDataFromRow (MYSQL_RES *mysql_res, static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departments) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *Txt_Another_institution; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = { @@ -474,12 +471,10 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm [Cns_FULL_NAME] = ActRenDptFul, }; unsigned NumDpt; - struct Dpt_Department *DptInLst; - struct Hie_Node Ins; + struct Dpt_Department *Dpt; unsigned NumIns; - struct Hie_Node *InsInLst; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + struct Hie_Node *Ins; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Begin table *****/ HTM_TABLE_BeginPadding (2); @@ -492,82 +487,65 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm NumDpt < Departments->Num; NumDpt++) { - DptInLst = &Departments->Lst[NumDpt]; - - /* Get data of institution of this department */ - Ins.HieCod = DptInLst->InsCod; - Ins_GetInstitDataByCod (&Ins); + Dpt = &Departments->Lst[NumDpt]; HTM_TR_Begin (NULL); /* Icon to remove department */ HTM_TD_Begin ("class=\"BM\""); - if (DptInLst->NumTchs) // Department has teachers ==> deletion forbidden + if (Dpt->NumTchs) // Department has teachers ==> deletion forbidden Ico_PutIconRemovalNotAllowed (); else Ico_PutContextualIconToRemove (ActRemDpt,NULL, - Dpt_PutParDptCod,&DptInLst->DptCod); + Dpt_PutParDptCod,&Dpt->DptCod); HTM_TD_End (); /* Department code */ HTM_TD_Begin ("class=\"DAT_%s CODE\"",The_GetSuffix ()); - HTM_TxtF ("%ld ",DptInLst->DptCod); + HTM_TxtF ("%ld ",Dpt->DptCod); HTM_TD_End (); /* Institution */ HTM_TD_Begin ("class=\"LM\""); Frm_BeginForm (ActChgDptIns); - ParCod_PutPar (ParCod_Dpt,DptInLst->DptCod); + ParCod_PutPar (ParCod_Dpt,Dpt->DptCod); HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, "name=\"OthInsCod\"" " class=\"HIE_SEL_NARROW INPUT_%s\"", The_GetSuffix ()); HTM_OPTION (HTM_Type_STRING,"0", - DptInLst->InsCod == 0 ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Dpt->InsCod == 0 ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, "%s",Txt_Another_institution); for (NumIns = 0; NumIns < Gbl.Hierarchy.List[Hie_CTY].Num; NumIns++) { - InsInLst = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; - HTM_OPTION (HTM_Type_LONG,&InsInLst->HieCod, - InsInLst->HieCod == DptInLst->InsCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Ins = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; + HTM_OPTION (HTM_Type_LONG,&Ins->HieCod, + Ins->HieCod == Dpt->InsCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",InsInLst->ShrtName); + "%s",Ins->ShrtName); } HTM_SELECT_End (); Frm_EndForm (); HTM_TD_End (); /* Department short name and full name */ - Name[Cns_SHRT_NAME] = DptInLst->ShrtName; - Name[Cns_FULL_NAME] = DptInLst->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"LM\""); - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_Dpt,DptInLst->DptCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - HTM_TD_End (); - } + Name[Cns_SHRT_NAME] = Dpt->ShrtName; + Name[Cns_FULL_NAME] = Dpt->FullName; + Frm_PutShortAndFullNames (ActionRename, + ParCod_Dpt,Dpt->DptCod, + Name, + true); // Put form /* Department WWW */ HTM_TD_Begin ("class=\"LM\""); Frm_BeginForm (ActChgDptWWW); - ParCod_PutPar (ParCod_Dpt,DptInLst->DptCod); - HTM_INPUT_URL ("WWW",DptInLst->WWW,HTM_SUBMIT_ON_CHANGE, + ParCod_PutPar (ParCod_Dpt,Dpt->DptCod); + HTM_INPUT_URL ("WWW",Dpt->WWW,HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_WWW_NARROW INPUT_%s\"" " required=\"required\"", The_GetSuffix ()); @@ -576,7 +554,7 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm /* Number of teachers */ HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ()); - HTM_Unsigned (DptInLst->NumTchs); + HTM_Unsigned (Dpt->NumTchs); HTM_TD_End (); HTM_TR_End (); @@ -821,7 +799,7 @@ static void Dpt_PutFormToCreateDepartment (void) extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *Txt_Another_institution; unsigned NumIns; - const struct Hie_Node *InsInLst; + const struct Hie_Node *Ins; Cns_ShrtOrFullName_t ShrtOrFullName; char *Name[Cns_NUM_SHRT_FULL_NAMES] = { @@ -860,12 +838,12 @@ static void Dpt_PutFormToCreateDepartment (void) NumIns < Gbl.Hierarchy.List[Hie_CTY].Num; NumIns++) { - InsInLst = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; - HTM_OPTION (HTM_Type_LONG,&InsInLst->HieCod, - InsInLst->HieCod == Dpt_EditingDpt->InsCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Ins = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; + HTM_OPTION (HTM_Type_LONG,&Ins->HieCod, + Ins->HieCod == Dpt_EditingDpt->InsCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",InsInLst->ShrtName); + "%s",Ins->ShrtName); } HTM_SELECT_End (); HTM_TD_End (); @@ -1050,7 +1028,7 @@ void Dpt_WriteSelectorDepartment (long InsCod,long DptCod, extern const char *Txt_Another_department; struct Dpt_Departments Departments; unsigned NumDpt; - const struct Dpt_Department *DptInLst; + const struct Dpt_Department *Dpt; bool NoDptSelectable; /***** Reset departments context *****/ @@ -1096,12 +1074,12 @@ void Dpt_WriteSelectorDepartment (long InsCod,long DptCod, NumDpt < Departments.Num; NumDpt++) { - DptInLst = &Departments.Lst[NumDpt]; - HTM_OPTION (HTM_Type_LONG,&DptInLst->DptCod, - DptInLst->DptCod == DptCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Dpt = &Departments.Lst[NumDpt]; + HTM_OPTION (HTM_Type_LONG,&Dpt->DptCod, + Dpt->DptCod == DptCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",DptInLst->FullName); + "%s",Dpt->FullName); } /* End selector */ diff --git a/swad_form.c b/swad_form.c index 6da93f49..8e90e469 100644 --- a/swad_form.c +++ b/swad_form.c @@ -352,3 +352,41 @@ void Frm_LabelColumn (const char *TDClass,const char *Id,const char *Label) /***** Column/cell end *****/ HTM_TD_End (); } + +/*****************************************************************************/ +/************************ Write short and full names *************************/ +/*****************************************************************************/ + +void Frm_PutShortAndFullNames (Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES], + ParCod_Param_t ParCod,long Cod, + const char *Name[Cns_NUM_SHRT_FULL_NAMES], + bool PutForm) + { + extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; + extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; + extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; + Cns_ShrtOrFullName_t ShrtOrFullName; + + for (ShrtOrFullName = Cns_SHRT_NAME; + ShrtOrFullName <= Cns_FULL_NAME; + ShrtOrFullName++) + { + HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); + if (PutForm) + { + Frm_BeginForm (ActionRename[ShrtOrFullName]); + ParCod_PutPar (ParCod,Cod); + HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], + Cns_MaxCharsShrtOrFullName[ShrtOrFullName], + Name[ShrtOrFullName], + HTM_SUBMIT_ON_CHANGE, + "class=\"%s INPUT_%s\"", + Cns_ClassShrtOrFullName[ShrtOrFullName], + The_GetSuffix ()); + Frm_EndForm (); + } + else + HTM_Txt (Name[ShrtOrFullName]); + HTM_TD_End (); + } + } diff --git a/swad_form.h b/swad_form.h index fb1c9427..91480af9 100644 --- a/swad_form.h +++ b/swad_form.h @@ -31,6 +31,7 @@ #include "swad_button.h" #include "swad_constant.h" #include "swad_cryptography.h" +#include "swad_parameter_code.h" /*****************************************************************************/ /************************** Public constants and types ***********************/ @@ -78,4 +79,9 @@ void Frm_FreeAnchorStr (char **Anchor); void Frm_LabelColumn (const char *TDClass,const char *Id,const char *Label); +void Frm_PutShortAndFullNames (Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES], + ParCod_Param_t ParCod,long Cod, + const char *Name[Cns_NUM_SHRT_FULL_NAMES], + bool PutForm); + #endif diff --git a/swad_group.c b/swad_group.c index 6103ba72..dd1d18e9 100644 --- a/swad_group.c +++ b/swad_group.c @@ -1390,13 +1390,13 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms) extern const char *Txt_No_assigned_room; extern const char *Txt_Another_room; unsigned NumGrpTyp1; - const struct GroupType *GrpTyp1InLst; + const struct GroupType *GrpTyp1; unsigned NumGrpTyp2; - const struct GroupType *GrpTyp2InLst; + const struct GroupType *GrpTyp2; unsigned NumGrpThisType; struct Group *Grp; unsigned NumRoo; - const struct Roo_Room *RooInLst; + const struct Roo_Room *Roo; Rol_Role_t Role; char StrMaxStudents[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; @@ -1411,12 +1411,12 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms) NumGrpTyp1 < Gbl.Crs.Grps.GrpTypes.NumGrpTypes; NumGrpTyp1++) { - GrpTyp1InLst = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp1]; + GrpTyp1 = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp1]; for (NumGrpThisType = 0; - NumGrpThisType < GrpTyp1InLst->NumGrps; + NumGrpThisType < GrpTyp1->NumGrps; NumGrpThisType++) { - Grp = &GrpTyp1InLst->LstGrps[NumGrpThisType]; + Grp = &GrpTyp1->LstGrps[NumGrpThisType]; HTM_TR_Begin (NULL); @@ -1471,12 +1471,12 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms) NumGrpTyp2 < Gbl.Crs.Grps.GrpTypes.NumGrpTypes; NumGrpTyp2++) { - GrpTyp2InLst = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp2]; - HTM_OPTION (HTM_Type_LONG,&GrpTyp2InLst->GrpTypCod, - GrpTyp2InLst->GrpTypCod == GrpTyp1InLst->GrpTypCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + GrpTyp2 = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp2]; + HTM_OPTION (HTM_Type_LONG,&GrpTyp2->GrpTypCod, + GrpTyp2->GrpTypCod == GrpTyp1->GrpTypCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",GrpTyp2InLst->GrpTypName); + "%s",GrpTyp2->GrpTypName); } /* End selector */ @@ -1524,12 +1524,12 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms) NumRoo < Rooms->Num; NumRoo++) { - RooInLst = &Rooms->Lst[NumRoo]; - HTM_OPTION (HTM_Type_LONG,&RooInLst->RooCod, - RooInLst->RooCod == Grp->Room.RooCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Roo = &Rooms->Lst[NumRoo]; + HTM_OPTION (HTM_Type_LONG,&Roo->RooCod, + Roo->RooCod == Grp->Room.RooCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",RooInLst->ShrtName); + "%s",Roo->ShrtName); } /* End selector */ @@ -2509,9 +2509,9 @@ static void Grp_PutFormToCreateGroup (const struct Roo_Rooms *Rooms) extern const char *Txt_No_assigned_room; extern const char *Txt_Another_room; unsigned NumGrpTyp; - const struct GroupType *GrpTypInLst; + const struct GroupType *GrpTyp; unsigned NumRoo; - const struct Roo_Room *RooInLst; + const struct Roo_Room *Roo; Rol_Role_t Role; char StrMaxStudents[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; @@ -2553,12 +2553,12 @@ static void Grp_PutFormToCreateGroup (const struct Roo_Rooms *Rooms) NumGrpTyp < Gbl.Crs.Grps.GrpTypes.NumGrpTypes; NumGrpTyp++) { - GrpTypInLst = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp]; - HTM_OPTION (HTM_Type_LONG,&GrpTypInLst->GrpTypCod, - GrpTypInLst->GrpTypCod == Gbl.Crs.Grps.GrpTyp.GrpTypCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + GrpTyp = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp]; + HTM_OPTION (HTM_Type_LONG,&GrpTyp->GrpTypCod, + GrpTyp->GrpTypCod == Gbl.Crs.Grps.GrpTyp.GrpTypCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",GrpTypInLst->GrpTypName); + "%s",GrpTyp->GrpTypName); } /* End selector */ @@ -2601,12 +2601,12 @@ static void Grp_PutFormToCreateGroup (const struct Roo_Rooms *Rooms) NumRoo < Rooms->Num; NumRoo++) { - RooInLst = &Rooms->Lst[NumRoo]; - HTM_OPTION (HTM_Type_LONG,&RooInLst->RooCod, - RooInLst->RooCod == Gbl.Crs.Grps.RooCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Roo = &Rooms->Lst[NumRoo]; + HTM_OPTION (HTM_Type_LONG,&Roo->RooCod, + Roo->RooCod == Gbl.Crs.Grps.RooCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",RooInLst->ShrtName); + "%s",Roo->ShrtName); } /* End selector */ diff --git a/swad_holiday.c b/swad_holiday.c index e6054af7..dde92eb8 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -490,9 +490,9 @@ static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays, extern const char *Txt_All_places; extern const char *Txt_HOLIDAY_TYPES[Hld_NUM_TYPES_HOLIDAY]; unsigned NumHld; - struct Hld_Holiday *HldInLst; + struct Hld_Holiday *Hld; unsigned NumPlc; - const struct Plc_Place *PlcInLst; + const struct Plc_Place *Plc; Hld_HolidayType_t HolidayType; unsigned HolidayTypeUnsigned; unsigned CurrentYear = Dat_GetCurrentYear (); @@ -519,43 +519,43 @@ static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays, NumHld < Holidays->Num; NumHld++) { - HldInLst = &Holidays->Lst[NumHld]; + Hld = &Holidays->Lst[NumHld]; HTM_TR_Begin (NULL); /* Put icon to remove holiday */ HTM_TD_Begin ("class=\"BM\""); Ico_PutContextualIconToRemove (ActRemHld,NULL, - Hld_PutParHldCod,&HldInLst->HldCod); + Hld_PutParHldCod,&Hld->HldCod); HTM_TD_End (); /* Holiday code */ HTM_TD_Begin ("class=\"CODE DAT_%s\"",The_GetSuffix ()); - HTM_TxtF ("%ld ",HldInLst->HldCod); + HTM_TxtF ("%ld ",Hld->HldCod); HTM_TD_End (); /* Holiday place */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActChgHldPlc); - ParCod_PutPar (ParCod_Hld,HldInLst->HldCod); + ParCod_PutPar (ParCod_Hld,Hld->HldCod); HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, "name=\"PlcCod\" class=\"PLC_SEL INPUT_%s\"", The_GetSuffix ()); HTM_OPTION (HTM_Type_STRING,"-1", - HldInLst->PlcCod <= 0 ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Hld->PlcCod <= 0 ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, "%s",Txt_All_places); for (NumPlc = 0; NumPlc < Places->Num; NumPlc++) { - PlcInLst = &Places->Lst[NumPlc]; - HTM_OPTION (HTM_Type_LONG,&PlcInLst->PlcCod, - PlcInLst->PlcCod == HldInLst->PlcCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Plc = &Places->Lst[NumPlc]; + HTM_OPTION (HTM_Type_LONG,&Plc->PlcCod, + Plc->PlcCod == Hld->PlcCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",PlcInLst->ShrtName); + "%s",Plc->ShrtName); } HTM_SELECT_End (); Frm_EndForm (); @@ -564,7 +564,7 @@ static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays, /* Holiday type */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActChgHldTyp); - ParCod_PutPar (ParCod_Hld,HldInLst->HldCod); + ParCod_PutPar (ParCod_Hld,Hld->HldCod); HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, "name=\"HldTyp\" class=\"INPUT_%s\"" " style=\"width:62px;\"", // TODO: Use a CSS class @@ -575,8 +575,8 @@ static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays, { HolidayTypeUnsigned = (unsigned) HolidayType; HTM_OPTION (HTM_Type_UNSIGNED,&HolidayTypeUnsigned, - HolidayType == HldInLst->HldTyp ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + HolidayType == Hld->HldTyp ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, "%s",Txt_HOLIDAY_TYPES[HolidayType]); } @@ -587,7 +587,7 @@ static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays, /* Holiday date / Non school period start date */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActChgHldStrDat); - ParCod_PutPar (ParCod_Hld,HldInLst->HldCod); + ParCod_PutPar (ParCod_Hld,Hld->HldCod); Dat_WriteFormDate (CurrentYear - 1, CurrentYear + 1, "Start", @@ -600,21 +600,21 @@ static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays, /* Non school period end date */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActChgHldEndDat); - ParCod_PutPar (ParCod_Hld,HldInLst->HldCod); + ParCod_PutPar (ParCod_Hld,Hld->HldCod); Dat_WriteFormDate (CurrentYear - 1, CurrentYear + 1, "End", &(Holidays->Lst[NumHld].EndDate), HTM_SUBMIT_ON_CHANGE, - (HldInLst->HldTyp == Hld_HOLIDAY)); + (Hld->HldTyp == Hld_HOLIDAY)); Frm_EndForm (); HTM_TD_End (); /* Holiday name */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActRenHld); - ParCod_PutPar (ParCod_Hld,HldInLst->HldCod); - HTM_INPUT_TEXT ("Name",Hld_MAX_CHARS_HOLIDAY_NAME,HldInLst->Name, + ParCod_PutPar (ParCod_Hld,Hld->HldCod); + HTM_INPUT_TEXT ("Name",Hld_MAX_CHARS_HOLIDAY_NAME,Hld->Name, HTM_SUBMIT_ON_CHANGE, "size=\"20\" class=\"INPUT_%s\"", The_GetSuffix ()); @@ -890,7 +890,7 @@ static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places) extern const char *Txt_All_places; extern const char *Txt_HOLIDAY_TYPES[Hld_NUM_TYPES_HOLIDAY]; unsigned NumPlc; - const struct Plc_Place *PlcInLst; + const struct Plc_Place *Plc; Hld_HolidayType_t HolidayType; unsigned HolidayTypeUnsigned; unsigned CurrentYear = Dat_GetCurrentYear (); @@ -925,12 +925,12 @@ static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places) NumPlc < Places->Num; NumPlc++) { - PlcInLst = &Places->Lst[NumPlc]; - HTM_OPTION (HTM_Type_LONG,&PlcInLst->PlcCod, - PlcInLst->PlcCod == Hld_EditingHld->PlcCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Plc = &Places->Lst[NumPlc]; + HTM_OPTION (HTM_Type_LONG,&Plc->PlcCod, + Plc->PlcCod == Hld_EditingHld->PlcCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",PlcInLst->ShrtName); + "%s",Plc->ShrtName); } HTM_SELECT_End (); HTM_TD_End (); diff --git a/swad_institution.c b/swad_institution.c index 8cb6dc7b..8a4ac15e 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -876,9 +876,6 @@ void Ins_WriteSelectorOfInstitution (void) static void Ins_ListInstitutionsForEdition (void) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; extern const char *Txt_INSTITUTION_STATUS[Hie_NUM_STATUS_TXT]; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = { @@ -893,8 +890,7 @@ static void Ins_ListInstitutionsForEdition (void) unsigned NumCtrs; unsigned NumUsrsIns; unsigned NumUsrsInCrssOfIns; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -953,28 +949,10 @@ static void Ins_ListInstitutionsForEdition (void) /* Institution short name and full name */ Name[Cns_SHRT_NAME] = Ins->ShrtName; Name[Cns_FULL_NAME] = Ins->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); - if (ICanEdit) - { - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_OthHie,Ins->HieCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - } - else - HTM_Txt (Name[ShrtOrFullName]); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_OthHie,Ins->HieCod, + Name, + ICanEdit); // Put form? /* Institution WWW */ HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); diff --git a/swad_institution_config.c b/swad_institution_config.c index 10d314e2..32812b37 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -299,7 +299,7 @@ static void InsCfg_Country (bool PrintView,bool PutForm) extern const char *Par_CodeStr[]; extern const char *Txt_Country; unsigned NumCty; - const struct Hie_Node *CtyInLst; + const struct Hie_Node *Cty; /***** Get list of countries *****/ Cty_GetBasicListOfCountries (); @@ -326,12 +326,12 @@ static void InsCfg_Country (bool PrintView,bool PutForm) NumCty < Gbl.Hierarchy.List[Hie_SYS].Num; NumCty++) { - CtyInLst = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; - HTM_OPTION (HTM_Type_LONG,&CtyInLst->HieCod, - CtyInLst->HieCod == Gbl.Hierarchy.Node[Hie_CTY].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Cty = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; + HTM_OPTION (HTM_Type_LONG,&Cty->HieCod, + Cty->HieCod == Gbl.Hierarchy.Node[Hie_CTY].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",CtyInLst->FullName); + "%s",Cty->FullName); } HTM_SELECT_End (); Frm_EndForm (); diff --git a/swad_link.c b/swad_link.c index b2a4b5a6..38926678 100644 --- a/swad_link.c +++ b/swad_link.c @@ -397,9 +397,6 @@ static void Lnk_FreeListLinks (struct Lnk_Links *Links) static void Lnk_ListLinksForEdition (const struct Lnk_Links *Links) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = { [Cns_SHRT_NAME] = ActRenLnkSho, @@ -407,8 +404,7 @@ static void Lnk_ListLinksForEdition (const struct Lnk_Links *Links) }; unsigned NumLnk; struct Lnk_Link *Lnk; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); @@ -439,24 +435,10 @@ static void Lnk_ListLinksForEdition (const struct Lnk_Links *Links) /* Link short name and full name */ Name[Cns_SHRT_NAME] = Lnk->ShrtName; Name[Cns_FULL_NAME] = Lnk->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"CM\""); - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_Lnk,Lnk->LnkCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"" - " required=\"required\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_Lnk,Lnk->LnkCod, + Name, + true); // Put form /* Link WWW */ HTM_TD_Begin ("class=\"CM\""); diff --git a/swad_place.c b/swad_place.c index 28a9e6da..4a149ab0 100644 --- a/swad_place.c +++ b/swad_place.c @@ -445,9 +445,6 @@ void Plc_FreeListPlaces (struct Plc_Places *Places) static void Plc_ListPlacesForEdition (const struct Plc_Places *Places) { - extern const char *Cns_ParShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern unsigned Cns_MaxCharsShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; - extern const char *Cns_ClassShrtOrFullName[Cns_NUM_SHRT_FULL_NAMES]; static Act_Action_t ActionRename[Cns_NUM_SHRT_FULL_NAMES] = { [Cns_SHRT_NAME] = ActRenPlcSho, @@ -455,8 +452,7 @@ static void Plc_ListPlacesForEdition (const struct Plc_Places *Places) }; unsigned NumPlc; struct Plc_Place *Plc; - Cns_ShrtOrFullName_t ShrtOrFullName; - char *Name[Cns_NUM_SHRT_FULL_NAMES]; + const char *Name[Cns_NUM_SHRT_FULL_NAMES]; /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); @@ -490,23 +486,10 @@ static void Plc_ListPlacesForEdition (const struct Plc_Places *Places) /* Place short name and full name */ Name[Cns_SHRT_NAME] = Plc->ShrtName; Name[Cns_FULL_NAME] = Plc->FullName; - for (ShrtOrFullName = Cns_SHRT_NAME; - ShrtOrFullName <= Cns_FULL_NAME; - ShrtOrFullName++) - { - HTM_TD_Begin ("class=\"CM\""); - Frm_BeginForm (ActionRename[ShrtOrFullName]); - ParCod_PutPar (ParCod_Plc,Plc->PlcCod); - HTM_INPUT_TEXT (Cns_ParShrtOrFullName[ShrtOrFullName], - Cns_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"", - Cns_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); - Frm_EndForm (); - HTM_TD_End (); - } + Frm_PutShortAndFullNames (ActionRename, + ParCod_Plc,Plc->PlcCod, + Name, + true); // Put form /* Number of centers */ HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ()); diff --git a/swad_record.c b/swad_record.c index 81813587..3c6ec55c 100644 --- a/swad_record.c +++ b/swad_record.c @@ -268,7 +268,7 @@ static void Rec_ListFieldsRecordsForEdition (void) { extern const char *Txt_RECORD_FIELD_VISIBILITY_MENU[Rec_NUM_TYPES_VISIBILITY]; unsigned NumField; - struct RecordField *FldInLst; + struct RecordField *Fld; Rec_VisibilityRecordFields_t Vis; unsigned VisUnsigned; char StrNumLines[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; @@ -284,20 +284,20 @@ static void Rec_ListFieldsRecordsForEdition (void) NumField < Gbl.Crs.Records.LstFields.Num; NumField++) { - FldInLst = &Gbl.Crs.Records.LstFields.Lst[NumField]; + Fld = &Gbl.Crs.Records.LstFields.Lst[NumField]; HTM_TR_Begin (NULL); /* Write icon to remove the field */ HTM_TD_Begin ("class=\"BM\""); Ico_PutContextualIconToRemove (ActReqRemFie,NULL, - Rec_PutParFldCod,&FldInLst->FieldCod); + Rec_PutParFldCod,&Fld->FieldCod); HTM_TD_End (); /* Name of the field */ HTM_TD_Begin ("class=\"LM\""); Frm_BeginForm (ActRenFie); - ParCod_PutPar (ParCod_Fld,FldInLst->FieldCod); + ParCod_PutPar (ParCod_Fld,Fld->FieldCod); HTM_INPUT_TEXT ("FieldName",Rec_MAX_CHARS_NAME_FIELD, Gbl.Crs.Records.LstFields.Lst[NumField].Name, HTM_SUBMIT_ON_CHANGE, @@ -309,9 +309,9 @@ static void Rec_ListFieldsRecordsForEdition (void) /* Number of lines in the form */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActChgRowFie); - ParCod_PutPar (ParCod_Fld,FldInLst->FieldCod); + ParCod_PutPar (ParCod_Fld,Fld->FieldCod); snprintf (StrNumLines,sizeof (StrNumLines),"%u", - FldInLst->NumLines); + Fld->NumLines); HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines, HTM_SUBMIT_ON_CHANGE, "size=\"2\" class=\"INPUT_%s\"", @@ -322,7 +322,7 @@ static void Rec_ListFieldsRecordsForEdition (void) /* Visibility of a field */ HTM_TD_Begin ("class=\"CM\""); Frm_BeginForm (ActChgVisFie); - ParCod_PutPar (ParCod_Fld,FldInLst->FieldCod); + ParCod_PutPar (ParCod_Fld,Fld->FieldCod); HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, "name=\"Visibility\" class=\"INPUT_%s\"", The_GetSuffix ()); @@ -332,8 +332,8 @@ static void Rec_ListFieldsRecordsForEdition (void) { VisUnsigned = (unsigned) Vis; HTM_OPTION (HTM_Type_UNSIGNED,&VisUnsigned, - Vis == FldInLst->Visibility ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Vis == Fld->Visibility ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, "%s",Txt_RECORD_FIELD_VISIBILITY_MENU[Vis]); } @@ -3161,7 +3161,7 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm) extern const char *Txt_Another_country; char *Label; unsigned NumCty; - const struct Hie_Node *CtyInLst; + const struct Hie_Node *Cty; /***** If list of countries is empty, try to get it *****/ Cty_GetBasicListOfCountries (); @@ -3200,12 +3200,12 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm) NumCty < Gbl.Hierarchy.List[Hie_SYS].Num; NumCty++) { - CtyInLst = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; - HTM_OPTION (HTM_Type_LONG,&CtyInLst->HieCod, - CtyInLst->HieCod == UsrDat->CtyCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Cty = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; + HTM_OPTION (HTM_Type_LONG,&Cty->HieCod, + Cty->HieCod == UsrDat->CtyCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",CtyInLst->FullName); + "%s",Cty->FullName); } HTM_SELECT_End (); HTM_TD_End (); @@ -3782,11 +3782,11 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) extern const char *Txt_Office; extern const char *Txt_Phone; unsigned NumCty; - const struct Hie_Node *CtyInLst; + const struct Hie_Node *Cty; unsigned NumIns; - const struct Hie_Node *InsInLst; + const struct Hie_Node *Ins; unsigned NumCtr; - const struct Hie_Node *CtrInLst; + const struct Hie_Node *Ctr; char StrRecordWidth[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char *Label; char *SelectClass; @@ -3832,12 +3832,12 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) NumCty < Gbl.Hierarchy.List[Hie_SYS].Num; NumCty++) { - CtyInLst = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; - HTM_OPTION (HTM_Type_LONG,&CtyInLst->HieCod, - CtyInLst->HieCod == Gbl.Usrs.Me.UsrDat.InsCtyCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Cty = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; + HTM_OPTION (HTM_Type_LONG,&Cty->HieCod, + Cty->HieCod == Gbl.Usrs.Me.UsrDat.InsCtyCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",CtyInLst->FullName); + "%s",Cty->FullName); } HTM_SELECT_End (); Frm_EndForm (); @@ -3883,12 +3883,12 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) NumIns < Gbl.Hierarchy.List[Hie_CTY].Num; NumIns++) { - InsInLst = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; - HTM_OPTION (HTM_Type_LONG,&InsInLst->HieCod, - InsInLst->HieCod == Gbl.Usrs.Me.UsrDat.InsCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Ins = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; + HTM_OPTION (HTM_Type_LONG,&Ins->HieCod, + Ins->HieCod == Gbl.Usrs.Me.UsrDat.InsCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",InsInLst->FullName); + "%s",Ins->FullName); } HTM_SELECT_End (); Frm_EndForm (); @@ -3935,12 +3935,12 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) NumCtr < Gbl.Hierarchy.List[Hie_SYS].Num; NumCtr++) { - CtrInLst = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCtr]; - HTM_OPTION (HTM_Type_LONG,&CtrInLst->HieCod, - CtrInLst->HieCod == Gbl.Usrs.Me.UsrDat.Tch.CtrCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Ctr = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCtr]; + HTM_OPTION (HTM_Type_LONG,&Ctr->HieCod, + Ctr->HieCod == Gbl.Usrs.Me.UsrDat.Tch.CtrCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - CtrInLst->FullName); + Ctr->FullName); } HTM_SELECT_End (); Frm_EndForm (); diff --git a/swad_room.c b/swad_room.c index 4f60c898..bd46a52b 100644 --- a/swad_room.c +++ b/swad_room.c @@ -770,7 +770,7 @@ static void Roo_PutSelectorBuilding (long BldCod, extern const char *Txt_No_assigned_building; extern const char *Txt_Another_building; unsigned NumBld; - const struct Bld_Building *BldInLst; + const struct Bld_Building *Bld; /***** Begin selector *****/ HTM_SELECT_Begin (SubmitOnChange,NULL, @@ -796,12 +796,12 @@ static void Roo_PutSelectorBuilding (long BldCod, NumBld < Buildings->Num; NumBld++) { - BldInLst = &Buildings->Lst[NumBld]; - HTM_OPTION (HTM_Type_LONG,&BldInLst->BldCod, - BldCod == BldInLst->BldCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + Bld = &Buildings->Lst[NumBld]; + HTM_OPTION (HTM_Type_LONG,&Bld->BldCod, + BldCod == Bld->BldCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",BldInLst->ShrtName); + "%s",Bld->ShrtName); } /***** End selector *****/