App_FrontController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Translate::init ();
  13. $this->loadParamsView ();
  14. $this->loadStylesAndScripts ();
  15. $this->loadNotifications ();
  16. }
  17. private function loadLibs () {
  18. require (LIB_PATH . '/lib_rss.php');
  19. require (LIB_PATH . '/SimplePie_autoloader.php');
  20. }
  21. private function loadModels () {
  22. include (APP_PATH . '/models/Exception/FeedException.php');
  23. include (APP_PATH . '/models/Exception/EntriesGetterException.php');
  24. include (APP_PATH . '/models/RSSConfiguration.php');
  25. include (APP_PATH . '/models/RSSThemes.php');
  26. include (APP_PATH . '/models/Days.php');
  27. include (APP_PATH . '/models/Category.php');
  28. include (APP_PATH . '/models/Feed.php');
  29. include (APP_PATH . '/models/Entry.php');
  30. include (APP_PATH . '/models/Log_Model.php');
  31. }
  32. private function loadParamsView () {
  33. try {
  34. $this->conf = Session::param ('conf', new RSSConfiguration ());
  35. } catch(MinzException $e) {
  36. // Permission denied or conf file does not exist
  37. // it's critical!
  38. print $e->getMessage();
  39. exit();
  40. }
  41. View::_param ('conf', $this->conf);
  42. Session::_param ('language', $this->conf->language ());
  43. $output = Request::param ('output');
  44. if(!$output) {
  45. $output = $this->conf->viewMode();
  46. Request::_param ('output', $output);
  47. }
  48. }
  49. private function loadStylesAndScripts () {
  50. $theme = RSSThemes::get_infos($this->conf->theme());
  51. if ($theme) {
  52. foreach($theme["files"] as $file) {
  53. View::appendStyle (Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));
  54. }
  55. }
  56. if (login_is_conf ($this->conf)) {
  57. View::appendScript ('https://login.persona.org/include.js');
  58. }
  59. $includeLazyLoad = $this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader');
  60. View::appendScript (Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad);
  61. if ($includeLazyLoad) {
  62. View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js')));
  63. }
  64. View::appendScript (Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
  65. }
  66. private function loadNotifications () {
  67. $notif = Session::param ('notification');
  68. if ($notif) {
  69. View::_param ('notification', $notif);
  70. Session::_param ('notification');
  71. }
  72. }
  73. }