archiving.phtml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. $this->partial('aside_configure');
  5. ?>
  6. <main class="post">
  7. <h1><?= _t('conf.archiving') ?></h1>
  8. <p class="help"><?= _i('help') ?> <?= _t('conf.archiving.help') ?></p>
  9. <form method="post" action="<?= _url('configure', 'archiving') ?>">
  10. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  11. <div class="form-group">
  12. <label class="group-name" for="ttl_default"><?= _t('conf.archiving.ttl') ?></label>
  13. <div class="group-controls">
  14. <select class="number" name="ttl_default" id="ttl_default" required="required" data-leave-validation="<?= FreshRSS_Context::userConf()->ttl_default ?>"><?php
  15. $found = false;
  16. foreach ([1200 => '20min', 1500 => '25min', 1800 => '30min', 2700 => '45min',
  17. 3600 => '1h', 5400 => '1.5h', 7200 => '2h', 10800 => '3h', 14400 => '4h', 18800 => '5h', 21600 => '6h', 25200 => '7h', 28800 => '8h',
  18. 36000 => '10h', 43200 => '12h', 64800 => '18h',
  19. 86400 => '1d', 129600 => '1.5d', 172800 => '2d', 259200 => '3d', 345600 => '4d', 432000 => '5d', 518400 => '6d',
  20. 604800 => '1wk'] as $v => $t) {
  21. echo '<option value="' . $v . (FreshRSS_Context::userConf()->ttl_default == $v ? '" selected="selected' : '') . '">' . $t . '</option>';
  22. if (FreshRSS_Context::userConf()->ttl_default == $v) {
  23. $found = true;
  24. }
  25. }
  26. if (!$found) {
  27. echo '<option value="' . intval(FreshRSS_Context::userConf()->ttl_default) . '" selected="selected">'
  28. . intval(FreshRSS_Context::userConf()->ttl_default) . 's</option>';
  29. }
  30. ?></select> (<?= _t('gen.short.by_default') ?>)
  31. </div>
  32. </div>
  33. <p class="alert alert-warn">
  34. <?= _t('conf.archiving.policy_warning') ?>
  35. </p>
  36. <div class="form-group">
  37. <label class="group-name"><?= _t('conf.archiving.policy') ?><br /><small>(<?= _t('gen.short.by_default') ?>)</small></label>
  38. <div class="group-controls">
  39. <label class="checkbox" for="enable_keep_max">
  40. <input type="checkbox" name="enable_keep_max" id="enable_keep_max" value="1"<?=
  41. empty(FreshRSS_Context::userConf()->archiving['keep_max']) ? '' : ' checked="checked"' ?>
  42. data-leave-validation="<?= empty(FreshRSS_Context::userConf()->archiving['keep_max']) ? 0 : 1 ?>"/>
  43. <?= _t('conf.archiving.keep_max') ?>
  44. <?php $keepMax = empty(FreshRSS_Context::userConf()->archiving['keep_max']) ? 200 : FreshRSS_Context::userConf()->archiving['keep_max']; ?>
  45. <input type="number" id="keep_max" name="keep_max" min="0" value="<?= $keepMax ?>" data-leave-validation="<?= $keepMax ?>"/>
  46. </label>
  47. </div>
  48. </div>
  49. <div class="form-group">
  50. <div class="group-controls">
  51. <label class="checkbox" for="enable_keep_period">
  52. <input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?=
  53. empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? '' : ' checked="checked"' ?>
  54. data-leave-validation="<?= empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? 0 : 1 ?>"/>
  55. <?= _t('conf.archiving.keep_period') ?>
  56. <input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"
  57. data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"/>
  58. <select class="number" name="keep_period_unit" id="keep_period_unit" data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['keep_period_unit'] ?>">
  59. <option></option>
  60. <option value="P1Y" <?= 'P1Y' === FreshRSS_Context::userConf()->volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.years') ?></option>
  61. <option value="P1M" <?= 'P1M' === FreshRSS_Context::userConf()->volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.months') ?></option>
  62. <option value="P1W" <?= 'P1W' === FreshRSS_Context::userConf()->volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.weeks') ?></option>
  63. <option value="P1D" <?= 'P1D' === FreshRSS_Context::userConf()->volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.days') ?></option>
  64. <option value="PT1H" <?= 'PT1H' === FreshRSS_Context::userConf()->volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.hours') ?></option>
  65. </select>
  66. </label>
  67. </div>
  68. </div>
  69. <div class="form-group">
  70. <label class="group-name"><?= _t('conf.archiving.exception') ?><br /><small>(<?= _t('gen.short.by_default') ?>)</small></label>
  71. <div class="group-controls">
  72. <label class="checkbox" for="keep_favourites">
  73. <input type="checkbox" name="keep_favourites" id="keep_favourites" value="1"<?=
  74. FreshRSS_Context::userConf()->archiving['keep_favourites'] !== false ? ' checked="checked"' : '' ?>
  75. data-leave-validation="<?= FreshRSS_Context::userConf()->archiving['keep_favourites'] !== false ? 1 : 0 ?>"/>
  76. <?= _t('conf.archiving.keep_favourites') ?>
  77. </label>
  78. </div>
  79. </div>
  80. <div class="form-group">
  81. <div class="group-controls">
  82. <label class="checkbox" for="keep_labels">
  83. <input type="checkbox" name="keep_labels" id="keep_labels" value="1"<?=
  84. FreshRSS_Context::userConf()->archiving['keep_labels'] !== false ? ' checked="checked"' : '' ?>
  85. data-leave-validation="<?= FreshRSS_Context::userConf()->archiving['keep_labels'] !== false ? 1 : 0 ?>"/>
  86. <?= _t('conf.archiving.keep_labels') ?>
  87. </label>
  88. </div>
  89. </div>
  90. <div class="form-group">
  91. <div class="group-controls">
  92. <label class="checkbox" for="keep_unreads">
  93. <input type="checkbox" name="keep_unreads" id="keep_unreads" value="1"<?=
  94. FreshRSS_Context::userConf()->archiving['keep_unreads'] ? ' checked="checked"' : '' ?>
  95. data-leave-validation="<?= FreshRSS_Context::userConf()->archiving['keep_unreads'] ? 1 : 0 ?>"/>
  96. <?= _t('conf.archiving.keep_unreads') ?>
  97. </label>
  98. </div>
  99. </div>
  100. <div class="form-group">
  101. <div class="group-controls">
  102. <label for="keep_min_default"><?= _t('conf.archiving.keep_min_by_feed') ?>
  103. <input type="number" id="keep_min_default" name="keep_min_default" min="0" value="<?=
  104. FreshRSS_Context::userConf()->archiving['keep_min'] ?>"
  105. data-leave-validation="<?= FreshRSS_Context::userConf()->archiving['keep_min'] ?>">
  106. </label>
  107. </div>
  108. </div>
  109. <div class="form-group form-actions">
  110. <div class="group-controls">
  111. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  112. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  113. </div>
  114. </div>
  115. </form>
  116. <h2><?= _t('conf.archiving.maintenance') ?></h2>
  117. <form method="post" action="<?= _url('entry', 'purge') ?>">
  118. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  119. <div class="form-group">
  120. <label class="group-name"><?= _t('conf.user.current') ?></label>
  121. <div class="group-controls">
  122. <?= _t('conf.user.articles_and_size', format_number($this->nb_total), format_bytes($this->size_user)) ?>
  123. </div>
  124. </div>
  125. <div class="form-group">
  126. <div class="group-controls">
  127. <button type="submit" class="btn btn-important confirm"><?= _t('conf.archiving.purge_now') ?></button>
  128. </div>
  129. </div>
  130. </form>
  131. <form method="post" action="<?= _url('entry', 'optimize') ?>">
  132. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  133. <div class="form-group">
  134. <div class="group-controls">
  135. <input type="hidden" name="optimiseDatabase" value="1" />
  136. <button type="submit" class="btn btn-important"><?= _t('conf.archiving.optimize') ?></button>
  137. <p class="help"><?= _i('help') ?> <?= _t('conf.archiving.optimize_help') ?></p>
  138. </div>
  139. </div>
  140. </form>
  141. <?php if (FreshRSS_Auth::hasAccess('admin')): ?>
  142. <div class="form-group">
  143. <label class="group-name"><?= _t('conf.user.users') ?></label>
  144. <div class="group-controls">
  145. <?= format_bytes($this->size_total) ?>
  146. </div>
  147. </div>
  148. <?php endif; ?>
  149. </main>