4
0

ConfigurationDAO.php 4.7 KB

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