update.phtml 13 KB

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