diff --git a/css/swad15.192.9.css b/css/swad15.193.css similarity index 99% rename from css/swad15.192.9.css rename to css/swad15.193.css index d27ffbba2..293e19025 100644 --- a/css/swad15.192.9.css +++ b/css/swad15.193.css @@ -1831,6 +1831,33 @@ a:hover img.CENTRE_PHOTO_SHOW .LOG {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#606060; font-size:11pt;} .LOG_R {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:red; font-size:11pt;} +/******************************** Image uploading ****************************/ +.IMG_UPLOAD_CONTAINER + { + vertical-align:top; + margin-bottom:10px; + } +.IMG_UPLOAD_BUTTON + { + cursor:pointer; + } +.IMG_UPLOAD_ICON + { + width:20px; + height:20px; + margin:0 5px; + vertical-align:middle; + } +.IMG_UPLOAD_FILE + { + display:none; + } +.IMG_UPLOAD_FILENAME + { + color:#808080; + font-size:12pt; + } + /******************************** Social activity ****************************/ #view_new_posts_container,#view_old_posts_container { @@ -1947,7 +1974,6 @@ a:hover img.CENTRE_PHOTO_SHOW { box-sizing:border-box; width:440px; - margin-bottom:10px; } .SOCIAL_TXT { @@ -2069,7 +2095,6 @@ a:hover img.CENTRE_PHOTO_SHOW { box-sizing:border-box; width:440px; - margin-bottom:10px; } /************************************ Forum **********************************/ diff --git a/js/swad15.190.1.js b/js/swad15.193.js similarity index 98% rename from js/swad15.190.1.js rename to js/swad15.193.js index a7545e700..94c88f0e5 100644 --- a/js/swad15.190.1.js +++ b/js/swad15.193.js @@ -887,6 +887,15 @@ function disableDetailedClicks () { document.getElementById('RowsPage').disabled = true; } +/*****************************************************************************/ +/************************** Upload images in a form **************************/ +/*****************************************************************************/ + +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 +} + /*****************************************************************************/ /************************ Draw an academic calendar **************************/ /*****************************************************************************/ diff --git a/swad_action.c b/swad_action.c index 5a43ef17b..75b1499f1 100644 --- a/swad_action.c +++ b/swad_action.c @@ -4529,6 +4529,24 @@ void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle) Gbl.Form.Id); } +/*****************************************************************************/ +/***************************** Get unique Id *********************************/ +/*****************************************************************************/ + +void Act_SetUniqueId (char UniqueId[Act_MAX_LENGTH_ID]) + { + static unsigned CountForThisExecution = 0; + + /***** Create Id. The id must be unique in timeline, + but the timeline is updated via AJAX. + So, Id uses: + - a name for this execution (Gbl.UniqueNameEncrypted) + - a number for each element in this execution (CountForThisExecution) *****/ + sprintf (UniqueId,"id_%s_%u", + Gbl.UniqueNameEncrypted, + ++CountForThisExecution); + } + /*****************************************************************************/ /***************** Adjust current action when no user's logged ***************/ /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index f7a7246fb..f2be37f6c 100644 --- a/swad_action.h +++ b/swad_action.h @@ -29,6 +29,7 @@ #include // For boolean type +#include "swad_cryptography.h" #include "swad_text.h" /*****************************************************************************/ @@ -77,6 +78,8 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 +#define Act_MAX_LENGTH_ID (32+Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+10+1) + /*****************************************************************************/ /************************* Not asociates with tabs ***************************/ /*****************************************************************************/ @@ -1451,6 +1454,8 @@ void Act_LinkFormSubmitUnique (const char *Title,const char *LinkStyle); void Act_LinkFormSubmitId (const char *Title,const char *LinkStyle,const char *Id); void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle); +void Act_SetUniqueId (char UniqueId[Act_MAX_LENGTH_ID]); + void Act_AdjustActionWhenNoUsrLogged (void); void Act_AdjustCurrentAction (void); diff --git a/swad_changelog.h b/swad_changelog.h index ab60990e1..c0523c4b2 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -131,18 +131,20 @@ // 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.192.13 (2016-04-13)" -#define CSS_FILE "swad15.192.9.css" -#define JS_FILE "swad15.190.1.js" +#define Log_PLATFORM_VERSION "SWAD 15.193 (2016-04-14)" +#define CSS_FILE "swad15.193.css" +#define JS_FILE "swad15.193.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.193: Apr 14, 2016 New layout of button used to upload images. (199357 lines) Version 15.192.13:Apr 13, 2016 Fixed bug in file upload, reported by Christian Morillas Gutiérrez. (199341 lines) Version 15.192.12:Apr 12, 2016 Fixed bug in groups reported by user raistmaj in GitHub. (199339 lines) Version 15.192.11:Apr 12, 2016 Image quality in social posts reduced to 50 in order to speed up page loading. diff --git a/swad_forum.c b/swad_forum.c index 04a0d9dfb..c2fe002b6 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -3778,9 +3778,6 @@ static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject) extern const char *Txt_New_thread; extern const char *Txt_MSG_Subject; extern const char *Txt_MSG_Message; - extern const char *Txt_Image; - extern const char *Txt_optional; - extern const char *Txt_Image_title_attribution; extern const char *Txt_Send_message; /***** Start frame *****/ @@ -3838,26 +3835,7 @@ static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject) Lay_HelpPlainEditor (); /***** Attached image (optional) *****/ - /* Action to perform on image */ - Par_PutHiddenParamUnsigned ("ImgAct",(unsigned) Img_ACTION_NEW_IMAGE); - - /* Image file */ - fprintf (Gbl.F.Out,"" - "" - "
", - Gbl.Prefs.IconsURL, - Txt_Image,Txt_Image,Txt_optional); - - /* Image title/attribution */ - fprintf (Gbl.F.Out,"", - Txt_Image_title_attribution,Txt_optional, - Img_MAX_BYTES_TITLE); + Img_PutImageUploader ("FOR_IMG_TIT"); /***** Send button *****/ Lay_PutCreateButton (Txt_Send_message); diff --git a/swad_image.c b/swad_image.c index c41c693dc..e42575965 100644 --- a/swad_image.c +++ b/swad_image.c @@ -151,6 +151,55 @@ void Img_GetImageNameAndTitleFromRow (const char *Name,const char *Title, } } +/*****************************************************************************/ +/************ Draw input fields to upload an image inside a form *************/ +/*****************************************************************************/ + +void Img_PutImageUploader (const char *ClassImgTit) + { + extern const char *Txt_Image; + extern const char *Txt_optional; + extern const char *Txt_Image_title_attribution; + char Id[Act_MAX_LENGTH_ID]; + + /***** Create unique id for this image uploader *****/ + Act_SetUniqueId (Id); + + /***** Start container *****/ + fprintf (Gbl.F.Out,"
"); + + /***** Action to perform on image *****/ + Par_PutHiddenParamUnsigned ("ImgAct",(unsigned) Img_ACTION_NEW_IMAGE); + + /***** Image file *****/ + fprintf (Gbl.F.Out,"" + "
", + Gbl.Prefs.IconsURL, + Txt_Image,Txt_Image,Txt_optional, + Id,Id); + + /***** Image title/attribution *****/ + fprintf (Gbl.F.Out,"", + Id, + Txt_Image_title_attribution,Txt_optional, + ClassImgTit,Img_MAX_BYTES_TITLE); + + /***** End container *****/ + fprintf (Gbl.F.Out,"
"); + } + /*****************************************************************************/ /***************************** Get image from form ***************************/ /*****************************************************************************/ diff --git a/swad_image.h b/swad_image.h index dd6e275da..5c684de94 100644 --- a/swad_image.h +++ b/swad_image.h @@ -103,6 +103,7 @@ void Img_FreeImageTitle (struct Image *Image); void Img_GetImageNameAndTitleFromRow (const char *Name,const char *Title, struct Image *Image); +void Img_PutImageUploader (const char *ClassImgTit); void Img_GetImageFromForm (unsigned NumOpt,struct Image *Image, void (*GetImageFromDB) (unsigned NumOpt,struct Image *Image), const char *ParamAction,const char *ParamFile,const char *ParamTitle, diff --git a/swad_message.c b/swad_message.c index 3a1e2174b..1457477bc 100644 --- a/swad_message.c +++ b/swad_message.c @@ -284,9 +284,6 @@ static void Msg_PutFormMsgUsrs (const char *Content) extern const char *Txt_Reply_message; extern const char *Txt_New_message; extern const char *Txt_MSG_To; - extern const char *Txt_Image; - extern const char *Txt_optional; - extern const char *Txt_Image_title_attribution; extern const char *Txt_Send_message; char YN[1+1]; @@ -421,26 +418,7 @@ static void Msg_PutFormMsgUsrs (const char *Content) Lay_HelpPlainEditor (); /***** Attached image (optional) *****/ - /* Action to perform on image */ - Par_PutHiddenParamUnsigned ("ImgAct",(unsigned) Img_ACTION_NEW_IMAGE); - - /* Image file */ - fprintf (Gbl.F.Out,"" - "" - "
", - Gbl.Prefs.IconsURL, - Txt_Image,Txt_Image,Txt_optional); - - /* Image title/attribution */ - fprintf (Gbl.F.Out,"", - Txt_Image_title_attribution,Txt_optional, - Img_MAX_BYTES_TITLE); + Img_PutImageUploader ("MSG_IMG_TIT"); /***** Send button *****/ Lay_PutCreateButton (Txt_Send_message); diff --git a/swad_social.c b/swad_social.c index f099736b6..14092b51f 100644 --- a/swad_social.c +++ b/swad_social.c @@ -64,8 +64,6 @@ // set also this constant to the new value // in JavaScript function readOldTimelineData -#define Soc_MAX_LENGTH_ID (32+Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+10+1) - typedef enum { Soc_TIMELINE_USR, // Show the timeline of a user @@ -176,10 +174,10 @@ static void Soc_PutTextarea (const char *Placeholder, static long Soc_ReceiveSocialPost (void); -static void Soc_PutIconToToggleCommentSocialNote (const char UniqueId[Soc_MAX_LENGTH_ID]); +static void Soc_PutIconToToggleCommentSocialNote (const char UniqueId[Act_MAX_LENGTH_ID]); static void Soc_PutIconCommentDisabled (void); static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod, - const char IdNewComment[Soc_MAX_LENGTH_ID]); + const char IdNewComment[Act_MAX_LENGTH_ID]); static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod); static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot); static void Soc_WriteSocialComment (struct SocialComment *SocCom, @@ -256,8 +254,6 @@ static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialCommen static void Soc_ResetSocialNote (struct SocialNote *SocNot); static void Soc_ResetSocialComment (struct SocialComment *SocCom); -static void Soc_SetUniqueId (char UniqueId[Soc_MAX_LENGTH_ID]); - static void Soc_ClearTimelineThisSession (void); static void Soc_AddNotesJustRetrievedToTimelineThisSession (void); @@ -1082,7 +1078,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot, char ForumName[512]; char SummaryStr[Cns_MAX_BYTES_TEXT+1]; unsigned NumComments; - char IdNewComment[Soc_MAX_LENGTH_ID]; + char IdNewComment[Act_MAX_LENGTH_ID]; /***** Start frame ****/ if (ShowNoteAlone) @@ -1261,7 +1257,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot, fprintf (Gbl.F.Out,"
"); /* Create unique id for new comment */ - Soc_SetUniqueId (IdNewComment); + Act_SetUniqueId (IdNewComment); /* Get number of comments in this social note */ NumComments = Soc_GetNumCommentsInSocialNote (SocNot->NotCod); @@ -1424,10 +1420,10 @@ static void Soc_WriteAuthorNote (struct UsrData *UsrDat) static void Soc_WriteDateTime (time_t TimeUTC) { extern const char *Txt_Today; - char IdDateTime[Soc_MAX_LENGTH_ID]; + char IdDateTime[Act_MAX_LENGTH_ID]; /***** Create unique Id *****/ - Soc_SetUniqueId (IdDateTime); + Act_SetUniqueId (IdDateTime); /***** Container where the date-time is written *****/ fprintf (Gbl.F.Out,"
" @@ -2000,14 +1996,11 @@ static void Soc_PutFormToWriteNewPost (void) static void Soc_PutTextarea (const char *Placeholder, const char *ClassTextArea,const char *ClassImgTit) { - extern const char *Txt_Image; - extern const char *Txt_optional; - extern const char *Txt_Image_title_attribution; extern const char *Txt_Post; - char IdDivImgButton[Soc_MAX_LENGTH_ID]; + char IdDivImgButton[Act_MAX_LENGTH_ID]; /***** Set unique id for the hidden div *****/ - Soc_SetUniqueId (IdDivImgButton); + Act_SetUniqueId (IdDivImgButton); /***** Textarea to write the content *****/ fprintf (Gbl.F.Out,"