mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-07 17:25:23 +02:00
Version 15.194.2
This commit is contained in:
parent
2cc8a82af1
commit
65671ee700
|
@ -137,13 +137,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.194.1 (2016-04-14)"
|
#define Log_PLATFORM_VERSION "SWAD 15.194.2 (2016-04-14)"
|
||||||
#define CSS_FILE "swad15.193.css"
|
#define CSS_FILE "swad15.193.css"
|
||||||
#define JS_FILE "swad15.193.js"
|
#define JS_FILE "swad15.193.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.194.2: Apr 14, 2016 Code refactoring related to uploading images. (199384 lines)
|
||||||
Version 15.194.1: Apr 14, 2016 Code refactoring related to uploading images. (199391 lines)
|
Version 15.194.1: Apr 14, 2016 Code refactoring related to uploading images. (199391 lines)
|
||||||
Version 15.194: Apr 14, 2016 Code refactoring related to uploading images. (199391 lines)
|
Version 15.194: Apr 14, 2016 Code refactoring related to uploading images. (199391 lines)
|
||||||
Version 15.193: Apr 14, 2016 New layout of button used to upload images. (199357 lines)
|
Version 15.193: Apr 14, 2016 New layout of button used to upload images. (199357 lines)
|
||||||
|
|
|
@ -3905,11 +3905,10 @@ void For_RecForumPst (void)
|
||||||
ParamUploadImg.Action = "ImgAct";
|
ParamUploadImg.Action = "ImgAct";
|
||||||
ParamUploadImg.File = "ImgFil";
|
ParamUploadImg.File = "ImgFil";
|
||||||
ParamUploadImg.Title = "ImgTit";
|
ParamUploadImg.Title = "ImgTit";
|
||||||
Img_GetImageFromForm (-1,&Image,NULL,
|
Image.Width = For_IMAGE_SAVED_MAX_WIDTH;
|
||||||
&ParamUploadImg,
|
Image.Height = For_IMAGE_SAVED_MAX_HEIGHT;
|
||||||
For_IMAGE_SAVED_MAX_WIDTH,
|
Image.Quality = For_IMAGE_SAVED_QUALITY;
|
||||||
For_IMAGE_SAVED_MAX_HEIGHT,
|
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||||
For_IMAGE_SAVED_QUALITY);
|
|
||||||
|
|
||||||
/***** Create a new message *****/
|
/***** Create a new message *****/
|
||||||
if (PstIsAReply) // This post is a reply to another posts in the thread
|
if (PstIsAReply) // This post is a reply to another posts in the thread
|
||||||
|
|
32
swad_image.c
32
swad_image.c
|
@ -64,9 +64,9 @@ extern struct Globals Gbl;
|
||||||
/***************************** Internal prototypes ***************************/
|
/***************************** Internal prototypes ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Img_ProcessImage (const char *FileNameImgOriginal,
|
static void Img_ProcessImage (struct Image *Image,
|
||||||
const char *FileNameImgProcessed,
|
const char *FileNameImgOriginal,
|
||||||
unsigned Width,unsigned Height,unsigned Quality);
|
const char *FileNameImgProcessed);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** Reset image fields ******************************/
|
/*************************** Reset image fields ******************************/
|
||||||
|
@ -206,10 +206,9 @@ void Img_PutImageUploader (const char *ClassImgTit,
|
||||||
/***************************** Get image from form ***************************/
|
/***************************** Get image from form ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Img_GetImageFromForm (unsigned NumOpt,struct Image *Image,
|
void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
||||||
void (*GetImageFromDB) (int NumOpt,struct Image *Image),
|
void (*GetImageFromDB) (int NumOpt,struct Image *Image),
|
||||||
struct ParamUploadImg *ParamUploadImg,
|
struct ParamUploadImg *ParamUploadImg)
|
||||||
unsigned Width,unsigned Height,unsigned Quality)
|
|
||||||
{
|
{
|
||||||
char Title[Img_MAX_BYTES_TITLE+1];
|
char Title[Img_MAX_BYTES_TITLE+1];
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
@ -225,8 +224,7 @@ void Img_GetImageFromForm (unsigned NumOpt,struct Image *Image,
|
||||||
{
|
{
|
||||||
case Img_ACTION_NEW_IMAGE: // Upload new image
|
case Img_ACTION_NEW_IMAGE: // Upload new image
|
||||||
/***** Get new image (if present ==> process and create temporary file) *****/
|
/***** Get new image (if present ==> process and create temporary file) *****/
|
||||||
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg->File,
|
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg->File);
|
||||||
Width,Height,Quality);
|
|
||||||
if (Image->Status != Img_FILE_PROCESSED) // No new image received-processed successfully
|
if (Image->Status != Img_FILE_PROCESSED) // No new image received-processed successfully
|
||||||
{
|
{
|
||||||
/* Reset image name */
|
/* Reset image name */
|
||||||
|
@ -241,8 +239,7 @@ void Img_GetImageFromForm (unsigned NumOpt,struct Image *Image,
|
||||||
break;
|
break;
|
||||||
case Img_ACTION_CHANGE_IMAGE: // Replace old image by new image
|
case Img_ACTION_CHANGE_IMAGE: // Replace old image by new image
|
||||||
/***** Get new image (if present ==> process and create temporary file) *****/
|
/***** Get new image (if present ==> process and create temporary file) *****/
|
||||||
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg->File,
|
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg->File);
|
||||||
Width,Height,Quality);
|
|
||||||
if (Image->Status != Img_FILE_PROCESSED && // No new image received-processed successfully
|
if (Image->Status != Img_FILE_PROCESSED && // No new image received-processed successfully
|
||||||
GetImageFromDB != NULL)
|
GetImageFromDB != NULL)
|
||||||
/* Get image name */
|
/* Get image name */
|
||||||
|
@ -292,8 +289,7 @@ Img_Action_t Img_GetImageActionFromForm (const char *ParamAction)
|
||||||
/**************************** Get image from form ****************************/
|
/**************************** Get image from form ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile,
|
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile)
|
||||||
unsigned Width,unsigned Height,unsigned Quality)
|
|
||||||
{
|
{
|
||||||
struct Param *Param;
|
struct Param *Param;
|
||||||
char FileNameImgSrc[PATH_MAX+1];
|
char FileNameImgSrc[PATH_MAX+1];
|
||||||
|
@ -363,7 +359,7 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
|
||||||
sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg",
|
sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg",
|
||||||
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,
|
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,
|
||||||
Image->Name);
|
Image->Name);
|
||||||
Img_ProcessImage (FileNameImgOrig,FileNameImgTmp,Width,Height,Quality);
|
Img_ProcessImage (Image,FileNameImgOrig,FileNameImgTmp);
|
||||||
Image->Status = Img_FILE_PROCESSED;
|
Image->Status = Img_FILE_PROCESSED;
|
||||||
|
|
||||||
/***** Remove temporary original file *****/
|
/***** Remove temporary original file *****/
|
||||||
|
@ -375,16 +371,18 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
|
||||||
/************ Process original image generating processed image **************/
|
/************ Process original image generating processed image **************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Img_ProcessImage (const char *FileNameImgOriginal,
|
static void Img_ProcessImage (struct Image *Image,
|
||||||
const char *FileNameImgProcessed,
|
const char *FileNameImgOriginal,
|
||||||
unsigned Width,unsigned Height,unsigned Quality)
|
const char *FileNameImgProcessed)
|
||||||
{
|
{
|
||||||
char Command[1024+PATH_MAX*2];
|
char Command[1024+PATH_MAX*2];
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
|
||||||
sprintf (Command,"convert %s -resize '%ux%u>' -quality %u %s",
|
sprintf (Command,"convert %s -resize '%ux%u>' -quality %u %s",
|
||||||
FileNameImgOriginal,
|
FileNameImgOriginal,
|
||||||
Width,Height,Quality,
|
Image->Width,
|
||||||
|
Image->Height,
|
||||||
|
Image->Quality,
|
||||||
FileNameImgProcessed);
|
FileNameImgProcessed);
|
||||||
ReturnCode = system (Command);
|
ReturnCode = system (Command);
|
||||||
if (ReturnCode == -1)
|
if (ReturnCode == -1)
|
||||||
|
|
11
swad_image.h
11
swad_image.h
|
@ -89,6 +89,9 @@ struct Image
|
||||||
char Name[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1];
|
char Name[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1];
|
||||||
char *Title; // Title/attribution (it must be initialized to NULL
|
char *Title; // Title/attribution (it must be initialized to NULL
|
||||||
// in order to not trying to free it when no memory allocated)
|
// in order to not trying to free it when no memory allocated)
|
||||||
|
unsigned Width;
|
||||||
|
unsigned Height;
|
||||||
|
unsigned Quality;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParamUploadImg
|
struct ParamUploadImg
|
||||||
|
@ -113,12 +116,10 @@ void Img_GetImageNameAndTitleFromRow (const char *Name,const char *Title,
|
||||||
void Img_PutImageUploader (const char *ClassImgTit,
|
void Img_PutImageUploader (const char *ClassImgTit,
|
||||||
struct ParamUploadImg *ParamUploadImg);
|
struct ParamUploadImg *ParamUploadImg);
|
||||||
void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
||||||
void (*GetImageFromDB) (unsigned NumOpt,struct Image *Image),
|
void (*GetImageFromDB) (int NumOpt,struct Image *Image),
|
||||||
struct ParamUploadImg *ParamUploadImg,
|
struct ParamUploadImg *ParamUploadImg);
|
||||||
unsigned Width,unsigned Height,unsigned Quality);
|
|
||||||
Img_Action_t Img_GetImageActionFromForm (const char *ParamAction);
|
Img_Action_t Img_GetImageActionFromForm (const char *ParamAction);
|
||||||
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile,
|
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile);
|
||||||
unsigned Width,unsigned Height,unsigned Quality);
|
|
||||||
|
|
||||||
void Img_MoveImageToDefinitiveDirectory (struct Image *Image);
|
void Img_MoveImageToDefinitiveDirectory (struct Image *Image);
|
||||||
void Img_ShowImage (struct Image *Image,const char *ClassImg);
|
void Img_ShowImage (struct Image *Image,const char *ClassImg);
|
||||||
|
|
|
@ -780,11 +780,10 @@ void Msg_RecMsgFromUsr (void)
|
||||||
ParamUploadImg.Action = "ImgAct";
|
ParamUploadImg.Action = "ImgAct";
|
||||||
ParamUploadImg.File = "ImgFil";
|
ParamUploadImg.File = "ImgFil";
|
||||||
ParamUploadImg.Title = "ImgTit";
|
ParamUploadImg.Title = "ImgTit";
|
||||||
Img_GetImageFromForm (-1,&Image,NULL,
|
Image.Width = Msg_IMAGE_SAVED_MAX_WIDTH;
|
||||||
&ParamUploadImg,
|
Image.Height = Msg_IMAGE_SAVED_MAX_HEIGHT;
|
||||||
Msg_IMAGE_SAVED_MAX_WIDTH,
|
Image.Quality = Msg_IMAGE_SAVED_QUALITY;
|
||||||
Msg_IMAGE_SAVED_MAX_HEIGHT,
|
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||||
Msg_IMAGE_SAVED_QUALITY);
|
|
||||||
|
|
||||||
/***** Loop over the list Gbl.Usrs.Select.All, that holds the list of the
|
/***** Loop over the list Gbl.Usrs.Select.All, that holds the list of the
|
||||||
recipients, creating a received message for each recipient *****/
|
recipients, creating a received message for each recipient *****/
|
||||||
|
|
|
@ -2096,11 +2096,10 @@ static long Soc_ReceiveSocialPost (void)
|
||||||
ParamUploadImg.Action = "ImgAct";
|
ParamUploadImg.Action = "ImgAct";
|
||||||
ParamUploadImg.File = "ImgFil";
|
ParamUploadImg.File = "ImgFil";
|
||||||
ParamUploadImg.Title = "ImgTit";
|
ParamUploadImg.Title = "ImgTit";
|
||||||
Img_GetImageFromForm (-1,&Image,NULL,
|
Image.Width = Soc_IMAGE_SAVED_MAX_WIDTH;
|
||||||
&ParamUploadImg,
|
Image.Height = Soc_IMAGE_SAVED_MAX_HEIGHT;
|
||||||
Soc_IMAGE_SAVED_MAX_WIDTH,
|
Image.Quality = Soc_IMAGE_SAVED_QUALITY;
|
||||||
Soc_IMAGE_SAVED_MAX_HEIGHT,
|
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||||
Soc_IMAGE_SAVED_QUALITY);
|
|
||||||
|
|
||||||
if (Content[0] || // Text not empty
|
if (Content[0] || // Text not empty
|
||||||
Image.Name[0]) // An image is attached
|
Image.Name[0]) // An image is attached
|
||||||
|
@ -2856,11 +2855,10 @@ static long Soc_ReceiveComment (void)
|
||||||
ParamUploadImg.Action = "ImgAct";
|
ParamUploadImg.Action = "ImgAct";
|
||||||
ParamUploadImg.File = "ImgFil";
|
ParamUploadImg.File = "ImgFil";
|
||||||
ParamUploadImg.Title = "ImgTit";
|
ParamUploadImg.Title = "ImgTit";
|
||||||
Img_GetImageFromForm (-1,&Image,NULL,
|
Image.Width = Soc_IMAGE_SAVED_MAX_WIDTH;
|
||||||
&ParamUploadImg,
|
Image.Height = Soc_IMAGE_SAVED_MAX_HEIGHT;
|
||||||
Soc_IMAGE_SAVED_MAX_WIDTH,
|
Image.Quality = Soc_IMAGE_SAVED_QUALITY;
|
||||||
Soc_IMAGE_SAVED_MAX_HEIGHT,
|
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||||
Soc_IMAGE_SAVED_QUALITY);
|
|
||||||
|
|
||||||
if (Content[0] || // Text not empty
|
if (Content[0] || // Text not empty
|
||||||
Image.Name[0]) // An image is attached
|
Image.Name[0]) // An image is attached
|
||||||
|
|
19
swad_test.c
19
swad_test.c
|
@ -5189,12 +5189,10 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
||||||
ParamUploadImg.Action = "ImgAct";
|
ParamUploadImg.Action = "ImgAct";
|
||||||
ParamUploadImg.File = "ImgFil";
|
ParamUploadImg.File = "ImgFil";
|
||||||
ParamUploadImg.Title = "ImgTit";
|
ParamUploadImg.Title = "ImgTit";
|
||||||
Img_GetImageFromForm (-1,&Gbl.Test.Image,
|
Gbl.Test.Image.Width = Tst_IMAGE_SAVED_MAX_WIDTH;
|
||||||
Tst_GetImageFromDB,
|
Gbl.Test.Image.Height = Tst_IMAGE_SAVED_MAX_HEIGHT;
|
||||||
&ParamUploadImg,
|
Gbl.Test.Image.Quality = Tst_IMAGE_SAVED_QUALITY;
|
||||||
Tst_IMAGE_SAVED_MAX_WIDTH,
|
Img_GetImageFromForm (-1,&Gbl.Test.Image,Tst_GetImageFromDB,&ParamUploadImg);
|
||||||
Tst_IMAGE_SAVED_MAX_HEIGHT,
|
|
||||||
Tst_IMAGE_SAVED_QUALITY);
|
|
||||||
|
|
||||||
/***** Get answers *****/
|
/***** Get answers *****/
|
||||||
Gbl.Test.Shuffle = false;
|
Gbl.Test.Shuffle = false;
|
||||||
|
@ -5253,12 +5251,11 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
||||||
ParamUploadImg.Action = ParamAction;
|
ParamUploadImg.Action = ParamAction;
|
||||||
ParamUploadImg.File = ParamFile;
|
ParamUploadImg.File = ParamFile;
|
||||||
ParamUploadImg.Title = ParamTitle;
|
ParamUploadImg.Title = ParamTitle;
|
||||||
|
Gbl.Test.Answer.Options[NumOpt].Image.Width = Tst_IMAGE_SAVED_MAX_WIDTH;
|
||||||
|
Gbl.Test.Answer.Options[NumOpt].Image.Height = Tst_IMAGE_SAVED_MAX_HEIGHT;
|
||||||
|
Gbl.Test.Answer.Options[NumOpt].Image.Quality = Tst_IMAGE_SAVED_QUALITY;
|
||||||
Img_GetImageFromForm ((int) NumOpt,&Gbl.Test.Answer.Options[NumOpt].Image,
|
Img_GetImageFromForm ((int) NumOpt,&Gbl.Test.Answer.Options[NumOpt].Image,
|
||||||
Tst_GetImageFromDB,
|
Tst_GetImageFromDB,&ParamUploadImg);
|
||||||
&ParamUploadImg,
|
|
||||||
Tst_IMAGE_SAVED_MAX_WIDTH,
|
|
||||||
Tst_IMAGE_SAVED_MAX_HEIGHT,
|
|
||||||
Tst_IMAGE_SAVED_QUALITY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user