App_FrontController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * MINZ - Copyright 2011 Marien Fressinaud
  4. * Sous licence AGPL3 <http://www.gnu.org/licenses/>
  5. */
  6. require ('FrontController.php');
  7. class App_FrontController extends FrontController {
  8. public function init () {
  9. $this->loadLibs ();
  10. $this->loadModels ();
  11. Session::init ();
  12. RSSThemes::init ();
  13. Translate::init ();
  14. $this->loadParamsView ();
  15. $this->loadStylesAndScripts ();
  16. $this->loadNotifications ();
  17. }
  18. private function loadLibs () {
  19. require (LIB_PATH . '/lib_phpQuery.php');
  20. require (LIB_PATH . '/lib_rss.php');
  21. require (LIB_PATH . '/SimplePie_autoloader.php');
  22. require (LIB_PATH . '/lib_text.php');
  23. }
  24. private function loadModels () {
  25. include (APP_PATH . '/models/Exception/FeedException.php');
  26. include (APP_PATH . '/models/Exception/EntriesGetterException.php');
  27. include (APP_PATH . '/models/RSSConfiguration.php');
  28. include (APP_PATH . '/models/RSSThemes.php');
  29. include (APP_PATH . '/models/Days.php');
  30. include (APP_PATH . '/models/Category.php');
  31. include (APP_PATH . '/models/Feed.php');
  32. include (APP_PATH . '/models/Entry.php');
  33. include (APP_PATH . '/models/EntriesGetter.php');
  34. include (APP_PATH . '/models/RSSPaginator.php');
  35. include (APP_PATH . '/models/Log.php');
  36. }
  37. private function loadParamsView () {
  38. $this->conf = Session::param ('conf', new RSSConfiguration ());
  39. View::_param ('conf', $this->conf);
  40. $entryDAO = new EntryDAO ();
  41. View::_param ('nb_not_read', $entryDAO->countNotRead ());
  42. Session::_param ('language', $this->conf->language ());
  43. }
  44. private function loadStylesAndScripts () {
  45. $theme = RSSThemes::get_infos($this->conf->theme());
  46. if ($theme) {
  47. foreach($theme["files"] as $file) {
  48. View::appendStyle (Url::display ('/themes/' . $theme['path'] . '/' . $file));
  49. }
  50. }
  51. View::appendStyle (Url::display ('/themes/printer/style.css'), 'print');
  52. if (login_is_conf ($this->conf)) {
  53. View::appendScript ('https://login.persona.org/include.js');
  54. }
  55. View::appendScript (Url::display ('/scripts/jquery.min.js'));
  56. if ($this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader')) {
  57. View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js'));
  58. }
  59. }
  60. private function loadNotifications () {
  61. $notif = Session::param ('notification');
  62. if ($notif) {
  63. View::_param ('notification', $notif);
  64. Session::_param ('notification');
  65. }
  66. }
  67. }