-
Notifications
You must be signed in to change notification settings - Fork 41
/
index.php
170 lines (148 loc) · 7.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/*
@nom: index
@auteur: Idleman (http://blog.idleman.fr)
@description: Page d'accueil et de lecture des flux
*/
require_once('header.php');
Plugin::callHook("index_pre_treatment", array(&$_));
//Récuperation de l'action (affichage) demandée
$action = (isset($_['action'])?$_['action']:'');
$tpl->assign('action',$action);
if($isAlwaysDisplayed) {
//Récuperation des dossiers de flux par ordre de nom
$tpl->assign('folders',$folderManager->populate('name'));
//Recuperation de tous les non Lu
$tpl->assign('unread',$feedManager->countUnreadEvents());
//recuperation de tous les flux
$allFeeds = $feedManager->getFeedsPerFolder();
$tpl->assign('allFeeds',$allFeeds);
//recuperation de tous les flux par dossier
$tpl->assign('allFeedsPerFolder',$allFeeds['folderMap']);
//recuperation de tous les event nons lu par dossiers
$tpl->assign('allEvents',$eventManager->getEventCountPerFolder());
//utilisé pour récupérer le statut d'un feed dans le template (en erreur ou ok)
$feedState = new Feed();
$tpl->assign('feedState',$feedState);
}
$articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
$articleDisplayDate = $configurationManager->get('articleDisplayDate');
$articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort');
$articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
$articleDisplayLink = $configurationManager->get('articleDisplayLink');
$articleDisplayMode = $configurationManager->get('articleDisplayMode');
$articlePerPages = (int) $configurationManager->get('articlePerPages');
$displayOnlyUnreadFeedFolder = $configurationManager->get('displayOnlyUnreadFeedFolder');
if (!isset($displayOnlyUnreadFeedFolder)) $displayOnlyUnreadFeedFolder=false;
($displayOnlyUnreadFeedFolder=='true')?$displayOnlyUnreadFeedFolder_reverse='false':$displayOnlyUnreadFeedFolder_reverse='true';
$optionFeedIsVerbose = $configurationManager->get('optionFeedIsVerbose');
$page = isset($_['page']) && (int) $_['page'] > 1 ? (int) $_['page'] : 1;
$startArticle = ($page - 1) * $articlePerPages;
$numberOfItem= 0;
$tpl->assign('articleDisplayAuthor',$articleDisplayAuthor);
$tpl->assign('articleDisplayDate',$articleDisplayDate);
$tpl->assign('articleDisplayFolderSort',$articleDisplayFolderSort);
$tpl->assign('articleDisplayHomeSort',$articleDisplayHomeSort);
$tpl->assign('articleDisplayLink',$articleDisplayLink);
$tpl->assign('articleDisplayMode',$articleDisplayMode);
$tpl->assign('articlePerPages',$articlePerPages);
$tpl->assign('displayOnlyUnreadFeedFolder',$displayOnlyUnreadFeedFolder);
$tpl->assign('displayOnlyUnreadFeedFolder_reverse',$displayOnlyUnreadFeedFolder_reverse);
$target = '`'.MYSQL_PREFIX.'event`.`title`,`'.MYSQL_PREFIX.'event`.`unread`,`'.MYSQL_PREFIX.'event`.`favorite`,`'.MYSQL_PREFIX.'event`.`feed`,';
if($articleDisplayMode=='summary') $target .= '`'.MYSQL_PREFIX.'event`.`description`,';
if($articleDisplayMode=='content') $target .= '`'.MYSQL_PREFIX.'event`.`content`,';
if($articleDisplayLink) $target .= '`'.MYSQL_PREFIX.'event`.`link`,';
if($articleDisplayDate) $target .= '`'.MYSQL_PREFIX.'event`.`pubdate`,';
if($articleDisplayAuthor) $target .= '`'.MYSQL_PREFIX.'event`.`creator`,';
$target .= '`'.MYSQL_PREFIX.'event`.`id`';
$tpl->assign('target',$target);
$tpl->assign('feeds',[]);
$tpl->assign('order','');
$tpl->assign('unreadEventsForFolder',0);
$pagesArray = array();
switch($action){
/* AFFICHAGE DES EVENEMENTS D'UN FLUX EN PARTICULIER */
case 'selectedFeed':
$currentFeed = $feedManager->getById($_['feed']);
if(!is_object($currentFeed)) {
header('location: ./');
exit;
}
$tpl->assign('currentFeed',$currentFeed);
$numberOfItem = $eventManager->rowCount(array('feed'=>$currentFeed->getId()));
$allowedOrder = array(
'date' => 'pubdate DESC',
'older' => 'pubdate',
'unread' => 'unread DESC,pubdate DESC'
);
$orderKey = isset($_['order']) && array_key_exists($_['order'], $allowedOrder) ?
$_['order'] : 'unread';
$order = $allowedOrder[$orderKey];
$events = $currentFeed->getEvents($order,$startArticle,$articlePerPages,$target);
$tpl->assign('order', $orderKey);
break;
/* AFFICHAGE DES EVENEMENTS D'UN DOSSIER EN PARTICULIER */
case 'selectedFolder':
$currentFolder = $folderManager->getById($_['folder']);
if(!is_object($currentFolder)) {
header('location: ./');
exit;
}
$tpl->assign('currentFolder',$currentFolder);
$numberOfItem = $currentFolder->unreadCount();
if($articleDisplayFolderSort) {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` desc';} else {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` asc';}
$events = $currentFolder->getEvents($order,$startArticle,$articlePerPages,$target);
break;
/* AFFICHAGE DES EVENEMENTS FAVORIS */
case 'favorites':
$numberOfItem = $eventManager->rowCount(array('favorite'=>1));
$events = $eventManager->loadAllOnlyColumn($target,array('favorite'=>1),'pubdate DESC',$startArticle.','.$articlePerPages);
$tpl->assign('numberOfItem',$numberOfItem);
break;
/* AFFICHAGE DES EVENEMENTS NON LUS (COMPORTEMENT PAR DEFAUT) */
case 'unreadEvents':
case 'wrongLogin':
$wrongLogin = true;
default:
$wrongLogin = !empty($wrongLogin);
$tpl->assign('wrongLogin',$wrongLogin);
if(!$isAlwaysDisplayed) {
break;
}
$filter = array('unread'=>1);
if($optionFeedIsVerbose) {
$numberOfItem = $eventManager->rowCount($filter);
} else {
$numberOfItem = $eventManager->getEventCountNotVerboseFeed();
}
if($articleDisplayHomeSort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
if($optionFeedIsVerbose) {
$events = $eventManager->loadAllOnlyColumn($target,$filter,$order,$startArticle.','.$articlePerPages);
} else {
$events = $eventManager->getEventsNotVerboseFeed($order,$startArticle,$articlePerPages,$target);
}
$tpl->assign('numberOfItem',$numberOfItem);
break;
}
$pages = ceil($numberOfItem/$articlePerPages);
$tpl->assign('pages',$pages);
$tpl->assign('page',$page);
$paginationScale = $configurationManager->get('paginationScale');
if (empty($paginationScale)) {
$configurationManager->put('paginationScale', 5);
$paginationScale = $configurationManager->get('paginationScale');
}
for($i=($page-$paginationScale<=0?1:$page-$paginationScale);$i<($page+$paginationScale>$pages+1?$pages+1:$page+$paginationScale);$i++){
$pagesArray[]=$i;
}
$tpl->assign('pagesArray',$pagesArray);
$tpl->assign('previousPages',($page-$paginationScale<0?-1:$page-$paginationScale-1));
$tpl->assign('nextPages',($page+$paginationScale>$pages+1?-1:$page+$paginationScale));
Plugin::callHook("index_post_treatment", array(&$events));
$tpl->assign('events',$events);
$tpl->assign('time',$_SERVER['REQUEST_TIME']);
$tpl->assign('hightlighted',0);
$tpl->assign('scroll',false);
$view = 'index';
require_once('footer.php');
?>