update.phtml 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. if ($this->feed === null) {
  5. return;
  6. }
  7. ?>
  8. <div class="post" id="feed_update" data-feed-id="<?= $this->feed->id() ?>">
  9. <h1><?= $this->feed->name() ?></h1>
  10. <div>
  11. <a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>"><?= _i('link') ?> <?= _t('gen.action.filter') ?></a>
  12. <?= _t('gen.short.or') ?>
  13. <a href="<?= _url('stats', 'repartition', 'id', $this->feed->id()) ?>"><?= _i('stats') ?> <?= _t('sub.feed.stats') ?></a>
  14. </div>
  15. <?php if ($this->feed->inError()): ?>
  16. <p class="alert alert-error">
  17. <span class="alert-head"><?= _t('gen.short.damn') ?></span>
  18. <?= _t('sub.feed.error') ?><br />
  19. <?= _t('sub.feed.last-update', timestampToMachineDate($this->feed->lastUpdate()), timeago($this->feed->lastUpdate())) ?>
  20. <?php if ($this->feed->lastError() > 1) { ?><br />
  21. <?= _t('sub.feed.last-error-date', timestampToMachineDate($this->feed->lastError()), timeago($this->feed->lastError())) ?>
  22. <?php } ?>
  23. </p>
  24. <?php else: ?>
  25. <p class="alert alert-success">
  26. <?= _t('sub.feed.last-update', timestampToMachineDate($this->feed->lastUpdate()), timeago($this->feed->lastUpdate())) ?>
  27. </p>
  28. <?php endif; ?>
  29. <?php $nbEntries = $this->feed->nbEntries(); ?>
  30. <?php if ($nbEntries === 0): ?>
  31. <p class="alert alert-warn"><?= _t('sub.feed.empty') ?></p>
  32. <?php endif; ?>
  33. <?php
  34. $from = Minz_Request::paramString('from');
  35. $slider = ['#', 'slider'];
  36. $ajax = Minz_Request::paramBoolean('ajax') || $this->displaySlider;
  37. if (!$ajax) {
  38. $from = 'feed';
  39. $slider = [];
  40. } elseif ($from === '') {
  41. $from = $this->cfrom ?: 'index';
  42. }
  43. if ($from === '') {
  44. $url = _url('subscription', 'feed', 'id', $this->feed->id(), ...$slider);
  45. } else {
  46. $get = Minz_Request::paramString('get');
  47. if ($get === '') {
  48. $url = _url('subscription', 'feed', 'id', $this->feed->id(), 'from', $from, 'error', Minz_Request::paramBoolean('error') ? 1 : 0, ...$slider);
  49. } else {
  50. $url = _url('subscription', 'feed', 'id', $this->feed->id(), 'from', $from, 'get', $get, ...$slider);
  51. }
  52. }
  53. ?>
  54. <form method="post" action="<?= $url ?>" autocomplete="off" enctype="multipart/form-data" data-auto-leave-validation="1">
  55. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  56. <fieldset>
  57. <legend><?= _t('sub.feed.information') ?></legend>
  58. <div class="form-group">
  59. <?php
  60. $currentIconUrl = $this->feed->favicon();
  61. $originalIconUrl = '';
  62. if ($this->feed->customFavicon()) {
  63. $this->feed->_attribute('customFavicon', false);
  64. $this->feed->resetFaviconHash();
  65. }
  66. $originalIconUrl = $this->feed->favicon();
  67. $this->feed->_attribute('customFavicon', $currentIconUrl !== $originalIconUrl);
  68. $this->feed->resetFaviconHash();
  69. $ext_url = Minz_ExtensionManager::callHook(Minz_HookType::CustomFaviconBtnUrl, $this->feed);
  70. ?>
  71. <div class="group-name"><?= _t('sub.feed.icon') ?></div>
  72. <div class="group-controls">
  73. <img class="favicon upload" src="<?= $currentIconUrl ?>" data-initial-src="<?= $currentIconUrl ?>" data-original-icon="<?= $originalIconUrl ?>" alt="✇" loading="lazy" />
  74. <div class="favicon-controls">
  75. <input id="favicon-upload" name="newFavicon" type="file" accept="image/*" />
  76. <label for="favicon-upload" class="btn"><?= _t('sub.feed.change_favicon') ?></label>
  77. <button id="reset-favicon" class="btn"<?= $this->feed->customFavicon() ? '' : ' disabled="disabled"'?>><?= _t('sub.feed.reset_favicon') ?></button>
  78. <?php if (is_string($ext_url)) { ?>
  79. <button id="favicon-ext-btn" class="btn" data-extension-url="<?= htmlspecialchars(html_entity_decode($ext_url), ENT_COMPAT, 'UTF-8') ?>"><?= _t('sub.feed.ext_favicon') ?></button>
  80. <?php } ?>
  81. </div>
  82. <p id="favicon-ext" class="<?= $this->feed->customFaviconExt() !== null ? '' : 'hidden' ?>"><?= _t('sub.feed.favicon_changed_by_ext', htmlspecialchars($this->feed->customFaviconExt() ?? '', ENT_NOQUOTES, 'UTF-8')) ?></p>
  83. <p id="favicon-error" class="error"></p>
  84. </div>
  85. </div>
  86. <div class="form-group">
  87. <label class="group-name" for="name"><?= _t('sub.feed.title') ?></label>
  88. <div class="group-controls">
  89. <input type="text" name="name" id="name" class="w100" value="<?= $this->feed->name(true) ?>" required="required" />
  90. </div>
  91. </div>
  92. <div class="form-group">
  93. <label class="group-name" for="description"><?= _t('sub.feed.description') ?></label>
  94. <div class="group-controls">
  95. <textarea name="description" id="description" class="w100"><?= htmlspecialchars($this->feed->description(), ENT_NOQUOTES, 'UTF-8') ?></textarea>
  96. </div>
  97. </div>
  98. <div class="form-group">
  99. <label class="group-name" for="website"><?= _t('sub.feed.website') ?></label>
  100. <div class="group-controls">
  101. <div class="stick w100">
  102. <input type="url" name="website" id="website" value="<?= $this->feed->website() ?>" />
  103. <a class="btn open-url" target="_blank" rel="noreferrer" href="<?= $this->feed->website() ?>" data-input="website" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="form-group">
  108. <label class="group-name" for="url"><?= _t('sub.feed.url') ?></label>
  109. <div class="group-controls">
  110. <div class="stick w100">
  111. <input type="url" name="url" id="url" value="<?= $this->feed->url() ?>" required="required" />
  112. <a class="btn open-url" target="_blank" rel="noreferrer" href="<?= $this->feed->url() ?>" data-input="url" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
  113. </div>
  114. <a class="btn open-url" target="_blank" rel="noreferrer" data-input="url" data-prefix="https://validator.w3.org/feed/check.cgi?url=" data-encode="1" href="https://validator.w3.org/feed/check.cgi?url=<?=
  115. rawurlencode(htmlspecialchars_decode($this->feed->url(), ENT_QUOTES)) ?>"><?= _t('sub.feed.validator') ?></a>
  116. </div>
  117. </div>
  118. <div class="form-group">
  119. <label class="group-name" for="category"><?= _t('sub.category') ?></label>
  120. <div class="group-controls">
  121. <select name="category" id="category" class="w100">
  122. <?php foreach ($this->categories as $cat) { ?>
  123. <option value="<?= $cat->id() ?>"<?= $cat->id() == $this->feed->categoryId() ? ' selected="selected"' : '' ?>>
  124. <?= $cat->name() ?>
  125. </option>
  126. <?php } ?>
  127. </select>
  128. </div>
  129. </div>
  130. <div class="form-group">
  131. <label class="group-name" for="priority"><?= _t('sub.feed.priority') ?></label>
  132. <div class="group-controls">
  133. <select name="priority" id="priority" class="w50">
  134. <option value="<?= FreshRSS_Feed::PRIORITY_IMPORTANT ?>" <?=
  135. FreshRSS_Feed::PRIORITY_IMPORTANT === $this->feed->priority() ? 'selected="selected"' : '' ?>><?= _t('sub.feed.priority.important') ?></option>
  136. <option value="<?= FreshRSS_Feed::PRIORITY_MAIN_STREAM ?>" <?=
  137. FreshRSS_Feed::PRIORITY_MAIN_STREAM === $this->feed->priority() ? 'selected="selected"' : '' ?>><?= _t('sub.feed.priority.main_stream') ?></option>
  138. <option value="<?= FreshRSS_Feed::PRIORITY_CATEGORY ?>" <?=
  139. FreshRSS_Feed::PRIORITY_CATEGORY === $this->feed->priority() ? 'selected="selected"' : '' ?>><?= _t('sub.feed.priority.category') ?></option>
  140. <option value="<?= FreshRSS_Feed::PRIORITY_FEED ?>" <?=
  141. FreshRSS_Feed::PRIORITY_FEED === $this->feed->priority() ? 'selected="selected"' : '' ?>><?= _t('sub.feed.priority.feed') ?></option>
  142. <option value="<?= FreshRSS_Feed::PRIORITY_HIDDEN ?>" <?=
  143. FreshRSS_Feed::PRIORITY_HIDDEN === $this->feed->priority() ? 'selected="selected"' : '' ?>><?= _t('sub.feed.priority.hidden') ?></option>
  144. </select>
  145. <?= _i('important') ?>
  146. </div>
  147. </div>
  148. <?php
  149. $feedDefaultSort = $this->feed->defaultSort();
  150. $feedDefaultOrder = $this->feed->defaultOrder();
  151. $feedDefaultSortOrder = $feedDefaultSort !== null
  152. ? ($feedDefaultSort === 'rand' ? 'rand' : $feedDefaultSort . '_' . strtolower($feedDefaultOrder ?? 'desc'))
  153. : '';
  154. ?>
  155. <div class="form-group">
  156. <label class="group-name" for="defaultSortOrder"><?= _t('index.menu.sort.primary') ?></label>
  157. <div class="group-controls">
  158. <select name="defaultSortOrder" id="defaultSortOrderFeed" class="w50">
  159. <option value=""></option>
  160. <option value="id_desc" <?= $feedDefaultSortOrder === 'id_desc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.id_desc') ?></option>
  161. <option value="date_desc" <?= $feedDefaultSortOrder === 'date_desc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.date_desc') ?></option>
  162. <option value="length_desc" <?= $feedDefaultSortOrder === 'length_desc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.length_desc') ?></option>
  163. <option value="link_desc" <?= $feedDefaultSortOrder === 'link_desc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.link_desc') ?></option>
  164. <option value="title_desc" <?= $feedDefaultSortOrder === 'title_desc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.title_desc') ?></option>
  165. <option disabled="disabled">────────────────</option>
  166. <option value="rand" <?= $feedDefaultSortOrder === 'rand' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.rand') ?></option>
  167. <option disabled="disabled">────────────────</option>
  168. <option value="id_asc" <?= $feedDefaultSortOrder === 'id_asc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.id_asc') ?></option>
  169. <option value="date_asc" <?= $feedDefaultSortOrder === 'date_asc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.date_asc') ?></option>
  170. <option value="length_asc" <?= $feedDefaultSortOrder === 'length_asc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.length_asc') ?></option>
  171. <option value="link_asc" <?= $feedDefaultSortOrder === 'link_asc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.link_asc') ?></option>
  172. <option value="title_asc" <?= $feedDefaultSortOrder === 'title_asc' ? 'selected="selected"' : '' ?>><?= _t('index.menu.sort.title_asc') ?></option>
  173. </select>
  174. </div>
  175. </div>
  176. <div class="form-group">
  177. <label class="group-name" for="unicityCriteria"><?= _t('sub.feed.unicityCriteria') ?></label>
  178. <?php
  179. $unicityCriteria = $this->feed->attributeString('unicityCriteria');
  180. if ($this->feed->attributeBoolean('hasBadGuids')) { // Legacy
  181. $unicityCriteria = 'link';
  182. }
  183. ?>
  184. <div class="group-controls">
  185. <select class="w50" name="unicityCriteria" id="unicityCriteria" required="required">
  186. <option value="id" <?= $unicityCriteria == null ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.id') ?></option>
  187. <option value="link" <?= $unicityCriteria === 'link' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.link') ?></option>
  188. <option value="sha1:link_published" <?= $unicityCriteria === 'sha1:link_published' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:link_published') ?></option>
  189. <option value="sha1:link_published_title" <?= $unicityCriteria === 'sha1:link_published_title' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:link_published_title') ?></option>
  190. <option value="sha1:link_published_title_content" <?= $unicityCriteria === 'sha1:link_published_title_content' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:link_published_title_content') ?></option>
  191. <option value="sha1:title" <?= $unicityCriteria === 'sha1:title' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:title') ?></option>
  192. <option value="sha1:title_published" <?= $unicityCriteria === 'sha1:title_published' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:title_published') ?></option>
  193. <option value="sha1:title_published_content" <?= $unicityCriteria === 'sha1:title_published_content' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:title_published_content') ?></option>
  194. <option value="sha1:content" <?= $unicityCriteria === 'sha1:content' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:content') ?></option>
  195. <option value="sha1:content_published" <?= $unicityCriteria === 'sha1:content_published' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:content_published') ?></option>
  196. <option value="sha1:published" <?= $unicityCriteria === 'sha1:published' ? 'selected="selected"' : '' ?>><?= _t('sub.feed.unicityCriteria.sha1:published') ?></option>
  197. </select>
  198. <label for="unicityCriteriaForced" class="inline">
  199. <input type="checkbox" name="unicityCriteriaForced" id="unicityCriteriaForced" value="1"<?= $this->feed->attributeBoolean('unicityCriteriaForced') ? ' checked="checked"' : '' ?> />
  200. <?= _t('sub.feed.unicityCriteria.forced') ?>
  201. </label>
  202. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.unicityCriteria.help') ?></p>
  203. </div>
  204. </div>
  205. <div class="form-group">
  206. <label class="group-name" for="ttl"><?= _t('sub.feed.ttl') ?></label>
  207. <div class="group-controls">
  208. <select class="w50" name="ttl" id="ttl" required="required"><?php
  209. $found = false;
  210. foreach ([FreshRSS_Feed::TTL_DEFAULT => _t('gen.short.by_default'), 900 => '15min', 1200 => '20min', 1500 => '25min', 1800 => '30min', 2700 => '45min',
  211. 3600 => '1h', 5400 => '1.5h', 7200 => '2h', 10800 => '3h', 14400 => '4h', 18800 => '5h', 21600 => '6h', 25200 => '7h', 28800 => '8h',
  212. 36000 => '10h', 43200 => '12h', 64800 => '18h',
  213. 86400 => '1d', 129600 => '1.5d', 172800 => '2d', 259200 => '3d', 345600 => '4d', 432000 => '5d', 518400 => '6d',
  214. 604800 => '1wk', 1209600 => '2wk', 1814400 => '3wk', 2419200 => '4wk', 2629744 => '1mo'] as $v => $t) {
  215. echo '<option value="' . $v . ($this->feed->ttl() === $v ? '" selected="selected' : '') . '">' . $t . '</option>';
  216. if ($this->feed->ttl() == $v) {
  217. $found = true;
  218. }
  219. }
  220. if (!$found) {
  221. echo '<option value="' . intval($this->feed->ttl()) . '" selected="selected">' . intval($this->feed->ttl()) . 's</option>';
  222. }
  223. ?></select>
  224. <label for="mute">
  225. <input type="checkbox" name="mute" id="mute" value="1"<?= $this->feed->mute() ? ' checked="checked"' : '' ?> />
  226. <?= _t('sub.feed.mute') ?>
  227. </label>
  228. </div>
  229. </div>
  230. <?php if ($this->feed->pubSubHubbubEnabled()) { ?>
  231. <div class="form-group">
  232. <div class="group-controls">
  233. <label class="checkbox" for="pubsubhubbub">
  234. <input type="checkbox" name="pubsubhubbub" id="pubsubhubbub" disabled="disabled" value="1" checked="checked" />
  235. <?= _t('sub.feed.websub') ?>
  236. </label>
  237. </div>
  238. </div>
  239. <?php } ?>
  240. <div class="form-group form-actions">
  241. <div class="group-controls">
  242. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  243. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  244. <?php
  245. if ($from === '') {
  246. $url = _url('feed', 'delete', 'id', $this->feed->id());
  247. } else {
  248. $url = _url('feed', 'delete', 'id', $this->feed->id(), 'from', $from);
  249. }
  250. ?>
  251. <button type="submit" class="btn btn-attention confirm"
  252. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  253. formaction="<?= $url ?>"
  254. formmethod="post"><?= _t('gen.action.remove') ?></button>
  255. </div>
  256. </div>
  257. </fieldset>
  258. <fieldset>
  259. <legend><?= _t('sub.feed.auth.configuration') ?></legend>
  260. <?php $auth = $this->feed->httpAuth(false); ?>
  261. <div class="form-group">
  262. <label class="group-name" for="http_user_feed<?= $this->feed->id() ?>"><?= _t('sub.feed.auth.username') ?></label>
  263. <div class="group-controls">
  264. <input type="text" name="http_user_feed<?= $this->feed->id() ?>" id="http_user_feed<?= $this->feed->id() ?>" class="w50" value="<?=
  265. empty($auth['username']) ? '' : $auth['username'] ?>" autocomplete="off" />
  266. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.auth.help') ?></p>
  267. </div>
  268. </div>
  269. <div class="form-group">
  270. <label class="group-name" for="http_pass_feed<?= $this->feed->id() ?>"><?= _t('sub.feed.auth.password') ?></label>
  271. <div class="group-controls">
  272. <div class="stick w50">
  273. <input type="password" name="http_pass_feed<?= $this->feed->id() ?>" id="http_pass_feed<?= $this->feed->id() ?>" value="<?=
  274. $auth['password'] ?>" autocomplete="new-password" />
  275. <button type="button" class="btn toggle-password"><?= _i('key') ?></button>
  276. </div>
  277. </div>
  278. </div>
  279. <div class="form-group form-actions">
  280. <div class="group-controls">
  281. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  282. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  283. </div>
  284. </div>
  285. </fieldset>
  286. <fieldset>
  287. <legend><?= _t('sub.feed.filteractions') ?></legend>
  288. <div class="form-group">
  289. <label class="group-name" for="mark_updated_article_unread"><?= _t('conf.reading.mark_updated_article_unread') ?></label>
  290. <div class="group-controls">
  291. <select name="mark_updated_article_unread" id="mark_updated_article_unread" class="w50">
  292. <option value=""<?= $this->feed->attributeBoolean('mark_updated_article_unread') === null ? ' selected="selected"' : '' ?>><?= _t('gen.short.by_default') ?></option>
  293. <option value="0"<?= $this->feed->attributeBoolean('mark_updated_article_unread') === false ? ' selected="selected"' : '' ?>><?= _t('gen.short.no') ?></option>
  294. <option value="1"<?= $this->feed->attributeBoolean('mark_updated_article_unread') === true ? ' selected="selected"' : '' ?>><?= _t('gen.short.yes') ?></option>
  295. </select>
  296. </div>
  297. </div>
  298. <div class="form-group">
  299. <label class="group-name" for="read_when_same_title_in_feed"><?= _t('conf.reading.read.when') ?></label>
  300. <div class="group-controls">
  301. <select name="read_when_same_title_in_feed" id="read_when_same_title_in_feed" class="w50">
  302. <option value=""<?= $this->feed->hasAttribute('read_when_same_title_in_feed') ? '' : ' selected="selected"' ?>><?= _t('gen.short.by_default') ?></option>
  303. <option value="0"<?= $this->feed->attributeBoolean('read_when_same_title_in_feed') === false ? ' selected="selected"' : '' ?>><?= _t('gen.short.no') ?></option>
  304. <option value="10"<?= $this->feed->attributeInt('read_when_same_title_in_feed') == 10 ? ' selected="selected"' : '' ?>>10</option>
  305. <option value="25"<?= $this->feed->attributeInt('read_when_same_title_in_feed') == 25 ? ' selected="selected"' : '' ?>>25</option>
  306. <option value="100"<?= $this->feed->attributeInt('read_when_same_title_in_feed') == 100 ? ' selected="selected"' : '' ?>>100</option>
  307. <option value="1000"<?= $this->feed->attributeInt('read_when_same_title_in_feed') == 1000 ? ' selected="selected"' : '' ?>>1 000</option>
  308. </select>
  309. <?= _t('conf.reading.read.when_same_title_in_feed') ?>
  310. </div>
  311. </div>
  312. <div class="form-group">
  313. <label class="group-name" for="read_upon_reception"><?= _t('conf.reading.read.when') ?></label>
  314. <div class="group-controls">
  315. <select name="read_upon_reception" id="read_upon_reception" class="w50">
  316. <option value=""<?= $this->feed->attributeBoolean('read_upon_reception') === null ? ' selected="selected"' : '' ?>><?= _t('gen.short.by_default') ?></option>
  317. <option value="0"<?= $this->feed->attributeBoolean('read_upon_reception') === false ? ' selected="selected"' : '' ?>><?= _t('gen.short.no') ?></option>
  318. <option value="1"<?= $this->feed->attributeBoolean('read_upon_reception') === true ? ' selected="selected"' : '' ?>><?= _t('gen.short.yes') ?></option>
  319. </select>
  320. <?= _t('conf.reading.read.upon_reception') ?>
  321. </div>
  322. </div>
  323. <div class="form-group">
  324. <label class="group-name" for="read_upon_gone"><?= _t('conf.reading.read.when') ?></label>
  325. <div class="group-controls">
  326. <select name="read_upon_gone" id="read_upon_gone" class="w50">
  327. <option value=""<?= $this->feed->attributeBoolean('read_upon_gone') === null ? ' selected="selected"' : '' ?>><?= _t('gen.short.by_default') ?></option>
  328. <option value="0"<?= $this->feed->attributeBoolean('read_upon_gone') === false ? ' selected="selected"' : '' ?>><?= _t('gen.short.no') ?></option>
  329. <option value="1"<?= $this->feed->attributeBoolean('read_upon_gone') === true ? ' selected="selected"' : '' ?>><?= _t('gen.short.yes') ?></option>
  330. </select>
  331. <?= _t('conf.reading.read.upon_gone') ?>
  332. </div>
  333. </div>
  334. <div class="form-group">
  335. <label class="group-name" for="filteractions_read"><?= _t('conf.reading.read.when') ?></label>
  336. <div class="group-controls">
  337. <textarea name="filteractions_read" id="filteractions_read" class="w100"
  338. placeholder="<?= _t('gen.short.blank_to_disable') ?>"><?php
  339. foreach ($this->feed->filtersAction('read') as $filterRead) {
  340. echo htmlspecialchars($filterRead->toString(expandUserQueries: false), ENT_NOQUOTES, 'UTF-8'), PHP_EOL;
  341. }
  342. ?></textarea>
  343. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.filteractions.help') ?></p>
  344. <p>
  345. <button class="btn" formaction="<?= _url('subscription', 'viewFilter', 'id', $this->feed->id()); ?>" formtarget="_blank">
  346. <?= _t('sub.feed.filteractions.view_filter') ?>
  347. </button>
  348. </p>
  349. </div>
  350. </div>
  351. <div class="form-group">
  352. <label class="group-name" for="keep_max_n_unread"><?= _t('conf.reading.read.keep_max_n_unread') ?></label>
  353. <div class="group-controls">
  354. <input type="number" name="keep_max_n_unread" id="keep_max_n_unread" class="w50" min="1" max="10000000"
  355. value="<?= $this->feed->attributeInt('keep_max_n_unread') ?>"
  356. placeholder="<?= _t('gen.short.by_default') ?>" />
  357. </div>
  358. </div>
  359. <div class="form-group form-actions">
  360. <div class="group-controls">
  361. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  362. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  363. </div>
  364. </div>
  365. </fieldset>
  366. <fieldset>
  367. <legend><?= _t('sub.feed.archiving') ?></legend>
  368. <div class="form-group">
  369. <div class="group-controls">
  370. <?= _t('sub.feed.number_entries', $nbEntries) ?>
  371. <a class="btn" href="<?= _url('feed', 'actualize', 'id', $this->feed->id(), '#', 'slider') ?>">
  372. <?= _i('refresh') ?> <?= _t('gen.action.actualize') ?>
  373. </a>
  374. </div>
  375. </div>
  376. <?php
  377. $archiving = $this->feed->attributeArray('archiving');
  378. /** @var array{default?:bool,keep_period?:string,keep_max?:int,keep_min?:int,keep_favourites?:bool,keep_labels?:bool,keep_unreads?:bool}|null $archiving */
  379. if (empty($archiving)) {
  380. $archiving = [ 'default' => true ];
  381. } else {
  382. $archiving['default'] = false;
  383. }
  384. $volatile = [
  385. 'enable_keep_period' => false,
  386. 'keep_period_count' => '3',
  387. 'keep_period_unit' => 'P1M',
  388. ];
  389. if (!empty($archiving['keep_period']) && is_string($archiving['keep_period'])) {
  390. if (preg_match('/^PT?(?P<count>\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) {
  391. $volatile['enable_keep_period'] = true;
  392. $volatile['keep_period_count'] = $matches['count'];
  393. $volatile['keep_period_unit'] = str_replace($matches['count'], '1', $archiving['keep_period']);
  394. }
  395. }
  396. //Defaults
  397. if (!isset($archiving['keep_max']) || !is_int($archiving['keep_max'])) {
  398. $archiving['keep_max'] = 0;
  399. }
  400. if (!isset($archiving['keep_min']) || !is_int($archiving['keep_min'])) {
  401. $archiving['keep_min'] = 50;
  402. }
  403. if (!isset($archiving['keep_favourites']) || !is_bool($archiving['keep_favourites'])) {
  404. $archiving['keep_favourites'] = true;
  405. }
  406. if (!isset($archiving['keep_labels']) || !is_bool($archiving['keep_labels'])) {
  407. $archiving['keep_labels'] = true;
  408. }
  409. if (!isset($archiving['keep_unreads']) || !is_bool($archiving['keep_unreads'])) {
  410. $archiving['keep_unreads'] = false;
  411. }
  412. ?>
  413. <p class="alert alert-warn">
  414. <?= _t('conf.archiving.policy_warning') ?>
  415. </p>
  416. <div class="form-group">
  417. <div class="group-name"><?= _t('conf.archiving.policy') ?></div>
  418. <div class="group-controls">
  419. <label class="checkbox">
  420. <input type="checkbox" name="use_default_purge_options" id="use_default_purge_options" value="1"<?= $archiving['default'] ? ' checked="checked"' : '' ?> />
  421. <?= _t('gen.short.by_default') ?>
  422. </label>
  423. </div>
  424. </div>
  425. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  426. <div class="group-controls">
  427. <label class="checkbox" for="enable_keep_max">
  428. <input type="checkbox" name="enable_keep_max" id="enable_keep_max" value="1"<?= empty($archiving['keep_max']) ? '' : ' checked="checked"' ?> />
  429. <?= _t('conf.archiving.keep_max') ?>
  430. <input type="number" id="keep_max" name="keep_max" min="0" value="<?= empty($archiving['keep_max']) ? 200 : $archiving['keep_max'] ?>" />
  431. </label>
  432. </div>
  433. </div>
  434. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  435. <div class="group-controls">
  436. <label class="checkbox" for="enable_keep_period">
  437. <input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?= $volatile['enable_keep_period'] ? ' checked="checked"' : '' ?> />
  438. <?= _t('conf.archiving.keep_period') ?>
  439. <input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= $volatile['keep_period_count'] ?>" />
  440. <select class="number" name="keep_period_unit" id="keep_period_unit">
  441. <option></option>
  442. <option value="P1Y" <?= 'P1Y' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.years') ?></option>
  443. <option value="P1M" <?= 'P1M' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.months') ?></option>
  444. <option value="P1W" <?= 'P1W' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.weeks') ?></option>
  445. <option value="P1D" <?= 'P1D' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.days') ?></option>
  446. <option value="PT1H" <?= 'PT1H' === $volatile['keep_period_unit'] ? 'selected="selected"' : '' ?>><?= _t('gen.period.hours') ?></option>
  447. </select>
  448. </label>
  449. </div>
  450. </div>
  451. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  452. <div class="group-name"><?= _t('conf.archiving.exception') ?></div>
  453. <div class="group-controls">
  454. <label class="checkbox" for="keep_favourites">
  455. <input type="checkbox" name="keep_favourites" id="keep_favourites" value="1"<?= $archiving['keep_favourites'] ? ' checked="checked"' : '' ?> />
  456. <?= _t('conf.archiving.keep_favourites') ?>
  457. </label>
  458. </div>
  459. </div>
  460. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  461. <div class="group-controls">
  462. <label class="checkbox" for="keep_labels">
  463. <input type="checkbox" name="keep_labels" id="keep_labels" value="1"<?= $archiving['keep_labels'] ? ' checked="checked"' : '' ?> />
  464. <?= _t('conf.archiving.keep_labels') ?>
  465. </label>
  466. </div>
  467. </div>
  468. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  469. <div class="group-controls">
  470. <label class="checkbox" for="keep_unreads">
  471. <input type="checkbox" name="keep_unreads" id="keep_unreads" value="1"<?= $archiving['keep_unreads'] ? ' checked="checked"' : '' ?> />
  472. <?= _t('conf.archiving.keep_unreads') ?>
  473. </label>
  474. </div>
  475. </div>
  476. <div class="form-group archiving"<?= $archiving['default'] ? ' hidden="hidden"' : '' ?>>
  477. <div class="group-controls">
  478. <label for="keep_min"><?= _t('sub.feed.keep_min') ?>
  479. <input type="number" id="keep_min" name="keep_min" min="0" value="<?= $archiving['keep_min'] ?>" />
  480. </label>
  481. </div>
  482. </div>
  483. <div class="form-group form-actions">
  484. <div class="group-controls">
  485. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  486. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  487. <button type="submit" class="btn btn-attention confirm" formmethod="post" formaction="<?= _url('feed', 'truncate', 'id', $this->feed->id(), '#', 'slider') ?>"><?= _t('gen.action.truncate') ?></button>
  488. </div>
  489. </div>
  490. </fieldset>
  491. <fieldset>
  492. <legend><?= _t('sub.feed.kind') ?></legend>
  493. <div class="form-group">
  494. <label class="group-name" for="feed_kind"><?= _t('sub.feed.kind') ?></label>
  495. <div class="group-controls">
  496. <select name="feed_kind" id="feed_kind" class="select-show w100">
  497. <option value="<?= FreshRSS_Feed::KIND_RSS ?>" <?= $this->feed->kind() === FreshRSS_Feed::KIND_RSS ? 'selected="selected"' : '' ?>><?= _t('sub.feed.kind.rss') ?></option>
  498. <option value="<?= FreshRSS_Feed::KIND_HTML_XPATH ?>" <?= $this->feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH ? 'selected="selected"' : '' ?> data-show="html_xpath"><?= _t('sub.feed.kind.html_xpath') ?></option>
  499. <option value="<?= FreshRSS_Feed::KIND_XML_XPATH ?>" <?= $this->feed->kind() === FreshRSS_Feed::KIND_XML_XPATH ? 'selected="selected"' : '' ?> data-show="html_xpath"><?= _t('sub.feed.kind.xml_xpath') ?></option>
  500. <option value="<?= FreshRSS_Feed::KIND_JSONFEED ?>" <?= $this->feed->kind() === FreshRSS_Feed::KIND_JSONFEED ? 'selected="selected"' : '' ?>><?= _t('sub.feed.kind.jsonfeed') ?></option>
  501. <option value="<?= FreshRSS_Feed::KIND_JSON_DOTNOTATION ?>" <?= $this->feed->kind() === FreshRSS_Feed::KIND_JSON_DOTNOTATION ? 'selected="selected"' : '' ?>
  502. data-show="json_dotnotation"><?= _t('sub.feed.kind.json_dotnotation') ?></option>
  503. <option value="<?= FreshRSS_Feed::KIND_HTML_XPATH_JSON_DOTNOTATION ?>" <?= $this->feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH_JSON_DOTNOTATION ? 'selected="selected"' : '' ?>
  504. data-show="json_dotnotation xPathToJsonGroup"><?= _t('sub.feed.kind.html_json') ?></option>
  505. </select>
  506. </div>
  507. </div>
  508. </fieldset>
  509. <fieldset id="html_xpath">
  510. <?php
  511. /** @var array<string> $xpath */
  512. $xpath = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeArray('xpath') ?? []);
  513. ?>
  514. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.help') ?></p>
  515. <div class="form-group">
  516. <label class="group-name" for="xPathItem"><small><?= _t('sub.feed.kind.html_xpath.xpath') ?></small><br />
  517. <?= _t('sub.feed.kind.html_xpath.item') ?></label>
  518. <div class="group-controls">
  519. <textarea class="valid-xpath w100" name="xPathItem" id="xPathItem" rows="2" cols="64" spellcheck="false"><?= $xpath['item'] ?? '' ?></textarea>
  520. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item.help') ?></p>
  521. </div>
  522. </div>
  523. <div class="form-group">
  524. <label class="group-name" for="xPathItemTitle"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  525. <?= _t('sub.feed.kind.html_xpath.item_title') ?></label>
  526. <div class="group-controls">
  527. <textarea class="valid-xpath w100" name="xPathItemTitle" id="xPathItemTitle" rows="2" cols="64" spellcheck="false"><?= $xpath['itemTitle'] ?? '' ?></textarea>
  528. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_title.help') ?></p>
  529. </div>
  530. </div>
  531. <div class="form-group">
  532. <label class="group-name" for="xPathItemContent"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  533. <?= _t('sub.feed.kind.html_xpath.item_content') ?></label>
  534. <div class="group-controls">
  535. <textarea class="valid-xpath w100" name="xPathItemContent" id="xPathItemContent" rows="2" cols="64" spellcheck="false"><?= $xpath['itemContent'] ?? '' ?></textarea>
  536. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_content.help') ?></p>
  537. </div>
  538. </div>
  539. <div class="form-group">
  540. <label class="group-name" for="xPathItemUri"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  541. <?= _t('sub.feed.kind.html_xpath.item_uri') ?></label>
  542. <div class="group-controls">
  543. <textarea class="valid-xpath w100" name="xPathItemUri" id="xPathItemUri" rows="2" cols="64" spellcheck="false"><?= $xpath['itemUri'] ?? '' ?></textarea>
  544. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_uri.help') ?></p>
  545. </div>
  546. </div>
  547. <div class="form-group">
  548. <label class="group-name" for="xPathItemThumbnail"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  549. <?= _t('sub.feed.kind.html_xpath.item_thumbnail') ?></label>
  550. <div class="group-controls">
  551. <textarea class="valid-xpath w100" name="xPathItemThumbnail" id="xPathItemThumbnail" rows="2" cols="64" spellcheck="false"><?= $xpath['itemThumbnail'] ?? '' ?></textarea>
  552. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_thumbnail.help') ?></p>
  553. </div>
  554. </div>
  555. <div class="form-group">
  556. <label class="group-name" for="xPathItemAuthor"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  557. <?= _t('sub.feed.kind.html_xpath.item_author') ?></label>
  558. <div class="group-controls">
  559. <textarea class="valid-xpath w100" name="xPathItemAuthor" id="xPathItemAuthor" rows="2" cols="64" spellcheck="false"><?= $xpath['itemAuthor'] ?? '' ?></textarea>
  560. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_author.help') ?></p>
  561. </div>
  562. </div>
  563. <div class="form-group">
  564. <label class="group-name" for="xPathItemTimestamp"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  565. <?= _t('sub.feed.kind.html_xpath.item_timestamp') ?></label>
  566. <div class="group-controls">
  567. <textarea class="valid-xpath w100" name="xPathItemTimestamp" id="xPathItemTimestamp" rows="2" cols="64" spellcheck="false"><?= $xpath['itemTimestamp'] ?? '' ?></textarea>
  568. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_timestamp.help') ?></p>
  569. </div>
  570. </div>
  571. <div class="form-group">
  572. <label class="group-name" for="xPathItemTimeFormat">
  573. <?= _t('sub.feed.kind.html_xpath.item_timeFormat') ?></label>
  574. <div class="group-controls">
  575. <textarea class="w100" name="xPathItemTimeFormat" id="xPathItemTimeFormat" rows="2" cols="64" spellcheck="false"><?= $xpath['itemTimeFormat'] ?? '' ?></textarea>
  576. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.item_timeFormat.help') ?></p>
  577. </div>
  578. </div>
  579. <div class="form-group">
  580. <label class="group-name" for="xPathItemCategories"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  581. <?= _t('sub.feed.kind.html_xpath.item_categories') ?></label>
  582. <div class="group-controls">
  583. <textarea class="valid-xpath w100" name="xPathItemCategories" id="xPathItemCategories" rows="2" cols="64" spellcheck="false"><?= $xpath['itemCategories'] ?? '' ?></textarea>
  584. </div>
  585. </div>
  586. <div class="form-group">
  587. <label class="group-name" for="xPathItemUid"><small><?= _t('sub.feed.kind.html_xpath.relative') ?></small><br />
  588. <?= _t('sub.feed.kind.html_xpath.item_uid') ?></label>
  589. <div class="group-controls">
  590. <textarea class="valid-xpath w100" name="xPathItemUid" id="xPathItemUid" rows="2" cols="64" spellcheck="false"><?= $xpath['itemUid'] ?? '' ?></textarea>
  591. </div>
  592. </div>
  593. </fieldset>
  594. <fieldset id="json_dotnotation">
  595. <?php
  596. /** @var array<string,string> $jsonSettings */
  597. $jsonSettings = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeArray('json_dotnotation') ?? []);
  598. $xPathToJson = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeString('xPathToJson'));
  599. ?>
  600. <div class="form-group" id="xPathToJsonGroup">
  601. <label class="group-name" for="xPathToJson"><?= _t('sub.feed.kind.html_json.xpath') ?></label>
  602. <div class="group-controls">
  603. <textarea class="valid-xpath w100" name="xPathToJson" id="xPathToJson" rows="2" cols="64" spellcheck="false"><?= $xPathToJson ?? '' ?></textarea>
  604. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_json.xpath.help') ?></p>
  605. </div>
  606. </div>
  607. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.help') ?></p>
  608. <div class="form-group">
  609. <label class="group-name" for="jsonItem"><small><?= _t('sub.feed.kind.json_dotnotation.json') ?></small><br />
  610. <?= _t('sub.feed.kind.json_dotnotation.item') ?></label>
  611. <div class="group-controls">
  612. <textarea class="valid-json w100" name="jsonItem" id="jsonItem" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['item'] ?? '' ?></textarea>
  613. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.item.help') ?></p>
  614. </div>
  615. </div>
  616. <div class="form-group">
  617. <label class="group-name" for="jsonItemTitle"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  618. <?= _t('sub.feed.kind.json_dotnotation.item_title') ?></label>
  619. <div class="group-controls">
  620. <textarea class="valid-json w100" name="jsonItemTitle" id="jsonItemTitle" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemTitle'] ?? '' ?></textarea>
  621. </div>
  622. </div>
  623. <div class="form-group">
  624. <label class="group-name" for="jsonItemContent"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  625. <?= _t('sub.feed.kind.json_dotnotation.item_content') ?></label>
  626. <div class="group-controls">
  627. <textarea class="valid-json w100" name="jsonItemContent" id="jsonItemContent" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemContent'] ?? '' ?></textarea>
  628. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.item_content.help') ?></p>
  629. </div>
  630. </div>
  631. <div class="form-group">
  632. <label class="group-name" for="jsonItemUri"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  633. <?= _t('sub.feed.kind.json_dotnotation.item_uri') ?></label>
  634. <div class="group-controls">
  635. <textarea class="valid-json w100" name="jsonItemUri" id="jsonItemUri" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemUri'] ?? '' ?></textarea>
  636. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.item_uri.help') ?></p>
  637. </div>
  638. </div>
  639. <div class="form-group">
  640. <label class="group-name" for="jsonItemThumbnail"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  641. <?= _t('sub.feed.kind.json_dotnotation.item_thumbnail') ?></label>
  642. <div class="group-controls">
  643. <textarea class="valid-json w100" name="jsonItemThumbnail" id="jsonItemThumbnail" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemThumbnail'] ?? '' ?></textarea>
  644. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.item_thumbnail.help') ?></p>
  645. </div>
  646. </div>
  647. <div class="form-group">
  648. <label class="group-name" for="jsonItemAuthor"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  649. <?= _t('sub.feed.kind.json_dotnotation.item_author') ?></label>
  650. <div class="group-controls">
  651. <textarea class="valid-json w100" name="jsonItemAuthor" id="jsonItemAuthor" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemAuthor'] ?? '' ?></textarea>
  652. </div>
  653. </div>
  654. <div class="form-group">
  655. <label class="group-name" for="jsonItemTimestamp"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  656. <?= _t('sub.feed.kind.json_dotnotation.item_timestamp') ?></label>
  657. <div class="group-controls">
  658. <textarea class="valid-json w100" name="jsonItemTimestamp" id="jsonItemTimestamp" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemTimestamp'] ?? '' ?></textarea>
  659. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.item_timestamp.help') ?></p>
  660. </div>
  661. </div>
  662. <div class="form-group">
  663. <label class="group-name" for="jsonItemTimeFormat">
  664. <?= _t('sub.feed.kind.json_dotnotation.item_timeFormat') ?></label>
  665. <div class="group-controls">
  666. <textarea class="w100" name="jsonItemTimeFormat" id="jsonItemTimeFormat" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemTimeFormat'] ?? '' ?></textarea>
  667. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.item_timeFormat.help') ?></p>
  668. </div>
  669. </div>
  670. <div class="form-group">
  671. <label class="group-name" for="jsonItemCategories"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  672. <?= _t('sub.feed.kind.json_dotnotation.item_categories') ?></label>
  673. <div class="group-controls">
  674. <textarea class="valid-json w100" name="jsonItemCategories" id="jsonItemCategories" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemCategories'] ?? '' ?></textarea>
  675. </div>
  676. </div>
  677. <div class="form-group">
  678. <label class="group-name" for="jsonItemUid"><small><?= _t('sub.feed.kind.json_dotnotation.relative') ?></small><br />
  679. <?= _t('sub.feed.kind.json_dotnotation.item_uid') ?></label>
  680. <div class="group-controls">
  681. <textarea class="valid-json w100" name="jsonItemUid" id="jsonItemUid" rows="2" cols="64" spellcheck="false"><?= $jsonSettings['itemUid'] ?? '' ?></textarea>
  682. </div>
  683. </div>
  684. <div class="form-group form-actions">
  685. <div class="group-controls">
  686. <button class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  687. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  688. </div>
  689. </div>
  690. </fieldset>
  691. <fieldset>
  692. <legend><?= _t('sub.feed.content_retrieval') ?></legend>
  693. <div class="form-group">
  694. <label class="group-name" for="path_entries"><?= _t('sub.feed.css_path') ?></label>
  695. <div class="group-controls">
  696. <div class="stick w100">
  697. <input type="text" name="path_entries" id="path_entries" class="w100" value="<?= $this->feed->pathEntries() ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
  698. <a id="popup-preview-selector" class="btn" href="<?=
  699. _url('feed', 'contentSelectorPreview', 'id', $this->feed->id(), 'selector', 'selector-token', 'selector_filter', 'selector-filter-token', '#', 'slider') ?>"><?= _i('look') ?></a>
  700. </div>
  701. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.css_help') ?></p>
  702. </div>
  703. </div>
  704. <div class="form-group">
  705. <label class="group-name" for="path_entries_conditions"><?= _t('sub.feed.path_entries_conditions') ?></label>
  706. <div class="group-controls">
  707. <textarea class="w100" id="path_entries_conditions" name="path_entries_conditions"
  708. rows="3" cols="64" spellcheck="false" placeholder="<?= _t('gen.short.blank_to_disable') ?>"><?php
  709. foreach ($this->feed->attributeArray('path_entries_conditions') ?? [] as $condition) {
  710. if (is_string($condition)) {
  711. echo htmlspecialchars($condition, ENT_NOQUOTES, 'UTF-8'), PHP_EOL;
  712. }
  713. }
  714. ?></textarea>
  715. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.filteractions.help') ?></p>
  716. </div>
  717. </div>
  718. </fieldset>
  719. <fieldset>
  720. <legend><?= _t('sub.feed.advanced') ?></legend>
  721. <div class="form-group">
  722. <?php
  723. $path_entries_filter = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeString('path_entries_filter') ?? '');
  724. ?>
  725. <label class="group-name" for="path_entries_filter"><?= _t('sub.feed.css_path_filter') ?></label>
  726. <div class="group-controls">
  727. <div class="w100">
  728. <input type="text" name="path_entries_filter" id="path_entries_filter" class="w100" value="<?= $path_entries_filter ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
  729. </div>
  730. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.css_path_filter.help') ?></p>
  731. </div>
  732. </div>
  733. <div class="form-group">
  734. <?php
  735. /** @var array<int,int|string> $curlParams */
  736. $curlParams = $this->feed->attributeArray('curl_params') ?? [];
  737. ?>
  738. <label class="group-name" for="curl_params_cookie"><?= _t('sub.feed.css_cookie') ?></label>
  739. <div class="group-controls">
  740. <input type="text" name="curl_params_cookie" id="curl_params_cookie" class="w100" value="<?=
  741. htmlspecialchars((string)($curlParams[CURLOPT_COOKIE] ?? ''), ENT_COMPAT, 'UTF-8')
  742. ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
  743. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.css_cookie_help') ?></p>
  744. <label for="curl_params_cookiefile">
  745. <input type="checkbox" name="curl_params_cookiefile" id="curl_params_cookiefile" value="1"<?=
  746. isset($curlParams[CURLOPT_COOKIEFILE]) ? ' checked="checked"' : ''
  747. ?> />
  748. <?= _t('sub.feed.accept_cookies') ?>
  749. </label>
  750. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.accept_cookies_help') ?></p>
  751. </div>
  752. </div>
  753. <div class="form-group">
  754. <label class="group-name" for="curl_params_redirects"><?= _t('sub.feed.max_http_redir') ?></label>
  755. <div class="group-controls">
  756. <input type="number" name="curl_params_redirects" id="curl_params_redirects" class="w50" min="-1" value="<?=
  757. !empty($curlParams[CURLOPT_MAXREDIRS]) ? $curlParams[CURLOPT_MAXREDIRS] : ''
  758. ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
  759. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.max_http_redir_help') ?></p>
  760. </div>
  761. </div>
  762. <div class="form-group">
  763. <label class="group-name" for="content_action"><?= _t('sub.feed.content_action') ?></label>
  764. <div class="group-controls">
  765. <select name="content_action" id="content_action" class="w50">
  766. <option value="replace"<?= 'replace' === $this->feed->attributeString('content_action') ? ' selected="selected"' : '' ?>><?= _t('sub.feed.content_action.replace') ?></option>
  767. <option value="prepend"<?= 'prepend' === $this->feed->attributeString('content_action') ? ' selected="selected"' : '' ?>><?= _t('sub.feed.content_action.prepend') ?></option>
  768. <option value="append"<?= 'append' === $this->feed->attributeString('content_action') ? ' selected="selected"' : '' ?>><?= _t('sub.feed.content_action.append') ?></option>
  769. </select>
  770. </div>
  771. </div>
  772. <div class="form-group">
  773. <label class="group-name" for="curl_params_useragent"><?= _t('sub.feed.useragent') ?></label>
  774. <div class="group-controls">
  775. <input type="text" name="curl_params_useragent" id="curl_params_useragent" class="w100" value="<?=
  776. htmlspecialchars((string)($curlParams[CURLOPT_USERAGENT] ?? ''), ENT_COMPAT, 'UTF-8')
  777. ?>" placeholder="<?= _t('gen.short.by_default') ?>" />
  778. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.useragent_help') ?></p>
  779. </div>
  780. </div>
  781. <div class="form-group">
  782. <label class="group-name" for="proxy_type"><?= _t('sub.feed.proxy') ?></label>
  783. <div class="group-controls">
  784. <select name="proxy_type" id="proxy_type"><?php
  785. defined('CURLPROXY_HTTPS') or define('CURLPROXY_HTTPS', 2); // Compatibility cURL 7.51
  786. $type = $curlParams[CURLOPT_PROXYTYPE] ?? '';
  787. if ($type === 3) { // Legacy for NONE
  788. $type = -1;
  789. }
  790. foreach (['' => '', -1 => 'NONE', CURLPROXY_HTTP => 'HTTP', CURLPROXY_HTTPS => 'HTTPS',
  791. CURLPROXY_SOCKS4 => 'SOCKS4', CURLPROXY_SOCKS4A => 'SOCKS4A', CURLPROXY_SOCKS5 => 'SOCKS5',
  792. CURLPROXY_SOCKS5_HOSTNAME => 'SOCKS5H'] as $k => $v) {
  793. echo '<option value="' . $k . ($type === $k ? '" selected="selected' : '' ) . '">' . $v . '</option>';
  794. }
  795. ?>
  796. </select>
  797. <input type="text" name="curl_params" id="curl_params" value="<?=
  798. htmlspecialchars((string)($curlParams[CURLOPT_PROXY] ?? ''), ENT_COMPAT, 'UTF-8')
  799. ?>" placeholder="<?= _t('gen.short.by_default') ?>" />
  800. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.proxy_help') ?></p>
  801. </div>
  802. </div>
  803. <div class="form-group">
  804. <label class="group-name" for="curl_method"><?= _t('sub.feed.method') ?></label>
  805. <div class="group-controls">
  806. <select class="number" name="curl_method" id="curl_method"><?php
  807. $curl_method = 'GET';
  808. if ($this->feed->attributeArray('curl_params') !== null && !empty($this->feed->attributeArray('curl_params')[CURLOPT_POST])) {
  809. $curl_method = 'POST';
  810. }
  811. foreach (['GET' => 'GET', 'POST' => 'POST'] as $k => $v) {
  812. echo '<option value="' . $k . ($curl_method === $k ? '" selected="selected' : '') . '">' . $v . '</option>';
  813. }
  814. ?>
  815. </select>
  816. <div class="stick">
  817. <?php
  818. $postFields = $this->feed->attributeArray('curl_params')[CURLOPT_POSTFIELDS] ?? '';
  819. if (!is_string($postFields)) {
  820. $postFields = '';
  821. }
  822. ?>
  823. <input type="text" name="curl_fields" id="curl_fields" value="<?=
  824. htmlspecialchars($postFields, ENT_COMPAT, 'UTF-8')
  825. ?>" placeholder="<?= _t('sub.feed.method_postparams') ?>" />
  826. </div>
  827. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.method_help') ?></p>
  828. </div>
  829. </div>
  830. <div class="form-group">
  831. <label class="group-name" for="timeout"><?= _t('sub.feed.timeout') ?></label>
  832. <div class="group-controls">
  833. <input type="number" name="timeout" id="timeout" class="w50" min="3" max="900" value="<?= $this->feed->attributeInt('timeout') ?>" placeholder="<?= _t('gen.short.by_default') ?>" />
  834. </div>
  835. </div>
  836. <div class="form-group">
  837. <label class="group-name" for="ssl_verify"><?= _t('sub.feed.ssl_verify') ?></label>
  838. <div class="group-controls">
  839. <select name="ssl_verify" id="ssl_verify" class="w50">
  840. <option value=""<?= $this->feed->attributeBoolean('ssl_verify') === null ? ' selected="selected"' : '' ?>><?= _t('gen.short.by_default') ?></option>
  841. <option value="0"<?= $this->feed->attributeBoolean('ssl_verify') === false ? ' selected="selected"' : '' ?>><?= _t('gen.short.no') ?></option>
  842. <option value="1"<?= $this->feed->attributeBoolean('ssl_verify') === true ? ' selected="selected"' : '' ?>><?= _t('gen.short.yes') ?></option>
  843. </select>
  844. </div>
  845. </div>
  846. <div class="form-group">
  847. <label class="group-name" for="http_headers"><?= _t('sub.feed.http_headers') ?></label>
  848. <div class="group-controls">
  849. <?php
  850. $httpHeaders = $this->feed->attributeArray('curl_params')[CURLOPT_HTTPHEADER] ?? [];
  851. if (!is_array($httpHeaders)) {
  852. $httpHeaders = [];
  853. }
  854. $httpHeaders = array_filter($httpHeaders, 'is_string');
  855. // Remove headers problematic for security
  856. $httpHeaders = array_filter($httpHeaders,
  857. fn(string $header) => !preg_match('/^(Remote-User|X-WebAuth-User)\\s*:/i', $header));
  858. ?>
  859. <textarea class="w100" id="http_headers" name="http_headers" rows="3" spellcheck="false"><?php
  860. foreach ($httpHeaders as $header) {
  861. echo htmlspecialchars($header, ENT_NOQUOTES, 'UTF-8'), PHP_EOL;
  862. }
  863. ?></textarea>
  864. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.http_headers_help') ?></p>
  865. </div>
  866. </div>
  867. <div class="form-group">
  868. <div class="group-controls">
  869. <label class="checkbox" for="clear_cache">
  870. <input type="checkbox" name="clear_cache" id="clear_cache" value="1"<?= $this->feed->attributeBoolean('clear_cache') ? ' checked="checked"' : '' ?> />
  871. <?= _t('sub.feed.clear_cache') ?>
  872. </label>
  873. </div>
  874. </div>
  875. <div class="form-group form-actions">
  876. <div class="group-controls">
  877. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  878. <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
  879. </div>
  880. </div>
  881. </fieldset>
  882. </form>
  883. <h2><?= _t('sub.feed.maintenance.title') ?></h2>
  884. <div class="form-group">
  885. <div class="group-controls">
  886. <button class="btn btn-important" form="post-csrf" formaction="<?= _url('feed', 'clearCache', 'id', $this->feed->id(), '#', 'slider') ?>">
  887. <?= _t('sub.feed.maintenance.clear_cache') ?>
  888. </button>
  889. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.maintenance.clear_cache_help') ?></p>
  890. </div>
  891. <div class="group-controls">
  892. <form method="post" action="<?= _url('feed', 'reload', '#', 'slider') ?>">
  893. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  894. <input type="hidden" name="id" value="<?= $this->feed->id() ?>" />
  895. <button type="submit" class="btn btn-important">
  896. <?= _t('sub.feed.maintenance.reload_articles') ?>
  897. </button>
  898. <input type="number" name="reload_limit" min="1" value="10" />
  899. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.maintenance.reload_articles_help') ?></p>
  900. </form>
  901. </div>
  902. </div>
  903. <h2><?= _t('sub.import_export.export') ?></h2>
  904. <div class="form-group">
  905. <div class="group-name"><?= _t('sub.feed.export-as-opml.label') ?></div>
  906. <div class="group-controls">
  907. <a class="btn btn-important" href="<?= _url('index', 'opml', 'get', 'f_' . $this->feed->id()) ?>" download="f_<?= $this->feed->id() ?> <?= $this->feed->name(true) ?>.opml.xml">
  908. <?= _t('sub.feed.export-as-opml.download') ?>
  909. </a>
  910. <p class="help"><?= _i('help') ?> <?= _t('sub.feed.export-as-opml.help') ?></p>
  911. </div>
  912. </div>
  913. </div>
  914. <div id="popup">
  915. <div id="popup-content">
  916. <div id="popup-close" class="popup-row"><?= _i('close') ?></div>
  917. <div id="popup-iframe-container" class="popup-row">
  918. <div id="popup-iframe-sub">
  919. <iframe id="popup-iframe" frameborder="0"></iframe>
  920. </div>
  921. </div>
  922. </div>
  923. </div>