FreshRSS.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. class FreshRSS extends Minz_FrontController {
  3. public function init () {
  4. Minz_Session::init ();
  5. Minz_Translate::init ();
  6. $this->loadParamsView ();
  7. $this->loadStylesAndScripts ();
  8. $this->loadNotifications ();
  9. }
  10. private function loadParamsView () {
  11. try {
  12. $this->conf = Minz_Session::param ('conf', new FreshRSS_Configuration ());
  13. } catch (Minz_Exception $e) {
  14. // Permission denied or conf file does not exist
  15. // it's critical!
  16. print $e->getMessage();
  17. exit();
  18. }
  19. Minz_View::_param ('conf', $this->conf);
  20. Minz_Session::_param ('language', $this->conf->language ());
  21. $output = Minz_Request::param ('output');
  22. if(!$output) {
  23. $output = $this->conf->viewMode();
  24. Minz_Request::_param ('output', $output);
  25. }
  26. }
  27. private function loadStylesAndScripts () {
  28. $theme = FreshRSS_Themes::get_infos($this->conf->theme());
  29. if ($theme) {
  30. foreach($theme["files"] as $file) {
  31. Minz_View::appendStyle (Minz_Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));
  32. }
  33. }
  34. if (login_is_conf ($this->conf)) {
  35. Minz_View::appendScript ('https://login.persona.org/include.js');
  36. }
  37. $includeLazyLoad = $this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Minz_Request::param ('output') === 'reader');
  38. Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad);
  39. if ($includeLazyLoad) {
  40. Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js')));
  41. }
  42. Minz_View::appendScript (Minz_Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
  43. }
  44. private function loadNotifications () {
  45. $notif = Minz_Session::param ('notification');
  46. if ($notif) {
  47. Minz_View::_param ('notification', $notif);
  48. Minz_Session::_param ('notification');
  49. }
  50. }
  51. }