update.phtml 49 KB

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