2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_pagination.h: pagination of assignments, forums and messages
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_PAG
|
|
|
|
|
#define _SWAD_PAG
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2020-01-01 14:53:57 +01:00
|
|
|
|
Copyright (C) 1999-2020 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 **********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
#include "swad_forum.h"
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define Pag_ITEMS_PER_PAGE 10
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Public types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-02-29 14:13:55 +01:00
|
|
|
|
#define Pag_NUM_WHAT_PAGINATE 11
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2020-02-29 14:13:55 +01:00
|
|
|
|
Pag_ASSIGNMENTS = 0,
|
|
|
|
|
Pag_PROJECTS = 1,
|
|
|
|
|
Pag_GAMES = 2,
|
|
|
|
|
Pag_SURVEYS = 3,
|
|
|
|
|
Pag_ATT_EVENTS = 4,
|
|
|
|
|
Pag_THREADS_FORUM = 5,
|
|
|
|
|
Pag_POSTS_FORUM = 6,
|
|
|
|
|
Pag_MESSAGES_RECEIVED = 7,
|
|
|
|
|
Pag_MESSAGES_SENT = 8,
|
|
|
|
|
Pag_MY_AGENDA = 9,
|
|
|
|
|
Pag_ANOTHER_AGENDA = 10,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
} Pag_WhatPaginate_t;
|
|
|
|
|
|
|
|
|
|
struct Pagination // Used for threads and messages pagination
|
|
|
|
|
{
|
|
|
|
|
unsigned NumItems;
|
2017-04-18 16:44:44 +02:00
|
|
|
|
unsigned StartPage;
|
|
|
|
|
unsigned LeftPage;
|
|
|
|
|
unsigned CurrentPage; // 1, 2, 3...
|
|
|
|
|
unsigned RightPage;
|
|
|
|
|
unsigned EndPage;
|
|
|
|
|
unsigned NumPags;
|
2016-10-26 01:23:02 +02:00
|
|
|
|
unsigned FirstItemVisible; // 1, 2, 3...
|
|
|
|
|
unsigned LastItemVisible; // 1, 2, 3...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool MoreThanOnePage;
|
2017-04-11 15:17:27 +02:00
|
|
|
|
char *Anchor; // Anchor in forms. Use NULL when not needed
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Pag_CalculatePagination (struct Pagination *Pagination);
|
2017-04-17 11:57:55 +02:00
|
|
|
|
void Pag_WriteLinksToPagesCentered (Pag_WhatPaginate_t WhatPaginate,
|
2019-12-11 00:13:09 +01:00
|
|
|
|
struct Pagination *Pagination,
|
2020-04-10 19:14:08 +02:00
|
|
|
|
const void *Context,long Cod);
|
2017-04-17 11:57:55 +02:00
|
|
|
|
void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|
|
|
|
struct Pagination *Pagination,
|
2020-04-10 19:14:08 +02:00
|
|
|
|
const void *Context,long Cod,
|
2019-11-18 18:19:41 +01:00
|
|
|
|
bool FirstMsgEnabled,
|
|
|
|
|
const char *Subject,const char *ClassTxt,
|
2017-04-17 11:57:55 +02:00
|
|
|
|
bool LinkToPagCurrent);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
void Pag_PutHiddenParamPagNum (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
|
|
|
|
unsigned Pag_GetParamPagNum (Pag_WhatPaginate_t WhatPaginate);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
void Pag_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
|
|
|
|
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate);
|
|
|
|
|
|
|
|
|
|
#endif
|