Version 15.226

This commit is contained in:
Antonio Cañas Vargas 2016-06-17 19:42:15 +02:00
parent 53f20c55e8
commit c725f3a7db
8 changed files with 90 additions and 115 deletions

View File

@ -645,7 +645,9 @@ function toggleDisplay (elementID) {
} }
// Zoom a user's photograph // Zoom a user's photograph
function zoom (img,urlPhoto,shortName) { // idCaption must be the id of a hidden div with the caption in innerHTML
// (this allows showing ' and ")
function zoom (img,urlPhoto,idCaption) {
var zoomImgWidth = 186; // big photo var zoomImgWidth = 186; // big photo
var zoomImgHeight = 248; // big photo var zoomImgHeight = 248; // big photo
var padding = 7; // padding around big photo including border var padding = 7; // padding around big photo including border
@ -668,7 +670,9 @@ function zoom (img,urlPhoto,shortName) {
document.getElementById('zoomLyr').style.left = xPos + 'px'; document.getElementById('zoomLyr').style.left = xPos + 'px';
document.getElementById('zoomLyr').style.top = yPos + 'px'; document.getElementById('zoomLyr').style.top = yPos + 'px';
document.getElementById('zoomImg').src = urlPhoto; document.getElementById('zoomImg').src = urlPhoto;
document.getElementById('zoomTxt').innerHTML = '<span class="ZOOM_TXT">' + shortName + '</span>'; document.getElementById('zoomTxt').innerHTML = '<span class="ZOOM_TXT">' +
document.getElementById(idCaption).innerHTML +
'</span>';
} }
// Exit from zooming a user's photograph // Exit from zooming a user's photograph

View File

@ -128,13 +128,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.225.21 (2016-06-17)" #define Log_PLATFORM_VERSION "SWAD 15.226 (2016-06-17)"
#define CSS_FILE "swad15.225.11.css" #define CSS_FILE "swad15.226.css"
#define JS_FILE "swad15.216.js" #define JS_FILE "swad15.226.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.226: Jun 17, 2016 Fixed bug in photo zoom. (202870 lines)
Version 15.225.21:Jun 17, 2016 Fixed bug in photo zoom, reported by Javier Fernández Baldomero. (202894 lines) Version 15.225.21:Jun 17, 2016 Fixed bug in photo zoom, reported by Javier Fernández Baldomero. (202894 lines)
Version 15.225.20:Jun 17, 2016 Show details of user's profile in similar users. (202893 lines) Version 15.225.20:Jun 17, 2016 Show details of user's profile in similar users. (202893 lines)
Version 15.225.19:Jun 17, 2016 Changed layout of listing of similar users. (202927 lines) Version 15.225.19:Jun 17, 2016 Changed layout of listing of similar users. (202927 lines)

View File

@ -549,9 +549,9 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
/* Write total number of connected users belonging to the current course */ /* Write total number of connected users belonging to the current course */
strcpy (CourseName,Gbl.CurrentCrs.Crs.ShortName); strcpy (CourseName,Gbl.CurrentCrs.Crs.ShortName);
Str_LimitLengthHTMLStr (CourseName,12); Str_LimitLengthHTMLStr (CourseName,12);
Str_ReplaceSpecialCharByCodes (CourseName,Crs_MAX_LENGTH_COURSE_SHORT_NAME);
Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs); Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs);
fprintf (Gbl.F.Out,"%u %s %s",Usrs.NumUsrs,Txt_from,CourseName); fprintf (Gbl.F.Out,"%u %s %s",
Usrs.NumUsrs,Txt_from,CourseName);
/* End of link to view more details about connected users */ /* End of link to view more details about connected users */
fprintf (Gbl.F.Out,"</a>"); fprintf (Gbl.F.Out,"</a>");

View File

@ -1123,21 +1123,17 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
bool FormUnique) bool FormUnique)
{ {
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
char SpecialFullName [3*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+1]; char FullName [3*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+1];
char SpecialShortName[3*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+6]; char ShortName[3*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+6];
char SpecialSurnames [2*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+1]; char Surnames [2*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+1];
bool PhotoExists; bool PhotoExists;
bool PutLinkToPublicProfile = !Gbl.Form.Inside && // Only if not inside another form bool PutLinkToPublicProfile = !Gbl.Form.Inside && // Only if not inside another form
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_MAIN_WINDOW; // Only in main window Act_Actions[Gbl.Action.Act].BrowserWindow == Act_MAIN_WINDOW; // Only in main window
bool PutZoomCode = PhotoURL && // Photo exists bool PutZoomCode = PhotoURL && // Photo exists
Zoom == Pho_ZOOM && // Make zoom Zoom == Pho_ZOOM && // Make zoom
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_MAIN_WINDOW; // Only in main window Act_Actions[Gbl.Action.Act].BrowserWindow == Act_MAIN_WINDOW; // Only in main window
char IdCaption[Act_MAX_LENGTH_ID];
/***** Replace tildes, ñ, etc. in full name by codes,
because some browsers (i.e., IE5)
don't show correctly tildes with AJAX *****/
strcpy (SpecialFullName,UsrDat->FullName);
Str_ReplaceSpecialCharByCodes (SpecialFullName,sizeof (SpecialFullName)-1);
/***** Start form to go to public profile *****/ /***** Start form to go to public profile *****/
if (PutLinkToPublicProfile) if (PutLinkToPublicProfile)
@ -1153,6 +1149,31 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
Act_LinkFormSubmit (NULL,NULL); Act_LinkFormSubmit (NULL,NULL);
} }
/***** Hidden div to pass user's name to Javascript *****/
strcpy (FullName,UsrDat->FullName);
if (PutZoomCode)
{
strcpy (ShortName,UsrDat->FirstName);
Str_LimitLengthHTMLStr (ShortName,23);
Surnames[0] = '\0';
if (UsrDat->Surname1[0])
strcpy (Surnames,UsrDat->Surname1);
if (UsrDat->Surname2[0])
{
strcat (Surnames," ");
strcat (Surnames,UsrDat->Surname2);
}
Str_LimitLengthHTMLStr (Surnames,23);
strcat (ShortName,"<br />");
strcat (ShortName,Surnames);
Act_SetUniqueId (IdCaption);
fprintf (Gbl.F.Out,"<div id=\"%s\" class=\"NOT_SHOWN\">"
"%s"
"</div>",
IdCaption,ShortName);
}
/***** Start image *****/ /***** Start image *****/
fprintf (Gbl.F.Out,"<img src=\""); fprintf (Gbl.F.Out,"<img src=\"");
PhotoExists = false; PhotoExists = false;
@ -1165,30 +1186,13 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
fprintf (Gbl.F.Out,"%s/usr_bl.jpg",Gbl.Prefs.IconsURL); fprintf (Gbl.F.Out,"%s/usr_bl.jpg",Gbl.Prefs.IconsURL);
fprintf (Gbl.F.Out,"\" alt=\"%s\" title=\"%s\"" fprintf (Gbl.F.Out,"\" alt=\"%s\" title=\"%s\""
" class=\"%s\"", " class=\"%s\"",
SpecialFullName,SpecialFullName, FullName,FullName,
ClassPhoto); ClassPhoto);
/***** Image zoom *****/ /***** Image zoom *****/
if (PutZoomCode) if (PutZoomCode)
{ fprintf (Gbl.F.Out," onmouseover=\"zoom(this,'%s','%s');\" onmouseout=\"noZoom();\"",
strcpy (SpecialShortName,UsrDat->FirstName); PhotoURL,IdCaption);
Str_LimitLengthHTMLStr (SpecialShortName,23);
Str_ReplaceSpecialCharByCodes (SpecialShortName,Usr_MAX_BYTES_NAME_SPEC_CHAR);
SpecialSurnames[0] = '\0';
if (UsrDat->Surname1[0])
strcpy (SpecialSurnames,UsrDat->Surname1);
if (UsrDat->Surname2[0])
{
strcat (SpecialSurnames," ");
strcat (SpecialSurnames,UsrDat->Surname2);
}
Str_LimitLengthHTMLStr (SpecialSurnames,23);
Str_ReplaceSpecialCharByCodes (SpecialSurnames,2*Usr_MAX_BYTES_NAME_SPEC_CHAR+1);
strcat (SpecialShortName,"<br />");
strcat (SpecialShortName,SpecialSurnames);
fprintf (Gbl.F.Out," onmouseover=\"zoom(this,'%s',&quot;%s&quot;);\" onmouseout=\"noZoom();\"",
PhotoURL,SpecialShortName);
}
/***** End image *****/ /***** End image *****/
fprintf (Gbl.F.Out," />"); fprintf (Gbl.F.Out," />");
@ -2337,9 +2341,14 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
unsigned PhotoHeight; unsigned PhotoHeight;
char PathRelAvgPhoto[PATH_MAX+1]; char PathRelAvgPhoto[PATH_MAX+1];
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
char CopyOfDegShortName[Deg_MAX_LENGTH_DEGREE_SHORT_NAME+1]; // Short name of degree
char PhotoCaption[512]; char PhotoCaption[512];
char CopyOfDegShortName[Deg_MAX_LENGTH_DEGREE_SHORT_NAME+1]; // Short name of degree
bool ShowDegPhoto; bool ShowDegPhoto;
char IdCaption[Act_MAX_LENGTH_ID];
/***** Initializations *****/
PhotoURL[0] = '\0';
PhotoCaption[0] = '\0';
/***** Compute photo width and height to be proportional to number of students *****/ /***** Compute photo width and height to be proportional to number of students *****/
Pho_ComputePhotoSize (NumStds,NumStdsWithPhoto,&PhotoWidth,&PhotoHeight); Pho_ComputePhotoSize (NumStds,NumStdsWithPhoto,&PhotoWidth,&PhotoHeight);
@ -2367,48 +2376,54 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
ShowDegPhoto = (NumStds > 0 && ShowDegPhoto = (NumStds > 0 &&
NumStdsWithPhoto >= Cfg_MIN_PHOTOS_TO_SHOW_AVERAGE); NumStdsWithPhoto >= Cfg_MIN_PHOTOS_TO_SHOW_AVERAGE);
/***** Show photo *****/
fprintf (Gbl.F.Out,"<img src=\"");
if (ShowDegPhoto) if (ShowDegPhoto)
{ {
sprintf (PathRelAvgPhoto,"%s/%s/%s/%ld_%s.jpg", sprintf (PathRelAvgPhoto,"%s/%s/%s/%ld_%s.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,
Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage], Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage],
Deg->DegCod,Usr_StringsSexDB[Sex]); Deg->DegCod,Usr_StringsSexDB[Sex]);
if (Fil_CheckIfPathExists (PathRelAvgPhoto)) if (Fil_CheckIfPathExists (PathRelAvgPhoto))
{ {
sprintf (PhotoURL,"%s/%s/%s/%ld_%s.jpg", sprintf (PhotoURL,"%s/%s/%s/%ld_%s.jpg",
Cfg_HTTPS_URL_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, Cfg_HTTPS_URL_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,
Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage], Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage],
Deg->DegCod,Usr_StringsSexDB[Sex]); Deg->DegCod,Usr_StringsSexDB[Sex]);
fprintf (Gbl.F.Out,"%s\" style=\"width:%upx; height:%upx;\"", if (SeeOrPrint == Pho_DEGREES_SEE)
PhotoURL,PhotoWidth,PhotoHeight);
if (SeeOrPrint == Pho_DEGREES_SEE) if (SeeOrPrint == Pho_DEGREES_SEE)
{ {
sprintf (PhotoCaption,"%s<br />" /***** Hidden div to pass user's name to Javascript *****/
"%d&nbsp;%s&nbsp;(%s)<br />" sprintf (PhotoCaption,"%s<br />"
"%d&nbsp;%s&nbsp;(%d%%)", "%d&nbsp;%s&nbsp;(%s)<br />"
Deg->ShortName, "%d&nbsp;%s&nbsp;(%d%%)",
NumStds,Txt_students_ABBREVIATION,Txt_SEX_PLURAL_abc[Sex], Deg->ShortName,
NumStdsWithPhoto,Txt_photos, NumStds,Txt_students_ABBREVIATION,Txt_SEX_PLURAL_abc[Sex],
NumStds > 0 ? (int) (((NumStdsWithPhoto * 100.0) / NumStds) + 0.5) : NumStdsWithPhoto,Txt_photos,
0); NumStds > 0 ? (int) (((NumStdsWithPhoto * 100.0) / NumStds) + 0.5) :
fprintf (Gbl.F.Out," onmouseover=\"zoom(this,'%s',&quot;%s&quot;);\" onmouseout=\"noZoom();\"", 0);
PhotoURL,PhotoCaption); Act_SetUniqueId (IdCaption);
} fprintf (Gbl.F.Out,"<div id=\"%s\" class=\"NOT_SHOWN\">"
} "%s"
else "</div>",
fprintf (Gbl.F.Out,"%s/usr_bl.jpg\"" IdCaption,PhotoCaption);
" style=\"width:%upx; height:%upx;\"", }
Gbl.Prefs.IconsURL,PhotoWidth,PhotoHeight); }
}
/***** Show photo *****/
fprintf (Gbl.F.Out,"<img src=\"");
if (PhotoURL[0])
{
fprintf (Gbl.F.Out,"%s\"",PhotoURL);
if (PhotoCaption[0])
fprintf (Gbl.F.Out," onmouseover=\"zoom(this,'%s','%s');\" onmouseout=\"noZoom();\"",
PhotoURL,IdCaption);
} }
else else
fprintf (Gbl.F.Out,"%s/usr_bl.jpg\"" fprintf (Gbl.F.Out,"%s/usr_bl.jpg\"",Gbl.Prefs.IconsURL);
" style=\"width:%upx; height:%upx;\"", fprintf (Gbl.F.Out," alt=\"%s\""
Gbl.Prefs.IconsURL,PhotoWidth,PhotoHeight); " style=\"width:%upx; height:%upx;\" />",
fprintf (Gbl.F.Out," alt=\"%s\" />", Deg->ShortName,
Deg->ShortName); PhotoWidth,PhotoHeight);
/***** Caption *****/ /***** Caption *****/
if (SeeOrPrint == Pho_DEGREES_PRINT) if (SeeOrPrint == Pho_DEGREES_PRINT)

View File

@ -2230,46 +2230,6 @@ void Str_GetNextStringUntilComma (const char **StrSrc,char *StrDst,size_t MaxLen
*(Ptr+1) = '\0'; *(Ptr+1) = '\0';
} }
/*****************************************************************************/
/********** Replace special characters in a string for HTML codes ************/
/*****************************************************************************/
void Str_ReplaceSpecialCharByCodes (char *Str,unsigned long MaxLengthStr)
{
char *Ptr, *PtrSrc, *PtrDst, *PtrEndStr;
int LengthSpecStrDst;
unsigned long LengthStrDst = 0;
char StrSpecialChar[256];
/***** Make the conversion *****/
for (Ptr = Str;
*Ptr;)
{
if (*Ptr >= 32 && *Ptr <= 126) // If character is printable in english ==> is OK; else ==> convert to code
{
LengthStrDst++;
Ptr++;
}
else
{
sprintf (StrSpecialChar,"&#%u;",(unsigned char) *Ptr);
PtrEndStr = Str + strlen (Str);
LengthSpecStrDst = strlen (StrSpecialChar);
LengthStrDst += LengthSpecStrDst;
if (LengthStrDst > MaxLengthStr)
Lay_ShowErrorAndExit ("Not enough memory to convert the format of a string.");
for (PtrSrc = PtrEndStr,
PtrDst = PtrSrc + LengthSpecStrDst - 1;
PtrSrc >= Ptr + 1;
*PtrDst-- = *PtrSrc--); /* Copy backward from '\0' (included) */
/* Copy to appropiate place the special character string */
strncpy (Ptr,StrSpecialChar,LengthSpecStrDst);
/* Increment pointer to character after ';' */
Ptr += LengthSpecStrDst;
}
}
}
/*****************************************************************************/ /*****************************************************************************/
/***************** Replace several spaces of a string for one ****************/ /***************** Replace several spaces of a string for one ****************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -98,7 +98,6 @@ void Str_GetNextStringUntilSpace (const char **StrSrc,char *StrDst,size_t MaxLen
void Str_GetNextStringUntilSeparator (const char **StrSrc,char *StrDst,size_t MaxLength); void Str_GetNextStringUntilSeparator (const char **StrSrc,char *StrDst,size_t MaxLength);
void Str_GetNextStringFromFileUntilSeparator (FILE *FileSrc,char *StrDst); void Str_GetNextStringFromFileUntilSeparator (FILE *FileSrc,char *StrDst);
void Str_GetNextStringUntilComma (const char **StrSrc,char *StrDst,size_t MaxLength); void Str_GetNextStringUntilComma (const char **StrSrc,char *StrDst,size_t MaxLength);
void Str_ReplaceSpecialCharByCodes (char *Str,unsigned long MaxLengthStr);
void Str_ReplaceSeveralSpacesForOne (char *Str); void Str_ReplaceSeveralSpacesForOne (char *Str);
void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength); void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength);
long Str_ConvertStrCodToLongCod (const char *Str); long Str_ConvertStrCodToLongCod (const char *Str);

View File

@ -744,10 +744,6 @@ void Usr_RestrictLengthAndWriteName (const struct UsrData *UsrDat,unsigned MaxCh
Str_LimitLengthHTMLStr (FirstName,MaxChars); Str_LimitLengthHTMLStr (FirstName,MaxChars);
Str_LimitLengthHTMLStr (Surnames,MaxChars); Str_LimitLengthHTMLStr (Surnames,MaxChars);
/***** Replace tildes, ñ, etc. by codes, because some browsers (i.e., IE5) don't show correctly tildes with AJAX *****/
Str_ReplaceSpecialCharByCodes (FirstName,Usr_MAX_BYTES_NAME_SPEC_CHAR);
Str_ReplaceSpecialCharByCodes (Surnames,2*Usr_MAX_BYTES_NAME_SPEC_CHAR+1);
/***** Write shorted firstname, then return, then shorted surnames *****/ /***** Write shorted firstname, then return, then shorted surnames *****/
fprintf (Gbl.F.Out,"%s<br />%s",FirstName,Surnames); fprintf (Gbl.F.Out,"%s<br />%s",FirstName,Surnames);
} }