Version19.46.9

This commit is contained in:
Antonio Cañas Vargas 2019-10-30 23:55:49 +01:00
parent a3f44db68c
commit 245cdd8fbd
6 changed files with 98 additions and 102 deletions

View File

@ -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 <img a HTM_IMG ()
Version 19.46.9: Oct 29, 2019 Code refactoring in HTML images. (246241 lines)
Version 19.46.8: Oct 29, 2019 Code refactoring in HTML images. (246244 lines)
Version 19.46.7: Oct 29, 2019 Code refactoring in HTML images. (246217 lines)
Version 19.46.6: Oct 29, 2019 Code refactoring in HTML images. (246226 lines)

View File

@ -88,6 +88,7 @@ void Log_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
long DegCod;
char *URL;
char *Icon;
bool ClassNotEmpty;
/***** Path to logo *****/
if (HieIcon[Scope]) // Scope is correct
@ -170,10 +171,17 @@ void Log_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
if (asprintf (&Icon,"%s",HieIcon[Scope]) < 0)
Lay_NotEnoughMemoryExit ();
}
ClassNotEmpty = false;
if (Class)
if (Class[0])
ClassNotEmpty = true;
HTM_IMG (URL,Icon,AltText,
"class=\"ICO%ux%u%s\"",
Size,Size,Class ? Class :
"");
"class=\"ICO%ux%u%s%s\"",
Size,Size,
ClassNotEmpty ? " " :
"",
ClassNotEmpty ? Class :
"");
free ((void *) Icon);
free ((void *) URL);
}

View File

@ -2754,6 +2754,8 @@ static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
unsigned Color;
unsigned BarWidth;
char *Icon;
char *Title;
/***** Compute color *****/
/*
@ -2804,14 +2806,18 @@ static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
/* Draw bar and write number of users for this score */
HTM_TD_Begin ("class=\"MCH_SCO_NUM%s\"",Mch_GetClassBorder (NumRow));
fprintf (Gbl.F.Out,"<img src=\"%s/score%u_1x1.png\"" // Background
" alt=\"\" title=\"%u %s\" class=\"MCH_SCO_BAR\""
" style=\"width:%u%%;\" />",
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,"&nbsp;%u",NumUsrs);
free ((void *) Title);
free ((void *) Icon);
HTM_TD_End ();
HTM_TR_End ();

View File

@ -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,"<img src=\"%s\" class=\"%s\" alt=\"\"",URL_JPG,ClassMedia);
if (Media->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,"<img src=\"%s\" class=\"%s\" alt=\"\"",
URL_PNG,
ClassMedia);
if (Media->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,"<span class=\"MED_PLAY_ICO\">"
@ -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);

View File

@ -28,9 +28,10 @@ TODO: Check if web service is called from an authorized IP.
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For fprintf
#include <stdio.h> // For fprintf, asprintf
#include <stdlib.h> // For calloc, free
#include <string.h>
@ -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,"<img src=\"%s/%s24x24.gif\" alt=\"%s\" title=\"%s\""
" class=\"ICO40x40\" />",
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,"<img src=\"%s/%s24x24.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICO40x40\" />",
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 */

View File

@ -25,7 +25,9 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <math.h> // For log10, floor, ceil, modf, sqrt...
#include <stdio.h> // For asprintf
#include <stdlib.h> // For getenv, malloc
#include <string.h> // 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,"<img src=\"%s/o1x1.png\"" // Orange background
" alt=\"\" title=\"\""
" style=\"width:10px; height:%upx;\" />",
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%%<br />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,"<img src=\"%s/ejexizq24x1.gif\""
" alt=\"\" title=\"\""
" style=\"display:block; width:%upx; height:1px;\" />",
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,"<img src=\"%s/ejex24x1.gif\""
" alt=\"\" title=\"\""
" style=\"display:block;"
" width:%upx; height:1px;\" />",
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,"<img src=\"%s/tr24x1.gif\""
" alt=\"\" title=\"\""
" style=\"display:block; width:%upx; height:1px;\" />",
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,"<img src=\"%s/%c1x1.png\""
" alt=\"\" title=\"\""
" style=\"display:block;"
" width:%upx; height:1px;\" />",
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,"<img src=\"%s/%s\""
" alt=\"%s\" title=\"%s\""
" class=\"BANNER_SMALL\""
" style=\"margin:0 10px 5px 0;\" />",
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,"<img src=\"%s/%c1x1.png\"" // Background
" alt=\"\" title=\"\""
" class=\"LM\""
" style=\"width:%upx; height:10px;\" />",
Cfg_URL_ICON_PUBLIC,Color,BarWidth);
fprintf (Gbl.F.Out,"&nbsp;");
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,"&nbsp;");
Str_WriteFloatNumToFile (Gbl.F.Out,HitsNum);
fprintf (Gbl.F.Out,"&nbsp;(%u",
(unsigned) (((HitsNum * 100.0) /