swad-core/swad_layout.c

2009 lines
70 KiB
C
Raw Normal View History

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.
2017-01-13 01:51:23 +01:00
Copyright (C) 1999-2017 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 ***********************************/
/*****************************************************************************/
#include <linux/stddef.h> // For NULL
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc
#include <string.h> // For string functions
#include "swad_action.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"
2015-10-30 22:12:28 +01:00
#include "swad_exam.h"
2017-02-16 20:22:13 +01:00
#include "swad_follow.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"
2017-05-07 18:06:34 +02:00
#include "swad_language.h"
2015-01-17 20:06:25 +01:00
#include "swad_logo.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"
#include "swad_preference.h"
2016-01-09 15:00:14 +01:00
#include "swad_social.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"
#include "swad_web_service.h"
/*****************************************************************************/
/************** 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);
2016-12-06 18:04:12 +01:00
static void Lay_StartRoundFrameInternal (const char *Width,const char *Title,
void (*FunctionToDrawContextualIcons) (void),
const char *HelpLink,
const char *ClassFrame);
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)
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2017-01-28 15:58:46 +01:00
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
2014-12-01 23:55:08 +01:00
extern const unsigned Txt_Current_CGI_SWAD_Language;
extern const char *The_TabOnBgColors[The_NUM_THEMES];
extern const char *Txt_NEW_YEAR_GREETING;
2015-11-30 01:13:00 +01:00
const char *LayoutMainZone[Mnu_NUM_MENUS] =
{
"main_horizontal", // Mnu_MENU_HORIZONTAL
"main_vertical", // Mnu_MENU_VERTICAL
};
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;
2015-12-20 01:41:07 +01:00
/***** Compute connected users to be displayed in right columns *****/
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
{
2015-07-17 00:52:35 +02:00
fprintf (Gbl.F.Out,"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
2014-12-20 16:20:51 +01:00
fprintf (Gbl.F.Out,"<html lang=\"%s\">\n"
2014-12-01 23:55:08 +01:00
"<head>\n"
2017-03-15 22:15:19 +01:00
"<meta http-equiv=\"Page-Enter\" content=\"blendTrans(Duration=0)\">\n"
"<meta http-equiv=\"Page-Exit\" content=\"blendTrans(Duration=0)\">\n"
2015-02-10 17:22:57 +01:00
"<meta http-equiv=\"Content-Type\" content=\"text/html;charset=windows-1252\" />\n"
2015-07-24 11:34:39 +02:00
"<meta name=\"description\" content=\"A free-software, educational, online tool for managing courses and students.\" />\n"
2015-02-10 17:22:57 +01:00
"<meta name=\"keywords\" content=\""
"%s,"
2015-07-24 11:34:39 +02:00
"SWAD,"
"shared workspace at a distance,"
2017-03-15 02:42:31 +01:00
"educational platform,"
2015-07-24 11:34:39 +02:00
"sistema web de apoyo a la docencia,"
2017-03-15 02:42:31 +01:00
"plataforma educativa,"
"campus virtual,"
2015-02-12 21:03:29 +01:00
"SWADroid,"
2015-07-24 11:34:39 +02:00
"LMS,"
"Learning Management System\" />\n",
2015-02-10 17:22:57 +01:00
Txt_STR_LANG_ID[Gbl.Prefs.Language],
Cfg_PLATFORM_SHORT_NAME);
2014-12-01 23:55:08 +01:00
2015-11-27 10:36:40 +01:00
/* Viewport (used for responsive design) */
fprintf (Gbl.F.Out,"<meta name=\"viewport\""
" content=\"width=device-width, initial-scale=1.0\">\n");
2014-12-01 23:55:08 +01:00
/* Title */
Lay_WritePageTitle ();
2015-02-10 17:22:57 +01:00
/* Canonical URL */
fprintf (Gbl.F.Out,"<link rel=\"canonical\""
" href=\"%s\" />\n",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_CGI);
2015-02-10 17:22:57 +01:00
2014-12-01 23:55:08 +01:00
/* Favicon */
fprintf (Gbl.F.Out,"<link type=\"image/x-icon\" href=\"%s/favicon.ico\" rel=\"icon\" />\n"
"<link type=\"image/x-icon\" href=\"%s/favicon.ico\" rel=\"shortcut icon\" />\n",
Gbl.Prefs.IconsURL,
Gbl.Prefs.IconsURL);
/* Style sheet for SWAD */
2015-11-30 11:00:53 +01:00
fprintf (Gbl.F.Out,"<link rel=\"StyleSheet\" href=\"%s/%s\" type=\"text/css\" />\n",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC,CSS_FILE);
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)
{
case ActFrmCreDocIns: // Brw_ADMI_DOCUM_INS
case ActFrmCreShaIns: // Brw_ADMI_SHARE_INS
case ActFrmCreDocCtr: // Brw_ADMI_DOCUM_CTR
case ActFrmCreShaCtr: // Brw_ADMI_SHARE_CTR
case ActFrmCreDocDeg: // Brw_ADMI_DOCUM_DEG
case ActFrmCreShaDeg: // Brw_ADMI_SHARE_DEG
case ActFrmCreDocCrs: // Brw_ADMI_DOCUM_CRS
case ActFrmCreDocGrp: // Brw_ADMI_DOCUM_GRP
case ActFrmCreTchCrs: // Brw_ADMI_TEACH_CRS
case ActFrmCreTchGrp: // Brw_ADMI_TEACH_GRP
case ActFrmCreShaCrs: // Brw_ADMI_SHARE_CRS
case ActFrmCreShaGrp: // Brw_ADMI_SHARE_GRP
case ActFrmCreAsgUsr: // Brw_ADMI_ASSIG_USR
case ActFrmCreAsgCrs: // Brw_ADMI_ASSIG_CRS
case ActFrmCreWrkUsr: // Brw_ADMI_WORKS_USR
case ActFrmCreWrkCrs: // Brw_ADMI_WORKS_CRS
case ActFrmCreMrkCrs: // Brw_ADMI_MARKS_CRS
case ActFrmCreMrkGrp: // Brw_ADMI_MARKS_GRP
case ActFrmCreBrf: // Brw_ADMI_BRIEF_USR
fprintf (Gbl.F.Out,"<link rel=\"StyleSheet\""
" href=\"%s/dropzone/css/dropzone.css\""
" type=\"text/css\" />\n",
Cfg_URL_SWAD_PUBLIC);
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
2014-12-01 23:55:08 +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
{
if (Gbl.Action.Act == ActLogIn || // Regular log in
Gbl.Action.Act == ActLogInNew) // Log in when checking account
Lay_WriteRedirToMyLangOnLogIn ();
else if (Gbl.Action.Act == ActLogInUsrAgd) // Log in to view another user's public agenda
Lay_WriteRedirToMyLangOnViewUsrAgd ();
}
2014-12-01 23:55:08 +01:00
/* Write initial scripts depending on the action */
Lay_WriteScripts ();
fprintf (Gbl.F.Out,"</head>\n");
/***** HTML body *****/
2016-10-21 00:38:34 +02:00
if (Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW)
2017-03-15 22:15:19 +01:00
fprintf (Gbl.F.Out,"<body onload=\"init();\">\n"
2015-09-29 01:47:32 +02:00
"<div id=\"zoomLyr\" class=\"ZOOM\">"
2016-01-10 23:00:15 +01:00
"<img id=\"zoomImg\" src=\"%s/usr_bl.jpg\""
2015-09-29 01:47:32 +02:00
" alt=\"\" title=\"\""
" class=\"IMG_USR\" />"
"<div id=\"zoomTxt\" class=\"CENTER_MIDDLE\">"
"</div>"
"</div>",
Gbl.Prefs.IconsURL);
else
2014-12-01 23:55:08 +01:00
{
2015-09-29 01:47:32 +02:00
fprintf (Gbl.F.Out,"<body>\n");
2014-12-01 23:55:08 +01:00
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten =
2015-11-27 21:24:24 +01:00
Gbl.Layout.DivsEndWritten = true;
2014-12-01 23:55:08 +01:00
return;
}
2015-11-25 01:42:16 +01:00
/***** Start of box that contains the whole page except the foot *****/
2015-12-01 22:31:01 +01:00
fprintf (Gbl.F.Out,"<div 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 *****/
fprintf (Gbl.F.Out,"<div 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
{
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"<aside id=\"left_col\">");
2015-11-27 12:57:56 +01:00
Lay_ShowLeftColumn ();
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"</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
{
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"<aside id=\"right_col\">");
2015-11-27 12:57:56 +01:00
Lay_ShowRightColumn ();
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"</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:
fprintf (Gbl.F.Out,"<div id=\"main_zone_central_none\">");
break;
case Lay_SHOW_LEFT_COLUMN:
fprintf (Gbl.F.Out,"<div id=\"main_zone_central_left\">");
break;
case Lay_SHOW_RIGHT_COLUMN:
fprintf (Gbl.F.Out,"<div id=\"main_zone_central_right\">");
break;
case (Lay_SHOW_LEFT_COLUMN | Lay_SHOW_RIGHT_COLUMN):
fprintf (Gbl.F.Out,"<div id=\"main_zone_central_both\">");
break;
}
2015-11-29 20:03:44 +01:00
fprintf (Gbl.F.Out,"<div id=\"main_zone_central_container\" class=\"%s\">",
2014-12-01 23:55:08 +01:00
The_TabOnBgColors[Gbl.Prefs.Theme]);
2015-11-30 01:13:00 +01:00
/* Layout with horizontal or vertical menu */
fprintf (Gbl.F.Out,"<div 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
2015-11-30 01:13:00 +01:00
/* Start of canvas: main zone for actions output */
2015-11-29 22:06:22 +01:00
fprintf (Gbl.F.Out,"<div class=\"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 */
if (Gbl.CurrentCrs.Info.ShowMsgMustBeRead)
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 &&
2016-01-17 15:10:54 +01:00
Act_Actions[Act_Actions[Gbl.Action.Act].SuperAction].IndexInMenu >= 0)
2014-12-01 23:55:08 +01:00
Lay_WriteTitleAction ();
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten = true;
/* Write new year greeting */
2016-12-05 13:26:12 +01:00
if (Gbl.Action.Act == ActLogIn ||
Gbl.Action.Act == ActLogInNew ||
Gbl.Action.Act == ActLogInLan)
2014-12-01 23:55:08 +01:00
if (Gbl.Now.Date.Month == 1 &&
Gbl.Now.Date.Day == 1)
{
2015-08-03 22:45:00 +02:00
fprintf (Gbl.F.Out,"<div class=\"ASG_TITLE CENTER_MIDDLE\""
2015-09-28 18:28:29 +02:00
" style=\"margin:62px;\">");
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,Txt_NEW_YEAR_GREETING,Gbl.Now.Date.Year);
2014-12-20 16:20:51 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/* Write message indicating number of clicks allowed before sending my photo */
Usr_InformAboutNumClicksBeforePhoto ();
}
/*****************************************************************************/
/************************ Write the end of the page **************************/
/*****************************************************************************/
static void Lay_WriteEndOfPage (void)
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
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 *****/
2015-11-30 01:13:00 +01:00
fprintf (Gbl.F.Out,"</div>" // Canvas (main zone to output content of the current action)
"</div>" // Layout with horizontal or vertical menu
2015-11-27 21:24:24 +01:00
"</div>"); // main_zone_central_container
/***** Write page footer *****/
2016-10-21 00:38:34 +02:00
if (Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW)
2015-12-02 00:32:46 +01:00
Lay_WriteFootFromHTMLFile ();
2015-11-27 21:24:24 +01:00
/***** End of main zone and page *****/
fprintf (Gbl.F.Out,"</div>" // main_zone_central
2015-11-27 12:57:56 +01:00
"</div>" // main_zone
"</div>\n"); // 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;
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<title>");
2016-03-30 14:25:04 +02:00
if (Gbl.Params.GetMethod && Gbl.CurrentDeg.Deg.DegCod > 0)
2014-12-01 23:55:08 +01:00
{
fprintf (Gbl.F.Out,"%s &gt; %s",
2016-03-20 22:31:57 +01:00
Cfg_PLATFORM_SHORT_NAME,
2016-10-28 10:03:37 +02:00
Gbl.CurrentDeg.Deg.ShrtName);
2014-12-01 23:55:08 +01:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
fprintf (Gbl.F.Out," &gt; %s",
2016-10-28 10:03:37 +02:00
Gbl.CurrentCrs.Crs.ShrtName);
2014-12-01 23:55:08 +01:00
}
else
2016-03-20 17:47:18 +01:00
fprintf (Gbl.F.Out,"%s: %s",
2016-03-20 22:31:57 +01:00
Cfg_PLATFORM_SHORT_NAME,Txt_TAGLINE);
2014-12-01 23:55:08 +01:00
2015-02-10 17:22:57 +01:00
fprintf (Gbl.F.Out,"</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
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2017-01-28 15:58:46 +01:00
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
2014-12-01 23:55:08 +01:00
2015-04-12 18:01:06 +02:00
fprintf (Gbl.F.Out,"<meta http-equiv=\"refresh\""
" content=\"0; url='%s/%s?act=%ld&amp;ses=%s'\">",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_CGI,
2014-12-01 23:55:08 +01:00
Txt_STR_LANG_ID[Gbl.Usrs.Me.UsrDat.Prefs.Language],
2016-12-05 13:26:12 +01:00
Act_Actions[ActLogInLan].ActCod,
2014-12-01 23:55:08 +01:00
Gbl.Session.Id);
}
2016-12-05 13:26:12 +01:00
static void Lay_WriteRedirToMyLangOnViewUsrAgd (void)
{
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2017-01-28 15:58:46 +01:00
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
2016-12-05 13:26:12 +01:00
fprintf (Gbl.F.Out,"<meta http-equiv=\"refresh\""
" content=\"0; url='%s/%s?act=%ld&amp;ses=%s&amp;agd=@%s'\">",
Cfg_URL_SWAD_CGI,
Txt_STR_LANG_ID[Gbl.Usrs.Me.UsrDat.Prefs.Language],
Act_Actions[ActLogInUsrAgdLan].ActCod,
Gbl.Session.Id,
Gbl.Usrs.Other.UsrDat.Nickname);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************ Write some scripts depending on the current action *************/
/*****************************************************************************/
static void Lay_WriteScripts (void)
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
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;
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 *****/
2015-12-29 11:35:01 +01:00
fprintf (Gbl.F.Out,"<script type=\"text/javascript\" src=\"%s/%s\">"
2014-12-01 23:55:08 +01:00
"</script>\n",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC,JS_FILE);
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
2015-04-09 12:09:44 +02:00
/***** Scripts used only in main window *****/
2016-10-21 00:38:34 +02:00
if (Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW)
2014-12-01 23:55:08 +01:00
{
Lay_WriteScriptInit ();
2016-01-09 15:00:14 +01:00
Lay_WriteScriptParamsAJAX ();
2014-12-01 23:55:08 +01:00
}
2015-10-30 17:05:33 +01:00
/***** Prepare script to draw months *****/
2015-11-27 12:57:56 +01:00
if ((Gbl.Prefs.SideCols & Lay_SHOW_LEFT_COLUMN) || // Left column visible
2017-02-09 14:32:19 +01:00
Gbl.Action.Act == ActSeeCalIns || Gbl.Action.Act == ActPrnCalIns ||
Gbl.Action.Act == ActSeeCalCtr || Gbl.Action.Act == ActPrnCalCtr ||
Gbl.Action.Act == ActSeeCalDeg || Gbl.Action.Act == ActPrnCalDeg ||
Gbl.Action.Act == ActSeeCalCrs || Gbl.Action.Act == ActPrnCalCrs)
2015-10-30 17:05:33 +01:00
{
/***** Get list of holidays *****/
if (!Gbl.Hlds.LstIsRead)
{
2017-01-29 12:42:19 +01:00
Gbl.Hlds.SelectedOrder = Hld_ORDER_BY_START_DATE;
2015-10-30 17:05:33 +01:00
Hld_GetListHolidays ();
}
/***** Create list of calls for examination *****/
2016-12-12 02:21:41 +01:00
Exa_CreateListDatesOfExamAnnouncements ();
2015-10-30 17:05:33 +01:00
/***** Write script to initialize variables used to draw months *****/
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n"
2017-05-04 20:11:39 +02:00
" var DAYS_CAPS = [");
2015-10-30 17:05:33 +01:00
for (DayOfWeek = 0;
DayOfWeek < 7;
DayOfWeek++)
{
if (DayOfWeek)
fprintf (Gbl.F.Out,",");
fprintf (Gbl.F.Out,"'%c'",Txt_DAYS_CAPS[DayOfWeek][0]);
}
fprintf (Gbl.F.Out,"];\n");
2016-12-12 23:10:11 +01:00
fprintf (Gbl.F.Out," var DAYS = [");
for (DayOfWeek = 0;
DayOfWeek < 7;
DayOfWeek++)
{
if (DayOfWeek)
fprintf (Gbl.F.Out,",");
fprintf (Gbl.F.Out,"'%s'",Txt_DAYS_SMALL[DayOfWeek]);
}
fprintf (Gbl.F.Out,"];\n");
2015-10-30 17:05:33 +01:00
fprintf (Gbl.F.Out," var STR_EXAM = '");
fprintf (Gbl.F.Out,Txt_Exam_of_X,Gbl.CurrentCrs.Crs.FullName);
2015-10-30 22:12:28 +01:00
fprintf (Gbl.F.Out,"';\n");
2015-10-30 17:05:33 +01:00
fprintf (Gbl.F.Out," var Hlds = [];\n");
for (NumHld = 0;
NumHld < Gbl.Hlds.Num;
NumHld++)
fprintf (Gbl.F.Out," Hlds.push({ PlcCod: %ld, HldTyp: %u, StartDate: %s, EndDate: %s, Name: '%s' });\n",
Gbl.Hlds.Lst[NumHld].PlcCod,
(unsigned) Gbl.Hlds.Lst[NumHld].HldTyp,
Gbl.Hlds.Lst[NumHld].StartDate.YYYYMMDD,
Gbl.Hlds.Lst[NumHld].EndDate.YYYYMMDD,
Gbl.Hlds.Lst[NumHld].Name);
fprintf (Gbl.F.Out," var LstExamAnnouncements = [];\n");
for (NumExamAnnouncement = 0;
2017-01-15 18:02:52 +01:00
NumExamAnnouncement < Gbl.ExamAnns.NumExaAnns;
2015-10-30 17:05:33 +01:00
NumExamAnnouncement++)
fprintf (Gbl.F.Out," LstExamAnnouncements.push({ Year: %u, Month: %u, Day: %u });\n",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.Lst[NumExamAnnouncement].Year,
Gbl.ExamAnns.Lst[NumExamAnnouncement].Month,
Gbl.ExamAnns.Lst[NumExamAnnouncement].Day);
2015-10-30 17:05:33 +01:00
2015-10-30 22:12:28 +01:00
fprintf (Gbl.F.Out,"</script>\n");
2016-06-01 13:43:22 +02:00
/***** Free list of dates of exam announcements *****/
Exa_FreeListExamAnnouncements ();
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
case ActFrmCreDocIns: // Brw_ADMI_DOCUM_INS
2015-12-29 13:18:25 +01:00
case ActFrmCreShaIns: // Brw_ADMI_SHARE_INS
2015-10-28 21:47:42 +01:00
case ActFrmCreDocCtr: // Brw_ADMI_DOCUM_CTR
2015-12-29 13:18:25 +01:00
case ActFrmCreShaCtr: // Brw_ADMI_SHARE_CTR
2015-10-28 21:47:42 +01:00
case ActFrmCreDocDeg: // Brw_ADMI_DOCUM_DEG
2015-12-29 13:18:25 +01:00
case ActFrmCreShaDeg: // Brw_ADMI_SHARE_DEG
2015-10-28 21:47:42 +01:00
case ActFrmCreDocCrs: // Brw_ADMI_DOCUM_CRS
case ActFrmCreDocGrp: // Brw_ADMI_DOCUM_GRP
2016-04-22 09:47:25 +02:00
case ActFrmCreTchCrs: // Brw_ADMI_TEACH_CRS
case ActFrmCreTchGrp: // Brw_ADMI_TEACH_GRP
2015-12-29 13:18:25 +01:00
case ActFrmCreShaCrs: // Brw_ADMI_SHARE_CRS
case ActFrmCreShaGrp: // Brw_ADMI_SHARE_GRP
2015-10-28 21:47:42 +01:00
case ActFrmCreAsgUsr: // Brw_ADMI_ASSIG_USR
case ActFrmCreAsgCrs: // Brw_ADMI_ASSIG_CRS
case ActFrmCreWrkUsr: // Brw_ADMI_WORKS_USR
case ActFrmCreWrkCrs: // Brw_ADMI_WORKS_CRS
case ActFrmCreMrkCrs: // Brw_ADMI_MARKS_CRS
case ActFrmCreMrkGrp: // Brw_ADMI_MARKS_GRP
case ActFrmCreBrf: // Brw_ADMI_BRIEF_USR
// Use charset="windows-1252" to force error messages in windows-1252 (default is UTF-8)
fprintf (Gbl.F.Out,"<script type=\"text/javascript\""
" src=\"%s/dropzone/dropzone.js\""
" charset=\"windows-1252\">"
"</script>\n",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC);
2015-10-28 21:47:42 +01:00
Lay_WriteScriptCustomDropzone ();
break;
case ActReqAccGbl:
case ActSeeAccGbl:
case ActReqAccCrs:
case ActSeeAccCrs:
case ActSeeAllStaCrs:
fprintf (Gbl.F.Out,"<script type=\"text/javascript\""
" src=\"%s/jstz/jstz.js\">"
"</script>\n",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC);
2015-10-28 21:47:42 +01:00
break;
default:
break;
2014-12-01 23:55:08 +01:00
}
/***** Script for Google Analytics *****/
fprintf (Gbl.F.Out,"%s",Cfg_GOOGLE_ANALYTICS);
}
// 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)
{
// MathJax configuration
/*
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
" window.MathJax = {"
" tex2jax: {"
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],"
" processEscapes: true"
" }"
" };"
"</script>");
*/
#ifdef Cfg_MATHJAX_LOCAL
// Use the local copy of MathJax
fprintf (Gbl.F.Out,"<script type=\"text/javascript\""
" src=\"%s/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">"
"</script>\n",
Cfg_URL_SWAD_PUBLIC);
#else
// Use the MathJax Content Delivery Network (CDN)
fprintf (Gbl.F.Out,"<script type=\"text/javascript\""
" src=\"//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">"
"</script>\n");
#endif
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******* Write script with init function executed after loading page *********/
/*****************************************************************************/
static void Lay_WriteScriptInit (void)
{
2017-01-28 15:58:46 +01:00
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
2014-12-01 23:55:08 +01:00
2015-10-27 19:44:31 +01:00
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n");
2015-11-27 12:57:56 +01:00
Dat_WriteScriptMonths ();
2015-10-27 19:44:31 +01:00
fprintf (Gbl.F.Out,"function init(){\n");
2014-12-01 23:55:08 +01:00
2015-11-27 12:57:56 +01:00
if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN)) // Right column visible
2014-12-01 23:55:08 +01:00
Con_WriteScriptClockConnected ();
// Put the focus on login form
2016-12-26 13:09:21 +01:00
fprintf (Gbl.F.Out," ActionAJAX = \"%s\";\n"
2015-09-17 17:49:46 +02:00
" setTimeout(\"refreshConnected()\",%lu);\n",
Txt_STR_LANG_ID[Gbl.Prefs.Language],
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Connected.TimeToRefreshInMs);
2016-01-15 02:41:55 +01:00
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActLstClk)
2016-01-15 02:41:55 +01:00
// Refresh timeline via AJAX
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," setTimeout(\"refreshLastClicks()\",%lu);\n",
Cfg_TIME_TO_REFRESH_LAST_CLICKS);
2017-02-17 10:30:59 +01:00
else
switch (Gbl.Action.Act)
{
case ActSeeSocTmlGbl:
case ActRcvSocPstGbl:
case ActRcvSocComGbl:
case ActShaSocNotGbl:
case ActUnsSocNotGbl:
case ActFavSocNotGbl:
case ActUnfSocNotGbl:
case ActFavSocComGbl:
case ActUnfSocComGbl:
case ActReqRemSocPubGbl:
case ActRemSocPubGbl:
case ActReqRemSocComGbl:
case ActRemSocComGbl:
// Refresh timeline via AJAX
fprintf (Gbl.F.Out," setTimeout(\"refreshNewTimeline()\",%lu);\n",
Cfg_TIME_TO_REFRESH_SOCIAL_TIMELINE);
break;
default:
break;
}
2017-03-15 22:15:19 +01:00
// fprintf (Gbl.F.Out," document.getElementById('whole_page').style.opacity='1';\n");
2015-09-17 17:49:46 +02:00
fprintf (Gbl.F.Out,"}\n"
"</script>\n");
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-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2016-01-14 01:39:02 +01:00
/***** Start script *****/
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n");
/***** Parameter to refresh connected users *****/
fprintf (Gbl.F.Out,"var RefreshParamNxtActCon = \"act=%ld\";\n",
2016-01-17 15:10:54 +01:00
Act_Actions[ActRefCon].ActCod);
2016-01-14 01:39:02 +01:00
/***** Parameter to refresh clicks in realtime *****/
fprintf (Gbl.F.Out,"var RefreshParamNxtActLog = \"act=%ld\";\n",
Act_Actions[ActRefLstClk].ActCod);
2017-02-17 10:30:59 +01:00
/***** Parameters related with social timeline refreshing *****/
switch (Gbl.Action.Act)
2016-01-14 01:39:02 +01:00
{
2017-02-17 10:30:59 +01:00
case ActSeeSocTmlGbl:
case ActRcvSocPstGbl:
case ActRcvSocComGbl:
case ActShaSocNotGbl:
case ActUnsSocNotGbl:
case ActFavSocNotGbl:
case ActUnfSocNotGbl:
case ActFavSocComGbl:
case ActUnfSocComGbl:
case ActReqRemSocPubGbl:
case ActRemSocPubGbl:
case ActReqRemSocComGbl:
case ActRemSocComGbl:
/* In all the actions related to view or editing global timeline ==>
put parameters used by AJAX */
fprintf (Gbl.F.Out,"var RefreshParamNxtActNewPub = \"act=%ld\";\n"
"var RefreshParamNxtActOldPub = \"act=%ld\";\n"
2017-02-24 03:38:18 +01:00
"var RefreshParamUsr = \"\";\n" // No user specified
"var RefreshParamWhichUsrs = \"WhichUsrs=%u\";\n",
2017-02-17 10:30:59 +01:00
Act_Actions[ActRefNewSocPubGbl].ActCod,
2017-02-24 03:38:18 +01:00
Act_Actions[ActRefOldSocPubGbl].ActCod,
(unsigned) Gbl.Social.WhichUsrs);
2017-02-17 10:30:59 +01:00
break;
case ActSeeOthPubPrf:
case ActRcvSocPstUsr:
case ActRcvSocComUsr:
case ActShaSocNotUsr:
case ActUnsSocNotUsr:
case ActFavSocNotUsr:
case ActUnfSocNotUsr:
case ActFavSocComUsr:
case ActUnfSocComUsr:
case ActReqRemSocPubUsr:
case ActRemSocPubUsr:
case ActReqRemSocComUsr:
case ActRemSocComUsr:
/* In all the actions related to view or editing user's timeline ==>
put parameters used by AJAX */
if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0)
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
if (!Gbl.Usrs.Other.UsrDat.Nickname[0])
Nck_GetNicknameFromUsrCod (Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.Nickname);
fprintf (Gbl.F.Out,"var RefreshParamNxtActOldPub = \"act=%ld\";\n"
"var RefreshParamUsr = \"OtherUsrCod=%s\";\n",
Act_Actions[ActRefOldSocPubUsr].ActCod,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
break;
default:
break;
2016-01-14 01:39:02 +01:00
}
/***** Parameters with code of session and current course code *****/
fprintf (Gbl.F.Out,"var RefreshParamIdSes = \"ses=%s\";\n"
2015-09-17 17:49:46 +02:00
"var RefreshParamCrsCod = \"crs=%ld\";\n"
"</script>\n",
Gbl.Session.Id,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Crs.CrsCod);
}
/*****************************************************************************/
/******* 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
2015-09-17 17:49:46 +02:00
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n"
"Dropzone.options.myAwesomeDropzone = {\n"
2014-12-01 23:55:08 +01:00
"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"
2015-09-17 17:49:46 +02:00
"};\n"
"</script>\n",
2014-12-01 23:55:08 +01:00
(unsigned long) (Fil_MAX_FILE_SIZE / (1024ULL * 1024ULL) - 1));
}
/*****************************************************************************/
/************************ 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
{
extern const char *The_ClassHead[The_NUM_THEMES];
2016-03-22 01:26:00 +01:00
extern const char *The_ClassTagline[The_NUM_THEMES];
extern const char *Txt_System;
extern const char *Txt_TAGLINE;
2016-03-22 00:03:43 +01:00
extern const char *Txt_TAGLINE_BR;
2015-11-30 09:44:17 +01:00
const char *ClassHeadRow1[The_NUM_THEMES] =
2015-09-27 19:31:10 +02:00
{
2015-11-30 09:44:17 +01:00
"HEAD_ROW_1_WHITE", // The_THEME_WHITE
"HEAD_ROW_1_GREY", // The_THEME_GREY
"HEAD_ROW_1_BLUE", // The_THEME_BLUE
"HEAD_ROW_1_YELLOW", // The_THEME_YELLOW
2015-09-27 19:31:10 +02:00
};
2015-12-01 22:31:01 +01:00
const char *ClassHeadRow2[The_NUM_THEMES] =
{
"HEAD_ROW_2_WHITE", // The_THEME_WHITE
"HEAD_ROW_2_GREY", // The_THEME_GREY
"HEAD_ROW_2_BLUE", // The_THEME_BLUE
"HEAD_ROW_2_YELLOW", // The_THEME_YELLOW
};
2016-12-18 19:50:33 +01:00
/***** Start header *****/
fprintf (Gbl.F.Out,"<header>");
2014-12-01 23:55:08 +01:00
2015-11-24 10:29:07 +01:00
/***** 1st. row *****/
2015-11-25 01:42:16 +01:00
/* Start of 1st. row */
2015-11-30 09:44:17 +01:00
fprintf (Gbl.F.Out,"<div 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 */
2015-11-30 19:50:06 +01:00
fprintf (Gbl.F.Out,"<div id=\"head_row_1_left\">");
2016-03-22 01:26:00 +01:00
/* Start form to go to home page */
Act_FormGoToStart (ActMnu);
Par_PutHiddenParamUnsigned ("NxtTab",(unsigned) TabSys);
fprintf (Gbl.F.Out,"<div id=\"head_row_1_logo_small\">");
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_System,NULL,NULL);
2016-03-22 01:26:00 +01:00
fprintf (Gbl.F.Out,"<img src=\"%s/%s\" alt=\"%s\" title=\"%s\""
2015-09-05 11:48:44 +02:00
" class=\"CENTER_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx; height:%upx;\" />"
2016-03-22 01:26:00 +01:00
"</a>", // head_row_1_logo_small
2015-11-30 12:58:19 +01:00
Gbl.Prefs.IconsURL,Cfg_PLATFORM_LOGO_SMALL_FILENAME,
2015-07-24 11:34:39 +02:00
Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_FULL_NAME,
2015-11-30 12:58:19 +01:00
Cfg_PLATFORM_LOGO_SMALL_WIDTH,Cfg_PLATFORM_LOGO_SMALL_HEIGHT);
2016-03-22 01:26:00 +01:00
fprintf (Gbl.F.Out,"</div>"
"<div id=\"head_row_1_logo_big\">");
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_System,NULL,NULL);
2016-03-22 01:26:00 +01:00
fprintf (Gbl.F.Out,"<img src=\"%s/%s\" alt=\"%s\" title=\"%s\""
2015-11-30 12:58:19 +01:00
" class=\"CENTER_MIDDLE\""
" style=\"width:%upx; height:%upx;\" />"
2016-03-22 01:26:00 +01:00
"</a>", // head_row_1_logo_big
2015-11-30 12:58:19 +01:00
Gbl.Prefs.IconsURL,Cfg_PLATFORM_LOGO_BIG_FILENAME,
Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_FULL_NAME,
Cfg_PLATFORM_LOGO_BIG_WIDTH,Cfg_PLATFORM_LOGO_BIG_HEIGHT);
2016-03-22 01:26:00 +01:00
fprintf (Gbl.F.Out,"</div>"
"<div id=\"head_row_1_tagline\">");
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_TAGLINE,The_ClassTagline[Gbl.Prefs.Theme],NULL);
2016-03-22 01:26:00 +01:00
fprintf (Gbl.F.Out,"%s"
"</a>"
"</div>", // head_row_1_tagline
2016-03-22 00:03:43 +01:00
Txt_TAGLINE_BR);
2016-03-19 02:21:09 +01:00
2016-03-22 01:26:00 +01:00
/* End form to go to home page */
Act_FormEnd ();
2016-06-24 20:16:06 +02:00
Sch_PutFormToSearchInPageTopHeading ();
2015-11-30 19:50:06 +01:00
fprintf (Gbl.F.Out,"</div>"); // 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 */
fprintf (Gbl.F.Out,"<div id=\"head_row_1_right\" class=\"%s\">",
2014-12-01 23:55:08 +01:00
The_ClassHead[Gbl.Prefs.Theme]);
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
2015-12-02 11:33:47 +01:00
fprintf (Gbl.F.Out,"<div id=\"login_box\">");
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.Logged)
Usr_PutFormLogOut ();
else
Usr_PutFormLogIn ();
2015-12-02 11:33:47 +01:00
fprintf (Gbl.F.Out,"</div>" // login_box
2015-11-30 16:21:56 +01:00
"</div>"); // head_row_1_right
2015-11-25 01:42:16 +01:00
2015-11-27 10:36:40 +01:00
/* End of 1st. row */
2015-11-30 16:21:56 +01:00
fprintf (Gbl.F.Out,"</div>"); // head_row_1
2014-12-01 23:55:08 +01:00
/***** 2nd. row *****/
2015-11-25 01:42:16 +01:00
/* Start of second row */
2015-12-01 22:31:01 +01:00
fprintf (Gbl.F.Out,"<div 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) */
2015-11-25 13:33:33 +01:00
fprintf (Gbl.F.Out,"<div id=\"head_row_2_time\">");
2015-11-24 10:29:07 +01:00
Dat_ShowClientLocalTime ();
2015-11-25 01:42:16 +01:00
fprintf (Gbl.F.Out,"</div>"); // End of first column
2015-11-24 10:29:07 +01:00
/* 2nd. row, 2nd. column: degree and course */
2015-11-25 13:41:22 +01:00
fprintf (Gbl.F.Out,"<div 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 ();
2015-11-25 13:41:22 +01:00
fprintf (Gbl.F.Out,"</div>");
2015-11-24 10:29:07 +01:00
/* 2nd. row, 3rd. column */
2015-11-25 13:58:45 +01:00
fprintf (Gbl.F.Out,"<div id=\"msg\">"); // Used for AJAX based refresh
2015-11-24 10:29:07 +01:00
if (Gbl.Usrs.Me.Logged)
Ntf_WriteNumberOfNewNtfs ();
2015-11-25 13:58:45 +01:00
fprintf (Gbl.F.Out,"</div>"); // Used for AJAX based refresh
2014-12-01 23:55:08 +01:00
2015-11-25 01:42:16 +01:00
/* End of 2nd. row */
fprintf (Gbl.F.Out,"</div>");
2015-11-24 10:29:07 +01:00
2016-12-18 19:50:33 +01:00
/***** End header *****/
fprintf (Gbl.F.Out,"</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)
{
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"<nav id=\"breadcrumb\">");
2016-11-14 16:47:46 +01:00
Hie_WriteHierarchyBreadcrumb ();
2015-12-26 12:08:45 +01:00
Crs_WriteSelectorMyCourses ();
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"</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)
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2014-12-01 23:55:08 +01:00
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];
2016-10-09 01:41:36 +02:00
Act_Action_t SuperAction = Act_Actions[Gbl.Action.Act].SuperAction;
2014-12-01 23:55:08 +01:00
/***** Container start *****/
fprintf (Gbl.F.Out,"<div id=\"action_title\""
2015-12-28 15:44:56 +01:00
" style=\"background-image:url('%s/%s/%s');\">",
2015-01-13 14:19:08 +01:00
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION,
2016-10-09 01:41:36 +02:00
Act_Actions[SuperAction].Icon);
2014-12-01 23:55:08 +01:00
/***** Title *****/
2014-12-20 16:20:51 +01:00
fprintf (Gbl.F.Out,"<div class=\"%s\">%s &gt; %s</div>",
2014-12-01 23:55:08 +01:00
The_ClassTitleAction[Gbl.Prefs.Theme],
2016-12-28 17:22:25 +01:00
Txt_TABS_TXT[Act_Actions[SuperAction].Tab],
2016-01-17 15:10:54 +01:00
Act_GetTitleAction (Gbl.Action.Act));
2014-12-01 23:55:08 +01:00
/***** Subtitle *****/
2014-12-20 16:20:51 +01:00
fprintf (Gbl.F.Out,"<div class=\"%s\">%s</div>",
2014-12-01 23:55:08 +01:00
The_ClassSubtitleAction[Gbl.Prefs.Theme],
2016-01-17 15:10:54 +01:00
Act_GetSubtitleAction (Gbl.Action.Act));
2014-12-01 23:55:08 +01:00
/***** Container end *****/
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/***************************** 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
2015-11-25 20:50:19 +01:00
fprintf (Gbl.F.Out,"<div style=\"width:160px;\">");
2014-12-01 23:55:08 +01:00
2017-03-24 21:29:13 +01:00
fprintf (Gbl.F.Out,"<div 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 ();
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
/***** Month *****/
2015-11-25 21:07:50 +01:00
fprintf (Gbl.F.Out,"<div class=\"LEFT_RIGHT_CELL\">");
2015-01-04 14:43:03 +01:00
Cal_DrawCurrentMonth ();
2015-11-25 20:50:19 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
/***** Notices (yellow notes) *****/
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
{
2015-11-25 21:07:50 +01:00
fprintf (Gbl.F.Out,"<div class=\"LEFT_RIGHT_CELL\">");
2016-11-06 22:37:12 +01:00
Not_ShowNotices (Not_LIST_BRIEF_NOTICES);
2015-11-25 20:50:19 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
2015-11-25 20:50:19 +01:00
fprintf (Gbl.F.Out,"</div>");
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;
/***** Banners *****/
Ban_WriteMenuWithBanners ();
/***** Number of connected users in the whole platform *****/
2017-02-01 19:56:46 +01:00
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
{
fprintf (Gbl.F.Out,"<div id=\"globalconnected\"" // Used for AJAX based refresh
" class=\"LEFT_RIGHT_CELL\">");
Con_ShowGlobalConnectedUsrs ();
fprintf (Gbl.F.Out,"</div>"); // Used for AJAX based refresh
}
2014-12-01 23:55:08 +01:00
/***** Number of connected users in the current course *****/
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // There is a course selected
{
2016-03-15 19:41:01 +01:00
fprintf (Gbl.F.Out,"<div id=\"courseconnected\"" // Used for AJAX based refresh
" class=\"LEFT_RIGHT_CELL\">");
2015-02-01 20:17:24 +01:00
Gbl.Scope.Current = Sco_SCOPE_CRS;
2016-03-15 22:15:25 +01:00
Con_ShowConnectedUsrsBelongingToCurrentCrs ();
2016-03-15 19:41:01 +01:00
fprintf (Gbl.F.Out,"</div>"); // 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
{
/***** Suggest one user to follow *****/
fprintf (Gbl.F.Out,"<div class=\"LEFT_RIGHT_CELL\">");
Fol_SuggestUsrsToFollowMainZoneOnRightColumn ();
fprintf (Gbl.F.Out,"</div>");
}
2014-12-01 23:55:08 +01:00
2017-03-24 21:29:13 +01:00
if (!Gbl.Usrs.Me.Logged)
/***** SWADroid advertisement *****/
2015-11-25 21:07:50 +01:00
fprintf (Gbl.F.Out,"<div class=\"LEFT_RIGHT_CELL\">"
2014-12-23 14:41:10 +01:00
"<a href=\"https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid\""
" target=\"_blank\" title=\"%s\">"
2015-07-22 11:30:21 +02:00
"<img src=\"%s/SWADroid120x200.png\""
" alt=\"SWADroid\" title=\"SWADroid\""
2015-09-28 18:28:29 +02:00
" style=\"width:150px; height:250px;\" />"
2014-12-01 23:55:08 +01:00
"</a>"
2015-11-25 20:50:19 +01:00
"</div>",
2014-12-01 23:55:08 +01:00
Txt_If_you_have_an_Android_device_try_SWADroid,
Gbl.Prefs.IconsURL);
}
2017-04-30 19:44:18 +02:00
/*****************************************************************************/
2017-04-30 23:48:48 +02:00
/***** Show contextual icons to remove, edit, view, hide, unhide, print ******/
2017-04-30 19:44:18 +02:00
/*****************************************************************************/
2017-04-30 23:48:48 +02:00
void Lay_PutContextualIconToRemove (Act_Action_t NextAction,void (*FuncParams) ())
{
extern const char *Txt_Remove;
Lay_PutContextualLink (NextAction,NULL,FuncParams,
"remove-on64x64.png",
Txt_Remove,NULL,
NULL);
}
void Lay_PutContextualIconToEdit (Act_Action_t NextAction,void (*FuncParams) ())
2017-04-30 19:44:18 +02:00
{
extern const char *Txt_Edit;
Lay_PutContextualLink (NextAction,NULL,FuncParams,
"edit64x64.png",
Txt_Edit,NULL,
NULL);
}
2017-04-30 23:48:48 +02:00
void Lay_PutContextualIconToView (Act_Action_t NextAction,void (*FuncParams) ())
2017-04-30 19:44:18 +02:00
{
extern const char *Txt_View;
Lay_PutContextualLink (NextAction,NULL,FuncParams,
"eye-on64x64.png",
Txt_View,NULL,
NULL);
}
2017-04-30 23:48:48 +02:00
void Lay_PutContextualIconToHide (Act_Action_t NextAction,void (*FuncParams) ())
2017-04-30 21:37:44 +02:00
{
extern const char *Txt_Hide;
Lay_PutContextualLink (NextAction,NULL,FuncParams,
"eye-on64x64.png",
Txt_Hide,NULL,
NULL);
}
2017-04-30 23:48:48 +02:00
void Lay_PutContextualIconToUnhide (Act_Action_t NextAction,void (*FuncParams) ())
2017-04-30 21:37:44 +02:00
{
extern const char *Txt_Show;
Lay_PutContextualLink (NextAction,NULL,FuncParams,
"eye-slash-on64x64.png",
Txt_Show,NULL,
NULL);
}
2017-04-30 23:48:48 +02:00
void Lay_PutContextualIconToPrint (Act_Action_t NextAction,void (*FuncParams) ())
2017-04-30 19:44:18 +02:00
{
extern const char *Txt_Print;
Lay_PutContextualLink (NextAction,NULL,FuncParams,
"print64x64.png",
Txt_Print,NULL,
NULL);
}
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
/*****************************************************************************/
2017-04-17 19:03:21 +02:00
void Lay_PutContextualLink (Act_Action_t NextAction,const char *Anchor,
2016-01-02 02:33:23 +01:00
void (*FuncParams) (),
2015-12-13 19:02:06 +01:00
const char *Icon,
2016-07-01 16:32:42 +02:00
const char *Title,const char *Text,
2016-07-04 14:33:31 +02:00
const char *OnSubmit)
2015-12-13 18:32:37 +01:00
{
extern const char *The_ClassFormBold[The_NUM_THEMES];
2016-11-22 10:44:58 +01:00
/***** Separator *****/
2015-12-13 22:45:57 +01:00
if (Text)
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
2015-12-13 20:24:39 +01:00
2016-11-22 10:44:58 +01:00
/***** Start form *****/
2017-04-17 19:03:21 +02:00
Act_FormStartAnchor (NextAction,Anchor);
2015-12-13 18:32:37 +01:00
if (FuncParams)
FuncParams ();
2016-11-22 10:44:58 +01:00
/***** Put icon with link *****/
2015-12-13 19:02:06 +01:00
Lay_PutIconLink (Icon,Title,Text,
Text ? The_ClassFormBold[Gbl.Prefs.Theme] :
2016-07-01 16:32:42 +02:00
NULL,
2016-07-04 14:33:31 +02:00
OnSubmit);
2016-11-22 10:44:58 +01:00
/***** End form *****/
Act_FormEnd ();
/***** Separator *****/
if (Text)
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,
2016-11-22 12:07:29 +01:00
void (*FuncParams) (),
2016-11-22 10:44:58 +01:00
const char *CheckboxName,bool Checked,
const char *Title,const char *Text)
{
extern const char *The_ClassFormBold[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 *****/
Act_FormStart (NextAction);
2016-11-22 12:07:29 +01:00
if (FuncParams)
FuncParams ();
2016-11-22 10:44:58 +01:00
2016-12-20 10:03:00 +01:00
/***** Start container and label *****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_OPT %s %s\" title=\"%s\">"
"<label>",
2016-11-22 10:44:58 +01:00
Checked ? "CHECKBOX_CHECKED" :
"CHECKBOX_UNCHECKED",
The_ClassFormBold[Gbl.Prefs.Theme],
Title);
/****** Checkbox and text *****/
fprintf (Gbl.F.Out,"<input type=\"checkbox\" name=\"%s\" value=\"Y\"",
CheckboxName);
if (Checked)
fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," onclick=\"document.getElementById('%s').submit();\" />",
Gbl.Form.Id);
if (Text)
if (Text[0])
fprintf (Gbl.F.Out,"&nbsp;%s",
Text);
2016-12-20 10:03:00 +01:00
/***** End label and container *****/
fprintf (Gbl.F.Out,"</label>"
"</div>");
2016-11-22 10:44:58 +01:00
/***** End form *****/
2015-12-13 18:32:37 +01:00
Act_FormEnd ();
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)
fprintf (Gbl.F.Out," "); // This space is necessary to enable
// jumping to the next line on narrow screens
2015-12-13 18:32:37 +01:00
}
/*****************************************************************************/
/****************** Show an icon with a link (without text) ******************/
/*****************************************************************************/
2015-12-13 19:02:06 +01:00
void Lay_PutIconLink (const char *Icon,const char *Title,const char *Text,
2016-07-04 14:33:31 +02:00
const char *LinkStyle,const char *OnSubmit)
2015-12-13 18:32:37 +01:00
{
2016-07-04 14:33:31 +02:00
Act_LinkFormSubmit (Title,LinkStyle,OnSubmit);
2015-12-13 18:32:37 +01:00
Lay_PutIconWithText (Icon,Title,Text);
fprintf (Gbl.F.Out,"</a>");
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/**************** Put a icon with a text to submit a form ********************/
/*****************************************************************************/
2015-04-12 18:01:06 +02:00
void Lay_PutIconWithText (const char *Icon,const char *Alt,const char *Text)
2014-12-01 23:55:08 +01:00
{
2017-05-02 11:39:17 +02:00
/***** Print icon and optional text *****/
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_OPT ICO_HIGHLIGHT\">"
2017-05-02 11:39:17 +02:00
"<img src=\"%s/%s\" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" />",
2015-07-22 11:30:21 +02:00
Gbl.Prefs.IconsURL,Icon,
Alt,Text ? Text : Alt);
2015-04-02 13:38:05 +02:00
if (Text)
if (Text[0])
2017-05-02 11:39:17 +02:00
fprintf (Gbl.F.Out,"&nbsp;%s",Text);
2015-12-13 18:32:37 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
2016-03-24 13:40:05 +01:00
/*****************************************************************************/
/********** Put a icon to submit a form. **********/
/********** When clicked, the icon will be replaced by an animation **********/
/*****************************************************************************/
void Lay_PutCalculateIcon (const char *Alt)
{
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_OPT ICO_HIGHLIGHT\">"
2016-03-24 18:46:57 +01:00
"<img id=\"update_%d\" src=\"%s/recycle16x16.gif\"" // TODO: change name and resolution to refresh64x64.png
2016-03-24 13:40:05 +01:00
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" />"
2016-03-24 18:46:57 +01:00
"<img id=\"updating_%d\" src=\"%s/working16x16.gif\"" // TODO: change name and resolution to refreshing64x64.gif
2016-03-24 13:40:05 +01:00
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" style=\"display:none;\" />" // Animated icon hidden
2016-03-24 13:40:05 +01:00
"</div>"
"</a>",
Gbl.Form.Num,Gbl.Prefs.IconsURL,Alt,Alt,
Gbl.Form.Num,Gbl.Prefs.IconsURL,Alt,Alt);
}
2015-03-13 14:05:56 +01:00
/*****************************************************************************/
/********** Put a icon with a text to submit a form. **********/
/********** When clicked, the icon will be replaced by an animation **********/
/*****************************************************************************/
2015-04-12 18:01:06 +02:00
void Lay_PutCalculateIconWithText (const char *Alt,const char *Text)
2015-03-13 14:05:56 +01:00
{
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"ICO_HIGHLIGHT\""
2015-12-12 19:47:10 +01:00
" style=\"margin:0 6px 0 0; display:inline;\">"
2015-07-22 11:30:21 +02:00
"<img id=\"update_%d\" src=\"%s/recycle16x16.gif\""
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" />"
2015-07-22 11:30:21 +02:00
"<img id=\"updating_%d\" src=\"%s/working16x16.gif\""
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" style=\"display:none;\" />" // Animated icon hidden
2015-04-02 13:38:05 +02:00
"&nbsp;%s"
"</div>"
"</a>",
2016-01-14 10:31:09 +01:00
Gbl.Form.Num,Gbl.Prefs.IconsURL,Alt,Text,
Gbl.Form.Num,Gbl.Prefs.IconsURL,Alt,Text,
2015-03-13 14:05:56 +01:00
Text);
}
2015-07-22 19:20:30 +02:00
/*****************************************************************************/
2015-07-22 19:59:28 +02:00
/******** Put a disabled icon indicating that removal is not allowed *********/
2015-07-22 19:20:30 +02:00
/*****************************************************************************/
void Lay_PutIconRemovalNotAllowed (void)
{
extern const char *Txt_Removal_not_allowed;
2015-12-08 22:20:44 +01:00
fprintf (Gbl.F.Out,"<img src=\"%s/remove-off64x64.png\""
2015-07-22 19:20:30 +02:00
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" />",
2015-07-22 19:20:30 +02:00
Gbl.Prefs.IconsURL,
Txt_Removal_not_allowed,
Txt_Removal_not_allowed);
}
2015-07-22 19:59:28 +02:00
void Lay_PutIconBRemovalNotAllowed (void)
{
extern const char *Txt_Removal_not_allowed;
2015-12-08 22:20:44 +01:00
fprintf (Gbl.F.Out,"<img src=\"%s/remove-off64x64.png\""
2015-07-22 19:59:28 +02:00
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20B\" />",
2015-07-22 19:59:28 +02:00
Gbl.Prefs.IconsURL,
Txt_Removal_not_allowed,
Txt_Removal_not_allowed);
}
/*****************************************************************************/
2017-04-30 23:48:48 +02:00
/******** Put an icon indicating that removal is not allowed *********/
2015-07-22 19:59:28 +02:00
/*****************************************************************************/
void Lay_PutIconRemove (void)
{
extern const char *Txt_Remove;
2015-12-08 22:20:44 +01:00
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/remove-on64x64.png\""
2015-07-22 19:59:28 +02:00
" alt=\"%s\" title=\"%s\""
2016-11-14 10:05:41 +01:00
" class=\"ICO20x20\" />",
2015-07-22 19:59:28 +02:00
Gbl.Prefs.IconsURL,
Txt_Remove,
Txt_Remove);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********************** Put a button to submit a form ************************/
/*****************************************************************************/
2017-05-11 23:45:46 +02:00
void Lay_PutButton (Lay_Button_t Button,const char *TxtButton)
2017-04-27 15:02:00 +02:00
{
if (TxtButton)
if (TxtButton[0])
switch (Button)
{
case Lay_NO_BUTTON:
break;
case Lay_CREATE_BUTTON:
Lay_PutCreateButton (TxtButton);
break;
case Lay_CONFIRM_BUTTON:
Lay_PutConfirmButton (TxtButton);
break;
case Lay_REMOVE_BUTTON:
Lay_PutRemoveButton (TxtButton);
break;
}
}
void Lay_PutCreateButton (const char *TxtButton)
2014-12-01 23:55:08 +01:00
{
2015-08-03 22:45:00 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"
2015-03-24 17:47:26 +01:00
"<button type=\"submit\" class=\"BT_SUBMIT BT_CREATE\">"
"%s"
"</button>"
2014-12-01 23:55:08 +01:00
"</div>",
2017-04-27 15:02:00 +02:00
TxtButton);
2015-03-24 17:47:26 +01:00
}
2017-04-27 15:02:00 +02:00
void Lay_PutCreateButtonInline (const char *TxtButton)
2015-03-24 17:47:26 +01:00
{
fprintf (Gbl.F.Out,"<button type=\"submit\" class=\"BT_SUBMIT_INLINE BT_CREATE\">"
"%s"
"</button>",
2017-04-27 15:02:00 +02:00
TxtButton);
2015-03-24 17:47:26 +01:00
}
2017-04-27 15:02:00 +02:00
void Lay_PutConfirmButton (const char *TxtButton)
2015-03-24 17:47:26 +01:00
{
2015-08-03 22:45:00 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"
2015-03-24 17:47:26 +01:00
"<button type=\"submit\" class=\"BT_SUBMIT BT_CONFIRM\">"
"%s"
"</button>"
"</div>",
2017-04-27 15:02:00 +02:00
TxtButton);
2015-03-24 17:47:26 +01:00
}
2017-04-27 15:02:00 +02:00
void Lay_PutConfirmButtonInline (const char *TxtButton)
2015-03-24 17:47:26 +01:00
{
fprintf (Gbl.F.Out,"<button type=\"submit\" class=\"BT_SUBMIT_INLINE BT_CONFIRM\">"
"%s"
"</button>",
2017-04-27 15:02:00 +02:00
TxtButton);
2015-03-24 17:47:26 +01:00
}
2017-04-27 15:02:00 +02:00
void Lay_PutRemoveButton (const char *TxtButton)
2015-03-24 17:47:26 +01:00
{
2015-08-03 22:45:00 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"
2015-03-24 17:47:26 +01:00
"<button type=\"submit\" class=\"BT_SUBMIT BT_REMOVE\">"
"%s"
"</button>"
"</div>",
2017-04-27 15:02:00 +02:00
TxtButton);
2014-12-01 23:55:08 +01:00
}
2017-04-27 15:02:00 +02:00
void Lay_PutRemoveButtonInline (const char *TxtButton)
2015-10-04 16:24:10 +02:00
{
fprintf (Gbl.F.Out,"<button type=\"submit\" class=\"BT_SUBMIT_INLINE BT_REMOVE\">"
"%s"
"</button>",
2017-04-27 15:02:00 +02:00
TxtButton);
2015-10-04 16:24:10 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/****************** Start and end a table with rounded frame *****************/
/*****************************************************************************/
2014-12-21 19:43:39 +01:00
// CellPadding must be 0, 1, 2, 4 or 8
2014-12-01 23:55:08 +01:00
2016-11-13 23:52:51 +01:00
void Lay_StartRoundFrameTable (const char *Width,const char *Title,
void (*FunctionToDrawContextualIcons) (void),
const char *HelpLink,
2017-05-01 10:22:16 +02:00
unsigned CellPadding) // CellPadding must be 0, 1, 2, 5 or 10
2015-04-03 14:04:26 +02:00
{
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrame (Width,Title,FunctionToDrawContextualIcons,HelpLink);
2017-05-01 10:22:16 +02:00
Lay_StartTableWide (CellPadding);
2015-04-03 14:04:26 +02:00
}
2016-12-06 18:04:12 +01:00
void Lay_StartRoundFrameTableShadow (const char *Width,const char *Title,
void (*FunctionToDrawContextualIcons) (void),
const char *HelpLink,
2017-05-01 10:22:16 +02:00
unsigned CellPadding) // CellPadding must be 0, 1, 2, 5 or 10
2016-12-06 18:04:12 +01:00
{
Lay_StartRoundFrameShadow (Width,Title,FunctionToDrawContextualIcons,HelpLink);
2017-05-01 10:22:16 +02:00
Lay_StartTableWide (CellPadding);
2016-12-06 18:04:12 +01:00
}
2016-11-12 21:39:29 +01:00
void Lay_StartRoundFrame (const char *Width,const char *Title,
2016-11-12 22:00:50 +01:00
void (*FunctionToDrawContextualIcons) (void),
const char *HelpLink)
2016-12-06 18:04:12 +01:00
{
Lay_StartRoundFrameInternal (Width,Title,
FunctionToDrawContextualIcons,
HelpLink,
"FRAME");
}
void Lay_StartRoundFrameShadow (const char *Width,const char *Title,
void (*FunctionToDrawContextualIcons) (void),
const char *HelpLink)
{
Lay_StartRoundFrameInternal (Width,Title,
FunctionToDrawContextualIcons,
HelpLink,
"FRAME_SHADOW");
}
static void Lay_StartRoundFrameInternal (const char *Width,const char *Title,
void (*FunctionToDrawContextualIcons) (void),
const char *HelpLink,
const char *ClassFrame)
2014-12-01 23:55:08 +01:00
{
2016-11-12 21:39:29 +01:00
extern const char *Txt_Help;
2017-04-10 12:24:20 +02:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_CONTAINER\">"
2016-12-06 18:04:12 +01:00
"<div class=\"%s\"",ClassFrame);
2014-12-01 23:55:08 +01:00
if (Width)
2016-12-06 18:04:12 +01:00
fprintf (Gbl.F.Out," style=\"width:%s;\"",Width);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,">");
2014-12-21 19:43:39 +01:00
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_ICO\">");
2016-03-16 11:15:25 +01:00
if (FunctionToDrawContextualIcons)
2016-11-12 21:39:29 +01:00
{
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_ICO_LEFT\">");
2016-03-16 11:15:25 +01:00
FunctionToDrawContextualIcons ();
2016-11-12 21:39:29 +01:00
fprintf (Gbl.F.Out,"</div>");
}
2016-11-12 22:00:50 +01:00
if (HelpLink)
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_ICO_RIGHT\">"
2017-03-02 21:05:09 +01:00
"<a href=\"%s%s\" target=\"_blank\">"
2016-11-14 10:05:41 +01:00
"<div class=\"CONTEXT_OPT HLP_HIGHLIGHT\">"
"<img src=\"%s/help64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />"
"</div>"
"</a>"
"</div>",
2017-03-02 21:05:09 +01:00
Hlp_WIKI,HelpLink,
2016-11-14 10:05:41 +01:00
Gbl.Prefs.IconsURL,
Txt_Help,Txt_Help);
2016-03-18 19:23:30 +01:00
fprintf (Gbl.F.Out,"</div>");
2016-03-16 11:15:25 +01:00
2014-12-01 23:55:08 +01:00
if (Title)
2016-11-23 23:58:46 +01:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_TITLE %s\">"
2014-12-26 17:55:42 +01:00
"%s"
"</div>",
2016-11-23 23:58:46 +01:00
Gbl.Layout.FrameNested ? "FRAME_TITLE_SMALL" :
"FRAME_TITLE_BIG",
2014-12-01 23:55:08 +01:00
Title);
2016-11-23 23:58:46 +01:00
Gbl.Layout.FrameNested++;
2014-12-01 23:55:08 +01:00
}
2015-04-12 18:01:06 +02:00
void Lay_EndRoundFrameTable (void)
{
2017-05-01 10:22:16 +02:00
Lay_EndTable ();
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrame ();
}
void Lay_EndRoundFrameTableWithButton (Lay_Button_t Button,const char *TxtButton)
2014-12-01 23:55:08 +01:00
{
2017-05-01 10:22:16 +02:00
Lay_EndTable ();
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameWithButton (Button,TxtButton);
2015-04-03 14:04:26 +02:00
}
2015-04-12 18:01:06 +02:00
void Lay_EndRoundFrameWithButton (Lay_Button_t Button,const char *TxtButton)
2015-04-03 14:04:26 +02:00
{
2017-04-27 15:02:00 +02:00
Lay_PutButton (Button,TxtButton);
2016-11-24 20:19:54 +01:00
Lay_EndRoundFrame ();
}
void Lay_EndRoundFrame (void)
{
Gbl.Layout.FrameNested--;
2015-04-03 14:04:26 +02:00
fprintf (Gbl.F.Out,"</div>"
2014-12-01 23:55:08 +01:00
"</div>");
}
2017-05-01 21:17:38 +02:00
void Lay_StartTable (unsigned CellPadding)
{
fprintf (Gbl.F.Out,"<table");
if (CellPadding)
fprintf (Gbl.F.Out," class=\"CELLS_PAD_%u\"",CellPadding); // CellPadding must be 0, 1, 2, 5 or 10
fprintf (Gbl.F.Out,">");
}
2017-05-01 12:36:24 +02:00
void Lay_StartTableCenter (unsigned CellPadding)
{
fprintf (Gbl.F.Out,"<table class=\"FRAME_TBL_CENTER");
if (CellPadding)
fprintf (Gbl.F.Out," CELLS_PAD_%u",CellPadding); // CellPadding must be 0, 1, 2, 5 or 10
fprintf (Gbl.F.Out,"\">");
}
2017-05-01 10:22:16 +02:00
void Lay_StartTableWide (unsigned CellPadding)
{
fprintf (Gbl.F.Out,"<table class=\"FRAME_TBL_WIDE");
if (CellPadding)
fprintf (Gbl.F.Out," CELLS_PAD_%u",CellPadding); // CellPadding must be 0, 1, 2, 5 or 10
fprintf (Gbl.F.Out,"\">");
}
2017-05-01 12:36:24 +02:00
void Lay_StartTableWideMargin (unsigned CellPadding)
{
fprintf (Gbl.F.Out,"<table class=\"FRAME_TBL_WIDE_MARGIN");
if (CellPadding)
fprintf (Gbl.F.Out," CELLS_PAD_%u",CellPadding); // CellPadding must be 0, 1, 2, 5 or 10
fprintf (Gbl.F.Out,"\">");
}
2017-05-01 10:22:16 +02:00
void Lay_EndTable (void)
{
fprintf (Gbl.F.Out,"</table>");
}
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
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
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)
2017-05-11 23:45:46 +02: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)
2014-12-01 23:55:08 +01:00
Sta_ComputeTimeToGeneratePage ();
if (Gbl.WebService.IsWebService) // Serving a plugin request
{
/***** Log access *****/
Gbl.TimeSendInMicroseconds = 0L;
2017-05-10 10:25:01 +02:00
Sta_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 *****/
2017-05-10 10:25:01 +02:00
Sta_LogAccess (Txt);
2015-12-02 00:32:46 +01:00
/***** End the output *****/
if (!Gbl.Layout.HTMLEndWritten)
{
// Here Gbl.F.Out is stdout
2016-10-21 00:38:34 +02:00
if (Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW)
2015-12-02 11:33:47 +01:00
Lay_WriteAboutZone ();
2015-12-02 00:32:46 +01:00
fprintf (Gbl.F.Out,"</body>\n"
"</html>\n");
Gbl.Layout.HTMLEndWritten = true;
}
}
2014-12-01 23:55:08 +01:00
}
/***** Close database connection *****/
DB_CloseDBConnection ();
/***** Exit *****/
if (Gbl.WebService.IsWebService)
2017-05-10 10:25:01 +02:00
Svc_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;
2016-12-18 19:50:33 +01:00
/***** Start about zone *****/
2016-12-19 02:00:00 +01:00
fprintf (Gbl.F.Out,"<address id=\"about_zone\" class=\"ABOUT\">");
2015-12-02 00:32:46 +01:00
/***** Institution and centre hosting the platform *****/
fprintf (Gbl.F.Out,"<a href=\"%s\" class=\"ABOUT\" target=\"_blank\">"
"<img src=\"%s/%s\""
" alt=\"%s\" title=\"%s\""
" style=\"width:%upx; height:%upx;\" />"
"<div>%s</div>"
"</a>",
Cfg_ABOUT_URL,
Gbl.Prefs.IconsURL,Cfg_ABOUT_LOGO,
Cfg_ABOUT_NAME,Cfg_ABOUT_NAME,
Cfg_ABOUT_LOGO_WIDTH,Cfg_ABOUT_LOGO_HEIGHT,
Cfg_ABOUT_NAME);
/***** Questions and problems *****/
2016-12-19 02:00:00 +01:00
fprintf (Gbl.F.Out,"<div>"
2016-04-18 13:32:46 +02:00
"%s: "
2015-12-02 00:32:46 +01:00
"<a href=\"mailto:%s\" class=\"ABOUT\" target=\"_blank\">%s</a>"
"</div>",
2016-04-18 13:32:46 +02:00
Txt_Questions_and_problems,
2016-11-16 23:19:52 +01:00
Cfg_PLATFORM_RESPONSIBLE_EMAIL,Cfg_PLATFORM_RESPONSIBLE_EMAIL);
2015-12-02 00:32:46 +01:00
/***** About and time to generate and send page *****/
fprintf (Gbl.F.Out,"<div>");
/* About */
fprintf (Gbl.F.Out,"<a href=\"%s\" class=\"ABOUT\" target=\"_blank\">",
Cfg_ABOUT_SWAD_URL);
fprintf (Gbl.F.Out,Txt_About_X,Log_PLATFORM_VERSION);
fprintf (Gbl.F.Out,"</a>"
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
/* Time to generate and send page */
Sta_WriteTimeToGenerateAndSendPage ();
fprintf (Gbl.F.Out,"</div>");
2016-12-18 19:50:33 +01:00
/***** End about zone *****/
2016-12-19 02:00:00 +01:00
fprintf (Gbl.F.Out,"</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) &&
Gbl.CurrentCrs.Crs.CrsCod > 0; // Right column visible && There is a course selected
2014-12-01 23:55:08 +01:00
// Sometimes, someone must do this work, so who best than processes that refresh via AJAX?
if (!(Gbl.PID % 11)) // Do this only one of 11 times ( 11 is prime)
2016-11-16 23:19:52 +01:00
Ntf_SendPendingNotifByEMailToAllUsrs (); // Send pending notifications by email
2014-12-01 23:55:08 +01:00
else if (!(Gbl.PID % 1013)) // Do this only one of 1013 times (1013 is prime)
Brw_RemoveExpiredExpandedFolders (); // Remove old expanded folders (from all users)
else if (!(Gbl.PID % 1019)) // Do this only one of 1019 times (1019 is prime)
2015-03-14 17:39:04 +01:00
Pre_RemoveOldPrefsFromIP (); // Remove old preferences from IP
2014-12-01 23:55:08 +01:00
else if (!(Gbl.PID % 1021)) // Do this only one of 1021 times (1021 is prime)
Sta_RemoveOldEntriesRecentLog (); // Remove old entries in recent log table, it's a slow query
// Send, before the HTML, the refresh time
fprintf (Gbl.F.Out,"%lu|",Gbl.Usrs.Connected.TimeToRefreshInMs);
if (Gbl.Usrs.Me.Logged)
Ntf_WriteNumberOfNewNtfs ();
fprintf (Gbl.F.Out,"|");
Con_ShowGlobalConnectedUsrs ();
fprintf (Gbl.F.Out,"|");
if (ShowConnected)
{
2015-02-01 20:17:24 +01:00
Gbl.Scope.Current = Sco_SCOPE_CRS;
2016-03-15 22:15:25 +01:00
Con_ShowConnectedUsrsBelongingToCurrentCrs ();
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"|");
if (ShowConnected)
fprintf (Gbl.F.Out,"%u",Gbl.Usrs.Connected.NumUsrsToList);
fprintf (Gbl.F.Out,"|");
if (ShowConnected)
for (NumUsr = 0;
NumUsr < Gbl.Usrs.Connected.NumUsrsToList;
NumUsr++)
2015-10-26 23:16:21 +01:00
fprintf (Gbl.F.Out,"%ld|",Gbl.Usrs.Connected.Lst[NumUsr].TimeDiff);
2014-12-01 23:55:08 +01:00
/***** All the output is made, so don't write anymore *****/
2015-11-27 21:24:24 +01:00
Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
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 *****/
fprintf (Gbl.F.Out,"%lu|",Cfg_TIME_TO_REFRESH_LAST_CLICKS);
/***** Get and show last clicks *****/
Con_GetAndShowLastClicks ();
}
2014-12-01 23:55:08 +01:00
/***** All the output is made, so don't write anymore *****/
2015-11-27 21:24:24 +01:00
Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
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")))
{
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"<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
2016-12-18 19:50:33 +01:00
fprintf (Gbl.F.Out,"</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)
{
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
struct Degree Deg;
struct Course Crs;
/***** Get data of institution *****/
Ins.InsCod = InsCod;
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
/***** Get data of degree *****/
Deg.DegCod = DegCod;
Deg_GetDataOfDegreeByCod (&Deg);
/***** Get data of course *****/
Crs.CrsCod = CrsCod;
Crs_GetDataOfCourseByCod (&Crs);
/***** Table start *****/
2016-03-18 22:17:35 +01:00
fprintf (Gbl.F.Out,"<table style=\"width:100%%; padding:12px;\">"
"<tr>");
2014-12-01 23:55:08 +01:00
/***** First column: institution logo *****/
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP\" style=\"width:80px;\">");
2014-12-01 23:55:08 +01:00
if (InsCod > 0)
{
if (!PrintView)
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\">",Ins.WWW);
2016-10-28 10:03:37 +02:00
Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.ShrtName,40,NULL,true);
2014-12-01 23:55:08 +01:00
if (!PrintView)
fprintf (Gbl.F.Out,"</a>");
}
fprintf (Gbl.F.Out,"</td>");
/***** Second column: class photo title *****/
2017-03-03 21:06:34 +01:00
fprintf (Gbl.F.Out,"<td class=\"CLASSPHOTO_TITLE CENTER_MIDDLE\">");
2014-12-01 23:55:08 +01:00
if (InsCod > 0)
{
if (!PrintView)
2017-03-03 21:06:34 +01:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"CLASSPHOTO_TITLE\">",
2014-12-01 23:55:08 +01:00
Ins.WWW);
fprintf (Gbl.F.Out,"%s",Ins.FullName);
if (!PrintView)
fprintf (Gbl.F.Out,"</a>");
}
if (DegCod > 0)
{
if (Ins.InsCod > 0)
fprintf (Gbl.F.Out," - ");
if (!PrintView)
2017-03-03 21:06:34 +01:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"CLASSPHOTO_TITLE\">",
2014-12-01 23:55:08 +01:00
Deg.WWW);
fprintf (Gbl.F.Out,"%s",Deg.FullName);
if (!PrintView)
fprintf (Gbl.F.Out,"</a>");
}
fprintf (Gbl.F.Out,"<br />");
if (CrsCod > 0)
{
fprintf (Gbl.F.Out,"%s",Crs.FullName);
if (DrawingClassPhoto && !Gbl.Usrs.ClassPhoto.AllGroups)
{
fprintf (Gbl.F.Out,"<br />");
Grp_WriteNamesOfSelectedGrps ();
}
}
fprintf (Gbl.F.Out,"</td>");
/***** Third column: degree logo *****/
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"RIGHT_TOP\" style=\"width:80px;\">");
2014-12-01 23:55:08 +01:00
if (DegCod > 0)
{
if (!PrintView)
2015-08-06 12:31:05 +02:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
2017-03-03 21:06:34 +01:00
" class=\"CLASSPHOTO_TITLE\">",
2014-12-01 23:55:08 +01:00
Deg.WWW);
2016-10-28 10:03:37 +02:00
Log_DrawLogo (Sco_SCOPE_DEG,Deg.DegCod,Deg.ShrtName,40,NULL,true);
2014-12-01 23:55:08 +01:00
if (!PrintView)
fprintf (Gbl.F.Out,"</a>");
}
fprintf (Gbl.F.Out,"</td>");
2016-03-20 13:47:46 +01:00
/***** End table *****/
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</tr>"
2016-03-18 22:17:35 +01:00
"</table>");
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))
{
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<div style=\"margin-top:25px;\">");
2015-03-27 16:56:48 +01:00
2014-12-01 23:55:08 +01:00
/***** Table start *****/
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrameTable (NULL,NULL,NULL,NULL,8);
2014-12-01 23:55:08 +01:00
/***** Show advertisement *****/
fprintf (Gbl.F.Out,"<tr>"
2015-08-03 22:45:00 +02:00
"<td class=\"DAT CENTER_MIDDLE\">"
2014-12-23 14:41:10 +01:00
"<a href=\"https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid\""
" class=\"DAT\">"
2014-12-01 23:55:08 +01:00
"%s<br /><br />"
2015-07-22 11:30:21 +02:00
"<img src=\"%s/SWADroid200x300.png\""
" alt=\"SWADroid\" title=\"%s\""
2015-09-28 18:28:29 +02:00
" style=\"width:250px; height:375px;\" />"
2014-12-01 23:55:08 +01:00
"</a>"
"</td>"
"</tr>",
Txt_Stay_connected_with_SWADroid,
2015-07-22 11:30:21 +02:00
Gbl.Prefs.IconsURL,
Txt_Stay_connected_with_SWADroid);
2014-12-01 23:55:08 +01:00
/***** End table *****/
2015-04-25 14:14:19 +02:00
Lay_EndRoundFrameTable ();
2015-03-27 16:56:48 +01:00
fprintf (Gbl.F.Out,"</div>");
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++)
2015-07-22 11:30:21 +02:00
fprintf (Gbl.F.Out,"<img src=\"%s/%s20x20.gif\""
" alt=\"\" title=\"\""
2016-11-14 10:05:41 +01:00
" class=\"ICO25x25\" />",
2014-12-29 13:26:39 +01:00
Gbl.Prefs.IconsURL,
IsLastItemInLevel[i] ? "tr" :
"subleft");
/***** Level *****/
2017-04-13 23:53:57 +02:00
if (Level)
fprintf (Gbl.F.Out,"<img src=\"%s/%s20x20.gif\""
" alt=\"\" title=\"\""
" class=\"ICO25x25\" />",
Gbl.Prefs.IconsURL,
IsLastItemInLevel[Level] ? "subend" :
"submid");
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$$&nbsp;\\[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;
fprintf (Gbl.F.Out,"<div class=\"HELP_EDIT\">"
2016-03-29 01:12:43 +02:00
"%s: %s"
2016-01-17 21:46:01 +01:00
" "
2016-03-29 01:12:43 +02:00
"%s: <code>%s</code>"
2016-01-17 21:46:01 +01:00
" "
2016-03-29 01:12:43 +02:00
"%s: <code>%s</code>"
2015-04-11 02:04:23 +02:00
"</div>",
Txt_Text,Text,
Txt_Inline_math,InlineMath,
Txt_Equation_centered,Equation);
}
2016-10-03 22:41:45 +02:00
/*****************************************************************************/
/************************** Help for the text editor *************************/
/*****************************************************************************/
void Lay_StartHTMLFile (FILE *File,const char *Title)
{
2017-01-28 15:58:46 +01:00
extern const char *Txt_STR_LANG_ID[1 + Txt_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",
2016-10-03 22:41:45 +02:00
Txt_STR_LANG_ID[Gbl.Prefs.Language], // Language
Title); // Page title
}