diff --git a/swad_changelog.h b/swad_changelog.h
index 072b2ee88..5847ea1c2 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -487,7 +487,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.46.8 (2019-10-29)"
+#define Log_PLATFORM_VERSION "SWAD 19.46.9 (2019-10-29)"
#define CSS_FILE "swad19.45.css"
#define JS_FILE "swad19.39.js"
/*
@@ -495,6 +495,7 @@ ps2pdf source.ps destination.pdf
// TODO: Impedir la creación y edición de proyectos si no son editables.
// TODO: Continuar convirtiendo ",
- Cfg_URL_ICON_PUBLIC,Color,
- NumUsrs,NumUsrs == 1 ? Txt_ROLES_SINGUL_abc[Rol_STD][Usr_SEX_UNKNOWN] :
- Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_UNKNOWN],
- BarWidth);
+ if (asprintf (&Icon,"score%u_1x1.png",Color) < 0) // Background
+ Lay_NotEnoughMemoryExit ();
+ if (asprintf (&Title,"%u %s",
+ NumUsrs,
+ NumUsrs == 1 ? Txt_ROLES_SINGUL_abc[Rol_STD][Usr_SEX_UNKNOWN] :
+ Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_UNKNOWN]) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,Title,
+ "class=\"MCH_SCO_BAR\" style=\"width:%u%%;\"",BarWidth);
fprintf (Gbl.F.Out," %u",NumUsrs);
+ free ((void *) Title);
+ free ((void *) Icon);
HTM_TD_End ();
HTM_TR_End ();
diff --git a/swad_media.c b/swad_media.c
index b61bf1a88..05e91070a 100644
--- a/swad_media.c
+++ b/swad_media.c
@@ -1530,7 +1530,7 @@ static void Med_ShowJPG (struct Media *Media,
extern const char *Txt_File_not_found;
char FileNameMedia[NAME_MAX + 1];
char FullPathMediaPriv[PATH_MAX + 1];
- char URL_JPG[PATH_MAX + 1];
+ char *URL;
/***** Build private path to JPG *****/
snprintf (FileNameMedia,sizeof (FileNameMedia),
@@ -1547,20 +1547,15 @@ static void Med_ShowJPG (struct Media *Media,
in order to gain access to it for showing/downloading *****/
Brw_CreateTmpPublicLinkToPrivateFile (FullPathMediaPriv,FileNameMedia);
- /***** Build URL pointing to symbolic link *****/
- snprintf (URL_JPG,sizeof (URL_JPG),
- "%s/%s/%s/%s",
- Cfg_URL_FILE_BROWSER_TMP_PUBLIC,
- Gbl.FileBrowser.TmpPubDir.L,
- Gbl.FileBrowser.TmpPubDir.R,
- FileNameMedia);
-
/***** Show media *****/
- fprintf (Gbl.F.Out,"Title)
- if (Media->Title[0])
- fprintf (Gbl.F.Out," title=\"%s\"",Media->Title);
- fprintf (Gbl.F.Out," lazyload=\"on\" />"); // Lazy load of the media
+ if (asprintf (&URL,"%s/%s/%s",
+ Cfg_URL_FILE_BROWSER_TMP_PUBLIC,
+ Gbl.FileBrowser.TmpPubDir.L,
+ Gbl.FileBrowser.TmpPubDir.R) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_IMG (URL,FileNameMedia,Media->Title,
+ "class=\"%s\" lazyload=\"on\"",ClassMedia); // Lazy load of the media
+ free ((void *) URL);
}
else
fprintf (Gbl.F.Out,"%s",Txt_File_not_found);
@@ -1577,31 +1572,33 @@ static void Med_ShowGIF (struct Media *Media,
extern const char *Txt_File_not_found;
char FileNameMedia[NAME_MAX + 1];
char FullPathMediaPriv[PATH_MAX + 1];
- char URL_GIF[PATH_MAX + 1];
- char URL_PNG[PATH_MAX + 1];
+ char *URL;
+ char *URL_GIF;
+ char *URL_PNG;
/***** Build private path to animated GIF image *****/
snprintf (FileNameMedia,sizeof (FileNameMedia),
"%s.%s",
Media->Name,Med_Extensions[Med_GIF]);
- snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv),
+ snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), // The animated GIF image
"%s/%s",
PathMedPriv,FileNameMedia);
/***** Check if private media file exists *****/
- if (Fil_CheckIfPathExists (FullPathMediaPriv)) // The animated GIF image
+ if (Fil_CheckIfPathExists (FullPathMediaPriv)) // The animated GIF image
{
/***** Create symbolic link from temporary public directory to private file
in order to gain access to it for showing/downloading *****/
Brw_CreateTmpPublicLinkToPrivateFile (FullPathMediaPriv,FileNameMedia);
/***** Create URL pointing to symbolic link *****/
- snprintf (URL_GIF,sizeof (URL_GIF),
- "%s/%s/%s/%s",
- Cfg_URL_FILE_BROWSER_TMP_PUBLIC,
- Gbl.FileBrowser.TmpPubDir.L,
- Gbl.FileBrowser.TmpPubDir.R,
- FileNameMedia);
+ if (asprintf (&URL,"%s/%s/%s",
+ Cfg_URL_FILE_BROWSER_TMP_PUBLIC,
+ Gbl.FileBrowser.TmpPubDir.L,
+ Gbl.FileBrowser.TmpPubDir.R) < 0)
+ Lay_NotEnoughMemoryExit ();
+ if (asprintf (&URL_GIF,"%s/%s",URL,FileNameMedia) < 0)
+ Lay_NotEnoughMemoryExit ();
/***** Build private path to static PNG image *****/
snprintf (FileNameMedia,sizeof (FileNameMedia),
@@ -1610,22 +1607,16 @@ static void Med_ShowGIF (struct Media *Media,
snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv),
"%s/%s",
PathMedPriv,FileNameMedia);
+ if (asprintf (&URL_PNG,"%s/%s",URL,FileNameMedia) < 0) // The static PNG image
+ Lay_NotEnoughMemoryExit ();
/***** Check if private media file exists *****/
- if (Fil_CheckIfPathExists (FullPathMediaPriv)) // The static PNG image
+ if (Fil_CheckIfPathExists (FullPathMediaPriv)) // The static PNG image
{
/***** Create symbolic link from temporary public directory to private file
in order to gain access to it for showing/downloading *****/
Brw_CreateTmpPublicLinkToPrivateFile (FullPathMediaPriv,FileNameMedia);
- /***** Create URL pointing to symbolic link *****/
- snprintf (URL_PNG,sizeof (URL_PNG),
- "%s/%s/%s/%s",
- Cfg_URL_FILE_BROWSER_TMP_PUBLIC,
- Gbl.FileBrowser.TmpPubDir.L,
- Gbl.FileBrowser.TmpPubDir.R,
- FileNameMedia);
-
/***** Show static PNG and animated GIF *****/
HTM_DIV_Begin ("class=\"MED_PLAY\""
" onmouseover=\"toggleOnGIF(this,'%s');\""
@@ -1634,13 +1625,8 @@ static void Med_ShowGIF (struct Media *Media,
URL_PNG);
/* Image */
- fprintf (Gbl.F.Out,"Title)
- if (Media->Title[0])
- fprintf (Gbl.F.Out," title=\"%s\"",Media->Title);
- fprintf (Gbl.F.Out," lazyload=\"on\" />"); // Lazy load of the media
+ HTM_IMG (URL,FileNameMedia,Media->Title,
+ "class=\"%s\" lazyload=\"on\"",ClassMedia); // Lazy load of the media
/* Overlay with GIF label */
fprintf (Gbl.F.Out,""
@@ -1651,6 +1637,11 @@ static void Med_ShowGIF (struct Media *Media,
}
else
fprintf (Gbl.F.Out,"%s",Txt_File_not_found);
+
+ /***** Free URLs *****/
+ free ((void *) URL_PNG);
+ free ((void *) URL_GIF);
+ free ((void *) URL);
}
else
fprintf (Gbl.F.Out,"%s",Txt_File_not_found);
diff --git a/swad_plugin.c b/swad_plugin.c
index 99f604bd8..2dd9744e5 100644
--- a/swad_plugin.c
+++ b/swad_plugin.c
@@ -28,9 +28,10 @@ TODO: Check if web service is called from an authorized IP.
/********************************* Headers ***********************************/
/*****************************************************************************/
+#define _GNU_SOURCE // For asprintf
#include // For NULL
#include // For boolean type
-#include // For fprintf
+#include // For fprintf, asprintf
#include // For calloc, free
#include
@@ -97,6 +98,7 @@ void Plg_ListPlugins (void)
unsigned NumPlg;
struct Plugin *Plg;
char URL[Cns_MAX_BYTES_WWW + Cns_BYTES_SESSION_ID + 1];
+ char *Icon;
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM)
{
@@ -139,10 +141,12 @@ void Plg_ListPlugins (void)
HTM_TD_Begin ("class=\"DAT LM\" style=\"width:45px;\"");
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"DAT\" target=\"_blank\"",
URL,Plg->Name);
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PLUGINS_PUBLIC,Gbl.Plugins.Lst[NumPlg].Logo,
- Plg->Name,Plg->Name);
+ if (asprintf (&Icon,"%s24x24.gif",
+ Gbl.Plugins.Lst[NumPlg].Logo) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_IMG (Cfg_URL_ICON_PLUGINS_PUBLIC,Icon,Plg->Name,
+ "class=\"ICO40x40\"");
+ free ((void *) Icon);
HTM_A_End ();
HTM_TD_End ();
@@ -379,6 +383,7 @@ static void Plg_ListPluginsForEdition (void)
{
unsigned NumPlg;
struct Plugin *Plg;
+ char *Icon;
/***** Write heading *****/
HTM_TABLE_BeginWidePadding (2);
@@ -409,13 +414,12 @@ static void Plg_ListPluginsForEdition (void)
/* Plugin logo */
// TODO: Change plugin icons to 32x32
HTM_TD_Begin ("class=\"CM\" style=\"width:45px;\"");
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PLUGINS_PUBLIC,
- Gbl.Plugins.Lst[NumPlg].Logo,
- Gbl.Plugins.Lst[NumPlg].Name,
- Gbl.Plugins.Lst[NumPlg].Name);
+ if (asprintf (&Icon,"%s24x24.gif",
+ Gbl.Plugins.Lst[NumPlg].Logo) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_IMG (Cfg_URL_ICON_PLUGINS_PUBLIC,Icon,Gbl.Plugins.Lst[NumPlg].Name,
+ "class=\"ICO40x40\"");
+ free ((void *) Icon);
HTM_TD_End ();
/* Plugin name */
diff --git a/swad_statistic.c b/swad_statistic.c
index f317a732f..de6bc3368 100644
--- a/swad_statistic.c
+++ b/swad_statistic.c
@@ -25,7 +25,9 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
+#define _GNU_SOURCE // For asprintf
#include // For log10, floor, ceil, modf, sqrt...
+#include // For asprintf
#include // For getenv, malloc
#include // For string functions
@@ -2851,10 +2853,8 @@ static void Sta_WriteAccessHour (unsigned Hour,struct Sta_Hits *Hits,unsigned Co
BarHeight = (unsigned) (((Hits->Num * 500.0) / Hits->Max) + 0.5);
if (BarHeight == 0)
BarHeight = 1;
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PUBLIC,BarHeight);
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,"o1x1.png",NULL, // Orange background
+ "style=\"width:10px;height:%upx;\"",BarHeight);
}
else
fprintf (Gbl.F.Out,"0%%
0");
@@ -2955,10 +2955,8 @@ static void Sta_ShowAverageAccessesPerMinute (unsigned long NumRows,MYSQL_RES *m
/* First division (left) */
HTM_TD_Begin ("class=\"LM\" style=\"width:%upx;\"",
Sta_WIDTH_SEMIDIVISION_GRAPHIC);
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PUBLIC,
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,"ejexizq24x1.gif",NULL,
+ "style=\"display:block;width:%upx;height:1px;\"",
Sta_WIDTH_SEMIDIVISION_GRAPHIC);
HTM_TD_End ();
@@ -2969,11 +2967,8 @@ static void Sta_ShowAverageAccessesPerMinute (unsigned long NumRows,MYSQL_RES *m
{
HTM_TD_Begin ("class=\"LM\" style=\"width:%upx;\"",
Sta_WIDTH_SEMIDIVISION_GRAPHIC);
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PUBLIC,
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,"ejex24x1.gif",NULL,
+ "style=\"display:block;width:%upx;height:1px;\"",
Sta_WIDTH_SEMIDIVISION_GRAPHIC);
HTM_TD_End ();
}
@@ -2981,10 +2976,8 @@ static void Sta_ShowAverageAccessesPerMinute (unsigned long NumRows,MYSQL_RES *m
/* Last division (right) */
HTM_TD_Begin ("class=\"LM\" style=\"width:%upx;\"",
Sta_WIDTH_SEMIDIVISION_GRAPHIC);
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PUBLIC,
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,"tr24x1.gif",NULL,
+ "style=\"display:block;width:%upx;height:1px;\"",
Sta_WIDTH_SEMIDIVISION_GRAPHIC);
HTM_TD_End ();
@@ -3083,14 +3076,12 @@ static void Sta_WriteAccessMinute (unsigned Minute,float HitsNum,float MaxX)
/***** Draw bar with a width proportional to the number of hits *****/
if (HitsNum != 0.0)
if ((BarWidth = (unsigned) (((HitsNum * (float) Sta_WIDTH_GRAPHIC / MaxX)) + 0.5)) != 0)
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PUBLIC,
- (Minute % 60) == 0 ? 'r' : // red background
- 'o', // orange background
- BarWidth);
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,
+ (Minute % 60) == 0 ? "r1x1.png" : // red background
+ "o1x1.png", // orange background
+ NULL,
+ "style=\"display:block;width:%upx;height:1px;\"",
+ BarWidth);
/***** End cell of graphic and end row *****/
HTM_TD_End ();
@@ -3315,14 +3306,8 @@ static void Sta_ShowNumHitsPerBanner (unsigned long NumRows,
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"DAT\" target=\"_blank\"",
Ban.WWW,
Ban.FullName);
- fprintf (Gbl.F.Out,"",
- Cfg_URL_BANNER_PUBLIC,
- Ban.Img,
- Ban.ShrtName,
- Ban.FullName);
+ HTM_IMG (Cfg_URL_BANNER_PUBLIC,Ban.Img,Ban.FullName,
+ "style=\"margin:0 10px 5px 0;\"");
HTM_A_End ();
/* Draw bar proportional to number of clicks */
@@ -3841,6 +3826,7 @@ static void Sta_DrawBarNumHits (char Color,
unsigned MaxBarWidth)
{
unsigned BarWidth;
+ char *Icon;
HTM_TD_Begin ("class=\"LOG LM\"");
@@ -3850,14 +3836,14 @@ static void Sta_DrawBarNumHits (char Color,
BarWidth = (unsigned) (((HitsNum * (float) MaxBarWidth) / HitsMax) + 0.5);
if (BarWidth == 0)
BarWidth = 1;
- fprintf (Gbl.F.Out,"",
- Cfg_URL_ICON_PUBLIC,Color,BarWidth);
- fprintf (Gbl.F.Out," ");
+ if (asprintf (&Icon,"%c1x1.png",Color) < 0) // Background
+ Lay_NotEnoughMemoryExit ();
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,NULL,
+ "style=\"width:%upx;height:10px;\"",BarWidth);
+ free ((void *) Icon);
/***** Write the number of hits *****/
+ fprintf (Gbl.F.Out," ");
Str_WriteFloatNumToFile (Gbl.F.Out,HitsNum);
fprintf (Gbl.F.Out," (%u",
(unsigned) (((HitsNum * 100.0) /