update.phtml 53 KB

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