index.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /*
  3. @nom: index
  4. @auteur: Idleman (http://blog.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. //afficher ou non le champ OTP
  27. $tpl->assign('otpEnabled', $configurationManager->get('otpEnabled'));
  28. $articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
  29. $articleDisplayDate = $configurationManager->get('articleDisplayDate');
  30. $articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort');
  31. $articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
  32. $articleDisplayLink = $configurationManager->get('articleDisplayLink');
  33. $articleDisplayMode = $configurationManager->get('articleDisplayMode');
  34. $articlePerPages = $configurationManager->get('articlePerPages');
  35. $displayOnlyUnreadFeedFolder = $configurationManager->get('displayOnlyUnreadFeedFolder');
  36. if (!isset($displayOnlyUnreadFeedFolder)) $displayOnlyUnreadFeedFolder=false;
  37. ($displayOnlyUnreadFeedFolder=='true')?$displayOnlyUnreadFeedFolder_reverse='false':$displayOnlyUnreadFeedFolder_reverse='true';
  38. $optionFeedIsVerbose = $configurationManager->get('optionFeedIsVerbose');
  39. $tpl->assign('articleDisplayAuthor',$articleDisplayAuthor);
  40. $tpl->assign('articleDisplayDate',$articleDisplayDate);
  41. $tpl->assign('articleDisplayFolderSort',$articleDisplayFolderSort);
  42. $tpl->assign('articleDisplayHomeSort',$articleDisplayHomeSort);
  43. $tpl->assign('articleDisplayLink',$articleDisplayLink);
  44. $tpl->assign('articleDisplayMode',$articleDisplayMode);
  45. $tpl->assign('articlePerPages',$articlePerPages);
  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($articleDisplayMode=='summary') $target .= '`'.MYSQL_PREFIX.'event`.`description`,';
  50. if($articleDisplayMode=='content') $target .= '`'.MYSQL_PREFIX.'event`.`content`,';
  51. if($articleDisplayLink) $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',0);
  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['unread']);
  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 DOSSIER EN PARTICULIER */
  75. case 'selectedFolder':
  76. $currentFolder = $folderManager->getById($_['folder']);
  77. $tpl->assign('currentFolder',$currentFolder);
  78. $numberOfItem = $currentFolder->unreadCount();
  79. $page = (isset($_['page'])?$_['page']:1);
  80. $pages = ceil($numberOfItem/$articlePerPages);
  81. $startArticle = ($page-1)*$articlePerPages;
  82. if($articleDisplayFolderSort) {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` desc';} else {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` asc';}
  83. $events = $currentFolder->getEvents($startArticle,$articlePerPages,$order,$target);
  84. break;
  85. /* AFFICHAGE DES EVENEMENTS FAVORIS */
  86. case 'favorites':
  87. $numberOfItem = $eventManager->rowCount(array('favorite'=>1));
  88. $page = (isset($_['page'])?$_['page']:1);
  89. $pages = ceil($numberOfItem/$articlePerPages);
  90. $startArticle = ($page-1)*$articlePerPages;
  91. $events = $eventManager->loadAllOnlyColumn($target,array('favorite'=>1),'pubdate DESC',$startArticle.','.$articlePerPages);
  92. $tpl->assign('numberOfItem',$numberOfItem);
  93. break;
  94. /* AFFICHAGE DES EVENEMENTS NON LUS (COMPORTEMENT PAR DEFAUT) */
  95. case 'unreadEvents':
  96. case 'wrongLogin':
  97. $wrongLogin = true;
  98. default:
  99. $wrongLogin = !empty($wrongLogin);
  100. $filter = array('unread'=>1);
  101. if($optionFeedIsVerbose) {
  102. $numberOfItem = $eventManager->rowCount($filter);
  103. } else {
  104. $numberOfItem = $eventManager->getEventCountNotVerboseFeed();
  105. }
  106. $page = (isset($_['page'])?$_['page']:1);
  107. $pages = ($articlePerPages>0?ceil($numberOfItem/$articlePerPages):1);
  108. $startArticle = ($page-1)*$articlePerPages;
  109. if($articleDisplayHomeSort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
  110. if($optionFeedIsVerbose) {
  111. $events = $eventManager->loadAllOnlyColumn($target,$filter,$order,$startArticle.','.$articlePerPages);
  112. } else {
  113. $events = $eventManager->getEventsNotVerboseFeed($startArticle,$articlePerPages,$order,$target);
  114. }
  115. $tpl->assign('numberOfItem',$numberOfItem);
  116. $tpl->assign('wrongLogin',$wrongLogin);
  117. break;
  118. }
  119. $tpl->assign('pages',$pages);
  120. $tpl->assign('page',$page);
  121. $paginationScale = $configurationManager->get('paginationScale');
  122. if (empty($paginationScale)) {
  123. $configurationManager->put('paginationScale', 5);
  124. $paginationScale = $configurationManager->get('paginationScale');
  125. }
  126. for($i=($page-$paginationScale<=0?1:$page-$paginationScale);$i<($page+$paginationScale>$pages+1?$pages+1:$page+$paginationScale);$i++){
  127. $pagesArray[]=$i;
  128. }
  129. $tpl->assign('pagesArray',$pagesArray);
  130. $tpl->assign('previousPages',($page-$paginationScale<0?-1:$page-$paginationScale-1));
  131. $tpl->assign('nextPages',($page+$paginationScale>$pages+1?-1:$page+$paginationScale));
  132. Plugin::callHook("index_post_treatment", array(&$events));
  133. $tpl->assign('events',$events);
  134. $tpl->assign('time',$_SERVER['REQUEST_TIME']);
  135. $tpl->assign('hightlighted',0);
  136. $tpl->assign('scroll',false);
  137. $view = 'index';
  138. require_once('footer.php');
  139. ?>