// 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.
Copyright (C) 1999-2019 Antonio Caņas Vargas
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 .
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include // For NULL
#include // For exit, system, malloc, calloc, free, etc
#include // For string functions
#include "swad_action.h"
#include "swad_API.h"
#include "swad_box.h"
#include "swad_calendar.h"
#include "swad_changelog.h"
#include "swad_config.h"
#include "swad_connected.h"
#include "swad_database.h"
#include "swad_exam.h"
#include "swad_firewall.h"
#include "swad_follow.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_help.h"
#include "swad_hierarchy.h"
#include "swad_language.h"
#include "swad_logo.h"
#include "swad_MFU.h"
#include "swad_notice.h"
#include "swad_notification.h"
#include "swad_parameter.h"
#include "swad_setting.h"
#include "swad_tab.h"
#include "swad_table.h"
#include "swad_theme.h"
#include "swad_timeline.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Lay_WriteEndOfPage (void);
static void Lay_WritePageTitle (void);
static void Lay_WriteRedirToMyLangOnLogIn (void);
static void Lay_WriteRedirToMyLangOnViewUsrAgd (void);
static void Lay_WriteScripts (void);
static void Lay_WriteScriptMathJax (void);
static void Lay_WriteScriptInit (void);
static void Lay_WriteScriptParamsAJAX (void);
static void Lay_WriteScriptCustomDropzone (void);
static void Lay_WritePageTopHeading (void);
static void Lay_WriteBreadcrumb (void);
static void Lay_WriteTitleAction (void);
static void Lay_ShowLeftColumn (void);
static void Lay_ShowRightColumn (void);
static void Lay_WriteAboutZone (void);
static void Lay_WriteFootFromHTMLFile (void);
static void Lay_HelpTextEditor (const char *Text,const char *InlineMath,const char *Equation);
/*****************************************************************************/
/*********************** Write the start of the page *************************/
/*****************************************************************************/
void Lay_WriteStartOfPage (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
extern const unsigned Txt_Current_CGI_SWAD_Language;
extern const char *The_TabOnBgColors[The_NUM_THEMES];
const char *LayoutMainZone[Mnu_NUM_MENUS] =
{
"main_horizontal", // Mnu_MENU_HORIZONTAL
"main_vertical", // Mnu_MENU_VERTICAL
};
Act_BrowserTab_t BrowserTab;
/***** If, when this function is called, the head is being written
or the head is already written ==> don't do anything *****/
if (Gbl.Layout.WritingHTMLStart ||
Gbl.Layout.HTMLStartWritten)
return;
/***** Compute connected users to be displayed in right columns *****/
Con_ComputeConnectedUsrsBelongingToCurrentCrs ();
/***** Send head width the file type for the HTTP protocol *****/
if (Gbl.Action.UsesAJAX)
// Don't generate a full HTML page, only the content of a DIV or similar
{
fprintf (Gbl.F.Out,"Content-Type: text/html; charset=windows-1252\r\n\r\n");
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten = Gbl.Layout.DivsEndWritten = true;
return;
}
/***** If serving a web service ==> don't do anything *****/
if (Gbl.WebService.IsWebService)
{
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten = Gbl.Layout.DivsEndWritten = true;
return;
}
Gbl.Layout.WritingHTMLStart = true;
/***** Write header to standard output to avoid timeout *****/
// Two \r\n are necessary
fprintf (stdout,"Content-type: text/html; charset=windows-1252\r\n\r\n"
"\n");
/***** Write start of HTML code *****/
// WARNING: It is necessary to comment the line 'AddDefaultCharset UTF8'
// in httpd.conf to enable meta tag
fprintf (Gbl.F.Out,"\n"
"\n"
// "\n"
// "\n"
"\n"
"\n"
"\n",
Lan_STR_LANG_ID[Gbl.Prefs.Language],
Cfg_PLATFORM_SHORT_NAME);
/* Viewport (used for responsive design) */
fprintf (Gbl.F.Out,"\n");
/* Title */
Lay_WritePageTitle ();
/* Canonical URL */
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_CGI);
/* Favicon */
fprintf (Gbl.F.Out,"\n"
"\n",
Cfg_URL_ICON_PUBLIC,
Cfg_URL_ICON_PUBLIC);
/* Style sheet for SWAD */
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC,CSS_FILE);
/* Style sheets for Font Awesome */
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC);
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC);
/* 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
switch (Gbl.Action.Act)
{
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
case ActFrmCreAssPrj: // Brw_ADMI_ASS_PRJ
case ActFrmCreMrkCrs: // Brw_ADMI_MRK_CRS
case ActFrmCreMrkGrp: // Brw_ADMI_MRK_GRP
case ActFrmCreBrf: // Brw_ADMI_BRF_USR
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC);
break;
default:
break;
}
/* Redirect to correct language */
if (Gbl.Usrs.Me.Logged && // I am logged
Gbl.Usrs.Me.UsrDat.Prefs.Language != Txt_Current_CGI_SWAD_Language) // My language != current language
{
if (Gbl.Action.Original == ActLogIn || // Regular log in
Gbl.Action.Original == ActLogInNew) // Log in when checking account
Lay_WriteRedirToMyLangOnLogIn ();
else if (Gbl.Action.Original == ActLogInUsrAgd) // Log in to view another user's public agenda
Lay_WriteRedirToMyLangOnViewUsrAgd ();
}
/* Write initial scripts depending on the action */
Lay_WriteScripts ();
fprintf (Gbl.F.Out,"\n");
/***** HTML body *****/
BrowserTab = Act_GetBrowserTab (Gbl.Action.Act);
switch (BrowserTab)
{
case Act_BRW_1ST_TAB:
fprintf (Gbl.F.Out,"\n"
"
"
""
"
"
"
"
"
",
Cfg_URL_ICON_PUBLIC);
break;
case Act_BRW_NEW_TAB:
case Act_BRW_2ND_TAB:
fprintf (Gbl.F.Out,"\n");
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten =
Gbl.Layout.DivsEndWritten = true;
return;
default:
fprintf (Gbl.F.Out,"\n");
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten =
Gbl.Layout.DivsEndWritten = true;
return;
}
/***** Start box that contains the whole page except the foot *****/
fprintf (Gbl.F.Out,"
");
/***** Header of layout *****/
Lay_WritePageTopHeading ();
/***** 3rd. row (tabs) *****/
Tab_DrawTabs ();
/***** 4th row: main zone *****/
fprintf (Gbl.F.Out,"
");
/* Left column */
if (Gbl.Prefs.SideCols & Lay_SHOW_LEFT_COLUMN) // Left column visible
{
fprintf (Gbl.F.Out,"");
}
/* Right column */
// 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.
if (Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) // Right column visible
{
fprintf (Gbl.F.Out,"");
}
/* Central (main) column */
switch (Gbl.Prefs.SideCols)
{
case 0:
fprintf (Gbl.F.Out,"
");
break;
case Lay_SHOW_LEFT_COLUMN:
fprintf (Gbl.F.Out,"
");
break;
case Lay_SHOW_RIGHT_COLUMN:
fprintf (Gbl.F.Out,"
");
break;
case (Lay_SHOW_LEFT_COLUMN | Lay_SHOW_RIGHT_COLUMN):
fprintf (Gbl.F.Out,"
");
break;
}
fprintf (Gbl.F.Out,"
",
The_TabOnBgColors[Gbl.Prefs.Theme]);
/* Layout with horizontal or vertical menu */
fprintf (Gbl.F.Out,"
",LayoutMainZone[Gbl.Prefs.Menu]);
/* Menu */
Mnu_WriteMenuThisTab ();
/* Start canvas: main zone for actions output */
fprintf (Gbl.F.Out,"
");
/* If it is mandatory to read any information about course */
if (Gbl.Crs.Info.ShowMsgMustBeRead)
Inf_WriteMsgYouMustReadInfo ();
/* Write title of the current action */
if (Gbl.Prefs.Menu == Mnu_MENU_VERTICAL &&
Act_GetIndexInMenu (Gbl.Action.Act) >= 0)
Lay_WriteTitleAction ();
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten = true;
/* Write message indicating number of clicks allowed before sending my photo */
Usr_InformAboutNumClicksBeforePhoto ();
}
/*****************************************************************************/
/*********************** 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");
}
/*****************************************************************************/
/************************ Write the end of the page **************************/
/*****************************************************************************/
static void Lay_WriteEndOfPage (void)
{
if (!Gbl.Layout.DivsEndWritten)
{
/***** End of central part of main zone *****/
fprintf (Gbl.F.Out,"
" // Canvas (main zone to output content of the current action)
"
" // Layout with horizontal or vertical menu
"
"); // main_zone_central_container
/***** Write page footer *****/
if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
Lay_WriteFootFromHTMLFile ();
/***** End of main zone and page *****/
fprintf (Gbl.F.Out,"
" // main_zone_central
"
" // main_zone
"
\n"); // whole_page_* (box that contains the whole page except the foot)
Gbl.Layout.DivsEndWritten = true;
}
}
/*****************************************************************************/
/************************* Write the title of the page ***********************/
/*****************************************************************************/
static void Lay_WritePageTitle (void)
{
extern const char *Txt_TAGLINE;
fprintf (Gbl.F.Out,"");
if (Gbl.Params.GetMethod && Gbl.Hierarchy.Deg.DegCod > 0)
{
fprintf (Gbl.F.Out,"%s > %s",
Cfg_PLATFORM_SHORT_NAME,
Gbl.Hierarchy.Deg.ShrtName);
if (Gbl.Hierarchy.Level == Hie_CRS)
fprintf (Gbl.F.Out," > %s",
Gbl.Hierarchy.Crs.ShrtName);
}
else
fprintf (Gbl.F.Out,"%s: %s",
Cfg_PLATFORM_SHORT_NAME,Txt_TAGLINE);
fprintf (Gbl.F.Out,"\n");
}
/*****************************************************************************/
/************* Write script and meta to redirect to my language **************/
/*****************************************************************************/
static void Lay_WriteRedirToMyLangOnLogIn (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
fprintf (Gbl.F.Out,"",
Cfg_URL_SWAD_CGI,
Lan_STR_LANG_ID[Gbl.Usrs.Me.UsrDat.Prefs.Language],
Act_GetActCod (ActLogInLan),
Gbl.Session.Id);
}
static void Lay_WriteRedirToMyLangOnViewUsrAgd (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
fprintf (Gbl.F.Out,"",
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);
}
/*****************************************************************************/
/************ Write some scripts depending on the current action *************/
/*****************************************************************************/
static void Lay_WriteScripts (void)
{
extern const char *Txt_DAYS_CAPS[7];
extern const char *Txt_DAYS_SMALL[7];
extern const char *Txt_Exam_of_X;
unsigned DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */
unsigned NumHld;
unsigned NumExamAnnouncement; // Number of exam announcement
/***** General scripts for swad *****/
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC,JS_FILE);
/***** Script for MathJax *****/
Lay_WriteScriptMathJax ();
/***** Write script with init function executed after loading page *****/
Lay_WriteScriptInit ();
/***** Write script to set parameters needed by AJAX *****/
Lay_WriteScriptParamsAJAX ();
/***** Prepare script to draw months *****/
if ((Gbl.Prefs.SideCols & Lay_SHOW_LEFT_COLUMN) || // Left column visible
(Gbl.Hierarchy.Ins.InsCod > 0 && // Institution selected
(Gbl.Action.Act == ActSeeCal || // Viewing calendar
Gbl.Action.Act == ActPrnCal || // Printing calendar
Gbl.Action.Act == ActChgCal1stDay))) // Changing first day
{
/***** Get list of holidays *****/
if (!Gbl.Hlds.LstIsRead)
{
Gbl.Hlds.SelectedOrder = Hld_ORDER_BY_START_DATE;
Hld_GetListHolidays ();
}
/***** Create list of calls for examination *****/
Exa_CreateListDatesOfExamAnnouncements ();
/***** Write script to initialize variables used to draw months *****/
fprintf (Gbl.F.Out,"\n");
/***** Free list of dates of exam announcements *****/
Exa_FreeListExamAnnouncements ();
}
/***** Scripts depending on action *****/
switch (Gbl.Action.Act)
{
/***** 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
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
case ActFrmCreAssPrj: // Brw_ADMI_ASS_PRJ
case ActFrmCreMrkCrs: // Brw_ADMI_MRK_CRS
case ActFrmCreMrkGrp: // Brw_ADMI_MRK_GRP
case ActFrmCreBrf: // Brw_ADMI_BRF_USR
// Use charset="windows-1252" to force error messages in windows-1252 (default is UTF-8)
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC);
Lay_WriteScriptCustomDropzone ();
break;
case ActReqAccGbl:
case ActSeeAccGbl:
case ActReqAccCrs:
case ActSeeAccCrs:
case ActSeeAllStaCrs:
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC);
break;
default:
break;
}
/***** Script for Google Analytics *****/
fprintf (Gbl.F.Out,"%s",Cfg_GOOGLE_ANALYTICS);
}
// Change page title
//function changeTitle(title) {
// document.title = title;
//}
/*****************************************************************************/
/************ Write some scripts depending on the current action *************/
/*****************************************************************************/
static void Lay_WriteScriptMathJax (void)
{
// MathJax configuration
/*
fprintf (Gbl.F.Out,"");
*/
#ifdef Cfg_MATHJAX_LOCAL
// Use the local copy of MathJax
fprintf (Gbl.F.Out,"\n",
Cfg_URL_SWAD_PUBLIC);
#else
// Use the MathJax Content Delivery Network (CDN)
fprintf (Gbl.F.Out,"\n");
#endif
}
/*****************************************************************************/
/******* Write script with init function executed after loading page *********/
/*****************************************************************************/
static void Lay_WriteScriptInit (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
bool RefreshConnected;
bool RefreshNewTimeline = false;
bool RefreshMatchStd = false;
bool RefreshMatchTch = false;
bool RefreshLastClicks = false;
RefreshConnected = Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB &&
(Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN); // Right column visible
switch (Gbl.Action.Act)
{
case ActSeeSocTmlGbl:
case ActRcvSocPstGbl:
case ActRcvSocComGbl:
case ActReqRemSocPubGbl:
case ActRemSocPubGbl:
case ActReqRemSocComGbl:
case ActRemSocComGbl:
RefreshNewTimeline = true;
break;
case ActJoiMch:
case ActAnsMchQstStd:
RefreshMatchStd = true;
break;
case ActNewMch:
case ActResMch:
case ActBckMch:
case ActPlyMch:
case ActPauMch:
case ActFwdMch:
case ActChgVisResMchQst:
RefreshMatchTch = true;
break;
case ActLstClk:
RefreshLastClicks = true;
break;
default:
break;
}
fprintf (Gbl.F.Out,"\n");
}
/*****************************************************************************/
/************** Write script to set parameters needed by AJAX ****************/
/*****************************************************************************/
static void Lay_WriteScriptParamsAJAX (void)
{
/***** Start script *****/
fprintf (Gbl.F.Out,"\n");
}
/*****************************************************************************/
/******* 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
fprintf (Gbl.F.Out,"\n",
(unsigned long) (Fil_MAX_FILE_SIZE / (1024ULL * 1024ULL) - 1));
}
/*****************************************************************************/
/************************ Write top heading of the page **********************/
/*****************************************************************************/
static void Lay_WritePageTopHeading (void)
{
extern const char *The_ClassTagline[The_NUM_THEMES];
extern const char *Txt_System;
extern const char *Txt_TAGLINE;
extern const char *Txt_TAGLINE_BR;
const char *ClassHeadRow1[The_NUM_THEMES] =
{
"HEAD_ROW_1_WHITE", // The_THEME_WHITE
"HEAD_ROW_1_GREY", // The_THEME_GREY
"HEAD_ROW_1_PURPLE", // The_THEME_PURPLE
"HEAD_ROW_1_BLUE", // The_THEME_BLUE
"HEAD_ROW_1_YELLOW", // The_THEME_YELLOW
"HEAD_ROW_1_PINK", // The_THEME_PINK
};
const char *ClassHeadRow2[The_NUM_THEMES] =
{
"HEAD_ROW_2_WHITE", // The_THEME_WHITE
"HEAD_ROW_2_GREY", // The_THEME_GREY
"HEAD_ROW_2_PURPLE", // The_THEME_PURPLE
"HEAD_ROW_2_BLUE", // The_THEME_BLUE
"HEAD_ROW_2_YELLOW", // The_THEME_YELLOW
"HEAD_ROW_2_PINK", // The_THEME_PINK
};
/***** Start header *****/
fprintf (Gbl.F.Out,"");
/***** 1st. row *****/
/* Start 1st. row */
fprintf (Gbl.F.Out,"
", // head_row_1_tagline
Txt_TAGLINE_BR);
/* End form to go to home page */
Frm_EndForm ();
Sch_PutFormToSearchInPageTopHeading ();
fprintf (Gbl.F.Out,"
"); // head_row_1_left
/* 1st. row, 3rd. column: logged user or language selection,
and link to open/close session */
fprintf (Gbl.F.Out,"
");
if (Gbl.Usrs.Me.Logged)
Usr_WriteLoggedUsrHead ();
else
Lan_PutSelectorToSelectLanguage ();
fprintf (Gbl.F.Out,"
");
if (Gbl.Usrs.Me.Logged)
Usr_PutFormLogOut ();
else
Usr_PutFormLogIn ();
fprintf (Gbl.F.Out,"
" // login_box
"
"); // head_row_1_right
/* End 1st. row */
fprintf (Gbl.F.Out,"
"); // Used for AJAX based refresh
}
/***** Number of connected users in the current course *****/
if (Gbl.Hierarchy.Level == Hie_CRS) // There is a course selected
{
fprintf (Gbl.F.Out,"
"); // Used for AJAX based refresh
}
else if (Gbl.Usrs.Me.Logged) // I am logged
{
/*
gettimeofday (&tv1,NULL);
*/
/***** Suggest one user to follow *****/
fprintf (Gbl.F.Out,"
",
Txt_If_you_have_an_Android_device_try_SWADroid,
Cfg_URL_ICON_PUBLIC);
}
/*****************************************************************************/
/**************** Show an icon with a link in contextual menu ****************/
/*****************************************************************************/
void Lay_PutContextualLinkOnlyIcon (Act_Action_t NextAction,const char *Anchor,
void (*FuncParams) (void),
const char *Icon,
const char *Title)
{
/***** Start form *****/
Frm_StartFormAnchor (NextAction,Anchor);
if (FuncParams)
FuncParams ();
/***** 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,
void (*FuncParams) (void),
const char *Icon,
const char *Text)
{
extern const char *The_ClassFormOutBoxBold[The_NUM_THEMES];
/***** Separator *****/
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
/***** Start form *****/
Frm_StartFormAnchor (NextAction,Anchor);
if (FuncParams)
FuncParams ();
/***** Put icon and text with link *****/
Frm_LinkFormSubmit (Text,The_ClassFormOutBoxBold[Gbl.Prefs.Theme],NULL);
Ico_PutIconTextLink (Icon,Text);
fprintf (Gbl.F.Out,"");
/***** End form *****/
Frm_EndForm ();
/***** Separator *****/
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
}
/*****************************************************************************/
/**************** Show an icon with a link in contextual menu ****************/
/*****************************************************************************/
void Lay_PutContextualLinkIconTextOnSubmit (Act_Action_t NextAction,const char *Anchor,
void (*FuncParams) (void),
const char *Icon,
const char *Text,
const char *OnSubmit)
{
extern const char *The_ClassFormOutBoxBold[The_NUM_THEMES];
/***** Separator *****/
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
/***** Start form *****/
Frm_StartFormAnchor (NextAction,Anchor);
if (FuncParams)
FuncParams ();
/***** Put icon with link *****/
Frm_LinkFormSubmit (Text,The_ClassFormOutBoxBold[Gbl.Prefs.Theme],OnSubmit);
Ico_PutIconTextLink (Icon,Text);
fprintf (Gbl.F.Out,"");
/***** End form *****/
Frm_EndForm ();
/***** Separator *****/
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
}
/*****************************************************************************/
/******************** Show a checkbox in contextual menu *********************/
/*****************************************************************************/
void Lay_PutContextualCheckbox (Act_Action_t NextAction,
void (*FuncParams) (void),
const char *CheckboxName,
bool Checked,bool Disabled,
const char *Title,const char *Text)
{
extern const char *The_ClassFormOutBoxBold[The_NUM_THEMES];
/***** Separator *****/
if (Text)
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
/***** Start form *****/
Frm_StartForm (NextAction);
if (FuncParams)
FuncParams ();
/***** Start container and label *****/
fprintf (Gbl.F.Out,"
"
""
"
");
/***** End form *****/
Frm_EndForm ();
/***** Separator *****/
if (Text)
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
}
/*****************************************************************************/
/****************************** Start/end section ****************************/
/*****************************************************************************/
void Lay_StartSection (const char *SectionId)
{
fprintf (Gbl.F.Out,"",SectionId);
}
void Lay_EndSection (void)
{
fprintf (Gbl.F.Out,"");
}
/*****************************************************************************/
/****************************** Start/end article ****************************/
/*****************************************************************************/
void Lay_StartArticle (const char *ArticleId)
{
fprintf (Gbl.F.Out,"",ArticleId);
}
void Lay_EndArticle (void)
{
fprintf (Gbl.F.Out,"");
}
/*****************************************************************************/
/********** Write error message and exit when not enough memory **************/
/*****************************************************************************/
void Lay_NotEnoughMemoryExit (void)
{
Lay_ShowErrorAndExit ("Not enough memory.");
}
/*****************************************************************************/
/************* Write error message and exit when wrong scope *****************/
/*****************************************************************************/
void Lay_WrongScopeExit (void)
{
Lay_ShowErrorAndExit ("Wrong scope.");
}
/*****************************************************************************/
/******* Write error message, close files, remove lock file, and exit ********/
/*****************************************************************************/
void Lay_ShowErrorAndExit (const char *Txt)
{
/***** Unlock tables if locked *****/
if (Gbl.DB.LockedTables)
{
Gbl.DB.LockedTables = false;
mysql_query (&Gbl.mysql,"UNLOCK TABLES");
}
if (!Gbl.WebService.IsWebService)
{
/****** If start of page is not written yet, do it now ******/
if (!Gbl.Layout.HTMLStartWritten)
Lay_WriteStartOfPage ();
/***** Write possible error message *****/
if (Txt)
Ale_ShowAlert (Ale_ERROR,Txt);
/***** Finish the page, except and *****/
Lay_WriteEndOfPage ();
}
/***** Free memory and close all the open files *****/
Gbl_Cleanup ();
/***** Page is generated (except and ).
Compute time to generate page *****/
if (!Gbl.Action.IsAJAXAutoRefresh)
Sta_ComputeTimeToGeneratePage ();
if (Gbl.WebService.IsWebService) // Serving a plugin request
{
/***** Log access *****/
Gbl.TimeSendInMicroseconds = 0L;
Sta_LogAccess (Txt);
}
else
{
/***** 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 ();
if (!Gbl.Action.IsAJAXAutoRefresh)
{
/***** Compute time to send page *****/
Sta_ComputeTimeToSendPage ();
/***** Log access *****/
Sta_LogAccess (Txt);
/***** Update last data for next time *****/
if (Gbl.Usrs.Me.Logged)
{
Usr_UpdateMyLastData ();
Crs_UpdateCrsLast ();
}
/***** End the output *****/
if (!Gbl.Layout.HTMLEndWritten)
{
// Here Gbl.F.Out is stdout
if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
Lay_WriteAboutZone ();
fprintf (Gbl.F.Out,"