Version 14.53.1

This commit is contained in:
Antonio Cañas Vargas 2015-01-04 14:49:32 +01:00
parent cc995feacf
commit 7bcf099d42
4 changed files with 242 additions and 238 deletions

View File

@ -35,12 +35,13 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 14.53 (2015/01/04)"
#define Log_PLATFORM_VERSION "SWAD 14.53.1 (2015/01/04)"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
/*
Version 14.53 :Jan 04, 2014 New module swad_calendar for calendar. (173254 lines)
Version 14.53.1 :Jan 04, 2014 Some functions moved from swad_layout to swad_menu. (173256 lines)
Version 14.53 :Jan 04, 2014 New module swad_calendar for drawing months and calendar. (173254 lines)
1 change necessary in Makefile:
Add swad_calendar.o to list of object files

View File

@ -108,9 +108,6 @@ static void Lay_DrawTabsDeskTop (void);
static void Lay_DrawTabsMobile (void);
static bool Lay_CheckIfICanViewTab (Act_Tab_t Tab);
static void Lay_DrawBreadcrumb (void);
static void Lay_WriteVerticalMenuThisTabDesktop (void);
static void Lay_WriteHorizontalMenuThisTabDesktop (void);
static void Lay_WriteMenuThisTabMobile (void);
static void Lay_WriteBreadcrumbHome (void);
static void Lay_WriteBreadcrumbTab (void);
@ -302,7 +299,7 @@ void Lay_WriteStartOfPage (void)
/* Tab content, including vertical menu (left) and main zone (right) */
fprintf (Gbl.F.Out,"<td style=\"width:140px; text-align:left;"
" vertical-align:top;\">");
Lay_WriteVerticalMenuThisTabDesktop ();
Mnu_WriteVerticalMenuThisTabDesktop ();
fprintf (Gbl.F.Out,"</td>");
}
break;
@ -314,7 +311,7 @@ void Lay_WriteStartOfPage (void)
if (Act_Actions[Act_Actions[Gbl.CurrentAct].SuperAction].IndexInMenu < 0) // Write vertical menu
{
if (Gbl.CurrentAct == ActMnu)
Lay_WriteMenuThisTabMobile ();
Mnu_WriteMenuThisTabMobile ();
else
Lay_DrawTabsMobile ();
}
@ -330,7 +327,7 @@ void Lay_WriteStartOfPage (void)
if (Gbl.Prefs.Layout == Lay_LAYOUT_DESKTOP &&
Gbl.Prefs.Menu == Mnu_MENU_HORIZONTAL)
Lay_WriteHorizontalMenuThisTabDesktop ();
Mnu_WriteHorizontalMenuThisTabDesktop ();
Usr_WarningWhenDegreeTypeDoesntAllowDirectLogin ();
@ -1119,236 +1116,6 @@ static void Lay_DrawBreadcrumb (void)
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/************* Write the menu of current tab (desktop layout) ****************/
/*****************************************************************************/
static void Lay_WriteVerticalMenuThisTabDesktop (void)
{
extern const char *The_ClassMenuOn[The_NUM_THEMES];
extern const char *The_ClassMenuOff[The_NUM_THEMES];
extern const char *The_ClassSeparator[The_NUM_THEMES];
extern const struct Act_Menu Act_Menu[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
extern const char *Txt_MENU_TITLE[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumOptInMenu;
Act_Action_t NumAct;
const char *Title;
bool IsTheSelectedAction;
bool SeparationBetweenPreviousAndCurrentOption = false;
bool PreviousVisibleOptions = false;
/***** List start *****/
fprintf (Gbl.F.Out,"<ul id=\"vertical_menu_container\">");
/***** Loop to write all options in menu. Each row holds an option *****/
for (NumOptInMenu = 0;
NumOptInMenu < Act_MAX_OPTIONS_IN_MENU_PER_TAB;
NumOptInMenu++)
{
NumAct = Act_Menu[Gbl.CurrentTab][NumOptInMenu].Action;
if (NumAct == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
break;
if (Act_CheckIfIHavePermissionToExecuteAction (NumAct))
{
IsTheSelectedAction = (NumAct == Act_Actions[Gbl.CurrentAct].SuperAction);
Title = Act_GetSubtitleAction (NumAct);
if (SeparationBetweenPreviousAndCurrentOption)
{
if (PreviousVisibleOptions)
fprintf (Gbl.F.Out,"<li>"
"<hr class=\"%s\" />"
"</li>",
The_ClassSeparator[Gbl.Prefs.Theme]);
SeparationBetweenPreviousAndCurrentOption = false;
}
/***** Start of element *****/
fprintf (Gbl.F.Out,"<li>");
/***** Start of container used to highlight this option *****/
if (!IsTheSelectedAction)
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\">");
/***** Start of form and link *****/
Act_FormStart (NumAct);
Act_LinkFormSubmit (Title,IsTheSelectedAction ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme]);
/***** Icon *****/
fprintf (Gbl.F.Out,"<div class=\"MENU_OPTION\""
" style=\"background-image: url('%s/%s/%s32x32.gif');\">",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION_32x32,
Act_Actions[NumAct].Icon);
/***** Text *****/
fprintf (Gbl.F.Out,"<div class=\"MENU_TEXT\">"
"<span class=\"%s\">%s</span>",
IsTheSelectedAction ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme],
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu]);
/***** End of link and form *****/
fprintf (Gbl.F.Out,"</div>"
"</div>"
"</a>"
"</form>");
/***** End of container used to highlight this option *****/
if (!IsTheSelectedAction)
fprintf (Gbl.F.Out,"</div>");
/***** End of element *****/
fprintf (Gbl.F.Out,"</li>");
PreviousVisibleOptions = true;
SeparationBetweenPreviousAndCurrentOption = Act_Menu[Gbl.CurrentTab][NumOptInMenu].SubsequentSeparation;
}
}
/***** List end *****/
fprintf (Gbl.F.Out,"</ul>");
}
/*****************************************************************************/
/********** Write horizontal menu of current tab (desktop layout) ************/
/*****************************************************************************/
static void Lay_WriteHorizontalMenuThisTabDesktop (void)
{
extern const char *The_ClassMenuOn[The_NUM_THEMES];
extern const char *The_ClassMenuOff[The_NUM_THEMES];
extern const struct Act_Menu Act_Menu[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
extern const char *Txt_MENU_TITLE[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumOptInMenu;
Act_Action_t NumAct;
const char *Title;
bool IsTheSelectedAction;
/***** List start *****/
fprintf (Gbl.F.Out,"<div id=\"horizontal_menu_container\">"
"<ul>");
/***** Loop to write all options in menu. Each row holds an option *****/
for (NumOptInMenu = 0;
NumOptInMenu < Act_MAX_OPTIONS_IN_MENU_PER_TAB;
NumOptInMenu++)
{
NumAct = Act_Menu[Gbl.CurrentTab][NumOptInMenu].Action;
if (NumAct == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
break;
if (Act_CheckIfIHavePermissionToExecuteAction (NumAct))
{
IsTheSelectedAction = (NumAct == Act_Actions[Gbl.CurrentAct].SuperAction);
Title = Act_GetSubtitleAction (NumAct);
/***** Start of element *****/
fprintf (Gbl.F.Out,"<li class=\"%s\">",
IsTheSelectedAction ? "MENU_ON" :
"MENU_OFF");
/***** Start of container used to highlight this option *****/
if (IsTheSelectedAction)
fprintf (Gbl.F.Out,"<div class=\"ICON_SCALED\" style=\"display:inline-block;\">");
else
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT ICON_SCALING\" style=\"display:inline-block;\">");
/***** Start of form and link *****/
Act_FormStart (NumAct);
Act_LinkFormSubmit (Title,IsTheSelectedAction ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"<img src=\"%s/%s/%s32x32.gif\""
" alt=\"%s\" class=\"ICON28x28\""
" style=\"margin:0;\" />"
"<div>%s</div>"
"</a>"
"</form>",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION_32x32,
Act_Actions[NumAct].Icon,
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu],
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu]);
/***** End of container used to highlight this option *****/
fprintf (Gbl.F.Out,"</div>");
/***** End of element *****/
fprintf (Gbl.F.Out,"</li>");
}
}
/***** List end *****/
fprintf (Gbl.F.Out,"</ul>"
"</div>");
}
/*****************************************************************************/
/************* Write the menu of current tab (mobile layout) *****************/
/*****************************************************************************/
static void Lay_WriteMenuThisTabMobile (void)
{
extern const char *The_ClassMenuOn[The_NUM_THEMES];
extern const char *The_ClassMenuOff[The_NUM_THEMES];
extern const struct Act_Menu Act_Menu[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
extern const char *Txt_MENU_TITLE[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumOptInMenu;
unsigned NumOptVisible; // Only options I can see
Act_Action_t NumAct;
const char *Title;
/***** Table start *****/
fprintf (Gbl.F.Out,"<table style=\"width:100%%;\">");
/***** Loop to write all options in menu. Each row holds an option *****/
for (NumOptInMenu = NumOptVisible = 0;
NumOptInMenu < Act_MAX_OPTIONS_IN_MENU_PER_TAB;
NumOptInMenu++)
{
if ((NumAct = Act_Menu[Gbl.CurrentTab][NumOptInMenu].Action) == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
break;
if (Act_CheckIfIHavePermissionToExecuteAction (NumAct))
{
Title = Act_GetSubtitleAction (NumAct);
if (NumOptVisible % Cfg_LAYOUT_MOBILE_NUM_COLUMNS == 0)
fprintf (Gbl.F.Out,"<tr>");
/* Icon at top and text at bottom */
fprintf (Gbl.F.Out,"<td style=\"width:25%%; text-align:center;"
" vertical-align:top;\">"
"<div class=\"ICON_HIGHLIGHT\">");
Act_FormStart (NumAct);
Act_LinkFormSubmit (Title,
(NumAct == Act_Actions[Gbl.CurrentAct].SuperAction) ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s/%s64x64.gif\""
" alt=\"%s\" class=\"ICON64x64\""
" style=\"margin:4px;\" />"
"<div>%s</div>"
"</a>"
"</form>"
"</div>"
"</td>",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION_64x64,
Act_Actions[NumAct].Icon,
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu],
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu]);
if ((NumOptVisible % Cfg_LAYOUT_MOBILE_NUM_COLUMNS) ==
(Cfg_LAYOUT_MOBILE_NUM_COLUMNS - 1))
fprintf (Gbl.F.Out,"</tr>");
NumOptVisible++;
}
}
/***** Table end *****/
fprintf (Gbl.F.Out,"</table>");
}
/*****************************************************************************/
/************************ Write home in breadcrumb ***************************/
/*****************************************************************************/

View File

@ -39,6 +39,7 @@
/*****************************************************************************/
extern struct Globals Gbl;
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
/*****************************************************************************/
/******************************** Private constants **************************/
@ -64,6 +65,237 @@ const char *Mnu_MenuIcons[Mnu_NUM_MENUS] =
"vertical",
};
/*****************************************************************************/
/************* Write the menu of current tab (desktop layout) ****************/
/*****************************************************************************/
void Mnu_WriteVerticalMenuThisTabDesktop (void)
{
extern const char *The_ClassMenuOn[The_NUM_THEMES];
extern const char *The_ClassMenuOff[The_NUM_THEMES];
extern const char *The_ClassSeparator[The_NUM_THEMES];
extern const struct Act_Menu Act_Menu[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
extern const char *Txt_MENU_TITLE[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumOptInMenu;
Act_Action_t NumAct;
const char *Title;
bool IsTheSelectedAction;
bool SeparationBetweenPreviousAndCurrentOption = false;
bool PreviousVisibleOptions = false;
/***** List start *****/
fprintf (Gbl.F.Out,"<ul id=\"vertical_menu_container\">");
/***** Loop to write all options in menu. Each row holds an option *****/
for (NumOptInMenu = 0;
NumOptInMenu < Act_MAX_OPTIONS_IN_MENU_PER_TAB;
NumOptInMenu++)
{
NumAct = Act_Menu[Gbl.CurrentTab][NumOptInMenu].Action;
if (NumAct == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
break;
if (Act_CheckIfIHavePermissionToExecuteAction (NumAct))
{
IsTheSelectedAction = (NumAct == Act_Actions[Gbl.CurrentAct].SuperAction);
Title = Act_GetSubtitleAction (NumAct);
if (SeparationBetweenPreviousAndCurrentOption)
{
if (PreviousVisibleOptions)
fprintf (Gbl.F.Out,"<li>"
"<hr class=\"%s\" />"
"</li>",
The_ClassSeparator[Gbl.Prefs.Theme]);
SeparationBetweenPreviousAndCurrentOption = false;
}
/***** Start of element *****/
fprintf (Gbl.F.Out,"<li>");
/***** Start of container used to highlight this option *****/
if (!IsTheSelectedAction)
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\">");
/***** Start of form and link *****/
Act_FormStart (NumAct);
Act_LinkFormSubmit (Title,IsTheSelectedAction ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme]);
/***** Icon *****/
fprintf (Gbl.F.Out,"<div class=\"MENU_OPTION\""
" style=\"background-image: url('%s/%s/%s32x32.gif');\">",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION_32x32,
Act_Actions[NumAct].Icon);
/***** Text *****/
fprintf (Gbl.F.Out,"<div class=\"MENU_TEXT\">"
"<span class=\"%s\">%s</span>",
IsTheSelectedAction ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme],
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu]);
/***** End of link and form *****/
fprintf (Gbl.F.Out,"</div>"
"</div>"
"</a>"
"</form>");
/***** End of container used to highlight this option *****/
if (!IsTheSelectedAction)
fprintf (Gbl.F.Out,"</div>");
/***** End of element *****/
fprintf (Gbl.F.Out,"</li>");
PreviousVisibleOptions = true;
SeparationBetweenPreviousAndCurrentOption = Act_Menu[Gbl.CurrentTab][NumOptInMenu].SubsequentSeparation;
}
}
/***** List end *****/
fprintf (Gbl.F.Out,"</ul>");
}
/*****************************************************************************/
/********** Write horizontal menu of current tab (desktop layout) ************/
/*****************************************************************************/
void Mnu_WriteHorizontalMenuThisTabDesktop (void)
{
extern const char *The_ClassMenuOn[The_NUM_THEMES];
extern const char *The_ClassMenuOff[The_NUM_THEMES];
extern const struct Act_Menu Act_Menu[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
extern const char *Txt_MENU_TITLE[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumOptInMenu;
Act_Action_t NumAct;
const char *Title;
bool IsTheSelectedAction;
/***** List start *****/
fprintf (Gbl.F.Out,"<div id=\"horizontal_menu_container\">"
"<ul>");
/***** Loop to write all options in menu. Each row holds an option *****/
for (NumOptInMenu = 0;
NumOptInMenu < Act_MAX_OPTIONS_IN_MENU_PER_TAB;
NumOptInMenu++)
{
NumAct = Act_Menu[Gbl.CurrentTab][NumOptInMenu].Action;
if (NumAct == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
break;
if (Act_CheckIfIHavePermissionToExecuteAction (NumAct))
{
IsTheSelectedAction = (NumAct == Act_Actions[Gbl.CurrentAct].SuperAction);
Title = Act_GetSubtitleAction (NumAct);
/***** Start of element *****/
fprintf (Gbl.F.Out,"<li class=\"%s\">",
IsTheSelectedAction ? "MENU_ON" :
"MENU_OFF");
/***** Start of container used to highlight this option *****/
if (IsTheSelectedAction)
fprintf (Gbl.F.Out,"<div class=\"ICON_SCALED\" style=\"display:inline-block;\">");
else
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT ICON_SCALING\" style=\"display:inline-block;\">");
/***** Start of form and link *****/
Act_FormStart (NumAct);
Act_LinkFormSubmit (Title,IsTheSelectedAction ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"<img src=\"%s/%s/%s32x32.gif\""
" alt=\"%s\" class=\"ICON28x28\""
" style=\"margin:0;\" />"
"<div>%s</div>"
"</a>"
"</form>",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION_32x32,
Act_Actions[NumAct].Icon,
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu],
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu]);
/***** End of container used to highlight this option *****/
fprintf (Gbl.F.Out,"</div>");
/***** End of element *****/
fprintf (Gbl.F.Out,"</li>");
}
}
/***** List end *****/
fprintf (Gbl.F.Out,"</ul>"
"</div>");
}
/*****************************************************************************/
/************* Write the menu of current tab (mobile layout) *****************/
/*****************************************************************************/
void Mnu_WriteMenuThisTabMobile (void)
{
extern const char *The_ClassMenuOn[The_NUM_THEMES];
extern const char *The_ClassMenuOff[The_NUM_THEMES];
extern const struct Act_Menu Act_Menu[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
extern const char *Txt_MENU_TITLE[Act_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumOptInMenu;
unsigned NumOptVisible; // Only options I can see
Act_Action_t NumAct;
const char *Title;
/***** Table start *****/
fprintf (Gbl.F.Out,"<table style=\"width:100%%;\">");
/***** Loop to write all options in menu. Each row holds an option *****/
for (NumOptInMenu = NumOptVisible = 0;
NumOptInMenu < Act_MAX_OPTIONS_IN_MENU_PER_TAB;
NumOptInMenu++)
{
if ((NumAct = Act_Menu[Gbl.CurrentTab][NumOptInMenu].Action) == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
break;
if (Act_CheckIfIHavePermissionToExecuteAction (NumAct))
{
Title = Act_GetSubtitleAction (NumAct);
if (NumOptVisible % Cfg_LAYOUT_MOBILE_NUM_COLUMNS == 0)
fprintf (Gbl.F.Out,"<tr>");
/* Icon at top and text at bottom */
fprintf (Gbl.F.Out,"<td style=\"width:25%%; text-align:center;"
" vertical-align:top;\">"
"<div class=\"ICON_HIGHLIGHT\">");
Act_FormStart (NumAct);
Act_LinkFormSubmit (Title,
(NumAct == Act_Actions[Gbl.CurrentAct].SuperAction) ? The_ClassMenuOn[Gbl.Prefs.Theme] :
The_ClassMenuOff[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s/%s64x64.gif\""
" alt=\"%s\" class=\"ICON64x64\""
" style=\"margin:4px;\" />"
"<div>%s</div>"
"</a>"
"</form>"
"</div>"
"</td>",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION_64x64,
Act_Actions[NumAct].Icon,
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu],
Txt_MENU_TITLE[Gbl.CurrentTab][NumOptInMenu]);
if ((NumOptVisible % Cfg_LAYOUT_MOBILE_NUM_COLUMNS) ==
(Cfg_LAYOUT_MOBILE_NUM_COLUMNS - 1))
fprintf (Gbl.F.Out,"</tr>");
NumOptVisible++;
}
}
/***** Table end *****/
fprintf (Gbl.F.Out,"</table>");
}
/*****************************************************************************/
/************* Put icons to select menu (horizontal or vertical) *************/
/*****************************************************************************/

View File

@ -49,6 +49,10 @@ typedef enum
/***************************** Public prototypes *****************************/
/*****************************************************************************/
void Mnu_WriteVerticalMenuThisTabDesktop (void);
void Mnu_WriteHorizontalMenuThisTabDesktop (void);
void Mnu_WriteMenuThisTabMobile (void);
void Mnu_PutIconsToSelectMenu (void);
void Mnu_ChangeMenu (void);
Mnu_Menu_t Mnu_GetParamMenu (void);