update.phtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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('category', 'update', '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.feed.filteractions') ?></legend>
  66. <div class="form-group">
  67. <label class="group-name" for="filteractions_read"><?= _t('conf.reading.read.when') ?></label>
  68. <div class="group-controls">
  69. <textarea name="filteractions_read" id="filteractions_read" class="w100"><?php
  70. foreach ($this->category->filtersAction('read') as $filterRead) {
  71. echo $filterRead->getRawInput(), PHP_EOL;
  72. }
  73. ?></textarea>
  74. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.filteractions.help') ?></p>
  75. </div>
  76. </div>
  77. <div class="form-group form-actions">
  78. <div class="group-controls">
  79. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  80. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  81. </div>
  82. </div>
  83. <legend><?= _t('sub.category.archiving') ?></legend>
  84. <?php
  85. $archiving = $this->category->attributes('archiving');
  86. if (empty($archiving)) {
  87. $archiving = [ 'default' => true ];
  88. } else {
  89. $archiving['default'] = false;
  90. }
  91. $volatile = [
  92. 'enable_keep_period' => false,
  93. 'keep_period_count' => '3',
  94. 'keep_period_unit' => 'P1M',
  95. ];
  96. if (!empty($archiving['keep_period'])) {
  97. if (preg_match('/^PT?(?P<count>\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) {
  98. $volatile['enable_keep_period'] = true;
  99. $volatile['keep_period_count'] = $matches['count'];
  100. $volatile['keep_period_unit'] = str_replace($matches['count'], '1', $archiving['keep_period']);
  101. }
  102. }
  103. //Defaults
  104. if (!isset($archiving['keep_max'])) {
  105. $archiving['keep_max'] = false;
  106. }
  107. if (!isset($archiving['keep_favourites'])) {
  108. $archiving['keep_favourites'] = true;
  109. }
  110. if (!isset($archiving['keep_labels'])) {
  111. $archiving['keep_labels'] = true;
  112. }
  113. if (!isset($archiving['keep_unreads'])) {
  114. $archiving['keep_unreads'] = false;
  115. }
  116. if (!isset($archiving['keep_min'])) {
  117. $archiving['keep_min'] = 50;
  118. }
  119. ?>
  120. <p class="alert alert-warn">
  121. <?= _t('conf.archiving.policy_warning') ?>
  122. </p>
  123. <div class="form-group">
  124. <label class="group-name" for="use_default_purge_options"><?= _t('conf.archiving.policy') ?></label>
  125. <div class="group-controls">
  126. <label class="checkbox">
  127. <input type="checkbox" name="use_default_purge_options" id="use_default_purge_options" value="1"<?= $archiving['default'] ? ' checked="checked"' : '' ?>
  128. data-leave-validation="<?= $archiving['default'] ? 1 : 0 ?>" />
  129. <?= _t('gen.short.by_default') ?>
  130. </label>
  131. </div>
  132. </div>
  133. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  134. <div class="group-controls">
  135. <label class="checkbox" for="enable_keep_max">
  136. <input type="checkbox" name="enable_keep_max" id="enable_keep_max" value="1"<?= empty($archiving['keep_max']) ? '' : ' checked="checked"' ?>
  137. data-leave-validation="<?= empty($archiving['keep_max']) ? 0 : 1 ?>"/>
  138. <?= _t('conf.archiving.keep_max') ?>
  139. <input type="number" id="keep_max" name="keep_max" min="0" value="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>"
  140. data-leave-validation="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>"/>
  141. </label>
  142. </div>
  143. </div>
  144. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  145. <div class="group-controls">
  146. <label class="checkbox" for="enable_keep_period">
  147. <input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?= $volatile['enable_keep_period'] ? ' checked="checked"' : '' ?>
  148. data-leave-validation="<?= $volatile['enable_keep_period'] ? 1 : 0 ?>"/>
  149. <?= _t('conf.archiving.keep_period') ?>
  150. <input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= $volatile['keep_period_count'] ?>"
  151. data-leave-validation="<?= $volatile['keep_period_count'] ?>"/>
  152. <select class="number" name="keep_period_unit" id="keep_period_unit" data-leave-validation="<?= $volatile['keep_period_unit'] ?>">
  153. <option></option>
  154. <option value="P1Y" <?= 'P1Y' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.years') ?></option>
  155. <option value="P1M" <?= 'P1M' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.months') ?></option>
  156. <option value="P1W" <?= 'P1W' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.weeks') ?></option>
  157. <option value="P1D" <?= 'P1D' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.days') ?></option>
  158. <option value="PT1H" <?= 'PT1H' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.hours') ?></option>
  159. </select>
  160. </label>
  161. </div>
  162. </div>
  163. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  164. <div class="group-name"><?= _t('conf.archiving.exception') ?></div>
  165. <div class="group-controls">
  166. <label class="checkbox" for="keep_favourites">
  167. <input type="checkbox" name="keep_favourites" id="keep_favourites" value="1"<?= $archiving['keep_favourites'] ? ' checked="checked"' : '' ?>
  168. data-leave-validation="<?= $archiving['keep_favourites'] ? 1 : 0 ?>"/>
  169. <?= _t('conf.archiving.keep_favourites') ?>
  170. </label>
  171. </div>
  172. </div>
  173. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  174. <div class="group-controls">
  175. <label class="checkbox" for="keep_labels">
  176. <input type="checkbox" name="keep_labels" id="keep_labels" value="1"<?= $archiving['keep_labels'] ? ' checked="checked"' : '' ?>
  177. data-leave-validation="<?= $archiving['keep_labels'] ? 1 : 0 ?>"/>
  178. <?= _t('conf.archiving.keep_labels') ?>
  179. </label>
  180. </div>
  181. </div>
  182. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  183. <div class="group-controls">
  184. <label class="checkbox" for="keep_unreads">
  185. <input type="checkbox" name="keep_unreads" id="keep_unreads" value="1"<?= $archiving['keep_unreads'] ? ' checked="checked"' : '' ?>
  186. data-leave-validation="<?= $archiving['keep_unreads'] ? 1 : 0 ?>"/>
  187. <?= _t('conf.archiving.keep_unreads') ?>
  188. </label>
  189. </div>
  190. </div>
  191. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  192. <div class="group-controls">
  193. <label for="keep_min"><?= _t('sub.feed.keep_min') ?>
  194. <input type="number" id="keep_min" name="keep_min" min="0" value="<?= $archiving['keep_min'] ?>"
  195. data-leave-validation="<?= $archiving['keep_min'] ?>">
  196. </label>
  197. </div>
  198. </div>
  199. <div class="form-group form-actions">
  200. <div class="group-controls">
  201. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  202. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  203. </div>
  204. </div>
  205. <?php if (!$this->category->isDefault()): ?>
  206. <p class="alert alert-warn">
  207. <?= _t('sub.feed.moved_category_deleted', _t('gen.short.default_category')) ?>
  208. </p>
  209. <?php endif;?>
  210. <div class="form-group form-actions">
  211. <div class="group-controls">
  212. <button type="submit" class="btn btn-attention confirm"
  213. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  214. formaction="<?= _url('category', 'empty', 'id', $this->category->id()) ?>"
  215. formmethod="post"><?= _t('gen.action.empty') ?></button>
  216. <?php if (!$this->category->isDefault()): ?>
  217. <button type="submit" class="btn btn-attention confirm"
  218. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  219. formaction="<?= _url('category', 'delete', 'id', $this->category->id()) ?>"
  220. formmethod="post"><?= _t('gen.action.remove') ?></button>
  221. <?php endif;?>
  222. </div>
  223. </div>
  224. </form>
  225. </div>