index.php 7.6 KB

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