update.phtml 12 KB

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