article.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /*
  3. @nom: article
  4. @auteur: Maël ILLOUZ (mael.illouz@cobestran.com)
  5. @description: Page de gestion de l'affichage des articles. Sera utilisé de base ainsi que pour le scroll infini
  6. */
  7. include ('common.php');
  8. Plugin::callHook("index_pre_treatment", array(&$_));
  9. $view = "article";
  10. $articleConf = array();
  11. //recuperation de tous les flux
  12. $allFeeds = $feedManager->getFeedsPerFolder();
  13. $tpl->assign('allFeeds',$allFeeds);
  14. $scroll = isset($_['scroll']) ? $_['scroll'] : 0;
  15. $tpl->assign('scrollpage',$scroll);
  16. // récupération des variables pour l'affichage
  17. $articleConf['articlePerPages'] = $configurationManager->get('articlePerPages');
  18. $articleDisplayLink = $configurationManager->get('articleDisplayLink');
  19. $articleDisplayDate = $configurationManager->get('articleDisplayDate');
  20. $articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
  21. $articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
  22. $articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort');
  23. $articleDisplayMode = $configurationManager->get('articleDisplayMode');
  24. $optionFeedIsVerbose = $configurationManager->get('optionFeedIsVerbose');
  25. $tpl->assign('articleDisplayAuthor',$articleDisplayAuthor);
  26. $tpl->assign('articleDisplayDate',$articleDisplayDate);
  27. $tpl->assign('articleDisplayLink',$articleDisplayLink);
  28. $tpl->assign('articleDisplayMode',$articleDisplayMode);
  29. if(isset($_['hightlighted'])) {
  30. $hightlighted = $_['hightlighted'];
  31. $tpl->assign('hightlighted',$hightlighted);
  32. }
  33. $tpl->assign('time',$_SERVER['REQUEST_TIME']);
  34. $target = '`'.MYSQL_PREFIX.'event`.`title`,`'.MYSQL_PREFIX.'event`.`unread`,`'.MYSQL_PREFIX.'event`.`favorite`,`'.MYSQL_PREFIX.'event`.`feed`,';
  35. if($articleDisplayMode=='summary') $target .= '`'.MYSQL_PREFIX.'event`.`description`,';
  36. if($articleDisplayMode=='content') $target .= '`'.MYSQL_PREFIX.'event`.`content`,';
  37. if($articleDisplayLink) $target .= '`'.MYSQL_PREFIX.'event`.`link`,';
  38. if($articleDisplayDate) $target .= '`'.MYSQL_PREFIX.'event`.`pubdate`,';
  39. if($articleDisplayAuthor) $target .= '`'.MYSQL_PREFIX.'event`.`creator`,';
  40. $target .= '`'.MYSQL_PREFIX.'event`.`id`';
  41. $nblus = isset($_['nblus']) ? $_['nblus'] : 0;
  42. $articleConf['startArticle'] = ($scroll*$articleConf['articlePerPages'])-$nblus;
  43. if ($articleConf['startArticle'] < 0) $articleConf['startArticle']=0;
  44. $action = $_['action'];
  45. $tpl->assign('action',$action);
  46. $filter = array();
  47. Plugin::callHook("article_pre_action", array(&$_,&$filter,&$articleConf));
  48. switch($action){
  49. /* AFFICHAGE DES EVENEMENTS D'UN FLUX EN PARTICULIER */
  50. case 'selectedFeed':
  51. $currentFeed = $feedManager->getById($_['feed']);
  52. $allowedOrder = array('date'=>'pubdate DESC','older'=>'pubdate','unread'=>'unread DESC,pubdate DESC');
  53. $order = (isset($_['order'])?$allowedOrder[$_['order']]:$allowedOrder['unread']);
  54. $events = $currentFeed->getEvents($articleConf['startArticle'],$articleConf['articlePerPages'],$order,$target,$filter);
  55. break;
  56. /* AFFICHAGE DES EVENEMENTS D'UN DOSSIER EN PARTICULIER */
  57. case 'selectedFolder':
  58. $currentFolder = $folderManager->getById($_['folder']);
  59. if($articleDisplayFolderSort) {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` desc';} else {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` asc';}
  60. $events = $currentFolder->getEvents($articleConf['startArticle'],$articleConf['articlePerPages'],$order,$target,$filter);
  61. break;
  62. /* AFFICHAGE DES EVENEMENTS FAVORIS */
  63. case 'favorites':
  64. $filter['favorite'] = 1;
  65. $events = $eventManager->loadAllOnlyColumn($target,$filter,'pubdate DESC',$articleConf['startArticle'].','.$articleConf['articlePerPages']);
  66. break;
  67. /* AFFICHAGE DES EVENEMENTS NON LUS (COMPORTEMENT PAR DEFAUT) */
  68. case 'unreadEvents':
  69. default:
  70. $filter['unread'] = 1;
  71. if($articleDisplayHomeSort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
  72. if($optionFeedIsVerbose) {
  73. $events = $eventManager->loadAllOnlyColumn($target,$filter,$order,$articleConf['startArticle'].','.$articleConf['articlePerPages']);
  74. } else {
  75. $events = $eventManager->getEventsNotVerboseFeed($articleConf['startArticle'],$articleConf['articlePerPages'],$order,$target);
  76. }
  77. break;
  78. }
  79. $tpl->assign('events',$events);
  80. $tpl->assign('scroll',$scroll);
  81. $view = "article";
  82. Plugin::callHook("index_post_treatment", array(&$events));
  83. $html = $tpl->draw($view);
  84. ?>