index.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. $articleDisplayContent = $configurationManager->get('articleDisplayContent');
  24. $articleView = $configurationManager->get('articleView');
  25. $articlePerPages = $configurationManager->get('articlePerPages');
  26. $articleDisplayLink = $configurationManager->get('articleDisplayLink');
  27. $articleDisplayDate = $configurationManager->get('articleDisplayDate');
  28. $articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
  29. $articleDisplaySort = $configurationManager->get('articleDisplaySort');
  30. $tpl->assign('articleDisplayContent',$configurationManager->get('articleDisplayContent'));
  31. $tpl->assign('articleView',$configurationManager->get('articleView'));
  32. $tpl->assign('articlePerPages',$configurationManager->get('articlePerPages'));
  33. $tpl->assign('articleDisplayLink',$configurationManager->get('articleDisplayLink'));
  34. $tpl->assign('articleDisplayDate',$configurationManager->get('articleDisplayDate'));
  35. $tpl->assign('articleDisplayAuthor',$configurationManager->get('articleDisplayAuthor'));
  36. $tpl->assign('articleDisplaySort',$configurationManager->get('articleDisplaySort'));
  37. $target = MYSQL_PREFIX.'event.title,'.MYSQL_PREFIX.'event.unread,'.MYSQL_PREFIX.'event.favorite,'.MYSQL_PREFIX.'event.feed,';
  38. if($articleDisplayContent && $articleView=='partial') $target .= MYSQL_PREFIX.'event.description,';
  39. if($articleDisplayContent && $articleView!='partial') $target .= MYSQL_PREFIX.'event.content,';
  40. if($articleDisplayLink) $target .= MYSQL_PREFIX.'event.link,';
  41. if($articleDisplayDate) $target .= MYSQL_PREFIX.'event.pubdate,';
  42. if($articleDisplayAuthor) $target .= MYSQL_PREFIX.'event.creator,';
  43. $target .= MYSQL_PREFIX.'event.id';
  44. $tpl->assign('target',$target);
  45. $tpl->assign('feeds','');
  46. $tpl->assign('order','');
  47. $tpl->assign('unreadEventsForFolder','');
  48. $pagesArray = array();
  49. switch($action){
  50. /* AFFICHAGE DES EVENEMENTS D'UN FLUX EN PARTICULIER */
  51. case 'selectedFeed':
  52. $currentFeed = $feedManager->getById($_['feed']);
  53. $tpl->assign('currentFeed',$currentFeed);
  54. $numberOfItem = $eventManager->rowCount(array('feed'=>$currentFeed->getId()));
  55. $allowedOrder = array('date'=>'pubdate DESC','older'=>'pubdate','unread'=>'unread DESC,pubdate DESC');
  56. $order = (isset($_['order'])?$allowedOrder[$_['order']]:$allowedOrder['date']);
  57. $page = (isset($_['page'])?$_['page']:1);
  58. $pages = ceil($numberOfItem/$articlePerPages);
  59. $startArticle = ($page-1)*$articlePerPages;
  60. $events = $currentFeed->getEvents($startArticle,$articlePerPages,$order,$target);
  61. $tpl->assign('order',(isset($_['order'])?$_['order']:''));
  62. break;
  63. /* AFFICHAGE DES EVENEMENTS D'UN DOSSIER EN PARTICULIER */
  64. case 'selectedFolder':
  65. $currentFolder = $folderManager->getById($_['folder']);
  66. $tpl->assign('currentFolder',$currentFolder);
  67. $numberOfItem = $currentFolder->unreadCount();
  68. $page = (isset($_['page'])?$_['page']:1);
  69. $pages = ceil($numberOfItem/$articlePerPages);
  70. $startArticle = ($page-1)*$articlePerPages;
  71. $events = $currentFolder->getEvents($startArticle,$articlePerPages,MYSQL_PREFIX.'event.pubdate DESC',$target);
  72. break;
  73. /* AFFICHAGE DES EVENEMENTS FAVORIS */
  74. case 'favorites':
  75. $numberOfItem = $eventManager->rowCount(array('favorite'=>1));
  76. $page = (isset($_['page'])?$_['page']:1);
  77. $pages = ceil($numberOfItem/$articlePerPages);
  78. $startArticle = ($page-1)*$articlePerPages;
  79. $events = $eventManager->loadAllOnlyColumn($target,array('favorite'=>1),'pubDate DESC',$startArticle.','.$articlePerPages);
  80. $tpl->assign('numberOfItem',$numberOfItem);
  81. break;
  82. /* AFFICHAGE DES EVENEMENTS NON LUS (COMPORTEMENT PAR DEFAUT) */
  83. case 'unreadEvents':
  84. default:
  85. $numberOfItem = $eventManager->rowCount(array('unread'=>1));
  86. $page = (isset($_['page'])?$_['page']:1);
  87. $pages = ceil($numberOfItem/$articlePerPages);
  88. $startArticle = ($page-1)*$articlePerPages;
  89. if($articleDisplaySort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
  90. $events = $eventManager->loadAllOnlyColumn($target,array('unread'=>1),$order,$startArticle.','.$articlePerPages);
  91. $tpl->assign('numberOfItem',$numberOfItem);
  92. break;
  93. }
  94. $tpl->assign('pages',$pages);
  95. $tpl->assign('page',$page);
  96. for($i=($page-PAGINATION_SCALE<=0?1:$page-PAGINATION_SCALE);$i<($page+PAGINATION_SCALE>$pages+1?$pages+1:$page+PAGINATION_SCALE);$i++){
  97. $pagesArray[]=$i;
  98. }
  99. $tpl->assign('pagesArray',$pagesArray);
  100. $tpl->assign('previousPages',($page-PAGINATION_SCALE<0?-1:$page-PAGINATION_SCALE-1));
  101. $tpl->assign('nextPages',($page+PAGINATION_SCALE>$pages+1?-1:$page+PAGINATION_SCALE));
  102. Plugin::callHook("index_post_treatment", array(&$events));
  103. $tpl->assign('events',$events);
  104. $tpl->assign('time',$_SERVER['REQUEST_TIME']);
  105. $tpl->assign('hightlighted',0);
  106. $view = 'index';
  107. require_once('footer.php');
  108. ?>