update.phtml 11 KB

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