mirror of https://github.com/acanas/swad-core.git
Version 15.197
This commit is contained in:
parent
7cafe043f1
commit
b35c57e82c
|
@ -870,7 +870,8 @@ function enableDisableImgAns (elem, isDisabled) {
|
|||
for (var i = 0; i < Tst_MAX_OPTIONS_PER_QUESTION; i++)
|
||||
if (elem.name == ('ImgAct' + i) ||
|
||||
elem.name == ('ImgFil' + i) ||
|
||||
elem.name == ('ImgTit' + i))
|
||||
elem.name == ('ImgTit' + i) ||
|
||||
elem.name == ('ImgURL' + i))
|
||||
elem.disabled = isDisabled;
|
||||
}
|
||||
|
||||
|
@ -892,12 +893,12 @@ function disableDetailedClicks () {
|
|||
/*****************************************************************************/
|
||||
|
||||
function imageUploadOnSelectFile (inputFile,id) {
|
||||
document.getElementById(id + '_fil').innerHTML = inputFile.value; // Display filename
|
||||
document.getElementById(id + '_tit').style.display = ''; // Show hidden field to enter title/attribution
|
||||
document.getElementById(id + '_fil').innerHTML = inputFile.value; // Display image filename
|
||||
document.getElementById(id + '_tit_url').style.display = ''; // Show hidden fields
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Draw an academic calendar **************************/
|
||||
/************************* Draw an academic calendar *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function Cal_DrawCalendar (id,FirstDayOfWeek,TimeUTC,CurrentPlcCod,PrintView,
|
|
@ -130,20 +130,20 @@
|
|||
// TODO: In social refreshing via AJAX, an error occurs when session expirates
|
||||
// TODO: Messages in msg_content_deleted older than a certain time should be deleted to ensure the protection of personal data
|
||||
// TODO: Request confirmation to remove user's photo
|
||||
// TODO: Optional link in images to original file
|
||||
// TODO: FIX BUG: In Statistics > Indicators, if we select only 5 indicators, the message "The list is too big..." is shown.
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.196 (2016-04-15)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.197 (2016-04-15)"
|
||||
#define CSS_FILE "swad15.193.css"
|
||||
#define JS_FILE "swad15.193.js"
|
||||
#define JS_FILE "swad15.197.js"
|
||||
|
||||
// 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
|
||||
/*
|
||||
Version 15.197: Apr 15, 2016 Input field to enter image URL. (199518 lines)
|
||||
Version 15.196: Apr 15, 2016 Changes related to image URL. (199467 lines)
|
||||
Version 15.195.1: Apr 15, 2016 New fields in images to store URL when a user click in the image. (199390 lines)
|
||||
7 changes necessary in database:
|
||||
|
|
77
swad_image.c
77
swad_image.c
|
@ -99,14 +99,15 @@ void Img_ResetImageExceptTitleAndURL (struct Image *Image)
|
|||
|
||||
void Img_ImageDestructor (struct Image *Image)
|
||||
{
|
||||
Img_FreeImageTitleAndURL (Image);
|
||||
Img_FreeImageTitle (Image);
|
||||
Img_FreeImageURL (Image);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Reset image title and URL ***************************/
|
||||
/****************************** Free image title *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Img_FreeImageTitleAndURL (struct Image *Image)
|
||||
void Img_FreeImageTitle (struct Image *Image)
|
||||
{
|
||||
// Image->Title must be initialized to NULL after declaration
|
||||
if (Image->Title)
|
||||
|
@ -114,6 +115,14 @@ void Img_FreeImageTitleAndURL (struct Image *Image)
|
|||
free ((void *) Image->Title);
|
||||
Image->Title = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Free image URL ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Img_FreeImageURL (struct Image *Image)
|
||||
{
|
||||
// Image->URL must be initialized to NULL after declaration
|
||||
if (Image->URL)
|
||||
{
|
||||
|
@ -142,11 +151,10 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
|
|||
Img_FILE_NONE;
|
||||
|
||||
|
||||
/***** Copy image title and URL to struct *****/
|
||||
// Image->Title and Image->URL can be empty or filled with previous values
|
||||
/***** Copy image title to struct *****/
|
||||
// Image->Title can be empty or filled with previous value
|
||||
// If filled ==> free it
|
||||
Img_FreeImageTitleAndURL (Image);
|
||||
|
||||
Img_FreeImageTitle (Image);
|
||||
if (Title[0])
|
||||
{
|
||||
/* Get and limit length of the title */
|
||||
|
@ -160,6 +168,10 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
|
|||
Image->Title[Length] = '\0';
|
||||
}
|
||||
|
||||
/***** Copy image URL to struct *****/
|
||||
// Image->URL can be empty or filled with previous value
|
||||
// If filled ==> free it
|
||||
Img_FreeImageURL (Image);
|
||||
if (URL[0])
|
||||
{
|
||||
/* Get and limit length of the URL */
|
||||
|
@ -178,11 +190,12 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
|
|||
/************ Draw input fields to upload an image inside a form *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTit)
|
||||
void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTitURL)
|
||||
{
|
||||
extern const char *Txt_Image;
|
||||
extern const char *Txt_optional;
|
||||
extern const char *Txt_Image_title_attribution;
|
||||
extern const char *Txt_Link;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
char Id[Act_MAX_LENGTH_ID];
|
||||
|
||||
|
@ -208,21 +221,29 @@ void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTit)
|
|||
" onchange=\"imageUploadOnSelectFile (this,'%s');\" />"
|
||||
"<span id=\"%s_fil\" class=\"IMG_UPLOAD_FILENAME\" />"
|
||||
"</span>"
|
||||
"</label>"
|
||||
"<br />",
|
||||
"</label>",
|
||||
Gbl.Prefs.IconsURL,
|
||||
Txt_Image,Txt_Image,Txt_optional,
|
||||
ParamUploadImg.File,
|
||||
Id,Id);
|
||||
|
||||
/***** Image title/attribution *****/
|
||||
fprintf (Gbl.F.Out,"<input type=\"text\" id=\"%s_tit\" name=\"%s\""
|
||||
" placeholder=\"%s (%s)…\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"\""
|
||||
" style=\"display:none;\" />",
|
||||
Id,ParamUploadImg.Title,
|
||||
/***** Image title/attribution and URL *****/
|
||||
fprintf (Gbl.F.Out,"<div id=\"%s_tit_url\" style=\"display:none;\">",
|
||||
Id);
|
||||
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"%s\""
|
||||
" placeholder=\"%s (%s)\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"\" />",
|
||||
ParamUploadImg.Title,
|
||||
Txt_Image_title_attribution,Txt_optional,
|
||||
ClassImgTit,Img_MAX_BYTES_TITLE);
|
||||
ClassImgTitURL,Img_MAX_BYTES_TITLE);
|
||||
fprintf (Gbl.F.Out,"<br />"
|
||||
"<input type=\"text\" name=\"%s\""
|
||||
" placeholder=\"%s (%s)\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"\" />",
|
||||
ParamUploadImg.URL,
|
||||
Txt_Link,Txt_optional,
|
||||
ClassImgTitURL,Img_MAX_BYTES_URL);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/***** End container *****/
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
@ -237,6 +258,7 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
|
|||
{
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
char Title[Img_MAX_BYTES_TITLE+1];
|
||||
char URL[Img_MAX_BYTES_URL+1];
|
||||
size_t Length;
|
||||
|
||||
/***** Set names of parameters depending on number of image in form *****/
|
||||
|
@ -278,7 +300,7 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
|
|||
break;
|
||||
}
|
||||
|
||||
/***** By last, get image title from form *****/
|
||||
/***** Third, get image title from form *****/
|
||||
Par_GetParToText (ParamUploadImg.Title,Title,Img_MAX_BYTES_TITLE);
|
||||
/* If the title coming from the form is empty, keep current image title unchanged
|
||||
If not empty, copy it to current image title */
|
||||
|
@ -286,12 +308,27 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
|
|||
{
|
||||
/* Overwrite current title (empty or coming from database)
|
||||
with the title coming from the form */
|
||||
Img_FreeImageTitleAndURL (Image);
|
||||
Img_FreeImageTitle (Image);
|
||||
if ((Image->Title = (char *) malloc (Length + 1)) == NULL)
|
||||
Lay_ShowErrorAndExit ("Error allocating memory for image title.");
|
||||
strncpy (Image->Title,Title,Length);
|
||||
Image->Title[Length] = '\0';
|
||||
}
|
||||
|
||||
/***** By last, get image URL from form *****/
|
||||
Par_GetParToText (ParamUploadImg.URL,URL,Img_MAX_BYTES_URL);
|
||||
/* If the URL coming from the form is empty, keep current image URL unchanged
|
||||
If not empty, copy it to current image URL */
|
||||
if ((Length = strlen (URL)) > 0)
|
||||
{
|
||||
/* Overwrite current URL (empty or coming from database)
|
||||
with the URL coming from the form */
|
||||
Img_FreeImageURL (Image);
|
||||
if ((Image->URL = (char *) malloc (Length + 1)) == NULL)
|
||||
Lay_ShowErrorAndExit ("Error allocating memory for image URL.");
|
||||
strncpy (Image->URL,URL,Length);
|
||||
Image->URL[Length] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -305,12 +342,14 @@ void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm)
|
|||
strcpy (ParamUploadImg->Action,"ImgAct");
|
||||
strcpy (ParamUploadImg->File ,"ImgFil");
|
||||
strcpy (ParamUploadImg->Title ,"ImgTit");
|
||||
strcpy (ParamUploadImg->URL ,"ImgURL");
|
||||
}
|
||||
else // Several images in form ==> add suffix
|
||||
{
|
||||
sprintf (ParamUploadImg->Action,"ImgAct%u",NumImgInForm);
|
||||
sprintf (ParamUploadImg->File ,"ImgFil%u",NumImgInForm);
|
||||
sprintf (ParamUploadImg->Title ,"ImgTit%u",NumImgInForm);
|
||||
sprintf (ParamUploadImg->URL ,"ImgURL%u",NumImgInForm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
/*****************************************************************************/
|
||||
|
||||
#define Img_MAX_BYTES_TITLE 255
|
||||
#define Img_MAX_BYTES_URL 255
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Public types ********************************/
|
||||
|
@ -103,6 +104,7 @@ struct ParamUploadImg
|
|||
char Action[16];
|
||||
char File[16];
|
||||
char Title[16];
|
||||
char URL[16];
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -112,14 +114,15 @@ struct ParamUploadImg
|
|||
void Img_ImageConstructor (struct Image *Image);
|
||||
void Img_ResetImageExceptTitleAndURL (struct Image *Image);
|
||||
void Img_ImageDestructor (struct Image *Image);
|
||||
void Img_FreeImageTitleAndURL (struct Image *Image);
|
||||
void Img_FreeImageTitle (struct Image *Image);
|
||||
void Img_FreeImageURL (struct Image *Image);
|
||||
|
||||
void Img_GetImageNameTitleAndURLFromRow (const char *Name,
|
||||
const char *Title,
|
||||
const char *URL,
|
||||
struct Image *Image);
|
||||
|
||||
void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTit);
|
||||
void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTitURL);
|
||||
void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
|
||||
void (*GetImageFromDB) (int NumImgInForm,struct Image *Image));
|
||||
void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm);
|
||||
|
|
25
swad_test.c
25
swad_test.c
|
@ -156,7 +156,7 @@ static void Tst_WriteQstAndAnsExam (unsigned NumQst,long QstCod,MYSQL_ROW row,
|
|||
double *ScoreThisQst,bool *AnswerIsNotBlank);
|
||||
static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm,
|
||||
const char *ClassImg,
|
||||
const char *ClassImgTit,
|
||||
const char *ClassImgTitURL,
|
||||
bool OptionsDisabled);
|
||||
static void Tst_UpdateScoreQst (long QstCod,float ScoreThisQst,bool AnswerIsNotBlank);
|
||||
static void Tst_UpdateMyNumAccessTst (unsigned NumAccessesTst);
|
||||
|
@ -1056,7 +1056,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem)
|
|||
|
||||
static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm,
|
||||
const char *ClassImg,
|
||||
const char *ClassImgTit,
|
||||
const char *ClassImgTitURL,
|
||||
bool OptionsDisabled)
|
||||
{
|
||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||
|
@ -1064,6 +1064,7 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm,
|
|||
extern const char *Txt_Current_image;
|
||||
extern const char *Txt_Change_image;
|
||||
extern const char *Txt_Image_title_attribution;
|
||||
extern const char *Txt_Link;
|
||||
extern const char *Txt_optional;
|
||||
static unsigned UniqueId = 0;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
@ -1124,17 +1125,25 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm,
|
|||
/***** Image title/attribution *****/
|
||||
fprintf (Gbl.F.Out,"<br />"
|
||||
"<input type=\"text\" name=\"%s\""
|
||||
" placeholder=\"%s (%s)…\""
|
||||
" placeholder=\"%s (%s)\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"%s\">",
|
||||
ParamUploadImg.Title,Txt_Image_title_attribution,Txt_optional,
|
||||
ClassImgTit,Img_MAX_BYTES_TITLE,Image->Title ? Image->Title : "");
|
||||
ClassImgTitURL,Img_MAX_BYTES_TITLE,Image->Title ? Image->Title : "");
|
||||
|
||||
/***** Image URL *****/
|
||||
fprintf (Gbl.F.Out,"<br />"
|
||||
"<input type=\"text\" name=\"%s\""
|
||||
" placeholder=\"%s (%s)\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"%s\">",
|
||||
ParamUploadImg.URL,Txt_Link,Txt_optional,
|
||||
ClassImgTitURL,Img_MAX_BYTES_URL,Image->URL ? Image->URL : "");
|
||||
|
||||
/***** End container *****/
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
}
|
||||
else // No current image
|
||||
/***** Attached image (optional) *****/
|
||||
Img_PutImageUploader (NumImgInForm,ClassImgTit);
|
||||
Img_PutImageUploader (NumImgInForm,ClassImgTitURL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4867,7 +4876,8 @@ static void Tst_InitImagesOfQuestion (void)
|
|||
|
||||
/***** Initialize image *****/
|
||||
Img_ResetImageExceptTitleAndURL (&Gbl.Test.Image);
|
||||
Img_FreeImageTitleAndURL (&Gbl.Test.Image);
|
||||
Img_FreeImageTitle (&Gbl.Test.Image);
|
||||
Img_FreeImageURL (&Gbl.Test.Image);
|
||||
|
||||
for (NumOpt = 0;
|
||||
NumOpt < Tst_MAX_OPTIONS_PER_QUESTION;
|
||||
|
@ -4875,7 +4885,8 @@ static void Tst_InitImagesOfQuestion (void)
|
|||
{
|
||||
/***** Initialize image *****/
|
||||
Img_ResetImageExceptTitleAndURL (&Gbl.Test.Answer.Options[NumOpt].Image);
|
||||
Img_FreeImageTitleAndURL (&Gbl.Test.Image);
|
||||
Img_FreeImageTitle (&Gbl.Test.Image);
|
||||
Img_FreeImageURL (&Gbl.Test.Image);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14308,17 +14308,17 @@ const char *Txt_Image =
|
|||
|
||||
const char *Txt_Image_title_attribution =
|
||||
#if L==1
|
||||
"Títol/reconeixement de la imatge";
|
||||
"Títol/atribució de la imatge";
|
||||
#elif L==2
|
||||
"Bildtitel / Namensnennung";
|
||||
#elif L==3
|
||||
"Image title/attribution";
|
||||
#elif L==4
|
||||
"Título/reconocimiento de la imagen";
|
||||
"Título/atribución de la imagen";
|
||||
#elif L==5
|
||||
"Titre/attribution de l'image";
|
||||
#elif L==6
|
||||
"Título/reconocimiento de la imagen"; // Okoteve traducción
|
||||
"Título/atribución de la imagen"; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Titolo/attribuzione delle immagine";
|
||||
#elif L==8
|
||||
|
|
Loading…
Reference in New Issue