update.phtml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. ?>
  5. <div class="post">
  6. <h2>
  7. <?= $this->category->name() ?>
  8. <?php if ($this->category->kind() == FreshRSS_Category::KIND_DYNAMIC_OPML) { echo _i('opml-dyn'); } ?>
  9. </h2>
  10. <div>
  11. <a href="<?= _url('index', 'index', 'get', 'c_' . $this->category->id()) ?>"><?= _i('link') ?> <?= _t('gen.action.filter') ?></a>
  12. </div>
  13. <form method="post" action="<?= _url('subscription', 'category', 'id', $this->category->id(), '#', 'slider') ?>" autocomplete="off">
  14. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  15. <legend><?= _t('sub.category.information') ?></legend>
  16. <div class="form-group">
  17. <label class="group-name" for="name"><?= _t('sub.category.title') ?></label>
  18. <div class="group-controls">
  19. <input type="text" name="name" id="name" value="<?= $this->category->name() ?>" <?php
  20. //Disallow changing the name of the default category
  21. echo $this->category->id() == FreshRSS_CategoryDAO::DEFAULTCATEGORYID ? 'disabled="disabled"' : '';
  22. ?> />
  23. </div>
  24. </div>
  25. <div class="form-group">
  26. <label class="group-name" for="position"><?= _t('sub.category.position') ?></label>
  27. <div class="group-controls">
  28. <input type="number" name="position" id="position" min="1" value="<?= $this->category->attributes('position') ?>" />
  29. <p class="help"><?= _i('help') ?> <?= _t('sub.category.position_help') ?></p>
  30. </div>
  31. </div>
  32. <div class="form-group form-actions">
  33. <div class="group-controls">
  34. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  35. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  36. </div>
  37. </div>
  38. <?php if (!$this->category->isDefault()): ?>
  39. <legend><?= _t('sub.category.dynamic_opml') ?> <?= _i('opml-dyn') ?></legend>
  40. <div class="form-group">
  41. <label class="group-name" for="opml_url"><?= _t('sub.category.opml_url') ?></label>
  42. <div class="group-controls">
  43. <div class="stick">
  44. <input id="opml_url" name="opml_url" type="url" autocomplete="off" class="long" data-disable-update="refreshOpml" value="<?= $this->category->attributes('opml_url') ?>" />
  45. <button type="submit" class="btn" id="refreshOpml" formmethod="post" formaction="<?= _url('category', 'refreshOpml', 'id', $this->category->id()) ?>">
  46. <?= _i('refresh') ?> <?= _t('gen.action.refresh_opml') ?>
  47. </button>
  48. <a class="btn open-url" target="_blank" rel="noreferrer" href="" data-input="opml_url" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
  49. </div>
  50. <p class="help"><?= _i('help') ?> <?= _t('gen.short.blank_to_disable') ?></p>
  51. <p class="help"><?= _i('help') ?> <?= _t('sub.category.dynamic_opml.help') ?></p>
  52. </div>
  53. </div>
  54. <div class="form-group form-actions">
  55. <div class="group-controls">
  56. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  57. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  58. <button type="submit" class="btn btn-attention confirm"
  59. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  60. formaction="<?= _url('category', 'empty', 'id', $this->category->id(), 'muted', 1) ?>"
  61. formmethod="post"><?= _t('gen.action.delete_muted_feeds') ?></button>
  62. </div>
  63. </div>
  64. <?php endif; ?>
  65. <legend><?= _t('sub.category.archiving') ?></legend>
  66. <?php
  67. $archiving = $this->category->attributes('archiving');
  68. if (empty($archiving)) {
  69. $archiving = [ 'default' => true ];
  70. } else {
  71. $archiving['default'] = false;
  72. }
  73. $volatile = [
  74. 'enable_keep_period' => false,
  75. 'keep_period_count' => '3',
  76. 'keep_period_unit' => 'P1M',
  77. ];
  78. if (!empty($archiving['keep_period'])) {
  79. if (preg_match('/^PT?(?P<count>\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) {
  80. $volatile['enable_keep_period'] = true;
  81. $volatile['keep_period_count'] = $matches['count'];
  82. $volatile['keep_period_unit'] = str_replace($matches['count'], '1', $archiving['keep_period']);
  83. }
  84. }
  85. //Defaults
  86. if (!isset($archiving['keep_max'])) {
  87. $archiving['keep_max'] = false;
  88. }
  89. if (!isset($archiving['keep_favourites'])) {
  90. $archiving['keep_favourites'] = true;
  91. }
  92. if (!isset($archiving['keep_labels'])) {
  93. $archiving['keep_labels'] = true;
  94. }
  95. if (!isset($archiving['keep_unreads'])) {
  96. $archiving['keep_unreads'] = false;
  97. }
  98. if (!isset($archiving['keep_min'])) {
  99. $archiving['keep_min'] = 50;
  100. }
  101. ?>
  102. <p class="alert alert-warn">
  103. <?= _t('conf.archiving.policy_warning') ?>
  104. </p>
  105. <div class="form-group">
  106. <label class="group-name" for="use_default_purge_options"><?= _t('conf.archiving.policy') ?></label>
  107. <div class="group-controls">
  108. <label class="checkbox">
  109. <input type="checkbox" name="use_default_purge_options" id="use_default_purge_options" value="1"<?= $archiving['default'] ? ' checked="checked"' : '' ?>
  110. data-leave-validation="<?= $archiving['default'] ? 1 : 0 ?>" />
  111. <?= _t('gen.short.by_default') ?>
  112. </label>
  113. </div>
  114. </div>
  115. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  116. <div class="group-controls">
  117. <label class="checkbox" for="enable_keep_max">
  118. <input type="checkbox" name="enable_keep_max" id="enable_keep_max" value="1"<?= empty($archiving['keep_max']) ? '' : ' checked="checked"' ?>
  119. data-leave-validation="<?= empty($archiving['keep_max']) ? 0 : 1 ?>"/>
  120. <?= _t('conf.archiving.keep_max') ?>
  121. <input type="number" id="keep_max" name="keep_max" min="0" value="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>"
  122. data-leave-validation="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>"/>
  123. </label>
  124. </div>
  125. </div>
  126. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  127. <div class="group-controls">
  128. <label class="checkbox" for="enable_keep_period">
  129. <input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?= $volatile['enable_keep_period'] ? ' checked="checked"' : '' ?>
  130. data-leave-validation="<?= $volatile['enable_keep_period'] ? 1 : 0 ?>"/>
  131. <?= _t('conf.archiving.keep_period') ?>
  132. <input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= $volatile['keep_period_count'] ?>"
  133. data-leave-validation="<?= $volatile['keep_period_count'] ?>"/>
  134. <select class="number" name="keep_period_unit" id="keep_period_unit" data-leave-validation="<?= $volatile['keep_period_unit'] ?>">
  135. <option></option>
  136. <option value="P1Y" <?= 'P1Y' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.years') ?></option>
  137. <option value="P1M" <?= 'P1M' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.months') ?></option>
  138. <option value="P1W" <?= 'P1W' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.weeks') ?></option>
  139. <option value="P1D" <?= 'P1D' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.days') ?></option>
  140. <option value="PT1H" <?= 'PT1H' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.hours') ?></option>
  141. </select>
  142. </label>
  143. </div>
  144. </div>
  145. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  146. <div class="group-name"><?= _t('conf.archiving.exception') ?></div>
  147. <div class="group-controls">
  148. <label class="checkbox" for="keep_favourites">
  149. <input type="checkbox" name="keep_favourites" id="keep_favourites" value="1"<?= $archiving['keep_favourites'] ? ' checked="checked"' : '' ?>
  150. data-leave-validation="<?= $archiving['keep_favourites'] ? 1 : 0 ?>"/>
  151. <?= _t('conf.archiving.keep_favourites') ?>
  152. </label>
  153. </div>
  154. </div>
  155. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  156. <div class="group-controls">
  157. <label class="checkbox" for="keep_labels">
  158. <input type="checkbox" name="keep_labels" id="keep_labels" value="1"<?= $archiving['keep_labels'] ? ' checked="checked"' : '' ?>
  159. data-leave-validation="<?= $archiving['keep_labels'] ? 1 : 0 ?>"/>
  160. <?= _t('conf.archiving.keep_labels') ?>
  161. </label>
  162. </div>
  163. </div>
  164. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  165. <div class="group-controls">
  166. <label class="checkbox" for="keep_unreads">
  167. <input type="checkbox" name="keep_unreads" id="keep_unreads" value="1"<?= $archiving['keep_unreads'] ? ' checked="checked"' : '' ?>
  168. data-leave-validation="<?= $archiving['keep_unreads'] ? 1 : 0 ?>"/>
  169. <?= _t('conf.archiving.keep_unreads') ?>
  170. </label>
  171. </div>
  172. </div>
  173. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  174. <div class="group-controls">
  175. <label for="keep_min"><?= _t('sub.feed.keep_min') ?>
  176. <input type="number" id="keep_min" name="keep_min" min="0" value="<?= $archiving['keep_min'] ?>"
  177. data-leave-validation="<?= $archiving['keep_min'] ?>">
  178. </label>
  179. </div>
  180. </div>
  181. <div class="form-group form-actions">
  182. <div class="group-controls">
  183. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  184. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  185. </div>
  186. </div>
  187. <?php if (!$this->category->isDefault()): ?>
  188. <p class="alert alert-warn">
  189. <?= _t('sub.feed.moved_category_deleted', _t('gen.short.default_category')) ?>
  190. </p>
  191. <?php endif;?>
  192. <div class="form-group form-actions">
  193. <div class="group-controls">
  194. <button type="submit" class="btn btn-attention confirm"
  195. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  196. formaction="<?= _url('category', 'empty', 'id', $this->category->id()) ?>"
  197. formmethod="post"><?= _t('gen.action.empty') ?></button>
  198. <?php if (!$this->category->isDefault()): ?>
  199. <button type="submit" class="btn btn-attention confirm"
  200. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  201. formaction="<?= _url('category', 'delete', 'id', $this->category->id()) ?>"
  202. formmethod="post"><?= _t('gen.action.remove') ?></button>
  203. <?php endif;?>
  204. </div>
  205. </div>
  206. </form>
  207. </div>