App_FrontController.php 2.7 KB

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