update.phtml 14 KB

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