diff --git a/swad_HTML.c b/swad_HTML.c
index 7bb4e77f..f77cf964 100644
--- a/swad_HTML.c
+++ b/swad_HTML.c
@@ -1246,17 +1246,40 @@ void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr)
Attr);
}
-void HTM_INPUT_IMAGE (const char *URL,const char *Icon,
- const char *Title,const char *Class)
+void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,
+ const char *fmt,...)
{
+ va_list ap;
+ int NumBytesPrinted;
+ char *Attr;
+
HTM_TxtF ("",
- Title,Title,Class);
+ HTM_TxtF (" alt=\"%s\" title=\"%s\"",
+ Title,Title);
+
+ if (fmt)
+ {
+ if (fmt[0])
+ {
+ va_start (ap,fmt);
+ NumBytesPrinted = vasprintf (&Attr,fmt,ap);
+ va_end (ap);
+ if (NumBytesPrinted < 0) // -1 if no memory or any other error
+ Err_NotEnoughMemoryExit ();
+
+ /***** Print attributes *****/
+ HTM_SPTxt (Attr);
+
+ free (Attr);
+ }
+ }
+
+ HTM_Txt (" />");
}
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
diff --git a/swad_HTML.h b/swad_HTML.h
index 6cf9b2af..38cc3ab9 100644
--- a/swad_HTML.h
+++ b/swad_HTML.h
@@ -148,8 +148,8 @@ void HTM_INPUT_FILE (const char *Name,const char *Accept,
HTM_SubmitOnChange_t SubmitOnChange,
const char *fmt,...);
void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr);
-void HTM_INPUT_IMAGE (const char *URL,const char *Icon,
- const char *Title,const char *Class);
+void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,
+ const char *fmt,...);
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
const char *AutoComplete,bool Required,
const char *fmt,...);
diff --git a/swad_banner.c b/swad_banner.c
index c4f4d356..c3a056e5 100644
--- a/swad_banner.c
+++ b/swad_banner.c
@@ -1051,7 +1051,8 @@ void Ban_WriteMenuWithBanners (void)
/* Banner image */
HTM_INPUT_IMAGE (Cfg_URL_BANNER_PUBLIC,Banners.Lst[NumBan].Img,
- Banners.Lst[NumBan].FullName,"BANNER");
+ Banners.Lst[NumBan].FullName,
+ "class=\"BANNER\"");
/* End form */
Frm_EndForm ();
diff --git a/swad_browser.c b/swad_browser.c
index 5239c2bd..547838d7 100644
--- a/swad_browser.c
+++ b/swad_browser.c
@@ -5138,7 +5138,6 @@ static void Brw_PutIconFileWithLinkToViewMetadata (struct FileMetadata *FileMeta
{
extern const char *Ico_ClassColor[Ico_NUM_COLORS][The_NUM_THEMES];
extern const char *Txt_Link;
- char *Class;
/***** Begin cell *****/
HTM_TD_Begin ("class=\"BM %s\"",Gbl.ColorRows[Gbl.RowEvenOdd]);
@@ -5151,18 +5150,14 @@ static void Brw_PutIconFileWithLinkToViewMetadata (struct FileMetadata *FileMeta
FileMetadata->FilCod);
/***** Icon depending on the file extension *****/
- if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE)
- Brw_PutIconFile (FileMetadata->FilFolLnk.Name,
- "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16",
- true); // Put link to view metadata
- else
- {
- if (asprintf (&Class,"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s",
- Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0)
- Err_NotEnoughMemoryExit ();
- HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"link.svg",Txt_Link,Class);
- free (Class);
- }
+ if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE)
+ Brw_PutIconFile (FileMetadata->FilFolLnk.Name,
+ "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16",
+ true); // Put link to view metadata
+ else
+ HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"link.svg",Txt_Link,
+ "class=\"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s\"",
+ Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
/***** End form *****/
Frm_EndForm ();
@@ -5212,10 +5207,9 @@ static void Brw_PutIconFile (const char *FileName,
}
if (PutLinkToViewMetadata)
- HTM_INPUT_IMAGE (URL,Icon,Title,Class);
+ HTM_INPUT_IMAGE (URL,Icon,Title,"class=\"%s\"",Class);
else
- HTM_IMG (URL,Icon,Title,
- "class=\"%s\"",Class);
+ HTM_IMG (URL,Icon,Title,"class=\"%s\"",Class);
free (Title);
free (Icon);
free (URL);
diff --git a/swad_changelog.h b/swad_changelog.h
index a2c8ea5e..0972ba06 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
TODO: Attach pdf files in multimedia.
*/
-#define Log_PLATFORM_VERSION "SWAD 21.83.6 (2022-03-15)"
+#define Log_PLATFORM_VERSION "SWAD 21.83.7 (2022-03-16)"
#define CSS_FILE "swad21.83.5.css"
#define JS_FILE "swad21.78.2.js"
/*
+ Version 21.83.7: Mar 16, 2022 Code refactoring in forms (input image). (323585 lines)
Version 21.83.6: Mar 15, 2022 Working on design of dark theme. (323581 lines)
Version 21.83.5: Mar 15, 2022 Working on design of dark theme. (323559 lines)
Version 21.83.4: Mar 11, 2022 Code refactoring in timetable. (323543 lines)
diff --git a/swad_connected.c b/swad_connected.c
index 1f6e1ec7..a3152fd8 100644
--- a/swad_connected.c
+++ b/swad_connected.c
@@ -425,7 +425,8 @@ static void Con_ShowConnectedUsrsWithARoleBelongingToCurrentCrsOnRightColumn (Ro
// is dynamically updated via AJAX
Sco_PutParamScope ("ScopeCon",HieLvl_CRS);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"ellipsis-h.svg",
- Txt_Connected_users,"ICO16x16");
+ Txt_Connected_users,
+ "class=\"ICO16x16\"");
Frm_EndForm ();
HTM_TD_End ();
HTM_TR_End ();
diff --git a/swad_course.c b/swad_course.c
index 4db1aecc..fe39d891 100644
--- a/swad_course.c
+++ b/swad_course.c
@@ -2220,7 +2220,7 @@ void Crs_PutIconToSelectMyCoursesInBreadcrumb (void)
/***** Put icon with link *****/
HTM_INPUT_IMAGE (Gbl.Prefs.URLTheme,"sitemap.svg",Txt_My_courses,
- "BC_ICON ICO_HIGHLIGHT");
+ "class=\"BC_ICON ICO_HIGHLIGHT\"");
/***** End form *****/
Frm_EndForm ();
diff --git a/swad_follow.c b/swad_follow.c
index c12c9284..4c64cc34 100644
--- a/swad_follow.c
+++ b/swad_follow.c
@@ -368,7 +368,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
"user-plus.svg",
IFollowUsr ? Txt_Following_unfollow :
Txt_Follow,
- "ICO_HIGHLIGHT ICO40x40");
+ "class=\"ICO_HIGHLIGHT ICO40x40\"");
Frm_EndForm ();
}
HTM_DIV_End ();
@@ -749,16 +749,13 @@ static void Fol_PutIconToFollow (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_
{
extern const char *Ico_ClassColor[Ico_NUM_COLORS][The_NUM_THEMES];
extern const char *Txt_Follow;
- char *Class;
/***** Form to unfollow *****/
Frm_BeginForm (ActFolUsr);
Usr_PutParamUsrCodEncrypted (EncryptedUsrCod);
- if (asprintf (&Class,"FOLLOW_USR_ICO ICO16x16 %s ICO_HIGHLIGHT",
- Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0)
- Err_NotEnoughMemoryExit ();
- HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",Txt_Follow,Class);
- free (Class);
+ HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",Txt_Follow,
+ "class=\"FOLLOW_USR_ICO ICO16x16 %s ICO_HIGHLIGHT\"",
+ Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
Frm_EndForm ();
}
@@ -774,7 +771,8 @@ static void Fol_PutIconToUnfollow (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTE
Frm_BeginForm (ActUnfUsr);
Usr_PutParamUsrCodEncrypted (EncryptedUsrCod);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-check.svg",
- Txt_Unfollow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
+ Txt_Unfollow,
+ "class=\"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16\"");
Frm_EndForm ();
}
diff --git a/swad_icon.c b/swad_icon.c
index ba8f81cb..dec372d3 100644
--- a/swad_icon.c
+++ b/swad_icon.c
@@ -454,13 +454,9 @@ void Ico_PutDivIcon (const char *DivClass,const char *Icon,Ico_Color_t Color,con
void Ico_PutIconLink (const char *Icon,Ico_Color_t Color,const char *Title)
{
- char *Class;
-
- if (asprintf (&Class,"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s",
- Ico_ClassColor[Color][Gbl.Prefs.Theme]) < 0)
- Err_NotEnoughMemoryExit ();
- HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,Class);
- free (Class);
+ HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,
+ "class=\"CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16 %s\"",
+ Ico_ClassColor[Color][Gbl.Prefs.Theme]);
}
/*****************************************************************************/
@@ -482,13 +478,9 @@ void Ico_PutIconTextLink (const char *Icon,Ico_Color_t Color,const char *Text)
void Ico_PutSettingIconLink (const char *Icon,Ico_Color_t Color,const char *Title)
{
- char *Class;
-
- if (asprintf (&Class,"ICO_HIGHLIGHT ICOx20 %s",
- Ico_ClassColor[Color][Gbl.Prefs.Theme]) < 0)
- Err_NotEnoughMemoryExit ();
- HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,Class);
- free (Class);
+ HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon,Title,
+ "class=\"ICO_HIGHLIGHT ICOx20 %s\"",
+ Ico_ClassColor[Color][Gbl.Prefs.Theme]);
}
/*****************************************************************************/
diff --git a/swad_layout.c b/swad_layout.c
index b948bc2e..6aa73357 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -1007,12 +1007,14 @@ static void Lay_WritePageTopHeading (void)
HTM_DIV_Begin ("id=\"head_row_1_logo_small\"");
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Cfg_PLATFORM_LOGO_SMALL_FILENAME,
- Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_LOGO_SMALL_CLASS);
+ Cfg_PLATFORM_SHORT_NAME,
+ "class=\"%s\"",Cfg_PLATFORM_LOGO_SMALL_CLASS);
HTM_DIV_End (); // head_row_1_logo_small
HTM_DIV_Begin ("id=\"head_row_1_logo_big\"");
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Cfg_PLATFORM_LOGO_BIG_FILENAME,
- Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_LOGO_BIG_CLASS);
+ Cfg_PLATFORM_SHORT_NAME,
+ "class=\"%s\"",Cfg_PLATFORM_LOGO_BIG_CLASS);
HTM_DIV_End (); // head_row_1_logo_big
HTM_DIV_Begin ("id=\"head_row_1_tagline\" class=\"TAGLINE_%s\"",
diff --git a/swad_match.c b/swad_match.c
index 13f86e24..5c081a57 100644
--- a/swad_match.c
+++ b/swad_match.c
@@ -1319,7 +1319,8 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
/***** Put icon to submit the form *****/
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"play.svg",
- Txt_Play,"CONTEXT_OPT ICO_HIGHLIGHT ICO64x64");
+ Txt_Play,
+ "class=\"CONTEXT_OPT ICO_HIGHLIGHT ICO64x64\"");
/***** End box *****/
Box_BoxEnd ();
diff --git a/swad_photo_shape.c b/swad_photo_shape.c
index 1150ee8b..773202f7 100644
--- a/swad_photo_shape.c
+++ b/swad_photo_shape.c
@@ -70,7 +70,6 @@ void PhoSha_PutIconsToSelectPhotoShape (void)
[PhoSha_SHAPE_RECTANGLE] = "ICO_HIGHLIGHT PHOTOR15x20B",
};
PhoSha_Shape_t Shape;
- char *Class;
Box_BoxBegin (NULL,Txt_User_photos,
PhoSha_PutIconsPhotoShape,NULL,
@@ -88,13 +87,11 @@ void PhoSha_PutIconsToSelectPhotoShape (void)
HTM_DIV_Begin ("class=\"PREF_OFF\"");
Frm_BeginForm (ActChgUsrPho);
Par_PutHiddenParamUnsigned (NULL,"PhotoShape",Shape);
- if (asprintf (&Class,"%s %s",
- ClassPhoto[Shape],
- Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0)
- Err_NotEnoughMemoryExit ();
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user.svg",
- Txt_PHOTO_SHAPES[Shape],Class);
- free (Class);
+ Txt_PHOTO_SHAPES[Shape],
+ "class=\"%s %s\"",
+ ClassPhoto[Shape],
+ Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
Frm_EndForm ();
HTM_DIV_End ();
}
diff --git a/swad_user.c b/swad_user.c
index d96721db..18785e4a 100644
--- a/swad_user.c
+++ b/swad_user.c
@@ -6510,7 +6510,6 @@ void Usr_PutWhoIcon (Usr_Who_t Who)
[Usr_WHO_FOLLOWED] = "user-check.svg",
[Usr_WHO_ALL ] = "users.svg",
};
- char *Class;
switch (Who)
{
@@ -6522,16 +6521,14 @@ void Usr_PutWhoIcon (Usr_Who_t Who)
Gbl.Usrs.Me.PhotoURL[0] ? NULL :
"usr_bl.jpg",
Txt_WHO[Who],
- "ICO_HIGHLIGHT PHOTOR15x20");
+ "class=\"ICO_HIGHLIGHT PHOTOR15x20\"");
break;
case Usr_WHO_SELECTED:
case Usr_WHO_FOLLOWED:
case Usr_WHO_ALL:
- if (asprintf (&Class,"ICO_HIGHLIGHT ICOx20 %s",
- Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0)
- Err_NotEnoughMemoryExit ();
- HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon[Who],Txt_WHO[Who],Class);
- free (Class);
+ HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,Icon[Who],Txt_WHO[Who],
+ "class=\"ICO_HIGHLIGHT ICOx20 %s\"",
+ Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]);
break;
default:
Err_WrongWhoExit ();