ConfigurationDAO.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. class FreshRSS_ConfigurationDAO extends Minz_ModelArray {
  3. public $language = 'en';
  4. public $posts_per_page = 20;
  5. public $view_mode = 'normal';
  6. public $default_view = 'not_read';
  7. public $display_posts = 'no';
  8. public $onread_jump_next = 'yes';
  9. public $lazyload = 'yes';
  10. public $sort_order = 'DESC';
  11. public $old_entries = 3;
  12. public $shortcuts = array (
  13. 'mark_read' => 'r',
  14. 'mark_favorite' => 'f',
  15. 'go_website' => 'space',
  16. 'next_entry' => 'j',
  17. 'prev_entry' => 'k',
  18. 'collapse_entry' => 'c',
  19. 'load_more' => 'm'
  20. );
  21. public $mail_login = '';
  22. public $mark_when = array (
  23. 'article' => 'yes',
  24. 'site' => 'yes',
  25. 'scroll' => 'no',
  26. 'reception' => 'no'
  27. );
  28. public $sharing = array (
  29. 'shaarli' => '',
  30. 'poche' => '',
  31. 'diaspora' => '',
  32. 'twitter' => true,
  33. 'g+' => true,
  34. 'facebook' => true,
  35. 'email' => true,
  36. 'print' => true
  37. );
  38. public $theme = 'default';
  39. public $anon_access = 'no';
  40. public $token = '';
  41. public $auto_load_more = 'no';
  42. public $topline_read = 'yes';
  43. public $topline_favorite = 'yes';
  44. public $topline_date = 'yes';
  45. public $topline_link = 'yes';
  46. public $bottomline_read = 'yes';
  47. public $bottomline_favorite = 'yes';
  48. public $bottomline_sharing = 'yes';
  49. public $bottomline_tags = 'yes';
  50. public $bottomline_date = 'yes';
  51. public $bottomline_link = 'yes';
  52. public function __construct ($nameFile = '') {
  53. if (empty($nameFile)) {
  54. $nameFile = DATA_PATH . '/' . Minz_Configuration::currentUser () . '_user.php';
  55. }
  56. parent::__construct ($nameFile);
  57. // TODO : simplifier ce code, une boucle for() devrait suffire !
  58. if (isset ($this->array['language'])) {
  59. $this->language = $this->array['language'];
  60. }
  61. if (isset ($this->array['posts_per_page'])) {
  62. $this->posts_per_page = $this->array['posts_per_page'];
  63. }
  64. if (isset ($this->array['view_mode'])) {
  65. $this->view_mode = $this->array['view_mode'];
  66. }
  67. if (isset ($this->array['default_view'])) {
  68. $this->default_view = $this->array['default_view'];
  69. }
  70. if (isset ($this->array['display_posts'])) {
  71. $this->display_posts = $this->array['display_posts'];
  72. }
  73. if (isset ($this->array['onread_jump_next'])) {
  74. $this->onread_jump_next = $this->array['onread_jump_next'];
  75. }
  76. if (isset ($this->array['lazyload'])) {
  77. $this->lazyload = $this->array['lazyload'];
  78. }
  79. if (isset ($this->array['sort_order'])) {
  80. $this->sort_order = $this->array['sort_order'];
  81. }
  82. if (isset ($this->array['old_entries'])) {
  83. $this->old_entries = $this->array['old_entries'];
  84. }
  85. if (isset ($this->array['shortcuts'])) {
  86. $this->shortcuts = array_merge (
  87. $this->shortcuts, $this->array['shortcuts']
  88. );
  89. }
  90. if (isset ($this->array['mail_login'])) {
  91. $this->mail_login = $this->array['mail_login'];
  92. }
  93. if (isset ($this->array['mark_when'])) {
  94. $this->mark_when = $this->array['mark_when'];
  95. }
  96. if (isset ($this->array['sharing'])) {
  97. $this->sharing = array_merge (
  98. $this->sharing, $this->array['sharing']
  99. );
  100. }
  101. if (isset ($this->array['theme'])) {
  102. $this->theme = $this->array['theme'];
  103. }
  104. if (isset ($this->array['anon_access'])) {
  105. $this->anon_access = $this->array['anon_access'];
  106. }
  107. if (isset ($this->array['token'])) {
  108. $this->token = $this->array['token'];
  109. }
  110. if (isset ($this->array['auto_load_more'])) {
  111. $this->auto_load_more = $this->array['auto_load_more'];
  112. }
  113. if (isset ($this->array['topline_read'])) {
  114. $this->topline_read = $this->array['topline_read'];
  115. }
  116. if (isset ($this->array['topline_favorite'])) {
  117. $this->topline_favorite = $this->array['topline_favorite'];
  118. }
  119. if (isset ($this->array['topline_date'])) {
  120. $this->topline_date = $this->array['topline_date'];
  121. }
  122. if (isset ($this->array['topline_link'])) {
  123. $this->topline_link = $this->array['topline_link'];
  124. }
  125. if (isset ($this->array['bottomline_read'])) {
  126. $this->bottomline_read = $this->array['bottomline_read'];
  127. }
  128. if (isset ($this->array['bottomline_favorite'])) {
  129. $this->bottomline_favorite = $this->array['bottomline_favorite'];
  130. }
  131. if (isset ($this->array['bottomline_sharing'])) {
  132. $this->bottomline_sharing = $this->array['bottomline_sharing'];
  133. }
  134. if (isset ($this->array['bottomline_tags'])) {
  135. $this->bottomline_tags = $this->array['bottomline_tags'];
  136. }
  137. if (isset ($this->array['bottomline_date'])) {
  138. $this->bottomline_date = $this->array['bottomline_date'];
  139. }
  140. if (isset ($this->array['bottomline_link'])) {
  141. $this->bottomline_link = $this->array['bottomline_link'];
  142. }
  143. }
  144. public function update ($values) {
  145. foreach ($values as $key => $value) {
  146. $this->array[$key] = $value;
  147. }
  148. $this->writeFile($this->array);
  149. invalidateHttpCache();
  150. }
  151. }