2014-12-01 23:55:08 +01:00
// swad_layout.c: page layout
/*
SWAD ( Shared Workspace At a Distance ) ,
is a web platform developed at the University of Granada ( Spain ) ,
and used to support university teaching .
This file is part of SWAD core .
2021-02-09 12:43:45 +01:00
Copyright ( C ) 1999 - 2021 Antonio Ca <EFBFBD> as Vargas
2014-12-01 23:55:08 +01:00
This program is free software : you can redistribute it and / or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation , either version 3 of the
License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Affero General Public License for more details .
You should have received a copy of the GNU Affero General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
2019-12-29 12:39:00 +01:00
# include <stddef.h> // For NULL
2019-11-11 11:20:31 +01:00
# include <stdlib.h> // For exit
2014-12-01 23:55:08 +01:00
# include <string.h> // For string functions
# include "swad_action.h"
2019-05-16 14:02:06 +02:00
# include "swad_API.h"
2020-04-14 17:15:17 +02:00
# include "swad_banner.h"
2017-06-10 21:38:10 +02:00
# include "swad_box.h"
2015-01-04 14:43:03 +01:00
# include "swad_calendar.h"
2014-12-01 23:55:08 +01:00
# include "swad_changelog.h"
# include "swad_config.h"
# include "swad_connected.h"
# include "swad_database.h"
2020-04-20 01:26:46 +02:00
# include "swad_exam_announcement.h"
2020-05-17 02:28:30 +02:00
# include "swad_exam_session.h"
2019-02-13 13:32:11 +01:00
# include "swad_firewall.h"
2017-02-16 20:22:13 +01:00
# include "swad_follow.h"
2018-11-09 20:47:39 +01:00
# include "swad_form.h"
2014-12-01 23:55:08 +01:00
# include "swad_global.h"
2017-03-02 21:05:09 +01:00
# include "swad_help.h"
2016-11-14 16:47:46 +01:00
# include "swad_hierarchy.h"
2021-02-11 22:57:09 +01:00
# include "swad_hierarchy_level.h"
2020-04-14 17:15:17 +02:00
# include "swad_holiday.h"
2019-10-23 19:05:05 +02:00
# include "swad_HTML.h"
2017-05-07 18:06:34 +02:00
# include "swad_language.h"
2020-04-14 17:15:17 +02:00
# include "swad_link.h"
2019-12-14 14:30:34 +01:00
# include "swad_log.h"
2015-01-17 20:06:25 +01:00
# include "swad_logo.h"
2020-04-08 03:06:45 +02:00
# include "swad_match.h"
2016-06-03 13:42:28 +02:00
# include "swad_MFU.h"
2014-12-01 23:55:08 +01:00
# include "swad_notice.h"
# include "swad_notification.h"
# include "swad_parameter.h"
2019-03-26 11:53:21 +01:00
# include "swad_setting.h"
2015-01-04 15:48:24 +01:00
# include "swad_tab.h"
2014-12-01 23:55:08 +01:00
# include "swad_theme.h"
2019-03-12 21:25:55 +01:00
# include "swad_timeline.h"
2021-02-11 13:27:44 +01:00
# include "swad_timeline_who.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl ;
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
2015-01-04 15:48:24 +01:00
/***************************** Private constants *****************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*****************************************************************************/
2017-04-27 15:02:00 +02:00
/******************************* Private types *******************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Lay_WriteEndOfPage ( void ) ;
static void Lay_WritePageTitle ( void ) ;
2016-12-05 13:26:12 +01:00
static void Lay_WriteRedirToMyLangOnLogIn ( void ) ;
static void Lay_WriteRedirToMyLangOnViewUsrAgd ( void ) ;
2014-12-01 23:55:08 +01:00
static void Lay_WriteScripts ( void ) ;
2017-03-15 22:15:19 +01:00
static void Lay_WriteScriptMathJax ( void ) ;
2014-12-01 23:55:08 +01:00
static void Lay_WriteScriptInit ( void ) ;
2016-01-09 15:00:14 +01:00
static void Lay_WriteScriptParamsAJAX ( void ) ;
2014-12-01 23:55:08 +01:00
static void Lay_WriteScriptCustomDropzone ( void ) ;
2015-11-27 12:57:56 +01:00
static void Lay_WritePageTopHeading ( void ) ;
2015-12-26 12:08:45 +01:00
static void Lay_WriteBreadcrumb ( void ) ;
2015-01-04 15:48:24 +01:00
2014-12-01 23:55:08 +01:00
static void Lay_WriteTitleAction ( void ) ;
static void Lay_ShowLeftColumn ( void ) ;
static void Lay_ShowRightColumn ( void ) ;
2015-12-02 00:32:46 +01:00
static void Lay_WriteAboutZone ( void ) ;
2014-12-01 23:55:08 +01:00
static void Lay_WriteFootFromHTMLFile ( void ) ;
2015-04-11 02:04:23 +02:00
static void Lay_HelpTextEditor ( const char * Text , const char * InlineMath , const char * Equation ) ;
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*********************** Write the start of the page *************************/
/*****************************************************************************/
void Lay_WriteStartOfPage ( void )
{
2018-12-08 16:43:13 +01:00
extern const char * Lan_STR_LANG_ID [ 1 + Lan_NUM_LANGUAGES ] ;
2018-12-09 10:46:57 +01:00
extern const unsigned Txt_Current_CGI_SWAD_Language ;
2014-12-01 23:55:08 +01:00
extern const char * The_TabOnBgColors [ The_NUM_THEMES ] ;
2019-11-21 16:47:07 +01:00
static const char * LayoutMainZone [ Mnu_NUM_MENUS ] =
2015-11-30 01:13:00 +01:00
{
2019-11-21 16:47:07 +01:00
[ Mnu_MENU_HORIZONTAL ] = " main_horizontal " ,
[ Mnu_MENU_VERTICAL ] = " main_vertical " ,
2015-11-30 01:13:00 +01:00
} ;
2019-05-22 09:36:18 +02:00
Act_BrowserTab_t BrowserTab ;
2014-12-01 23:55:08 +01:00
2015-04-12 18:01:06 +02:00
/***** If, when this function is called, the head is being written
or the head is already written = = > don ' t do anything * * * * */
2014-12-01 23:55:08 +01:00
if ( Gbl . Layout . WritingHTMLStart | |
Gbl . Layout . HTMLStartWritten )
return ;
2020-05-09 18:18:04 +02:00
/***** Compute connected users to be displayed in right column *****/
2015-12-20 01:41:07 +01:00
Con_ComputeConnectedUsrsBelongingToCurrentCrs ( ) ;
2014-12-01 23:55:08 +01:00
/***** Send head width the file type for the HTTP protocol *****/
2016-01-17 15:10:54 +01:00
if ( Gbl . Action . UsesAJAX )
2016-01-09 15:00:14 +01:00
// Don't generate a full HTML page, only the content of a DIV or similar
2014-12-01 23:55:08 +01:00
{
2019-11-11 00:15:44 +01:00
HTM_Txt ( " Content-Type: text/html; charset=windows-1252 \r \n \r \n " ) ;
2014-12-01 23:55:08 +01:00
Gbl . Layout . WritingHTMLStart = false ;
2015-11-27 21:24:24 +01:00
Gbl . Layout . HTMLStartWritten = Gbl . Layout . DivsEndWritten = true ;
2014-12-01 23:55:08 +01:00
return ;
}
/***** If serving a web service ==> don't do anything *****/
if ( Gbl . WebService . IsWebService )
{
Gbl . Layout . WritingHTMLStart = false ;
2015-11-27 21:24:24 +01:00
Gbl . Layout . HTMLStartWritten = Gbl . Layout . DivsEndWritten = true ;
2014-12-01 23:55:08 +01:00
return ;
}
Gbl . Layout . WritingHTMLStart = true ;
/***** Write header to standard output to avoid timeout *****/
// Two \r\n are necessary
2014-12-21 14:47:04 +01:00
fprintf ( stdout , " Content-type: text/html; charset=windows-1252 \r \n \r \n "
2014-12-20 16:20:51 +01:00
" <!DOCTYPE html> \n " ) ;
2014-12-01 23:55:08 +01:00
2014-12-21 14:47:04 +01:00
/***** Write start of HTML code *****/
2015-04-12 18:01:06 +02:00
// WARNING: It is necessary to comment the line 'AddDefaultCharset UTF8'
// in httpd.conf to enable meta tag
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <html lang= \" %s \" > \n " , Lan_STR_LANG_ID [ Gbl . Prefs . Language ] ) ;
HTM_Txt ( " <head> \n "
" <meta http-equiv= \" Content-Type \" content= \" text/html;charset=windows-1252 \" /> \n "
" <meta name= \" description \" content= \" A free-software, educational, online tool for managing courses and students. \" /> \n "
" <meta name= \" keywords \" content= \" " ) ;
HTM_Txt ( Cfg_PLATFORM_SHORT_NAME ) ;
HTM_Txt ( " , "
" SWAD, "
" shared workspace at a distance, "
" educational platform, "
" sistema web de apoyo a la docencia, "
" plataforma educativa, "
" campus virtual, "
" SWADroid, "
" LMS, "
" Learning Management System \" /> \n " ) ;
2014-12-01 23:55:08 +01:00
2015-11-27 10:36:40 +01:00
/* Viewport (used for responsive design) */
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <meta name= \" viewport \" "
" content= \" width=device-width, initial-scale=1.0 \" > \n " ) ;
2015-11-27 10:36:40 +01:00
2014-12-01 23:55:08 +01:00
/* Title */
Lay_WritePageTitle ( ) ;
2015-02-10 17:22:57 +01:00
/* Canonical URL */
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <link rel= \" canonical \" href= \" %s \" /> \n " , Cfg_URL_SWAD_CGI ) ;
2015-02-10 17:22:57 +01:00
2014-12-01 23:55:08 +01:00
/* Favicon */
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <link type= \" image/x-icon \" href= \" %s/favicon.ico \" rel= \" icon \" /> \n " ,
Cfg_URL_ICON_PUBLIC ) ;
HTM_TxtF ( " <link type= \" image/x-icon \" href= \" %s/favicon.ico \" rel= \" shortcut icon \" /> \n " ,
Cfg_URL_ICON_PUBLIC ) ;
2014-12-01 23:55:08 +01:00
/* Style sheet for SWAD */
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <link rel= \" stylesheet \" href= \" %s/%s \" type= \" text/css \" /> \n " ,
Cfg_URL_SWAD_PUBLIC , CSS_FILE ) ;
2014-12-01 23:55:08 +01:00
2019-09-09 14:41:06 +02:00
/* Style sheets for Font Awesome */
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <link rel= \" stylesheet \" "
" href= \" %s/fontawesome/css/fontawesome.css \" "
" type= \" text/css \" /> \n " ,
Cfg_URL_SWAD_PUBLIC ) ;
HTM_TxtF ( " <link rel= \" stylesheet \" "
" href= \" %s/fontawesome/css/solid.css \" "
" type= \" text/css \" /> \n " ,
Cfg_URL_SWAD_PUBLIC ) ;
2019-09-09 14:41:06 +02:00
2014-12-01 23:55:08 +01:00
/* Style sheet for Dropzone.js (http://www.dropzonejs.com/) */
// The public directory dropzone must hold:
// dropzone.js
// css/dropzone.css
// images/spritemap@2x.png
// images/spritemap.png
2017-02-17 10:30:59 +01:00
switch ( Gbl . Action . Act )
{
2017-10-08 00:51:49 +02:00
case ActFrmCreDocIns : // Brw_ADMI_DOC_INS
case ActFrmCreShaIns : // Brw_ADMI_SHR_INS
case ActFrmCreDocCtr : // Brw_ADMI_DOC_CTR
case ActFrmCreShaCtr : // Brw_ADMI_SHR_CTR
case ActFrmCreDocDeg : // Brw_ADMI_DOC_DEG
case ActFrmCreShaDeg : // Brw_ADMI_SHR_DEG
case ActFrmCreDocCrs : // Brw_ADMI_DOC_CRS
case ActFrmCreDocGrp : // Brw_ADMI_DOC_GRP
case ActFrmCreTchCrs : // Brw_ADMI_TCH_CRS
case ActFrmCreTchGrp : // Brw_ADMI_TCH_GRP
case ActFrmCreShaCrs : // Brw_ADMI_SHR_CRS
case ActFrmCreShaGrp : // Brw_ADMI_SHR_GRP
case ActFrmCreAsgUsr : // Brw_ADMI_ASG_USR
case ActFrmCreAsgCrs : // Brw_ADMI_ASG_CRS
case ActFrmCreWrkUsr : // Brw_ADMI_WRK_USR
case ActFrmCreWrkCrs : // Brw_ADMI_WRK_CRS
case ActFrmCreDocPrj : // Brw_ADMI_DOC_PRJ
2017-10-08 16:12:58 +02:00
case ActFrmCreAssPrj : // Brw_ADMI_ASS_PRJ
2017-10-08 00:51:49 +02:00
case ActFrmCreMrkCrs : // Brw_ADMI_MRK_CRS
case ActFrmCreMrkGrp : // Brw_ADMI_MRK_GRP
case ActFrmCreBrf : // Brw_ADMI_BRF_USR
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <link rel= \" stylesheet \" "
" href= \" %s/dropzone/css/dropzone.css \" "
" type= \" text/css \" /> \n " ,
Cfg_URL_SWAD_PUBLIC ) ;
2017-02-17 10:30:59 +01:00
break ;
default :
break ;
}
2014-12-01 23:55:08 +01:00
/* Redirect to correct language */
2016-12-05 13:26:12 +01:00
if ( Gbl . Usrs . Me . Logged & & // I am logged
2018-12-09 10:46:57 +01:00
Gbl . Usrs . Me . UsrDat . Prefs . Language ! = Txt_Current_CGI_SWAD_Language ) // My language != current language
2016-12-05 13:26:12 +01:00
{
2019-02-14 19:22:38 +01:00
if ( Gbl . Action . Original = = ActLogIn | | // Regular log in
Gbl . Action . Original = = ActLogInNew ) // Log in when checking account
2016-12-05 13:26:12 +01:00
Lay_WriteRedirToMyLangOnLogIn ( ) ;
2019-02-14 19:22:38 +01:00
else if ( Gbl . Action . Original = = ActLogInUsrAgd ) // Log in to view another user's public agenda
2016-12-05 13:26:12 +01:00
Lay_WriteRedirToMyLangOnViewUsrAgd ( ) ;
}
2014-12-01 23:55:08 +01:00
/* Write initial scripts depending on the action */
Lay_WriteScripts ( ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </head> \n " ) ;
2014-12-01 23:55:08 +01:00
/***** HTML body *****/
2019-05-22 09:36:18 +02:00
BrowserTab = Act_GetBrowserTab ( Gbl . Action . Act ) ;
switch ( BrowserTab )
2014-12-01 23:55:08 +01:00
{
2019-05-22 09:36:18 +02:00
case Act_BRW_1ST_TAB :
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <body onload= \" init(); \" > \n " ) ;
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" zoomLyr \" class= \" ZOOM \" " ) ;
2019-10-30 00:42:01 +01:00
HTM_IMG ( Cfg_URL_ICON_PUBLIC , " usr_bl.jpg " , NULL ,
2019-10-30 22:31:03 +01:00
" class= \" IMG_USR \" id= \" zoomImg \" " ) ;
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" zoomTxt \" class= \" CM \" " ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
HTM_DIV_End ( ) ;
2019-05-22 09:36:18 +02:00
break ;
case Act_BRW_NEW_TAB :
2019-07-15 22:08:06 +02:00
case Act_BRW_2ND_TAB :
2020-03-12 13:53:37 +01:00
HTM_Txt ( " <body onload= \" init(); \" " ) ;
switch ( Gbl . Action . Act )
{
case ActNewMch :
case ActResMch :
case ActBckMch :
case ActPlyPauMch :
case ActFwdMch :
case ActChgNumColMch :
case ActChgVisResMchQst :
case ActMchCntDwn :
HTM_Txt ( " class= \" MCH_BG \" " ) ;
break ;
default :
break ;
}
HTM_Txt ( " > \n " ) ;
Gbl . Layout . WritingHTMLStart = false ;
2019-05-22 09:36:18 +02:00
Gbl . Layout . HTMLStartWritten =
Gbl . Layout . DivsEndWritten = true ;
return ;
default :
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <body> \n " ) ;
2019-05-22 09:36:18 +02:00
Gbl . Layout . WritingHTMLStart = false ;
Gbl . Layout . HTMLStartWritten =
Gbl . Layout . DivsEndWritten = true ;
return ;
2014-12-01 23:55:08 +01:00
}
2019-10-26 02:19:42 +02:00
/***** Begin box that contains the whole page except the foot *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" whole_page \" " ) ;
2015-11-25 01:42:16 +01:00
/***** Header of layout *****/
2015-11-27 12:57:56 +01:00
Lay_WritePageTopHeading ( ) ;
2014-12-31 13:30:26 +01:00
2016-12-18 19:50:33 +01:00
/***** 3rd. row (tabs) *****/
Tab_DrawTabs ( ) ;
2015-11-25 14:54:46 +01:00
/***** 4th row: main zone *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" main_zone \" " ) ;
2015-11-25 01:42:16 +01:00
/* Left column */
2015-11-27 12:57:56 +01:00
if ( Gbl . Prefs . SideCols & Lay_SHOW_LEFT_COLUMN ) // Left column visible
{
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <aside id= \" left_col \" > " ) ;
2015-11-27 12:57:56 +01:00
Lay_ShowLeftColumn ( ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </aside> " ) ;
2015-11-27 12:57:56 +01:00
}
2015-11-25 01:42:16 +01:00
2015-11-27 10:36:40 +01:00
/* Right column */
2015-11-27 21:24:24 +01:00
// Right column is written before central column
// but it must be drawn at right using "position:absolute; right:0".
// The reason to write right column before central column
// is that central column may hold a lot of content drawn slowly.
2015-11-27 12:57:56 +01:00
if ( Gbl . Prefs . SideCols & Lay_SHOW_RIGHT_COLUMN ) // Right column visible
{
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <aside id= \" right_col \" > " ) ;
2015-11-27 12:57:56 +01:00
Lay_ShowRightColumn ( ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </aside> " ) ;
2015-11-27 12:57:56 +01:00
}
2015-11-27 10:36:40 +01:00
2015-11-27 21:24:24 +01:00
/* Central (main) column */
2015-11-27 10:36:40 +01:00
switch ( Gbl . Prefs . SideCols )
{
case 0 :
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" main_zone_central_none \" " ) ;
2015-11-27 10:36:40 +01:00
break ;
case Lay_SHOW_LEFT_COLUMN :
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" main_zone_central_left \" " ) ;
2015-11-27 10:36:40 +01:00
break ;
case Lay_SHOW_RIGHT_COLUMN :
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" main_zone_central_right \" " ) ;
2015-11-27 10:36:40 +01:00
break ;
case ( Lay_SHOW_LEFT_COLUMN | Lay_SHOW_RIGHT_COLUMN ) :
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" main_zone_central_both \" " ) ;
2015-11-27 10:36:40 +01:00
break ;
}
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" main_zone_central_container \" class= \" %s \" " ,
The_TabOnBgColors [ Gbl . Prefs . Theme ] ) ;
2015-11-30 01:13:00 +01:00
/* Layout with horizontal or vertical menu */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" %s \" " , LayoutMainZone [ Gbl . Prefs . Menu ] ) ;
2014-12-01 23:55:08 +01:00
2015-11-29 22:06:22 +01:00
/* Menu */
Mnu_WriteMenuThisTab ( ) ;
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/* Start canvas: main zone for actions output */
2019-10-26 01:56:36 +02:00
HTM_MAIN_Begin ( " MAIN_ZONE_CANVAS " ) ;
2015-11-27 12:57:56 +01:00
2014-12-31 13:30:26 +01:00
/* If it is mandatory to read any information about course */
2019-04-04 10:45:15 +02:00
if ( Gbl . Crs . Info . ShowMsgMustBeRead )
2014-12-31 13:30:26 +01:00
Inf_WriteMsgYouMustReadInfo ( ) ;
2014-12-01 23:55:08 +01:00
/* Write title of the current action */
2015-11-27 12:57:56 +01:00
if ( Gbl . Prefs . Menu = = Mnu_MENU_VERTICAL & &
2018-04-24 13:21:53 +02:00
Act_GetIndexInMenu ( Gbl . Action . Act ) > = 0 )
2014-12-01 23:55:08 +01:00
Lay_WriteTitleAction ( ) ;
Gbl . Layout . WritingHTMLStart = false ;
Gbl . Layout . HTMLStartWritten = true ;
/* Write message indicating number of clicks allowed before sending my photo */
Usr_InformAboutNumClicksBeforePhoto ( ) ;
}
2017-10-04 12:20:58 +02:00
/*****************************************************************************/
/*********************** Write status 204 No Content *************************/
/*****************************************************************************/
void Lay_WriteHTTPStatus204NoContent ( void )
{
/***** The HTTP response is a code status *****/
/* Don't write HTML at all */
Gbl . Layout . HTMLStartWritten =
Gbl . Layout . DivsEndWritten =
Gbl . Layout . HTMLEndWritten = true ;
/* Start HTTP response */
fprintf ( stdout , " Content-type: text/plain; charset=windows-1252 \n " ) ;
/* Return HTTP status code 204 No Content:
The server has successfully fulfilled the request
and there is no additional content to send
in the response payload body . */
fprintf ( stdout , " Status: 204 \r \n \r \n " ) ;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************ Write the end of the page **************************/
/*****************************************************************************/
static void Lay_WriteEndOfPage ( void )
{
2015-11-27 21:24:24 +01:00
if ( ! Gbl . Layout . DivsEndWritten )
2014-12-01 23:55:08 +01:00
{
2015-11-27 21:24:24 +01:00
/***** End of central part of main zone *****/
2019-10-26 01:56:36 +02:00
HTM_MAIN_End ( ) ; // Canvas (main zone to output content of the current action)
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // Layout with horizontal or vertical menu
HTM_DIV_End ( ) ; // main_zone_central_container
2015-11-27 21:24:24 +01:00
/***** Write page footer *****/
2018-04-24 13:21:53 +02:00
if ( Act_GetBrowserTab ( Gbl . Action . Act ) = = Act_BRW_1ST_TAB )
2015-12-02 00:32:46 +01:00
Lay_WriteFootFromHTMLFile ( ) ;
2015-11-27 21:24:24 +01:00
/***** End of main zone and page *****/
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // main_zone_central
HTM_DIV_End ( ) ; // main_zone
HTM_DIV_End ( ) ; // whole_page_* (box that contains the whole page except the foot)
2015-11-27 21:24:24 +01:00
Gbl . Layout . DivsEndWritten = true ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************************* Write the title of the page ***********************/
/*****************************************************************************/
static void Lay_WritePageTitle ( void )
{
2016-03-20 17:47:18 +01:00
extern const char * Txt_TAGLINE ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <title> " ) ;
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
if ( Gbl . Params . GetMethod & & Gbl . Hierarchy . Deg . DegCod > 0 )
2014-12-01 23:55:08 +01:00
{
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " %s > %s " , Cfg_PLATFORM_SHORT_NAME , Gbl . Hierarchy . Deg . ShrtName ) ;
2021-02-11 22:57:09 +01:00
if ( Gbl . Hierarchy . Level = = Hie_Lvl_CRS )
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " > %s " , Gbl . Hierarchy . Crs . ShrtName ) ;
2014-12-01 23:55:08 +01:00
}
else
2019-11-11 10:59:24 +01:00
HTM_TxtF ( " %s: %s " , Cfg_PLATFORM_SHORT_NAME , Txt_TAGLINE ) ;
2014-12-01 23:55:08 +01:00
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </title> \n " ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Write script and meta to redirect to my language **************/
/*****************************************************************************/
2016-12-05 13:26:12 +01:00
static void Lay_WriteRedirToMyLangOnLogIn ( void )
2014-12-01 23:55:08 +01:00
{
2018-12-08 16:43:13 +01:00
extern const char * Lan_STR_LANG_ID [ 1 + Lan_NUM_LANGUAGES ] ;
2014-12-01 23:55:08 +01:00
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <meta http-equiv= \" refresh \" "
" content= \" 0; url='%s/%s?act=%ld&ses=%s' \" > " ,
Cfg_URL_SWAD_CGI ,
Lan_STR_LANG_ID [ Gbl . Usrs . Me . UsrDat . Prefs . Language ] ,
Act_GetActCod ( ActLogInLan ) ,
Gbl . Session . Id ) ;
2014-12-01 23:55:08 +01:00
}
2016-12-05 13:26:12 +01:00
static void Lay_WriteRedirToMyLangOnViewUsrAgd ( void )
{
2018-12-08 16:43:13 +01:00
extern const char * Lan_STR_LANG_ID [ 1 + Lan_NUM_LANGUAGES ] ;
2016-12-05 13:26:12 +01:00
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " <meta http-equiv= \" refresh \" "
" content= \" 0; url='%s/%s?act=%ld&ses=%s&agd=@%s' \" > " ,
Cfg_URL_SWAD_CGI ,
Lan_STR_LANG_ID [ Gbl . Usrs . Me . UsrDat . Prefs . Language ] ,
Act_GetActCod ( ActLogInUsrAgdLan ) ,
Gbl . Session . Id ,
Gbl . Usrs . Other . UsrDat . Nickname ) ;
2016-12-05 13:26:12 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************ Write some scripts depending on the current action *************/
/*****************************************************************************/
static void Lay_WriteScripts ( void )
{
2015-10-30 17:05:33 +01:00
extern const char * Txt_DAYS_CAPS [ 7 ] ;
2016-12-12 23:10:11 +01:00
extern const char * Txt_DAYS_SMALL [ 7 ] ;
2015-10-30 17:05:33 +01:00
extern const char * Txt_Exam_of_X ;
2020-04-13 22:04:46 +02:00
struct Hld_Holidays Holidays ;
2020-04-20 01:26:46 +02:00
struct ExaAnn_ExamAnnouncements ExamAnns ;
2015-10-30 17:05:33 +01:00
unsigned DayOfWeek ; /* 0, 1, 2, 3, 4, 5, 6 */
unsigned NumHld ;
unsigned NumExamAnnouncement ; // Number of exam announcement
2014-12-01 23:55:08 +01:00
/***** General scripts for swad *****/
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( Cfg_URL_SWAD_PUBLIC " / " JS_FILE , NULL ) ;
HTM_SCRIPT_End ( ) ;
2015-04-07 21:44:24 +02:00
/***** Script for MathJax *****/
2017-03-16 10:06:44 +01:00
Lay_WriteScriptMathJax ( ) ;
2015-04-07 21:44:24 +02:00
2017-09-24 12:31:48 +02:00
/***** Write script with init function executed after loading page *****/
Lay_WriteScriptInit ( ) ;
/***** Write script to set parameters needed by AJAX *****/
Lay_WriteScriptParamsAJAX ( ) ;
2014-12-01 23:55:08 +01:00
2019-11-11 13:11:38 +01:00
/***** Write script to initialize variables used to draw dates *****/
HTM_SCRIPT_Begin ( NULL , NULL ) ;
HTM_Txt ( " \t var DAYS = [ " ) ;
for ( DayOfWeek = 0 ;
DayOfWeek < 7 ;
DayOfWeek + + )
{
if ( DayOfWeek )
HTM_Comma ( ) ;
HTM_TxtF ( " '%s' " , Txt_DAYS_SMALL [ DayOfWeek ] ) ;
}
HTM_Txt ( " ]; \n " ) ;
HTM_SCRIPT_End ( ) ;
2015-10-30 17:05:33 +01:00
/***** Prepare script to draw months *****/
2019-02-15 10:50:30 +01:00
if ( ( Gbl . Prefs . SideCols & Lay_SHOW_LEFT_COLUMN ) | | // Left column visible
2019-11-11 13:11:38 +01:00
( Gbl . Hierarchy . Ins . InsCod > 0 & & // Institution selected
2019-02-15 13:39:37 +01:00
( Gbl . Action . Act = = ActSeeCal | | // Viewing calendar
Gbl . Action . Act = = ActPrnCal | | // Printing calendar
Gbl . Action . Act = = ActChgCal1stDay ) ) ) // Changing first day
2015-10-30 17:05:33 +01:00
{
2020-04-13 22:04:46 +02:00
/***** Reset places context *****/
Hld_ResetHolidays ( & Holidays ) ;
2015-10-30 17:05:33 +01:00
/***** Get list of holidays *****/
2020-04-13 22:04:46 +02:00
Holidays . SelectedOrder = Hld_ORDER_BY_START_DATE ;
Hld_GetListHolidays ( & Holidays ) ;
2015-10-30 17:05:33 +01:00
2020-04-12 20:08:37 +02:00
/***** Reset exam announcements context *****/
2020-05-07 19:31:58 +02:00
ExaAnn_ResetExamAnns ( & ExamAnns ) ;
2020-04-12 20:08:37 +02:00
/***** Create list of exam announcements *****/
2020-05-07 19:31:58 +02:00
ExaAnn_CreateListExamAnns ( & ExamAnns ) ;
2015-10-30 17:05:33 +01:00
/***** Write script to initialize variables used to draw months *****/
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( NULL , NULL ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " \t var DAYS_CAPS = [ " ) ;
2015-10-30 17:05:33 +01:00
for ( DayOfWeek = 0 ;
DayOfWeek < 7 ;
DayOfWeek + + )
{
if ( DayOfWeek )
2019-11-11 00:15:44 +01:00
HTM_Comma ( ) ;
HTM_TxtF ( " '%c' " , Txt_DAYS_CAPS [ DayOfWeek ] [ 0 ] ) ;
2015-10-30 17:05:33 +01:00
}
2019-11-11 00:15:44 +01:00
HTM_Txt ( " ]; \n " ) ;
2015-10-30 17:05:33 +01:00
2019-11-11 00:15:44 +01:00
HTM_Txt ( " \t var STR_EXAM = ' " ) ;
HTM_TxtF ( Txt_Exam_of_X , Gbl . Hierarchy . Crs . FullName ) ;
HTM_Txt ( " '; \n " ) ;
2015-10-30 17:05:33 +01:00
2019-11-11 00:15:44 +01:00
HTM_Txt ( " \t var Hlds = []; \n " ) ;
2020-04-13 22:04:46 +02:00
2015-10-30 17:05:33 +01:00
for ( NumHld = 0 ;
2020-04-13 22:04:46 +02:00
NumHld < Holidays . Num ;
2015-10-30 17:05:33 +01:00
NumHld + + )
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t Hlds.push({ PlcCod: %ld, HldTyp: %u, StartDate: %s, EndDate: %s, Name: '%s' }); \n " ,
2020-04-13 22:04:46 +02:00
Holidays . Lst [ NumHld ] . PlcCod ,
( unsigned ) Holidays . Lst [ NumHld ] . HldTyp ,
Holidays . Lst [ NumHld ] . StartDate . YYYYMMDD ,
Holidays . Lst [ NumHld ] . EndDate . YYYYMMDD ,
Holidays . Lst [ NumHld ] . Name ) ;
2019-11-11 00:15:44 +01:00
2019-11-12 09:55:43 +01:00
HTM_TxtF ( " \t var LstExamAnnouncements = []; \n " ) ;
2015-10-30 17:05:33 +01:00
for ( NumExamAnnouncement = 0 ;
2020-04-12 20:08:37 +02:00
NumExamAnnouncement < ExamAnns . NumExaAnns ;
2015-10-30 17:05:33 +01:00
NumExamAnnouncement + + )
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " LstExamAnnouncements.push({ ExaCod: %ld, Year: %u, Month: %u, Day: %u }); \n " ,
2020-04-12 20:08:37 +02:00
ExamAnns . Lst [ NumExamAnnouncement ] . ExaCod ,
ExamAnns . Lst [ NumExamAnnouncement ] . ExamDate . Year ,
ExamAnns . Lst [ NumExamAnnouncement ] . ExamDate . Month ,
ExamAnns . Lst [ NumExamAnnouncement ] . ExamDate . Day ) ;
2015-10-30 17:05:33 +01:00
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_End ( ) ;
2016-06-01 13:43:22 +02:00
2020-04-12 20:08:37 +02:00
/***** Free list of exam announcements *****/
2020-05-07 19:31:58 +02:00
ExaAnn_FreeListExamAnns ( & ExamAnns ) ;
2020-04-13 22:04:46 +02:00
/***** Free list of holidays *****/
Hld_FreeListHolidays ( & Holidays ) ;
2015-10-30 17:05:33 +01:00
}
2015-10-28 21:47:42 +01:00
/***** Scripts depending on action *****/
2016-01-17 15:10:54 +01:00
switch ( Gbl . Action . Act )
2014-12-01 23:55:08 +01:00
{
2015-10-28 21:47:42 +01:00
/***** Script to print world map *****/
case ActSeeCty :
Cty_WriteScriptGoogleGeochart ( ) ;
break ;
/***** Script for uploading files using Dropzone.js (http://www.dropzonejs.com/) *****/
// The public directory dropzone must hold:
// dropzone.js
// css/dropzone.css
// images/spritemap@2x.png
// images/spritemap.png
2017-10-08 00:51:49 +02:00
case ActFrmCreDocIns : // Brw_ADMI_DOC_INS
case ActFrmCreShaIns : // Brw_ADMI_SHR_INS
case ActFrmCreDocCtr : // Brw_ADMI_DOC_CTR
case ActFrmCreShaCtr : // Brw_ADMI_SHR_CTR
case ActFrmCreDocDeg : // Brw_ADMI_DOC_DEG
case ActFrmCreShaDeg : // Brw_ADMI_SHR_DEG
case ActFrmCreDocCrs : // Brw_ADMI_DOC_CRS
case ActFrmCreDocGrp : // Brw_ADMI_DOC_GRP
case ActFrmCreTchCrs : // Brw_ADMI_TCH_CRS
case ActFrmCreTchGrp : // Brw_ADMI_TCH_GRP
case ActFrmCreShaCrs : // Brw_ADMI_SHR_CRS
case ActFrmCreShaGrp : // Brw_ADMI_SHR_GRP
case ActFrmCreAsgUsr : // Brw_ADMI_ASG_USR
case ActFrmCreAsgCrs : // Brw_ADMI_ASG_CRS
case ActFrmCreWrkUsr : // Brw_ADMI_WRK_USR
case ActFrmCreWrkCrs : // Brw_ADMI_WRK_CRS
case ActFrmCreDocPrj : // Brw_ADMI_DOC_PRJ
2017-10-08 16:12:58 +02:00
case ActFrmCreAssPrj : // Brw_ADMI_ASS_PRJ
2017-10-08 00:51:49 +02:00
case ActFrmCreMrkCrs : // Brw_ADMI_MRK_CRS
case ActFrmCreMrkGrp : // Brw_ADMI_MRK_GRP
case ActFrmCreBrf : // Brw_ADMI_BRF_USR
2015-10-28 21:47:42 +01:00
// Use charset="windows-1252" to force error messages in windows-1252 (default is UTF-8)
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( Cfg_URL_SWAD_PUBLIC " /dropzone/dropzone.js " , " windows-1252 " ) ;
HTM_SCRIPT_End ( ) ;
2015-10-28 21:47:42 +01:00
Lay_WriteScriptCustomDropzone ( ) ;
break ;
case ActReqAccGbl :
case ActSeeAccGbl :
case ActReqAccCrs :
case ActSeeAccCrs :
case ActSeeAllStaCrs :
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( Cfg_URL_SWAD_PUBLIC " /jstz/jstz.js " , NULL ) ;
HTM_SCRIPT_End ( ) ;
2015-10-28 21:47:42 +01:00
break ;
default :
break ;
2014-12-01 23:55:08 +01:00
}
/***** Script for Google Analytics *****/
2019-11-10 12:36:37 +01:00
HTM_Txt ( Cfg_GOOGLE_ANALYTICS ) ;
2014-12-01 23:55:08 +01:00
}
// Change page title
//function changeTitle(title) {
// document.title = title;
//}
2017-03-15 22:15:19 +01:00
/*****************************************************************************/
/************ Write some scripts depending on the current action *************/
/*****************************************************************************/
static void Lay_WriteScriptMathJax ( void )
{
2020-03-14 16:49:04 +01:00
/* MathJax 2.5.1 (obsolete) */
2017-03-15 22:15:19 +01:00
/*
# ifdef Cfg_MATHJAX_LOCAL
// Use the local copy of MathJax
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( Cfg_URL_SWAD_PUBLIC " /MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML " , NULL ) ;
2017-03-15 22:15:19 +01:00
# else
// Use the MathJax Content Delivery Network (CDN)
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( " //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML " , NULL ) ;
2017-03-15 22:15:19 +01:00
# endif
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_End ( ) ;
2020-03-14 16:49:04 +01:00
*/
/* MathJax 3.0.1 (march 2020)
Source :
http : //docs.mathjax.org/en/latest/web/configuration.html
*/
/* Configuration Using an In-Line Script */
/*
HTM_Txt ( " <script type= \" text/x-mathjax-config \" > \n "
" MathJax = { \n "
" tex: { \n "
" inlineMath: [['$','$'], [' \\ \\ (',' \\ \\ )']] \n "
" } \n "
" }; \n "
" </script> " ) ;
*/
/* Using a Local File for Configuration
Using a Local File for Configuration
If you are using the same MathJax configuration over multiple pages ,
you may find it convenient to store your configuration
in a separate JavaScript file that you load into the page .
For example , you could create a file called mathjax - config . js that contains
window . MathJax = {
tex : {
inlineMath : [ [ ' $ ' , ' $ ' ] , [ ' \ \ ( ' , ' \ \ ) ' ] ] ,
} ,
svg : {
fontCache : ' global '
}
} ;
and then use
< script src = " mathjax-config.js " defer > < / script >
< script type = " text/javascript " id = " MathJax-script " defer
src = " https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js " >
< / script >
to first load your configuration file ,
and then load the tex - svg component from the jsdelivr CDN .
Note that here we use the defer attribute on both scripts
so that they will execute in order ,
but still not block the rest of the page
while the files are being downloaded to the browser .
If the async attribute were used ,
there is no guarantee that the configuration would run first ,
and so you could get instances
where MathJax doesn ' t get properly configured ,
and they would seem to occur randomly .
*/
HTM_TxtF ( " <script src= \" %s/mathjax-config.js \" defer> \n "
" </script> \n " ,
Cfg_URL_SWAD_PUBLIC ) ;
# ifdef Cfg_MATHJAX_LOCAL
// Use the local copy of MathJax
HTM_TxtF ( " <script type= \" text/javascript \" id= \" MathJax-script \" defer "
" src= \" %s/mathjax/tex-chtml.js \" > \n "
" </script> \n " ,
Cfg_URL_SWAD_PUBLIC ) ;
# else
// Use the MathJax Content Delivery Network (CDN)
HTM_TxtF ( " <script type= \" text/javascript \" id= \" MathJax-script \" defer "
" src= \" https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js \" > \n "
" </script> \n " ) ;
# endif
2017-03-15 22:15:19 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******* Write script with init function executed after loading page *********/
/*****************************************************************************/
static void Lay_WriteScriptInit ( void )
{
2018-12-08 16:43:13 +01:00
extern const char * Lan_STR_LANG_ID [ 1 + Lan_NUM_LANGUAGES ] ;
2019-07-15 22:08:06 +02:00
bool RefreshConnected ;
2020-04-23 02:28:28 +02:00
bool RefreshLastClicks = false ;
bool RefreshNewTimeline = false ;
bool RefreshMatchStd = false ;
bool RefreshMatchTch = false ;
2019-03-13 09:55:23 +01:00
2019-07-15 22:08:06 +02:00
RefreshConnected = Act_GetBrowserTab ( Gbl . Action . Act ) = = Act_BRW_1ST_TAB & &
( Gbl . Prefs . SideCols & Lay_SHOW_RIGHT_COLUMN ) ; // Right column visible
2019-03-13 09:55:23 +01:00
switch ( Gbl . Action . Act )
{
2020-04-23 02:28:28 +02:00
/* Last clicks */
case ActLstClk :
RefreshLastClicks = true ;
break ;
/* Timeline */
2021-02-22 10:23:55 +01:00
case ActSeeGblTL :
case ActRcvPstGblTL :
case ActRcvComGblTL :
case ActReqRemPubGblTL :
case ActRemPubGblTL :
case ActReqRemComGblTL :
case ActRemComGblTL :
2019-03-13 09:55:23 +01:00
RefreshNewTimeline = true ;
break ;
2020-04-23 02:28:28 +02:00
/* Match */
2019-09-29 21:33:27 +02:00
case ActJoiMch :
2019-12-03 02:46:46 +01:00
case ActSeeMchAnsQstStd :
case ActRemMchAnsQstStd :
2019-09-26 19:54:09 +02:00
case ActAnsMchQstStd :
RefreshMatchStd = true ;
break ;
2019-09-29 21:33:27 +02:00
case ActNewMch :
case ActResMch :
case ActBckMch :
2019-10-17 22:47:44 +02:00
case ActPlyPauMch :
2019-09-29 21:33:27 +02:00
case ActFwdMch :
2019-10-23 00:49:03 +02:00
case ActChgNumColMch :
2019-09-25 21:58:12 +02:00
case ActChgVisResMchQst :
2019-12-13 23:38:29 +01:00
case ActMchCntDwn :
2019-09-26 19:54:09 +02:00
RefreshMatchTch = true ;
2019-05-22 09:36:18 +02:00
break ;
2020-04-23 02:28:28 +02:00
2019-03-13 09:55:23 +01:00
default :
break ;
}
2014-12-01 23:55:08 +01:00
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( NULL , NULL ) ;
2015-10-27 19:44:31 +01:00
2015-11-27 12:57:56 +01:00
Dat_WriteScriptMonths ( ) ;
2015-10-27 19:44:31 +01:00
2020-04-23 02:28:28 +02:00
if ( RefreshNewTimeline ) // Refresh new timeline via AJAX
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t var delayNewTL = %lu; \n " , Cfg_TIME_TO_REFRESH_TIMELINE ) ;
2020-04-23 02:28:28 +02:00
else if ( RefreshMatchStd ) // Refresh match via AJAX
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t var delayMatch = %lu; \n " , Cfg_TIME_TO_REFRESH_MATCH_STD ) ;
2020-04-23 02:28:28 +02:00
else if ( RefreshMatchTch ) // Refresh match via AJAX
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t var delayMatch = %lu; \n " , Cfg_TIME_TO_REFRESH_MATCH_TCH ) ;
2019-03-13 09:55:23 +01:00
2019-11-01 17:35:26 +01:00
/***** Function init () ******/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " function init(){ \n " ) ;
2014-12-01 23:55:08 +01:00
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t ActionAJAX = \" %s \" ; \n " , Lan_STR_LANG_ID [ Gbl . Prefs . Language ] ) ;
2014-12-01 23:55:08 +01:00
2019-07-15 22:08:06 +02:00
if ( RefreshConnected ) // Refresh connected users via AJAX
{
Con_WriteScriptClockConnected ( ) ;
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t setTimeout( \" refreshConnected() \" ,%lu); \n " ,
Gbl . Usrs . Connected . TimeToRefreshInMs ) ;
2019-07-15 22:08:06 +02:00
}
2016-01-15 02:41:55 +01:00
2020-04-23 02:28:28 +02:00
if ( RefreshLastClicks ) // Refresh last clicks via AJAX
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " \t setTimeout( \" refreshLastClicks() \" ,%lu); \n " ,
Cfg_TIME_TO_REFRESH_LAST_CLICKS ) ;
2020-04-23 02:28:28 +02:00
else if ( RefreshNewTimeline ) // Refresh timeline via AJAX
HTM_Txt ( " \t setTimeout( \" refreshNewTL() \" ,delayNewTL); \n " ) ;
else if ( RefreshMatchStd ) // Refresh match for a student via AJAX
2019-11-11 00:15:44 +01:00
HTM_Txt ( " \t setTimeout( \" refreshMatchStd() \" ,delayMatch); \n " ) ;
2020-04-23 02:28:28 +02:00
else if ( RefreshMatchTch ) // Refresh match for a teacher via AJAX
2019-11-11 00:15:44 +01:00
HTM_Txt ( " \t setTimeout( \" refreshMatchTch() \" ,delayMatch); \n " ) ;
2019-03-13 09:55:23 +01:00
2019-11-11 00:15:44 +01:00
HTM_Txt ( " } \n " ) ;
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_End ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-01-09 15:00:14 +01:00
/************** Write script to set parameters needed by AJAX ****************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-09 15:00:14 +01:00
static void Lay_WriteScriptParamsAJAX ( void )
2014-12-01 23:55:08 +01:00
{
2016-01-14 01:39:02 +01:00
/***** Start script *****/
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( NULL , NULL ) ;
2016-01-14 01:39:02 +01:00
2019-05-22 09:36:18 +02:00
/***** Parameters with code of session and current course code *****/
2019-10-17 22:47:44 +02:00
// Refresh parameters
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamIdSes = \" ses=%s \" ; \n "
" var RefreshParamCrsCod = \" crs=%ld \" ; \n " ,
Gbl . Session . Id ,
Gbl . Hierarchy . Crs . CrsCod ) ;
2016-01-14 01:39:02 +01:00
2019-05-22 09:36:18 +02:00
/***** Parameter to refresh connected users *****/
if ( Act_GetBrowserTab ( Gbl . Action . Act ) = = Act_BRW_1ST_TAB )
2019-10-17 22:47:44 +02:00
// Refresh parameter
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamNxtActCon = \" act=%ld \" ; \n " ,
Act_GetActCod ( ActRefCon ) ) ;
2016-01-14 01:39:02 +01:00
2017-10-04 01:12:52 +02:00
/***** Parameters related with expanding/contracting folders in file browsers *****/
if ( Gbl . FileBrowser . Type ! = Brw_UNKNOWN )
/* In all the actions related to file browsers ==>
put parameters used by AJAX */
2019-10-17 22:47:44 +02:00
// Refresh parameters
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamExpand = \" act=%ld \" ; \n "
" var RefreshParamContract = \" act=%ld \" ; \n " ,
Act_GetActCod ( Brw_GetActionExpand ( ) ) ,
Act_GetActCod ( Brw_GetActionContract ( ) ) ) ;
2017-10-04 01:12:52 +02:00
2019-05-22 09:36:18 +02:00
/***** Parameters related with other actions *****/
2017-02-17 10:30:59 +01:00
switch ( Gbl . Action . Act )
2016-01-14 01:39:02 +01:00
{
2019-05-22 09:36:18 +02:00
/* Parameters related with global timeline refreshing */
2021-02-22 10:23:55 +01:00
case ActSeeGblTL :
case ActRcvPstGblTL :
case ActRcvComGblTL :
case ActReqRemPubGblTL :
case ActRemPubGblTL :
case ActReqRemComGblTL :
case ActRemComGblTL :
2017-02-17 10:30:59 +01:00
/* In all the actions related to view or editing global timeline ==>
put parameters used by AJAX */
2019-10-17 22:47:44 +02:00
// Refresh parameters
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamNxtActNewPub = \" act=%ld \" ; \n "
" var RefreshParamNxtActOldPub = \" act=%ld \" ; \n "
2019-11-12 00:31:41 +01:00
" var RefreshParamWho = \" Who=%u \" ; \n " ,
2021-02-22 10:23:55 +01:00
Act_GetActCod ( ActRefNewPubGblTL ) ,
Act_GetActCod ( ActRefOldPubGblTL ) ,
2021-03-04 17:47:08 +01:00
( unsigned ) Tml_Who_GetGlobalWho ( ) ) ; // Global variable got in a priori function
2017-02-17 10:30:59 +01:00
break ;
2019-05-22 09:36:18 +02:00
/* Parameters related with user timeline refreshing */
2017-02-17 10:30:59 +01:00
case ActSeeOthPubPrf :
2021-02-22 10:23:55 +01:00
case ActRcvPstUsrTL :
case ActRcvComUsrTL :
case ActReqRemPubUsrTL :
case ActRemPubUsrTL :
case ActReqRemComUsrTL :
case ActRemComUsrTL :
2017-02-17 10:30:59 +01:00
/* In all the actions related to view or editing user's timeline ==>
put parameters used by AJAX */
if ( Gbl . Usrs . Other . UsrDat . UsrCod < = 0 )
2019-12-05 15:47:23 +01:00
Usr_GetParamOtherUsrCodEncrypted ( & Gbl . Usrs . Other . UsrDat ) ;
2019-10-17 22:47:44 +02:00
// Refresh parameters
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamNxtActOldPub = \" act=%ld \" ; \n "
" var RefreshParamUsr = \" OtherUsrCod=%s \" ; \n " ,
2021-02-22 10:23:55 +01:00
Act_GetActCod ( ActRefOldPubUsrTL ) ,
2021-02-15 16:25:55 +01:00
Gbl . Usrs . Other . UsrDat . EnUsrCod ) ;
2017-02-17 10:30:59 +01:00
break ;
2019-09-26 19:54:09 +02:00
/* Parameters related with match refreshing (for students) */
2019-09-29 21:33:27 +02:00
case ActJoiMch :
2019-12-03 02:46:46 +01:00
case ActSeeMchAnsQstStd :
case ActRemMchAnsQstStd :
2019-09-26 19:54:09 +02:00
case ActAnsMchQstStd :
2019-10-17 22:47:44 +02:00
// Refresh parameters
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamNxtActMch = \" act=%ld \" ; \n "
" var RefreshParamMchCod = \" MchCod=%ld \" ; \n " ,
Act_GetActCod ( ActRefMchStd ) ,
2020-04-08 03:06:45 +02:00
Mch_GetMchCodBeingPlayed ( ) ) ;
2019-09-26 19:54:09 +02:00
break ;
2019-07-17 18:17:44 +02:00
/* Parameters related with match refreshing (for teachers) */
2019-09-29 21:33:27 +02:00
case ActNewMch :
case ActResMch :
case ActBckMch :
2019-10-17 22:47:44 +02:00
case ActPlyPauMch :
2019-09-29 21:33:27 +02:00
case ActFwdMch :
2019-10-23 00:49:03 +02:00
case ActChgNumColMch :
2019-09-25 21:58:12 +02:00
case ActChgVisResMchQst :
2019-12-13 23:38:29 +01:00
case ActMchCntDwn :
2019-10-17 22:47:44 +02:00
// Handle keys in keyboard/presenter
2019-11-11 00:15:44 +01:00
HTM_Txt ( " document.addEventListener( \" keydown \" ,handleMatchKeys); \n " ) ;
2019-10-17 22:47:44 +02:00
// Refresh parameters
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamNxtActMch = \" act=%ld \" ; \n "
" var RefreshParamMchCod = \" MchCod=%ld \" ; \n " ,
Act_GetActCod ( ActRefMchTch ) ,
2020-04-08 03:06:45 +02:00
Mch_GetMchCodBeingPlayed ( ) ) ;
2019-07-16 22:33:28 +02:00
break ;
2019-05-22 09:36:18 +02:00
/* Parameter related with clicks refreshing */
case ActLstClk :
2019-10-17 22:47:44 +02:00
// Refresh parameter
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " var RefreshParamNxtActLstClk = \" act=%ld \" ; \n " ,
Act_GetActCod ( ActRefLstClk ) ) ;
2019-05-22 09:36:18 +02:00
break ;
2017-02-17 10:30:59 +01:00
default :
break ;
2016-01-14 01:39:02 +01:00
}
2019-05-22 09:36:18 +02:00
/***** End script *****/
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_End ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******* Write script to customize upload of files using Dropzone.js *********/
/*****************************************************************************/
// More info: http://www.dropzonejs.com/
static void Lay_WriteScriptCustomDropzone ( void )
{
// "myAwesomeDropzone" is the camelized version of the HTML element's ID
// Add a line "forceFallback: true,\n" to test classic upload
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_Begin ( NULL , NULL ) ;
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " Dropzone.options.myAwesomeDropzone = { \n "
" maxFiles: 100, \n "
" parallelUploads: 100, \n "
" maxFilesize: %lu, \n "
" fallback: function() { \n "
" document.getElementById('dropzone-upload').style.display='none'; \n "
" document.getElementById('classic-upload').style.display='block'; \n "
" } \n "
" }; \n " ,
( unsigned long ) ( Fil_MAX_FILE_SIZE / ( 1024ULL * 1024ULL ) - 1 ) ) ;
2019-11-01 17:35:26 +01:00
HTM_SCRIPT_End ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************ Write top heading of the page **********************/
/*****************************************************************************/
2015-11-27 12:57:56 +01:00
static void Lay_WritePageTopHeading ( void )
2014-12-01 23:55:08 +01:00
{
2016-03-22 01:26:00 +01:00
extern const char * The_ClassTagline [ The_NUM_THEMES ] ;
extern const char * Txt_TAGLINE ;
2016-03-22 00:03:43 +01:00
extern const char * Txt_TAGLINE_BR ;
2019-11-21 16:47:07 +01:00
static const char * ClassHeadRow1 [ The_NUM_THEMES ] =
2015-09-27 19:31:10 +02:00
{
2019-11-21 16:47:07 +01:00
[ The_THEME_WHITE ] = " HEAD_ROW_1_WHITE " ,
[ The_THEME_GREY ] = " HEAD_ROW_1_GREY " ,
[ The_THEME_PURPLE ] = " HEAD_ROW_1_PURPLE " ,
[ The_THEME_BLUE ] = " HEAD_ROW_1_BLUE " ,
[ The_THEME_YELLOW ] = " HEAD_ROW_1_YELLOW " ,
[ The_THEME_PINK ] = " HEAD_ROW_1_PINK " ,
} ;
static const char * ClassHeadRow2 [ The_NUM_THEMES ] =
2015-12-01 22:31:01 +01:00
{
2019-11-21 16:47:07 +01:00
[ The_THEME_WHITE ] = " HEAD_ROW_2_WHITE " ,
[ The_THEME_GREY ] = " HEAD_ROW_2_GREY " ,
[ The_THEME_PURPLE ] = " HEAD_ROW_2_PURPLE " ,
[ The_THEME_BLUE ] = " HEAD_ROW_2_BLUE " ,
[ The_THEME_YELLOW ] = " HEAD_ROW_2_YELLOW " ,
[ The_THEME_PINK ] = " HEAD_ROW_2_PINK " ,
2015-12-01 22:31:01 +01:00
} ;
2016-12-18 19:50:33 +01:00
/***** Start header *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <header> " ) ;
2014-12-01 23:55:08 +01:00
2015-11-24 10:29:07 +01:00
/***** 1st. row *****/
2017-06-12 14:16:33 +02:00
/* Start 1st. row */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_1 \" class= \" %s \" " , ClassHeadRow1 [ Gbl . Prefs . Theme ] ) ;
2015-11-25 01:42:16 +01:00
2016-03-19 02:21:09 +01:00
/* 1st. row, 1st. column: logo, tagline and search */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_1_left \" " ) ;
2015-11-30 19:50:06 +01:00
2019-10-20 22:00:28 +02:00
/* Begin form to go to home page */
2021-03-02 00:54:26 +01:00
Frm_BeginFormGoTo ( ActMnu ) ;
2019-11-03 13:19:32 +01:00
Par_PutHiddenParamUnsigned ( NULL , " NxtTab " , ( unsigned ) TabSys ) ;
2016-03-22 01:26:00 +01:00
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_1_logo_small \" " ) ;
2019-11-18 14:21:01 +01:00
HTM_INPUT_IMAGE ( Cfg_URL_ICON_PUBLIC , Cfg_PLATFORM_LOGO_SMALL_FILENAME ,
Cfg_PLATFORM_SHORT_NAME , Cfg_PLATFORM_LOGO_SMALL_CLASS ) ;
2019-10-27 22:29:08 +01:00
HTM_DIV_End ( ) ; // head_row_1_logo_small
2019-11-01 17:35:26 +01:00
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_1_logo_big \" " ) ;
2019-11-18 14:21:01 +01:00
HTM_INPUT_IMAGE ( Cfg_URL_ICON_PUBLIC , Cfg_PLATFORM_LOGO_BIG_FILENAME ,
Cfg_PLATFORM_SHORT_NAME , Cfg_PLATFORM_LOGO_BIG_CLASS ) ;
2019-10-27 22:29:08 +01:00
HTM_DIV_End ( ) ; // head_row_1_logo_big
2019-11-01 17:35:26 +01:00
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_1_tagline \" " ) ;
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin ( Txt_TAGLINE , The_ClassTagline [ Gbl . Prefs . Theme ] , NULL ) ;
2019-11-10 12:36:37 +01:00
HTM_Txt ( Txt_TAGLINE_BR ) ;
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // head_row_1_tagline
2016-03-19 02:21:09 +01:00
2016-03-22 01:26:00 +01:00
/* End form to go to home page */
2018-11-09 20:47:39 +01:00
Frm_EndForm ( ) ;
2016-03-22 01:26:00 +01:00
2016-06-24 20:16:06 +02:00
Sch_PutFormToSearchInPageTopHeading ( ) ;
2015-11-30 19:50:06 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // head_row_1_left
2014-12-01 23:55:08 +01:00
2015-11-30 16:21:56 +01:00
/* 1st. row, 3rd. column: logged user or language selection,
and link to open / close session */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_1_right \" " ) ;
2014-12-01 23:55:08 +01:00
if ( Gbl . Usrs . Me . Logged )
Usr_WriteLoggedUsrHead ( ) ;
else
2017-05-07 18:06:34 +02:00
Lan_PutSelectorToSelectLanguage ( ) ;
2014-12-01 23:55:08 +01:00
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" login_box \" " ) ;
2014-12-01 23:55:08 +01:00
if ( Gbl . Usrs . Me . Logged )
Usr_PutFormLogOut ( ) ;
else
Usr_PutFormLogIn ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // login_box
2019-11-01 17:35:26 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // head_row_1_right
2015-11-25 01:42:16 +01:00
2017-06-12 14:16:33 +02:00
/* End 1st. row */
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // head_row_1
2014-12-01 23:55:08 +01:00
/***** 2nd. row *****/
2017-06-12 14:16:33 +02:00
/* Start second row */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_2 \" class= \" %s \" " , ClassHeadRow2 [ Gbl . Prefs . Theme ] ) ;
2015-11-25 01:42:16 +01:00
2015-11-24 10:29:07 +01:00
/* 2nd. row, 1st. column
Clock with hour : minute ( server hour is shown ) */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_2_time \" " ) ;
2015-11-24 10:29:07 +01:00
Dat_ShowClientLocalTime ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // End first column
2015-11-24 10:29:07 +01:00
/* 2nd. row, 2nd. column: degree and course */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" head_row_2_hierarchy \" " ) ;
2015-12-26 12:08:45 +01:00
Lay_WriteBreadcrumb ( ) ;
2016-11-14 16:47:46 +01:00
Hie_WriteBigNameCtyInsCtrDegCrs ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2015-11-24 10:29:07 +01:00
/* 2nd. row, 3rd. column */
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" msg \" " ) ; // Used for AJAX based refresh
2015-11-24 10:29:07 +01:00
if ( Gbl . Usrs . Me . Logged )
Ntf_WriteNumberOfNewNtfs ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ; // Used for AJAX based refresh
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/* End 2nd. row */
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2015-11-24 10:29:07 +01:00
2016-12-18 19:50:33 +01:00
/***** End header *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </header> " ) ;
2015-11-24 10:29:07 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2015-12-26 12:08:45 +01:00
/*********** Write breadcrumb with the path to the current location **********/
/*****************************************************************************/
static void Lay_WriteBreadcrumb ( void )
{
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <nav id= \" breadcrumb \" > " ) ;
2018-10-09 17:56:18 +02:00
Crs_PutIconToSelectMyCoursesInBreadcrumb ( ) ;
Hie_WriteHierarchyInBreadcrumb ( ) ;
Crs_WriteSelectorMyCoursesInBreadcrumb ( ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </nav> " ) ;
2015-12-26 12:08:45 +01:00
}
/*****************************************************************************/
2014-12-01 23:55:08 +01:00
/*********** Write icon and title associated to the current action ***********/
/*****************************************************************************/
static void Lay_WriteTitleAction ( void )
{
extern const char * The_ClassTitleAction [ The_NUM_THEMES ] ;
extern const char * The_ClassSubtitleAction [ The_NUM_THEMES ] ;
2016-12-28 17:22:25 +01:00
extern const char * Txt_TABS_TXT [ Tab_NUM_TABS ] ;
2014-12-01 23:55:08 +01:00
/***** Container start *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" action_title \" style= \" background-image:url('%s/%s'); \" " ,
Gbl . Prefs . URLIconSet ,
Act_GetIcon ( Act_GetSuperAction ( Gbl . Action . Act ) ) ) ;
2014-12-01 23:55:08 +01:00
/***** Title *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" %s \" " , The_ClassTitleAction [ Gbl . Prefs . Theme ] ) ;
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " %s > %s " , Txt_TABS_TXT [ Act_GetTab ( Gbl . Action . Act ) ] ,
Act_GetTitleAction ( Gbl . Action . Act ) ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
/***** Subtitle *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" %s \" " , The_ClassSubtitleAction [ Gbl . Prefs . Theme ] ) ;
2019-11-10 12:36:37 +01:00
HTM_Txt ( Act_GetSubtitleAction ( Gbl . Action . Act ) ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
/***** Container end *****/
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/***************************** Show left column ******************************/
/*****************************************************************************/
static void Lay_ShowLeftColumn ( void )
{
2016-06-03 13:42:28 +02:00
struct MFU_ListMFUActions ListMFUActions ;
2014-12-01 23:55:08 +01:00
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " style= \" width:160px; \" " ) ;
2014-12-01 23:55:08 +01:00
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" LEFT_RIGHT_CELL \" " ) ;
2014-12-01 23:55:08 +01:00
if ( Gbl . Usrs . Me . Logged )
{
2017-03-24 21:29:13 +01:00
/***** Most frequently used actions *****/
2016-06-03 13:42:28 +02:00
MFU_AllocateMFUActions ( & ListMFUActions , 6 ) ;
MFU_GetMFUActions ( & ListMFUActions , 6 ) ;
MFU_WriteSmallMFUActions ( & ListMFUActions ) ;
MFU_FreeMFUActions ( & ListMFUActions ) ;
2014-12-01 23:55:08 +01:00
}
2017-03-24 21:29:13 +01:00
else
/***** Institutional links *****/
Lnk_WriteMenuWithInstitutionalLinks ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
/***** Month *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" LEFT_RIGHT_CELL \" " ) ;
2015-01-04 14:43:03 +01:00
Cal_DrawCurrentMonth ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
/***** Notices (yellow notes) *****/
2021-02-11 22:57:09 +01:00
if ( Gbl . Hierarchy . Level = = Hie_Lvl_CRS )
2014-12-01 23:55:08 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" LEFT_RIGHT_CELL \" " ) ;
2019-03-24 23:17:32 +01:00
Not_ShowNotices ( Not_LIST_BRIEF_NOTICES ,
- 1L ) ; // No notice highlighted
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
}
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************************** Show right column ******************************/
/*****************************************************************************/
static void Lay_ShowRightColumn ( void )
{
extern const char * Txt_If_you_have_an_Android_device_try_SWADroid ;
2019-03-24 23:17:32 +01:00
// struct timeval tv1,tv2;
// long tv_usecs;
2014-12-01 23:55:08 +01:00
/***** Banners *****/
Ban_WriteMenuWithBanners ( ) ;
/***** Number of connected users in the whole platform *****/
2017-06-04 18:18:54 +02:00
if ( Gbl . Usrs . Me . Role . Logged = = Rol_SYS_ADM )
2017-02-01 19:56:46 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" globalconnected \" class= \" LEFT_RIGHT_CELL \" " ) ; // Used for AJAX based refresh
2017-02-01 19:56:46 +01:00
Con_ShowGlobalConnectedUsrs ( ) ;
2019-10-24 00:04:40 +02:00
HTM_DIV_End ( ) ; // Used for AJAX based refresh
2017-02-01 19:56:46 +01:00
}
2014-12-01 23:55:08 +01:00
/***** Number of connected users in the current course *****/
2021-02-11 22:57:09 +01:00
if ( Gbl . Hierarchy . Level = = Hie_Lvl_CRS ) // There is a course selected
2014-12-01 23:55:08 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " id= \" courseconnected \" class= \" LEFT_RIGHT_CELL \" " ) ; // Used for AJAX based refresh
2021-02-11 22:57:09 +01:00
Gbl . Scope . Current = Hie_Lvl_CRS ;
2016-03-15 22:15:25 +01:00
Con_ShowConnectedUsrsBelongingToCurrentCrs ( ) ;
2019-10-24 00:04:40 +02:00
HTM_DIV_End ( ) ; // Used for AJAX based refresh
2014-12-01 23:55:08 +01:00
}
2017-02-17 01:59:58 +01:00
else if ( Gbl . Usrs . Me . Logged ) // I am logged
2017-02-16 20:22:13 +01:00
{
2019-03-24 23:17:32 +01:00
/*
2019-03-24 19:35:48 +01:00
gettimeofday ( & tv1 , NULL ) ;
2019-03-24 23:17:32 +01:00
*/
2017-02-16 20:22:13 +01:00
/***** Suggest one user to follow *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" LEFT_RIGHT_CELL \" " ) ;
2017-02-16 20:22:13 +01:00
Fol_SuggestUsrsToFollowMainZoneOnRightColumn ( ) ;
2019-03-24 23:17:32 +01:00
/*
2019-03-24 19:35:48 +01:00
gettimeofday ( & tv2 , NULL ) ;
tv_usecs = ( tv2 . tv_sec - tv1 . tv_sec ) * 1E6 +
( tv2 . tv_usec - tv1 . tv_usec ) ;
DB_QueryINSERT ( " can not debug " ,
" INSERT INTO debug "
" (DebugTime,Txt) "
" VALUES "
" (NOW(),'Fol_SuggestUsrsToFollowMainZoneOnRightColumn: %ld us') " ,
tv_usecs ) ;
2019-03-24 23:17:32 +01:00
*/
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2017-02-16 20:22:13 +01:00
}
2014-12-01 23:55:08 +01:00
2017-03-24 21:29:13 +01:00
if ( ! Gbl . Usrs . Me . Logged )
2019-10-23 20:07:56 +02:00
{
2017-03-24 21:29:13 +01:00
/***** SWADroid advertisement *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" LEFT_RIGHT_CELL \" " ) ;
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid \" "
" target= \" _blank \" title= \" %s \" " ,
Txt_If_you_have_an_Android_device_try_SWADroid ) ;
2019-10-30 00:42:01 +01:00
HTM_IMG ( Cfg_URL_ICON_PUBLIC , " SWADroid120x200.png " , " SWADroid " ,
2019-10-30 22:31:03 +01:00
" style= \" width:150px; height:250px; \" " ) ;
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
}
2014-12-01 23:55:08 +01:00
}
2015-12-13 18:32:37 +01:00
/*****************************************************************************/
2016-11-22 10:44:58 +01:00
/**************** Show an icon with a link in contextual menu ****************/
2015-12-13 18:32:37 +01:00
/*****************************************************************************/
2019-01-12 03:00:59 +01:00
void Lay_PutContextualLinkOnlyIcon ( Act_Action_t NextAction , const char * Anchor ,
2020-03-26 02:54:30 +01:00
void ( * FuncParams ) ( void * Args ) , void * Args ,
2019-01-12 03:00:59 +01:00
const char * Icon ,
const char * Title )
{
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2019-01-12 03:00:59 +01:00
Frm_StartFormAnchor ( NextAction , Anchor ) ;
if ( FuncParams )
2020-03-26 02:54:30 +01:00
FuncParams ( Args ) ;
2019-01-12 03:00:59 +01:00
/***** Put icon with link *****/
Ico_PutIconLink ( Icon , Title ) ;
/***** End form *****/
Frm_EndForm ( ) ;
}
/*****************************************************************************/
/**************** Show an icon with a link in contextual menu ****************/
/*****************************************************************************/
void Lay_PutContextualLinkIconText ( Act_Action_t NextAction , const char * Anchor ,
2020-03-26 02:54:30 +01:00
void ( * FuncParams ) ( void * Args ) , void * Args ,
2019-01-12 03:00:59 +01:00
const char * Icon ,
const char * Text )
{
2019-11-18 14:21:01 +01:00
extern const char * The_ClassFormLinkOutBoxBold [ The_NUM_THEMES ] ;
2019-01-12 03:00:59 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " " ) ; // This space is necessary to enable
// jumping to the next line on narrow screens
2019-01-12 03:00:59 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2019-01-12 03:00:59 +01:00
Frm_StartFormAnchor ( NextAction , Anchor ) ;
if ( FuncParams )
2020-03-26 02:54:30 +01:00
FuncParams ( Args ) ;
2019-01-12 03:00:59 +01:00
/***** Put icon and text with link *****/
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin ( Text , The_ClassFormLinkOutBoxBold [ Gbl . Prefs . Theme ] , NULL ) ;
2019-01-12 19:46:33 +01:00
Ico_PutIconTextLink ( Icon , Text ) ;
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ( ) ;
2019-01-12 03:00:59 +01:00
/***** End form *****/
Frm_EndForm ( ) ;
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " " ) ; // This space is necessary to enable
// jumping to the next line on narrow screens
2019-01-12 03:00:59 +01:00
}
/*****************************************************************************/
/**************** Show an icon with a link in contextual menu ****************/
/*****************************************************************************/
void Lay_PutContextualLinkIconTextOnSubmit ( Act_Action_t NextAction , const char * Anchor ,
2020-04-11 15:21:30 +02:00
void ( * FuncParams ) ( const void * Args ) , const void * Args ,
2019-04-11 14:45:31 +02:00
const char * Icon ,
const char * Text ,
const char * OnSubmit )
2015-12-13 18:32:37 +01:00
{
2019-11-18 14:21:01 +01:00
extern const char * The_ClassFormLinkOutBoxBold [ The_NUM_THEMES ] ;
2015-12-13 18:32:37 +01:00
2016-11-22 10:44:58 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " " ) ; // This space is necessary to enable
// jumping to the next line on narrow screens
2015-12-13 20:24:39 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor ( NextAction , Anchor ) ;
2015-12-13 18:32:37 +01:00
if ( FuncParams )
2020-04-11 15:21:30 +02:00
FuncParams ( Args ) ;
2016-11-22 10:44:58 +01:00
/***** Put icon with link *****/
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin ( Text , The_ClassFormLinkOutBoxBold [ Gbl . Prefs . Theme ] , OnSubmit ) ;
2019-01-12 19:46:33 +01:00
Ico_PutIconTextLink ( Icon , Text ) ;
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ( ) ;
2016-11-22 10:44:58 +01:00
/***** End form *****/
2018-11-09 20:47:39 +01:00
Frm_EndForm ( ) ;
2016-11-22 10:44:58 +01:00
/***** Separator *****/
2019-11-11 10:59:24 +01:00
HTM_Txt ( " " ) ; // This space is necessary to enable
2019-11-11 00:15:44 +01:00
// jumping to the next line on narrow screens
2016-11-22 10:44:58 +01:00
}
/*****************************************************************************/
/******************** Show a checkbox in contextual menu *********************/
/*****************************************************************************/
void Lay_PutContextualCheckbox ( Act_Action_t NextAction ,
2019-04-11 14:45:31 +02:00
void ( * FuncParams ) ( void ) ,
2017-05-22 12:23:08 +02:00
const char * CheckboxName ,
bool Checked , bool Disabled ,
2016-11-22 10:44:58 +01:00
const char * Title , const char * Text )
{
2019-02-22 21:47:50 +01:00
extern const char * The_ClassFormOutBoxBold [ The_NUM_THEMES ] ;
2016-11-22 10:44:58 +01:00
/***** Separator *****/
if ( Text )
2019-11-11 00:15:44 +01:00
HTM_Txt ( " " ) ; // This space is necessary to enable
// jumping to the next line on narrow screens
2016-11-22 10:44:58 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2021-03-02 00:54:26 +01:00
Frm_BeginForm ( NextAction ) ;
2016-11-22 12:07:29 +01:00
if ( FuncParams )
FuncParams ( ) ;
2016-11-22 10:44:58 +01:00
2021-03-02 00:54:26 +01:00
/***** Begin container and label *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" CONTEXT_OPT %s %s \" title= \" %s \" " ,
Checked ? " CHECKBOX_CHECKED " :
" CHECKBOX_UNCHECKED " ,
The_ClassFormOutBoxBold [ Gbl . Prefs . Theme ] ,
Title ) ;
2019-11-03 10:41:31 +01:00
HTM_LABEL_Begin ( NULL ) ;
2016-11-22 10:44:58 +01:00
2019-11-03 11:20:14 +01:00
/****** Checkbox *****/
2020-03-12 13:53:37 +01:00
HTM_INPUT_CHECKBOX ( CheckboxName , HTM_SUBMIT_ON_CHANGE ,
2019-11-04 20:41:35 +01:00
" value= \" Y \" %s%s " ,
2020-03-12 13:53:37 +01:00
Checked ? " checked= \" checked \" " :
" " ,
Disabled ? " disabled= \" disabled \" " :
" " ) ;
2019-11-03 11:20:14 +01:00
/***** Text *****/
2016-11-22 10:44:58 +01:00
if ( Text )
if ( Text [ 0 ] )
2019-11-11 10:59:24 +01:00
HTM_TxtF ( " %s " , Text ) ;
2016-11-22 10:44:58 +01:00
2016-12-20 10:03:00 +01:00
/***** End label and container *****/
2019-11-02 12:59:31 +01:00
HTM_LABEL_End ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2016-11-22 10:44:58 +01:00
/***** End form *****/
2018-11-09 20:47:39 +01:00
Frm_EndForm ( ) ;
2015-12-13 22:45:57 +01:00
2016-11-22 10:44:58 +01:00
/***** Separator *****/
2015-12-13 22:45:57 +01:00
if ( Text )
2019-11-11 00:15:44 +01:00
HTM_Txt ( " " ) ; // This space is necessary to enable
// jumping to the next line on narrow screens
2015-12-13 18:32:37 +01:00
}
2019-03-24 23:17:32 +01:00
2018-10-18 20:06:54 +02:00
/*****************************************************************************/
/********** Write error message and exit when not enough memory **************/
/*****************************************************************************/
void Lay_NotEnoughMemoryExit ( void )
{
2018-10-24 23:03:11 +02:00
Lay_ShowErrorAndExit ( " Not enough memory. " ) ;
}
/*****************************************************************************/
/************* Write error message and exit when wrong scope *****************/
/*****************************************************************************/
void Lay_WrongScopeExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
2018-10-18 20:06:54 +02:00
}
2020-01-07 22:07:06 +01:00
/*****************************************************************************/
/************* Write error message and exit when wrong order *****************/
/*****************************************************************************/
void Lay_WrongOrderExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong order. " ) ;
}
2020-04-08 03:06:45 +02:00
/*****************************************************************************/
/************* Write error message and exit when wrong order *****************/
/*****************************************************************************/
void Lay_WrongTypeOfViewExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong type of view. " ) ;
}
2020-05-09 18:18:04 +02:00
/*****************************************************************************/
/************* Write error message and exit when wrong project ***************/
/*****************************************************************************/
void Lay_WrongProjectExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong project. " ) ;
}
2020-04-25 01:36:53 +02:00
/*****************************************************************************/
/************** Write error message and exit when wrong exam *****************/
/*****************************************************************************/
void Lay_WrongExamExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong exam. " ) ;
}
2020-04-26 01:54:27 +02:00
/*****************************************************************************/
/********* Write error message and exit when wrong set of questions **********/
/*****************************************************************************/
void Lay_WrongSetExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong set of questions. " ) ;
}
2020-04-25 01:36:53 +02:00
/*****************************************************************************/
2020-05-17 02:28:30 +02:00
/*********** Write error message and exit when wrong exam session ************/
2020-04-25 01:36:53 +02:00
/*****************************************************************************/
2020-05-17 02:28:30 +02:00
void Lay_WrongExamSessionExit ( void )
2020-04-25 01:36:53 +02:00
{
2020-05-17 02:28:30 +02:00
Lay_ShowErrorAndExit ( " Wrong exam session. " ) ;
2020-04-25 01:36:53 +02:00
}
2021-02-08 20:38:12 +01:00
/*****************************************************************************/
/*** Write error message and exit when wrong parameter "who" (which users) ***/
/*****************************************************************************/
void Lay_WrongWhoExit ( void )
{
Lay_ShowErrorAndExit ( " Wrong parameter who. " ) ;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******* Write error message, close files, remove lock file, and exit ********/
/*****************************************************************************/
2017-05-10 10:25:01 +02:00
void Lay_ShowErrorAndExit ( const char * Txt )
2014-12-01 23:55:08 +01:00
{
/***** Unlock tables if locked *****/
if ( Gbl . DB . LockedTables )
{
Gbl . DB . LockedTables = false ;
mysql_query ( & Gbl . mysql , " UNLOCK TABLES " ) ;
}
if ( ! Gbl . WebService . IsWebService )
{
2017-04-27 15:02:00 +02:00
/****** If start of page is not written yet, do it now ******/
if ( ! Gbl . Layout . HTMLStartWritten )
Lay_WriteStartOfPage ( ) ;
2014-12-01 23:55:08 +01:00
/***** Write possible error message *****/
2017-05-10 10:25:01 +02:00
if ( Txt )
2019-02-16 17:20:05 +01:00
Ale_ShowAlert ( Ale_ERROR , Txt ) ;
2014-12-01 23:55:08 +01:00
/***** Finish the page, except </body> and </html> *****/
Lay_WriteEndOfPage ( ) ;
}
/***** Free memory and close all the open files *****/
Gbl_Cleanup ( ) ;
2015-12-02 00:32:46 +01:00
/***** Page is generated (except </body> and </html>).
Compute time to generate page * * * * */
2017-02-05 22:23:41 +01:00
if ( ! Gbl . Action . IsAJAXAutoRefresh )
2019-12-17 00:36:22 +01:00
Gbl . TimeGenerationInMicroseconds = ( long ) Sta_ComputeTimeToGeneratePage ( ) ;
2014-12-01 23:55:08 +01:00
if ( Gbl . WebService . IsWebService ) // Serving a plugin request
{
/***** Log access *****/
Gbl . TimeSendInMicroseconds = 0L ;
2019-12-14 14:30:34 +01:00
Log_LogAccess ( Txt ) ;
2014-12-01 23:55:08 +01:00
}
2015-12-02 00:32:46 +01:00
else
2014-12-01 23:55:08 +01:00
{
2015-12-02 00:32:46 +01:00
/***** Send page.
The HTML output is now in Gbl . F . Out file = = >
= = > copy it to standard output * * * * */
rewind ( Gbl . F . Out ) ;
Fil_FastCopyOfOpenFiles ( Gbl . F . Out , stdout ) ;
Fil_CloseAndRemoveFileForHTMLOutput ( ) ;
2014-12-01 23:55:08 +01:00
2017-02-05 22:23:41 +01:00
if ( ! Gbl . Action . IsAJAXAutoRefresh )
2015-12-02 00:32:46 +01:00
{
/***** Compute time to send page *****/
Sta_ComputeTimeToSendPage ( ) ;
/***** Log access *****/
2019-12-14 14:30:34 +01:00
Log_LogAccess ( Txt ) ;
2015-12-02 00:32:46 +01:00
2019-04-01 13:15:15 +02:00
/***** Update last data for next time *****/
if ( Gbl . Usrs . Me . Logged )
{
Usr_UpdateMyLastData ( ) ;
Crs_UpdateCrsLast ( ) ;
}
2015-12-02 00:32:46 +01:00
/***** End the output *****/
if ( ! Gbl . Layout . HTMLEndWritten )
{
// Here Gbl.F.Out is stdout
2018-04-24 13:21:53 +02:00
if ( Act_GetBrowserTab ( Gbl . Action . Act ) = = Act_BRW_1ST_TAB )
2015-12-02 11:33:47 +01:00
Lay_WriteAboutZone ( ) ;
2015-12-02 00:32:46 +01:00
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </body> \n "
" </html> \n " ) ;
2015-12-02 00:32:46 +01:00
Gbl . Layout . HTMLEndWritten = true ;
}
}
2014-12-01 23:55:08 +01:00
}
/***** Close database connection *****/
DB_CloseDBConnection ( ) ;
/***** Exit *****/
if ( Gbl . WebService . IsWebService )
2019-05-16 14:02:06 +02:00
API_Exit ( Txt ) ;
2014-12-01 23:55:08 +01:00
exit ( 0 ) ;
}
2015-12-02 00:32:46 +01:00
/*****************************************************************************/
/***************** Write about zone at the end of the page *******************/
/*****************************************************************************/
static void Lay_WriteAboutZone ( void )
{
extern const char * Txt_About_X ;
extern const char * Txt_Questions_and_problems ;
2019-11-11 13:11:38 +01:00
unsigned i ;
2015-12-02 00:32:46 +01:00
2016-12-18 19:50:33 +01:00
/***** Start about zone *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <address id= \" about_zone \" class= \" ABOUT \" > " ) ;
2015-12-02 00:32:46 +01:00
2021-03-07 21:21:04 +01:00
/***** Institution and center hosting the platform *****/
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" %s \" class= \" ABOUT \" target= \" _blank \" " , Cfg_ABOUT_URL ) ;
2019-10-30 09:12:12 +01:00
HTM_IMG ( Cfg_URL_ICON_PUBLIC , Cfg_ABOUT_LOGO , Cfg_ABOUT_NAME ,
2019-10-30 22:31:03 +01:00
" style= \" width:%upx; height:%upx; \" " ,
Cfg_ABOUT_LOGO_WIDTH , Cfg_ABOUT_LOGO_HEIGHT ) ;
2019-10-24 23:03:19 +02:00
HTM_DIV_Begin ( NULL ) ;
2019-11-10 12:36:37 +01:00
HTM_Txt ( Cfg_ABOUT_NAME ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2015-12-02 00:32:46 +01:00
/***** Questions and problems *****/
2019-10-24 23:03:19 +02:00
HTM_DIV_Begin ( NULL ) ;
2020-01-11 15:22:02 +01:00
HTM_TxtColonNBSP ( Txt_Questions_and_problems ) ;
2019-10-30 00:42:01 +01:00
HTM_A_Begin ( " href= \" mailto:%s \" class= \" ABOUT \" target= \" _blank \" " ,
Cfg_PLATFORM_RESPONSIBLE_EMAIL ) ;
2019-11-10 12:36:37 +01:00
HTM_Txt ( Cfg_PLATFORM_RESPONSIBLE_EMAIL ) ;
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2015-12-02 00:32:46 +01:00
/***** About and time to generate and send page *****/
2019-10-24 23:03:19 +02:00
HTM_DIV_Begin ( NULL ) ;
2015-12-02 00:32:46 +01:00
/* About */
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" %s \" class= \" ABOUT \" target= \" _blank \" " , Cfg_ABOUT_SWAD_URL ) ;
2019-11-11 00:15:44 +01:00
HTM_TxtF ( Txt_About_X , Log_PLATFORM_VERSION ) ;
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2019-11-11 13:11:38 +01:00
for ( i = 0 ;
2019-11-11 00:15:44 +01:00
i < 5 ;
i + + )
2019-11-14 08:59:11 +01:00
HTM_NBSP ( ) ;
2015-12-02 00:32:46 +01:00
/* Time to generate and send page */
Sta_WriteTimeToGenerateAndSendPage ( ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2015-12-02 00:32:46 +01:00
2016-12-18 19:50:33 +01:00
/***** End about zone *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </address> " ) ; // about_zone
2015-12-02 00:32:46 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*********** Refresh notifications and connected users via AJAX **************/
/*****************************************************************************/
void Lay_RefreshNotifsAndConnected ( void )
{
unsigned NumUsr ;
2015-11-27 12:57:56 +01:00
bool ShowConnected = ( Gbl . Prefs . SideCols & Lay_SHOW_RIGHT_COLUMN ) & &
2021-02-11 22:57:09 +01:00
Gbl . Hierarchy . Level = = Hie_Lvl_CRS ; // Right column visible && There is a course selected
2014-12-01 23:55:08 +01:00
2019-02-13 13:32:11 +01:00
/***** Sometimes, someone must do this work,
so who best than processes that refresh via AJAX ? * * * * */
2019-03-20 01:36:36 +01:00
// We use (PID % prime-number) to do only one action as much
if ( ! ( Gbl . PID % 11 ) )
2016-11-16 23:19:52 +01:00
Ntf_SendPendingNotifByEMailToAllUsrs ( ) ; // Send pending notifications by email
2019-03-20 01:36:36 +01:00
else if ( ! ( Gbl . PID % 19 ) )
FW_PurgeFirewall ( ) ; // Remove old clicks from firewall
2019-03-20 13:05:09 +01:00
else if ( ! ( Gbl . PID % 23 ) )
Fil_RemoveOldTmpFiles ( Cfg_PATH_FILE_BROWSER_TMP_PUBLIC , Cfg_TIME_TO_DELETE_BROWSER_TMP_FILES , false ) ; // Remove the oldest temporary public directories used for downloading
2019-03-20 01:36:36 +01:00
else if ( ! ( Gbl . PID % 101 ) )
2014-12-01 23:55:08 +01:00
Brw_RemoveExpiredExpandedFolders ( ) ; // Remove old expanded folders (from all users)
2019-03-20 01:36:36 +01:00
else if ( ! ( Gbl . PID % 103 ) )
2019-03-26 11:53:21 +01:00
Set_RemoveOldSettingsFromIP ( ) ; // Remove old settings from IP
2019-03-20 01:36:36 +01:00
else if ( ! ( Gbl . PID % 107 ) )
2019-12-14 14:30:34 +01:00
Log_RemoveOldEntriesRecentLog ( ) ; // Remove old entries in recent log table, it's a slow query
2019-03-20 01:36:36 +01:00
else if ( ! ( Gbl . PID % 109 ) )
Fil_RemoveOldTmpFiles ( Cfg_PATH_OUT_PRIVATE , Cfg_TIME_TO_DELETE_HTML_OUTPUT , false ) ;
else if ( ! ( Gbl . PID % 113 ) )
Fil_RemoveOldTmpFiles ( Cfg_PATH_PHOTO_TMP_PUBLIC , Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES , false ) ;
2019-03-20 13:05:09 +01:00
else if ( ! ( Gbl . PID % 127 ) )
2019-03-20 01:36:36 +01:00
Fil_RemoveOldTmpFiles ( Cfg_PATH_PHOTO_TMP_PRIVATE , Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES , false ) ;
2019-03-20 13:05:09 +01:00
else if ( ! ( Gbl . PID % 131 ) )
2019-03-20 01:36:36 +01:00
Fil_RemoveOldTmpFiles ( Cfg_PATH_MEDIA_TMP_PRIVATE , Cfg_TIME_TO_DELETE_MEDIA_TMP_FILES , false ) ;
2019-03-20 13:05:09 +01:00
else if ( ! ( Gbl . PID % 137 ) )
2019-03-20 01:36:36 +01:00
Fil_RemoveOldTmpFiles ( Cfg_PATH_ZIP_PRIVATE , Cfg_TIME_TO_DELETE_BROWSER_ZIP_FILES , false ) ;
2019-03-20 13:05:09 +01:00
else if ( ! ( Gbl . PID % 139 ) )
2019-03-20 01:36:36 +01:00
Fil_RemoveOldTmpFiles ( Cfg_PATH_MARK_PRIVATE , Cfg_TIME_TO_DELETE_MARKS_TMP_FILES , false ) ;
2019-03-20 13:05:09 +01:00
else if ( ! ( Gbl . PID % 149 ) )
2019-03-20 01:36:36 +01:00
Fil_RemoveOldTmpFiles ( Cfg_PATH_TEST_PRIVATE , Cfg_TIME_TO_DELETE_TEST_TMP_FILES , false ) ;
2014-12-01 23:55:08 +01:00
2019-02-13 13:32:11 +01:00
/***** Send, before the HTML, the refresh time *****/
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " %lu| " , Gbl . Usrs . Connected . TimeToRefreshInMs ) ;
2014-12-01 23:55:08 +01:00
if ( Gbl . Usrs . Me . Logged )
Ntf_WriteNumberOfNewNtfs ( ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " | " ) ;
2014-12-01 23:55:08 +01:00
Con_ShowGlobalConnectedUsrs ( ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " | " ) ;
2014-12-01 23:55:08 +01:00
if ( ShowConnected )
{
2021-02-11 22:57:09 +01:00
Gbl . Scope . Current = Hie_Lvl_CRS ;
2016-03-15 22:15:25 +01:00
Con_ShowConnectedUsrsBelongingToCurrentCrs ( ) ;
2014-12-01 23:55:08 +01:00
}
2019-11-11 00:15:44 +01:00
HTM_Txt ( " | " ) ;
2014-12-01 23:55:08 +01:00
if ( ShowConnected )
2019-11-10 13:31:47 +01:00
HTM_Unsigned ( Gbl . Usrs . Connected . NumUsrsToList ) ;
2019-11-11 00:15:44 +01:00
HTM_Txt ( " | " ) ;
2014-12-01 23:55:08 +01:00
if ( ShowConnected )
for ( NumUsr = 0 ;
NumUsr < Gbl . Usrs . Connected . NumUsrsToList ;
NumUsr + + )
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " %ld| " , Gbl . Usrs . Connected . Lst [ NumUsr ] . TimeDiff ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-01-09 15:00:14 +01:00
/**************** Refresh last clicks in realtime via AJAX *******************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Lay_RefreshLastClicks ( void )
{
2017-02-06 01:23:33 +01:00
if ( Gbl . Session . IsOpen ) // If session has been closed, do not write anything
{
/***** Send, before the HTML, the refresh time *****/
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " %lu| " , Cfg_TIME_TO_REFRESH_LAST_CLICKS ) ;
2017-02-06 01:23:33 +01:00
/***** Get and show last clicks *****/
2019-12-14 14:30:34 +01:00
Log_GetAndShowLastClicks ( ) ;
2017-02-06 01:23:33 +01:00
}
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************ Write the end of the page **************************/
/*****************************************************************************/
static void Lay_WriteFootFromHTMLFile ( void )
{
FILE * FileHTML ;
/***** Open file with the HTML page for the chat *****/
if ( ( FileHTML = fopen ( Cfg_PATH_AND_FILE_REL_HTML_PRIVATE , " rb " ) ) )
{
2019-11-11 00:15:44 +01:00
HTM_Txt ( " <footer id= \" foot_zone \" > " ) ;
2015-12-02 00:32:46 +01:00
2014-12-01 23:55:08 +01:00
/***** Copy HTML to output file *****/
Fil_FastCopyOfOpenFiles ( FileHTML , Gbl . F . Out ) ;
fclose ( FileHTML ) ;
2015-12-02 00:32:46 +01:00
2019-11-11 00:15:44 +01:00
HTM_Txt ( " </footer> " ) ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/****** Write header and footer of the class photo or academic calendar ******/
/*****************************************************************************/
2016-03-18 22:17:35 +01:00
void Lay_WriteHeaderClassPhoto ( bool PrintView , bool DrawingClassPhoto ,
2014-12-01 23:55:08 +01:00
long InsCod , long DegCod , long CrsCod )
{
2021-02-11 23:27:48 +01:00
struct Hie_Hierarchy Hie ;
2014-12-01 23:55:08 +01:00
/***** Get data of institution *****/
2021-02-11 23:27:48 +01:00
Hie . Ins . InsCod = InsCod ;
Ins_GetDataOfInstitutionByCod ( & Hie . Ins ) ;
2014-12-01 23:55:08 +01:00
/***** Get data of degree *****/
2021-02-11 23:27:48 +01:00
Hie . Deg . DegCod = DegCod ;
Deg_GetDataOfDegreeByCod ( & Hie . Deg ) ;
2014-12-01 23:55:08 +01:00
/***** Get data of course *****/
2021-02-11 23:27:48 +01:00
Hie . Crs . CrsCod = CrsCod ;
Crs_GetDataOfCourseByCod ( & Hie . Crs ) ;
2014-12-01 23:55:08 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_BeginWidePadding ( 10 ) ;
HTM_TR_Begin ( NULL ) ;
2014-12-01 23:55:08 +01:00
/***** First column: institution logo *****/
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ( " class= \" LT \" style= \" width:60px; \" " ) ;
2014-12-01 23:55:08 +01:00
if ( InsCod > 0 )
{
if ( ! PrintView )
2021-02-11 23:27:48 +01:00
HTM_A_Begin ( " href= \" %s \" target= \" _blank \" " , Hie . Ins . WWW ) ;
Lgo_DrawLogo ( Hie_Lvl_INS , Hie . Ins . InsCod , Hie . Ins . ShrtName , 40 , NULL , true ) ;
2014-12-01 23:55:08 +01:00
if ( ! PrintView )
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2014-12-01 23:55:08 +01:00
}
2019-10-23 19:05:05 +02:00
HTM_TD_End ( ) ;
2014-12-01 23:55:08 +01:00
/***** Second column: class photo title *****/
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ( " class= \" CLASSPHOTO_TITLE CM \" " ) ;
2014-12-01 23:55:08 +01:00
if ( InsCod > 0 )
{
if ( ! PrintView )
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" %s \" target= \" _blank \" class= \" CLASSPHOTO_TITLE \" " ,
2021-02-11 23:27:48 +01:00
Hie . Ins . WWW ) ;
HTM_Txt ( Hie . Ins . FullName ) ;
2014-12-01 23:55:08 +01:00
if ( ! PrintView )
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2014-12-01 23:55:08 +01:00
}
if ( DegCod > 0 )
{
2021-02-11 23:27:48 +01:00
if ( Hie . Ins . InsCod > 0 )
2019-11-11 00:15:44 +01:00
HTM_Txt ( " - " ) ;
2014-12-01 23:55:08 +01:00
if ( ! PrintView )
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" %s \" target= \" _blank \" class= \" CLASSPHOTO_TITLE \" " ,
2021-02-11 23:27:48 +01:00
Hie . Deg . WWW ) ;
HTM_Txt ( Hie . Deg . FullName ) ;
2014-12-01 23:55:08 +01:00
if ( ! PrintView )
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2014-12-01 23:55:08 +01:00
}
2019-11-09 21:08:20 +01:00
HTM_BR ( ) ;
2014-12-01 23:55:08 +01:00
if ( CrsCod > 0 )
{
2021-02-11 23:27:48 +01:00
HTM_Txt ( Hie . Crs . FullName ) ;
2014-12-01 23:55:08 +01:00
if ( DrawingClassPhoto & & ! Gbl . Usrs . ClassPhoto . AllGroups )
{
2019-11-09 21:08:20 +01:00
HTM_BR ( ) ;
2014-12-01 23:55:08 +01:00
Grp_WriteNamesOfSelectedGrps ( ) ;
}
}
2019-10-23 19:05:05 +02:00
HTM_TD_End ( ) ;
2014-12-01 23:55:08 +01:00
/***** Third column: degree logo *****/
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ( " class= \" RT \" style= \" width:60px; \" " ) ;
2014-12-01 23:55:08 +01:00
if ( DegCod > 0 )
{
if ( ! PrintView )
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" %s \" target= \" _blank \" class= \" CLASSPHOTO_TITLE \" " ,
2021-02-11 23:27:48 +01:00
Hie . Deg . WWW ) ;
Lgo_DrawLogo ( Hie_Lvl_DEG , Hie . Deg . DegCod , Hie . Deg . ShrtName , 40 , NULL , true ) ;
2014-12-01 23:55:08 +01:00
if ( ! PrintView )
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2014-12-01 23:55:08 +01:00
}
2019-10-23 19:05:05 +02:00
HTM_TD_End ( ) ;
2014-12-01 23:55:08 +01:00
2016-03-20 13:47:46 +01:00
/***** End table *****/
2019-10-23 19:05:05 +02:00
HTM_TR_End ( ) ;
HTM_TABLE_End ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Show advertisement about mobile version ********************/
/*****************************************************************************/
2015-03-27 16:56:48 +01:00
# define Lay_SHOW_ADVERTISEMENT_ONE_TIME_OF_X 5 // n ==> show advertisement 1/n of the times
2014-12-01 23:55:08 +01:00
void Lay_AdvertisementMobile ( void )
{
extern const char * Txt_Stay_connected_with_SWADroid ;
if ( ! ( rand ( ) % Lay_SHOW_ADVERTISEMENT_ONE_TIME_OF_X ) )
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " style= \" margin-top:25px; \" " ) ;
2015-03-27 16:56:48 +01:00
2019-10-26 02:19:42 +02:00
/***** Begin box and table *****/
2020-03-26 02:54:30 +01:00
Box_BoxTableBegin ( NULL , NULL ,
NULL , NULL ,
2017-06-12 15:03:29 +02:00
NULL , Box_NOT_CLOSABLE , 8 ) ;
2014-12-01 23:55:08 +01:00
/***** Show advertisement *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin ( NULL ) ;
HTM_TD_Begin ( " class= \" DAT CM \" " ) ;
2019-10-28 20:38:29 +01:00
HTM_A_Begin ( " href= \" https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid \" "
" class= \" DAT \" " ) ;
2019-11-10 12:36:37 +01:00
HTM_Txt ( Txt_Stay_connected_with_SWADroid ) ;
2019-11-09 21:08:20 +01:00
HTM_BR ( ) ;
HTM_BR ( ) ;
2019-10-30 00:42:01 +01:00
HTM_IMG ( Cfg_URL_ICON_PUBLIC , " SWADroid200x300.png " , Txt_Stay_connected_with_SWADroid ,
2019-10-30 22:31:03 +01:00
" style= \" width:250px; height:375px; \" " ) ;
2019-10-28 13:56:04 +01:00
HTM_A_End ( ) ;
2019-10-23 19:05:05 +02:00
HTM_TD_End ( ) ;
HTM_TR_End ( ) ;
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2019-11-25 23:18:08 +01:00
Box_BoxTableEnd ( ) ;
2015-03-27 16:56:48 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2014-12-01 23:55:08 +01:00
}
}
2014-12-29 13:26:39 +01:00
/*****************************************************************************/
/*********************** Indent forum or chat title **************************/
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
// IsLastItemInLevel[] is a vector with at least 1 + Level booleans
2014-12-29 13:26:39 +01:00
void Lay_IndentDependingOnLevel ( unsigned Level , bool IsLastItemInLevel [ ] )
{
unsigned i ;
/***** Indent (from 1 to Level-1) *****/
for ( i = 1 ;
i < Level ;
i + + )
2019-10-29 21:41:54 +01:00
Ico_PutIcon ( IsLastItemInLevel [ i ] ? " tr20x20.gif " :
" subleft20x20.gif " ,
" " , " ICO25x25 " ) ;
2014-12-29 13:26:39 +01:00
/***** Level *****/
2017-04-13 23:53:57 +02:00
if ( Level )
2019-10-29 21:41:54 +01:00
Ico_PutIcon ( IsLastItemInLevel [ Level ] ? " subend20x20.gif " :
" submid20x20.gif " ,
" " , " ICO25x25 " ) ;
2014-12-29 13:26:39 +01:00
}
2016-10-03 22:41:45 +02:00
2015-04-11 02:04:23 +02:00
/*****************************************************************************/
/************************** Help for the text editor *************************/
/*****************************************************************************/
void Lay_HelpPlainEditor ( void )
{
extern const char * Txt_TEXT_plain ;
Lay_HelpTextEditor ( Txt_TEXT_plain ,
" \\ (LaTeX \\ ) " ,
2016-01-20 14:07:15 +01:00
" $$LaTeX$$ \\ [LaTeX \\ ] " ) ;
2015-04-11 02:04:23 +02:00
}
void Lay_HelpRichEditor ( void )
{
Lay_HelpTextEditor ( " <a href= \" http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown \" "
2016-01-17 21:46:01 +01:00
" target= \" _blank \" >Markdown+Pandoc</a> " ,
2015-04-11 02:04:23 +02:00
" $LaTeX$ " ,
" $$LaTeX$$ " ) ;
}
static void Lay_HelpTextEditor ( const char * Text , const char * InlineMath , const char * Equation )
{
extern const char * Txt_Text ;
extern const char * Txt_Inline_math ;
extern const char * Txt_Equation_centered ;
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ( " class= \" HELP_EDIT \" " ) ;
2019-11-11 00:15:44 +01:00
HTM_TxtF ( " %s: %s "
" "
" %s: <code>%s</code> "
" "
" %s: <code>%s</code> " ,
Txt_Text , Text ,
Txt_Inline_math , InlineMath ,
Txt_Equation_centered , Equation ) ;
2019-10-23 20:07:56 +02:00
HTM_DIV_End ( ) ;
2015-04-11 02:04:23 +02:00
}
2016-10-03 22:41:45 +02:00
/*****************************************************************************/
/************************** Help for the text editor *************************/
/*****************************************************************************/
void Lay_StartHTMLFile ( FILE * File , const char * Title )
{
2018-12-08 16:43:13 +01:00
extern const char * Lan_STR_LANG_ID [ 1 + Lan_NUM_LANGUAGES ] ;
2016-10-03 22:41:45 +02:00
fprintf ( File , " <!DOCTYPE html> \n "
" <html lang= \" %s \" > \n "
" <head> \n "
" <meta http-equiv= \" Content-Type \" "
" content= \" text/html;charset=windows-1252 \" /> \n "
" <title>%s</title> \n "
2016-10-04 01:16:52 +02:00
" </head> \n " ,
2018-12-08 16:43:13 +01:00
Lan_STR_LANG_ID [ Gbl . Prefs . Language ] , // Language
2016-10-03 22:41:45 +02:00
Title ) ; // Page title
}