From 6f566c2ab875fc5b9a1324220791b3f5bc8d3c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 23 Oct 2019 21:37:01 +0200 Subject: [PATCH] Version19.42.3 --- swad_HTML.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ swad_HTML.h | 1 + swad_account.c | 18 +++++++++--------- swad_agenda.c | 34 +++++++++++++++------------------ swad_alert.c | 4 ++-- swad_announcement.c | 11 +++++------ swad_assignment.c | 15 ++++++--------- swad_attendance.c | 14 ++++++-------- swad_banner.c | 2 +- swad_box.c | 12 ++++++------ swad_button.c | 6 +++--- swad_calendar.c | 10 +++++----- swad_centre.c | 12 ++++++------ swad_changelog.h | 3 ++- swad_connected.c | 25 +++++++++++++----------- swad_cookie.c | 6 +++--- swad_country.c | 12 ++++++------ swad_course.c | 6 +++--- swad_date.c | 8 ++++---- swad_degree.c | 6 +++--- swad_enrolment.c | 14 +++++++------- 21 files changed, 153 insertions(+), 112 deletions(-) diff --git a/swad_HTML.c b/swad_HTML.c index 17bfb8d3..f3c383c3 100644 --- a/swad_HTML.c +++ b/swad_HTML.c @@ -59,6 +59,7 @@ static unsigned HTM_TABLE_NestingLevel = 0; static unsigned HTM_TR_NestingLevel = 0; static unsigned HTM_TH_NestingLevel = 0; static unsigned HTM_TD_NestingLevel = 0; +static unsigned HTM_DIV_NestingLevel = 0; /*****************************************************************************/ /***************************** Private prototypes ****************************/ @@ -73,6 +74,8 @@ static void HTM_TH_BeginAttr (const char *fmt,...); static void HTM_TD_BeginWithoutAttr (void); +static void HTM_DIV_BeginWithoutAttr (void); + /*****************************************************************************/ /******************************* Start/end table *****************************/ /*****************************************************************************/ @@ -447,7 +450,50 @@ void HTM_TD_ColouredEmpty (unsigned NumColumns) /************************************ Divs ***********************************/ /*****************************************************************************/ +void HTM_DIV_Begin (const char *fmt,...) + { + va_list ap; + int NumBytesPrinted; + char *Attr; + + if (fmt) + { + if (fmt[0]) + { + va_start (ap,fmt); + NumBytesPrinted = vasprintf (&Attr,fmt,ap); + va_end (ap); + + if (NumBytesPrinted < 0) // If memory allocation wasn't possible, + // or some other error occurs, + // vasprintf will return -1 + Lay_NotEnoughMemoryExit (); + + /***** Print HTML *****/ + fprintf (Gbl.F.Out,"
",Attr); + + free ((void *) Attr); + } + else + HTM_DIV_BeginWithoutAttr (); + } + else + HTM_DIV_BeginWithoutAttr (); + + HTM_DIV_NestingLevel++; + } + +static void HTM_DIV_BeginWithoutAttr (void) + { + fprintf (Gbl.F.Out,"
"); + } + void HTM_DIV_End (void) { + if (HTM_DIV_NestingLevel == 0) // No TH open + Ale_ShowAlert (Ale_ERROR,"Trying to close unopened DIV."); + fprintf (Gbl.F.Out,"
"); + + HTM_TD_NestingLevel--; } diff --git a/swad_HTML.h b/swad_HTML.h index 3bd47395..c7b64834 100644 --- a/swad_HTML.h +++ b/swad_HTML.h @@ -62,6 +62,7 @@ void HTM_TD_End (void); void HTM_TD_Empty (unsigned NumColumns); void HTM_TD_ColouredEmpty (unsigned NumColumns); +void HTM_DIV_Begin (const char *fmt,...); void HTM_DIV_End (void); #endif diff --git a/swad_account.c b/swad_account.c index b6d6fc06..95baa35a 100644 --- a/swad_account.c +++ b/swad_account.c @@ -116,7 +116,7 @@ void Acc_ShowFormMyAccount (void) else // Not logged { /***** Links to other actions *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CONTEXT_MENU\""); Usr_PutLinkToLogin (); Pwd_PutLinkToSendNewPasswd (); Lan_PutLinkToChangeLanguage (); @@ -189,7 +189,7 @@ void Acc_CheckIfEmptyAccountExists (void) MYSQL_ROW row; /***** Links to other actions *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CONTEXT_MENU\""); Usr_PutLinkToLogin (); Pwd_PutLinkToSendNewPasswd (); Lan_PutLinkToChangeLanguage (); @@ -325,7 +325,7 @@ static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrD void Acc_ShowFormCreateMyAccount (void) { /***** Links to other actions *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CONTEXT_MENU\""); Usr_PutLinkToLogin (); Pwd_PutLinkToSendNewPasswd (); Lan_PutLinkToChangeLanguage (); @@ -486,16 +486,16 @@ void Acc_ShowFormChgMyAccount (void) } /***** Start container for this user *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"REC_USR\""); /***** Show form to change my password and my nickname ****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"REC_LEFT\""); Pwd_ShowFormChgMyPwd (); Nck_ShowFormChangeMyNickname (IMustCreateMyNicknameNow); HTM_DIV_End (); /***** Show form to change my email and my ID *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"REC_RIGHT\""); Mai_ShowFormChangeMyEmail (IMustFillInMyEmailNow,IShouldConfirmMyEmailNow); ID_ShowFormChangeMyID (IShouldFillInMyIDNow); HTM_DIV_End (); @@ -525,16 +525,16 @@ void Acc_ShowFormChgOtherUsrAccount (void) &Gbl.Usrs.Other.UsrDat,NULL); /***** Start container for this user *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"REC_USR\""); /***** Show form to change password and nickname *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"REC_LEFT\""); Pwd_ShowFormChgOtherUsrPwd (); Nck_ShowFormChangeOtherUsrNickname (); HTM_DIV_End (); /***** Show form to change email and ID *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"REC_RIGHT\""); Mai_ShowFormChangeOtherUsrEmail (); ID_ShowFormChangeOtherUsrID (); HTM_DIV_End (); diff --git a/swad_agenda.c b/swad_agenda.c index 19a52499..5d3d8be2 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -193,9 +193,9 @@ static void Agd_ShowFormToSelPast__FutureEvents (void) PstFut <= Agd_FUTURE_EVENTS; PstFut++) { - fprintf (Gbl.F.Out,"
", - (Gbl.Agenda.Past__FutureEvents & (1 << PstFut)) ? "PREF_ON" : - "PREF_OFF"); + HTM_DIV_Begin ("class=\"%s\"", + (Gbl.Agenda.Past__FutureEvents & (1 << PstFut)) ? "PREF_ON" : + "PREF_OFF"); Frm_StartForm (ActSeeMyAgd); Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents ^ (1 << PstFut), // Toggle Gbl.Agenda.PrivatPublicEvents, @@ -229,9 +229,9 @@ static void Agd_ShowFormToSelPrivatPublicEvents (void) PrvPub <= Agd_PUBLIC_EVENTS; PrvPub++) { - fprintf (Gbl.F.Out,"
", - (Gbl.Agenda.PrivatPublicEvents & (1 << PrvPub)) ? "PREF_ON" : - "PREF_OFF"); + HTM_DIV_Begin ("class=\"%s\"", + (Gbl.Agenda.PrivatPublicEvents & (1 << PrvPub)) ? "PREF_ON" : + "PREF_OFF"); Frm_StartForm (ActSeeMyAgd); Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents, Gbl.Agenda.PrivatPublicEvents ^ (1 << PrvPub), // Toggle @@ -265,9 +265,9 @@ static void Agd_ShowFormToSelHiddenVisiblEvents (void) HidVis <= Agd_VISIBL_EVENTS; HidVis++) { - fprintf (Gbl.F.Out,"
", - (Gbl.Agenda.HiddenVisiblEvents & (1 << HidVis)) ? "PREF_ON" : - "PREF_OFF"); + HTM_DIV_Begin ("class=\"%s\"", + (Gbl.Agenda.HiddenVisiblEvents & (1 << HidVis)) ? "PREF_ON" : + "PREF_OFF"); Frm_StartForm (ActSeeMyAgd); Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents, Gbl.Agenda.PrivatPublicEvents, @@ -772,11 +772,9 @@ static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod) /* Location */ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - fprintf (Gbl.F.Out,"
" - "%s", - AgdEvent.Hidden ? "ASG_TITLE_LIGHT" : - "ASG_TITLE", - AgdEvent.Location); + HTM_DIV_Begin ("class=\"%s\"",AgdEvent.Hidden ? "ASG_TITLE_LIGHT" : + "ASG_TITLE"); + fprintf (Gbl.F.Out,"%s",AgdEvent.Location); HTM_DIV_End (); HTM_TD_End (); @@ -805,11 +803,9 @@ static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod) Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - fprintf (Gbl.F.Out,"
" - "%s", - AgdEvent.Hidden ? "DAT_LIGHT" : - "DAT", - Txt); + HTM_DIV_Begin ("class=\"PAR %s\"",AgdEvent.Hidden ? "DAT_LIGHT" : + "DAT"); + fprintf (Gbl.F.Out,"%s",Txt); HTM_DIV_End (); HTM_TD_End (); diff --git a/swad_alert.c b/swad_alert.c index 72c722ff..35cdfd22 100644 --- a/swad_alert.c +++ b/swad_alert.c @@ -413,12 +413,12 @@ static void Ale_ShowFixAlertAndButton1 (Ale_AlertType_t AlertType,const char *Tx fprintf (Gbl.F.Out," id=\"%s\"",IdAlert); } fprintf (Gbl.F.Out," class=\"CM\">"); - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"ALERT\""); /***** Icon to close the alert *****/ if (AlertClosable[AlertType]) { - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"ALERT_CLOSE\""); fprintf (Gbl.F.Out,"" ""); + HTM_DIV_Begin ("class=\"CM\""); for (NumAnn = 0; NumAnn < NumAnnouncements; @@ -303,8 +303,7 @@ static void Ann_DrawAnAnnouncement (long AnnCod,Ann_Status_t Status, Gbl.Announcements.AnnCod = AnnCod; // Parameter for forms /***** Start yellow note *****/ - fprintf (Gbl.F.Out,"
", - ContainerClass[Status]); + HTM_DIV_Begin ("class=\"%s\"",ContainerClass[Status]); if (ICanEdit) { @@ -324,17 +323,17 @@ static void Ann_DrawAnAnnouncement (long AnnCod,Ann_Status_t Status, } /***** Write the subject of the announcement *****/ - fprintf (Gbl.F.Out,"
",SubjectClass[Status]); + HTM_DIV_Begin ("class=\"%s\"",SubjectClass[Status]); fprintf (Gbl.F.Out,"%s",Subject); HTM_DIV_End (); /***** Write the content of the announcement *****/ - fprintf (Gbl.F.Out,"
",ContentClass[Status]); + HTM_DIV_Begin ("class=\"%s\"",ContentClass[Status]); fprintf (Gbl.F.Out,"%s",Content); HTM_DIV_End (); /***** Write form *****/ - fprintf (Gbl.F.Out,"
",UsersClass[Status]); + HTM_DIV_Begin ("class=\"NOTICE_USERS %s\"",UsersClass[Status]); if (ShowAllAnnouncements) { diff --git a/swad_assignment.c b/swad_assignment.c index af3fc855..e94236a6 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -443,9 +443,8 @@ static void Asg_ShowOneAssignment (long AsgCod,bool PrintView) HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); if (Gbl.Crs.Grps.NumGrps) Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (&Asg); - fprintf (Gbl.F.Out,"
", - Asg.Hidden ? "DAT_LIGHT" : - "DAT"); + HTM_DIV_Begin ("class=\"PAR %s\"",Asg.Hidden ? "DAT_LIGHT" : + "DAT"); fprintf (Gbl.F.Out,"%s",Txt); HTM_DIV_End (); HTM_TD_End (); @@ -1632,12 +1631,10 @@ static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Assignment *Asg) Asg->AsgCod); /***** Write heading *****/ - fprintf (Gbl.F.Out,"
", - Asg->Hidden ? "ASG_GRP_LIGHT" : - "ASG_GRP"); - fprintf (Gbl.F.Out,"%s: ", - (NumRows == 1) ? Txt_Group : - Txt_Groups); + HTM_DIV_Begin ("class=\"%s\"",Asg->Hidden ? "ASG_GRP_LIGHT" : + "ASG_GRP"); + fprintf (Gbl.F.Out,"%s: ",(NumRows == 1) ? Txt_Group : + Txt_Groups); /***** Write groups *****/ if (NumRows) // Groups found... diff --git a/swad_attendance.c b/swad_attendance.c index 1641cb06..b49d0046 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -172,14 +172,14 @@ void Att_SeeAttEvents (void) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CONTEXT_MENU\""); Att_PutFormToListMyAttendance (); HTM_DIV_End (); break; case Rol_NET: case Rol_TCH: case Rol_SYS_ADM: - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CONTEXT_MENU\""); Att_PutFormToListStdsAttendance (); HTM_DIV_End (); break; @@ -481,9 +481,8 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); if (Gbl.Crs.Grps.NumGrps) Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (Att); - fprintf (Gbl.F.Out,"
", - Att->Hidden ? "DAT_LIGHT" : - "DAT"); + HTM_DIV_Begin ("class=\"%s\"",Att->Hidden ? "DAT_LIGHT" : + "DAT"); fprintf (Gbl.F.Out,"%s",Description); HTM_DIV_End (); HTM_TD_End (); @@ -1523,9 +1522,8 @@ static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct AttendanceEve Att->AttCod); /***** Write heading *****/ - fprintf (Gbl.F.Out,"
", - Att->Hidden ? "ASG_GRP_LIGHT" : - "ASG_GRP"); + HTM_DIV_Begin ("class=\"%s\"",Att->Hidden ? "ASG_GRP_LIGHT" : + "ASG_GRP"); fprintf (Gbl.F.Out,"%s: ", (NumGrps == 1) ? Txt_Group : Txt_Groups); diff --git a/swad_banner.c b/swad_banner.c index 5be9da01..ac85445c 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -1045,7 +1045,7 @@ void Ban_WriteMenuWithBanners (void) NumBan++) { /* Write data of this banner */ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CM\""); Frm_StartForm (ActClkBan); Ban_PutParamBanCod (Gbl.Banners.Lst[NumBan].BanCod); Par_PutHiddenParamString ("URL",Gbl.Banners.Lst[NumBan].WWW); diff --git a/swad_box.c b/swad_box.c index a94145b9..94973f29 100644 --- a/swad_box.c +++ b/swad_box.c @@ -155,18 +155,18 @@ static void Box_StartBoxInternal (const char *Width,const char *Title, fprintf (Gbl.F.Out,">"); /***** Row for left and right icons *****/ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"FRAME_ICO\""); /* Contextual icons at left */ if (FunctionToDrawContextualIcons) { - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"FRAME_ICO_LEFT\""); FunctionToDrawContextualIcons (); HTM_DIV_End (); } /* Icons at right: help and close */ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"FRAME_ICO_RIGHT\""); if (HelpLink) // Link to help { @@ -195,9 +195,9 @@ static void Box_StartBoxInternal (const char *Width,const char *Title, /***** Frame title *****/ if (Title) { - fprintf (Gbl.F.Out,"
", - Gbl.Box.Nested ? "FRAME_TITLE_SMALL" : - "FRAME_TITLE_BIG"); + HTM_DIV_Begin ("class=\"FRAME_TITLE %s\"", + Gbl.Box.Nested ? "FRAME_TITLE_SMALL" : + "FRAME_TITLE_BIG"); fprintf (Gbl.F.Out,"%s",Title); HTM_DIV_End (); } diff --git a/swad_button.c b/swad_button.c index ad2dbd17..f7a023a3 100644 --- a/swad_button.c +++ b/swad_button.c @@ -99,7 +99,7 @@ void Btn_PutButtonInline (Btn_Button_t Button,const char *TxtButton) void Btn_PutCreateButton (const char *TxtButton) { - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CM\""); fprintf (Gbl.F.Out,"", @@ -117,7 +117,7 @@ void Btn_PutCreateButtonInline (const char *TxtButton) void Btn_PutConfirmButton (const char *TxtButton) { - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CM\""); fprintf (Gbl.F.Out,"", @@ -135,7 +135,7 @@ void Btn_PutConfirmButtonInline (const char *TxtButton) void Btn_PutRemoveButton (const char *TxtButton) { - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CM\""); fprintf (Gbl.F.Out,"", diff --git a/swad_calendar.c b/swad_calendar.c index d3fe48c1..8755ccb4 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -117,9 +117,9 @@ void Cal_ShowFormToSelFirstDayOfWeek (Act_Action_t Action,void (*FuncParams) (vo FirstDayOfWeek++) if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek]) { - fprintf (Gbl.F.Out,"
", - FirstDayOfWeek == Gbl.Prefs.FirstDayOfWeek ? "PREF_ON" : - "PREF_OFF"); + HTM_DIV_Begin ("class=\"%s\"", + FirstDayOfWeek == Gbl.Prefs.FirstDayOfWeek ? "PREF_ON" : + "PREF_OFF"); Frm_StartForm (Action); Par_PutHiddenParamUnsigned ("FirstDayOfWeek",FirstDayOfWeek); if (FuncParams) // Extra parameters depending on the action @@ -210,7 +210,7 @@ void Cal_DrawCurrentMonth (void) /***** Draw the month in JavaScript *****/ /* JavaScript will write HTML here */ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("id=\"CurrentMonth\""); HTM_DIV_End (); /* Write script to draw the month */ @@ -278,7 +278,7 @@ static void Cal_DrawCalendar (Act_Action_t ActionSeeCalendar, /***** Draw several months *****/ /* JavaScript will write HTML here */ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("id=\"calendar\""); HTM_DIV_End (); /* Write script to draw the month */ diff --git a/swad_centre.c b/swad_centre.c index 460f5dde..fa85bfad 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -332,7 +332,7 @@ static void Ctr_Configuration (bool PrintView) /***** Title *****/ PutLink = !PrintView && Gbl.Hierarchy.Ctr.WWW[0]; - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"FRAME_TITLE FRAME_TITLE_BIG\""); if (PutLink) fprintf (Gbl.F.Out,"", @@ -352,7 +352,7 @@ static void Ctr_Configuration (bool PrintView) Ctr_GetPhotoAttribution (Gbl.Hierarchy.Ctr.CtrCod,&PhotoAttribution); /* Photo image */ - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"DAT_SMALL CM\""); if (PutLink) fprintf (Gbl.F.Out,"", Gbl.Hierarchy.Ctr.WWW); @@ -377,7 +377,7 @@ static void Ctr_Configuration (bool PrintView) // Only centre admins, institution admins and centre admins // have permission to edit photo attribution { - fprintf (Gbl.F.Out,"
"); + HTM_DIV_Begin ("class=\"CM\""); Frm_StartForm (ActChgCtrPhoAtt); fprintf (Gbl.F.Out,"