App_FrontController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. }
  23. private function loadModels () {
  24. include (APP_PATH . '/models/Exception/FeedException.php');
  25. include (APP_PATH . '/models/Exception/EntriesGetterException.php');
  26. include (APP_PATH . '/models/RSSConfiguration.php');
  27. include (APP_PATH . '/models/RSSThemes.php');
  28. include (APP_PATH . '/models/Days.php');
  29. include (APP_PATH . '/models/Category.php');
  30. include (APP_PATH . '/models/Feed.php');
  31. include (APP_PATH . '/models/Entry.php');
  32. include (APP_PATH . '/models/EntriesGetter.php');
  33. include (APP_PATH . '/models/RSSPaginator.php');
  34. include (APP_PATH . '/models/Log_Model.php');
  35. }
  36. private function loadParamsView () {
  37. $this->conf = Session::param ('conf', new RSSConfiguration ());
  38. View::_param ('conf', $this->conf);
  39. Session::_param ('language', $this->conf->language ());
  40. }
  41. private function loadStylesAndScripts () {
  42. $theme = RSSThemes::get_infos($this->conf->theme());
  43. if ($theme) {
  44. foreach($theme["files"] as $file) {
  45. View::appendStyle (Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));
  46. }
  47. }
  48. View::appendStyle (Url::display ('/themes/printer/style.css?' . @filemtime(PUBLIC_PATH . '/themes/printer/style.css')), 'print');
  49. if (login_is_conf ($this->conf)) {
  50. View::appendScript ('https://login.persona.org/include.js');
  51. }
  52. View::appendScript (Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')));
  53. if ($this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader')) {
  54. View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js')));
  55. }
  56. View::appendScript (Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
  57. }
  58. private function loadNotifications () {
  59. $notif = Session::param ('notification');
  60. if ($notif) {
  61. View::_param ('notification', $notif);
  62. Session::_param ('notification');
  63. }
  64. }
  65. }