App_FrontController.php 2.8 KB

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