update.phtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. <?= $this->category->kind() === FreshRSS_Category::KIND_DYNAMIC_OPML ? _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" 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="<?= htmlspecialchars($this->category->attributeString('opml_url') ?? '', ENT_COMPAT, 'UTF-8') ?>" />
  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 htmlspecialchars($filterRead->toString(expandUserQueries: false), ENT_NOQUOTES, 'UTF-8'), PHP_EOL;
  93. }
  94. ?></textarea>
  95. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.filteractions.help') ?></p>
  96. <p>
  97. <button class="btn" formaction="<?= _url('category', 'viewFilter', 'id', $this->category->id()); ?>" formtarget="_blank">
  98. <?= _t('sub.feed.filteractions.view_filter') ?>
  99. </button>
  100. </p>
  101. </div>
  102. </div>
  103. <div class="form-group form-actions">
  104. <div class="group-controls">
  105. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  106. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  107. </div>
  108. </div>
  109. </fieldset>
  110. <fieldset>
  111. <legend><?= _t('sub.category.archiving') ?></legend>
  112. <?php
  113. $archiving = $this->category->attributeArray('archiving');
  114. /** @var array{default?:bool,keep_period?:string,keep_max?:int,keep_min?:int,keep_favourites?:bool,keep_labels?:bool,keep_unreads?:bool}|null $archiving */
  115. if (empty($archiving)) {
  116. $archiving = [ 'default' => true ];
  117. } else {
  118. $archiving['default'] = false;
  119. }
  120. $volatile = [
  121. 'enable_keep_period' => false,
  122. 'keep_period_count' => '3',
  123. 'keep_period_unit' => 'P1M',
  124. ];
  125. if (!empty($archiving['keep_period']) && is_string($archiving['keep_period'])) {
  126. if (preg_match('/^PT?(?P<count>\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) {
  127. $volatile['enable_keep_period'] = true;
  128. $volatile['keep_period_count'] = $matches['count'];
  129. $volatile['keep_period_unit'] = str_replace($matches['count'], '1', $archiving['keep_period']);
  130. }
  131. }
  132. //Defaults
  133. if (!isset($archiving['keep_max']) || !is_int($archiving['keep_max'])) {
  134. $archiving['keep_max'] = 0;
  135. }
  136. if (!isset($archiving['keep_min']) || !is_int($archiving['keep_min'])) {
  137. $archiving['keep_min'] = 50;
  138. }
  139. if (!isset($archiving['keep_favourites']) || !is_bool($archiving['keep_favourites'])) {
  140. $archiving['keep_favourites'] = true;
  141. }
  142. if (!isset($archiving['keep_labels']) || !is_bool($archiving['keep_labels'])) {
  143. $archiving['keep_labels'] = true;
  144. }
  145. if (!isset($archiving['keep_unreads']) || !is_bool($archiving['keep_unreads'])) {
  146. $archiving['keep_unreads'] = false;
  147. }
  148. ?>
  149. <p class="alert alert-warn">
  150. <?= _t('conf.archiving.policy_warning') ?><br />
  151. <?= _t('conf.reading.apply_to_individual_feed') ?>
  152. </p>
  153. <div class="form-group">
  154. <label class="group-name" for="use_default_purge_options"><?= _t('conf.archiving.policy') ?></label>
  155. <div class="group-controls">
  156. <label class="checkbox">
  157. <input type="checkbox" name="use_default_purge_options" id="use_default_purge_options" value="1"<?= $archiving['default'] ? ' checked="checked"' : '' ?> />
  158. <?= _t('gen.short.by_default') ?>
  159. </label>
  160. </div>
  161. </div>
  162. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  163. <div class="group-controls">
  164. <label class="checkbox" for="enable_keep_max">
  165. <input type="checkbox" name="enable_keep_max" id="enable_keep_max" value="1"<?= empty($archiving['keep_max']) ? '' : ' checked="checked"' ?> />
  166. <?= _t('conf.archiving.keep_max') ?>
  167. <input type="number" id="keep_max" name="keep_max" min="0" value="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>" />
  168. </label>
  169. </div>
  170. </div>
  171. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  172. <div class="group-controls">
  173. <label class="checkbox" for="enable_keep_period">
  174. <input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?= $volatile['enable_keep_period'] ? ' checked="checked"' : '' ?> />
  175. <?= _t('conf.archiving.keep_period') ?>
  176. <input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= $volatile['keep_period_count'] ?>" />
  177. <select class="number" name="keep_period_unit" id="keep_period_unit">
  178. <option></option>
  179. <option value="P1Y" <?= 'P1Y' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.years') ?></option>
  180. <option value="P1M" <?= 'P1M' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.months') ?></option>
  181. <option value="P1W" <?= 'P1W' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.weeks') ?></option>
  182. <option value="P1D" <?= 'P1D' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.days') ?></option>
  183. <option value="PT1H" <?= 'PT1H' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.hours') ?></option>
  184. </select>
  185. </label>
  186. </div>
  187. </div>
  188. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  189. <div class="group-name"><?= _t('conf.archiving.exception') ?></div>
  190. <div class="group-controls">
  191. <label class="checkbox" for="keep_favourites">
  192. <input type="checkbox" name="keep_favourites" id="keep_favourites" value="1"<?= $archiving['keep_favourites'] ? ' checked="checked"' : '' ?> />
  193. <?= _t('conf.archiving.keep_favourites') ?>
  194. </label>
  195. </div>
  196. </div>
  197. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  198. <div class="group-controls">
  199. <label class="checkbox" for="keep_labels">
  200. <input type="checkbox" name="keep_labels" id="keep_labels" value="1"<?= $archiving['keep_labels'] ? ' checked="checked"' : '' ?> />
  201. <?= _t('conf.archiving.keep_labels') ?>
  202. </label>
  203. </div>
  204. </div>
  205. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  206. <div class="group-controls">
  207. <label class="checkbox" for="keep_unreads">
  208. <input type="checkbox" name="keep_unreads" id="keep_unreads" value="1"<?= $archiving['keep_unreads'] ? ' checked="checked"' : '' ?> />
  209. <?= _t('conf.archiving.keep_unreads') ?>
  210. </label>
  211. </div>
  212. </div>
  213. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  214. <div class="group-controls">
  215. <label for="keep_min"><?= _t('sub.feed.keep_min') ?>
  216. <input type="number" id="keep_min" name="keep_min" min="0" value="<?= $archiving['keep_min'] ?>" />
  217. </label>
  218. </div>
  219. </div>
  220. <div class="form-group form-actions">
  221. <div class="group-controls">
  222. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  223. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  224. </div>
  225. </div>
  226. </fieldset>
  227. <fieldset>
  228. <?php if (!$this->category->isDefault()): ?>
  229. <p class="alert alert-warn">
  230. <?= _t('sub.feed.moved_category_deleted', _t('gen.short.default_category')) ?>
  231. </p>
  232. <?php endif;?>
  233. <div class="form-group form-actions">
  234. <div class="group-controls">
  235. <button type="submit" class="btn btn-attention confirm"
  236. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  237. formaction="<?= _url('category', 'empty', 'id', $this->category->id(), 'errored', 1) ?>"
  238. formmethod="post"><?= _t('gen.action.delete_errored_feeds') ?></button>
  239. <button type="submit" class="btn btn-attention confirm"
  240. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  241. formaction="<?= _url('category', 'empty', 'id', $this->category->id()) ?>"
  242. formmethod="post"><?= _t('gen.action.delete_all_feeds') ?></button>
  243. <?php if (!$this->category->isDefault()): ?>
  244. <button type="submit" class="btn btn-attention confirm"
  245. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  246. formaction="<?= _url('category', 'delete', 'id', $this->category->id()) ?>"
  247. formmethod="post"><?= _t('gen.action.remove') ?></button>
  248. <?php endif;?>
  249. </div>
  250. </div>
  251. </fieldset>
  252. <fieldset>
  253. <legend><?= _t('sub.import_export.export') ?></legend>
  254. <div class="form-group">
  255. <label class="group-name"><?= _t('sub.feed.export-as-opml.label') ?></label>
  256. <div class="group-controls">
  257. <a class="btn btn-important" href="<?= _url('index', 'opml', 'get', 'c_' . $this->category->id()) ?>" download="c_<?= $this->category->id() ?> <?= $this->category->name() ?>.opml.xml">
  258. <?= _t('sub.feed.export-as-opml.download') ?>
  259. </a>
  260. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.export-as-opml.help') ?></p>
  261. </div>
  262. </div>
  263. </fieldset>
  264. </form>
  265. </div>