update.phtml 49 KB

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