App_FrontController.php 2.8 KB

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