query.phtml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. if ($this->query === null) {
  5. throw new FreshRSS_Context_Exception('Query not initialised!');
  6. }
  7. $ajax = Minz_Request::paramBoolean('ajax') || $this->displaySlider;
  8. ?>
  9. <div class="post">
  10. <h2><?= $this->query->getName() ?></h2>
  11. <div>
  12. <a href="<?= $this->query->getUrl() ?>"><?= _i('link') ?> <?= _t('gen.action.filter') ?></a>
  13. </div>
  14. <form method="post" action="<?= _url('configure', 'query', 'id', $this->queryId, 'from', $ajax ? 'queries' : 'query', ...($ajax ? ['#', 'slider'] : [])) ?>" autocomplete="off" data-auto-leave-validation="1">
  15. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  16. <div class="form-group">
  17. <label class="group-name" for="name"><?= _t('conf.query.name') ?></label>
  18. <div class="group-controls">
  19. <input type="text" class="w100" name="name" id="name" value="<?= $this->query->getName() ?>" />
  20. <input type="hidden" name="query[token]" id="query_token" value="<?= $this->query->getToken() ?>" />
  21. </div>
  22. </div>
  23. <div class="form-group">
  24. <label class="group-name" for="description"><?= _t('conf.query.description') ?></label>
  25. <div class="group-controls">
  26. <input type="text" class="w100" name="query[description]" id="description" value="<?= $this->query->getDescription() ?>" />
  27. </div>
  28. </div>
  29. <div class="form-group">
  30. <label class="group-name" for="imageUrl"><?= _t('conf.query.image_url') ?></label>
  31. <div class="group-controls">
  32. <input type="text" class="w100" name="query[imageUrl]" id="imageUrl" value="<?= $this->query->getImageUrl() ?>" />
  33. </div>
  34. </div>
  35. <?php if (FreshRSS_Context::systemConf()->api_enabled) { ?>
  36. <fieldset>
  37. <legend><?= _t('conf.query.share') ?></legend>
  38. <div class="form-group">
  39. <div class="group-controls">
  40. <label class="checkbox" for="shareRss">
  41. <input type="checkbox" name="query[shareRss]" id="shareRss" value="1" <?= $this->query->shareRss() ? 'checked="checked"' : ''?> />
  42. <?= _t('conf.query.filter.shareRss') ?>
  43. </label>
  44. <?php if ($this->query->sharedUrlRss() !== ''): ?>
  45. <ul>
  46. <li><a href="<?= $this->query->sharedUrlHtml() ?>"><?= _i('link') ?> <?= _t('conf.query.share.html') ?></a></li>
  47. <li><a href="<?= $this->query->sharedUrlRss() ?>"><?= _i('link') ?> <?= _t('conf.query.share.rss') ?></a></li>
  48. </ul>
  49. </div>
  50. <div class="group-controls">
  51. <label class="checkbox" for="includeArticleTags">
  52. <input type="checkbox" name="query[includeArticleTags]" id="includeArticleTags" value="1" <?= !$this->query->excludeArticleTags() ? 'checked="checked"' : ''?> />
  53. <?= _t('conf.query.filter.include_article_tags_label') ?>
  54. </label>
  55. <label class="checkbox" for="includeUserLabels">
  56. <input type="checkbox" name="query[includeUserLabels]" id="includeUserLabels" value="1" <?= $this->query->includeUserLabels() ? 'checked="checked"' : ''?> />
  57. <?= _t('conf.query.filter.include_user_labels_label') ?>
  58. <input type="text" name="query[userLabelPrefix]" id="userLabelPrefix" class="w20"
  59. value="<?= htmlspecialchars($this->query->userLabelPrefix() ?: (Minz_User::name() ?? '') . '/', ENT_COMPAT, 'UTF-8') ?>"
  60. placeholder="<?= htmlspecialchars((Minz_User::name() ?? '') . '/', ENT_COMPAT, 'UTF-8') ?>" />
  61. </label>
  62. <?php endif; ?>
  63. </div>
  64. <div class="group-controls">
  65. <label class="checkbox" for="shareOpml">
  66. <input type="checkbox" name="query[shareOpml]" id="shareOpml" value="1" <?= $this->query->shareOpml() && $this->query->safeForOpml() ? 'checked="checked"' : '' ?>
  67. <?= $this->query->safeForOpml() ? '' : 'disabled="disabled"' ?> />
  68. <?= _t('conf.query.filter.shareOpml') ?>
  69. </label>
  70. <?php if ($this->query->sharedUrlOpml() !== ''): ?>
  71. <ul>
  72. <li><a href="<?= $this->query->sharedUrlOpml() ?>"><?= _i('link') ?> <?= _t('conf.query.share.opml') ?></a></li>
  73. <li><a href="<?= $this->query->sharedUrlGreader() ?>"><?= _i('link') ?> <?= _t('conf.query.share.greader') ?></a></li>
  74. </ul>
  75. <?php endif; ?>
  76. </div>
  77. <p class="help"><?= _i('help') ?> <?= _t('conf.query.share.help') ?></a></p>
  78. <p class="help"><?= _i('help') ?> <?= _t('conf.query.help') ?></a></p>
  79. </div>
  80. <div class="form-group form-actions">
  81. <div class="group-controls">
  82. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  83. </div>
  84. </div>
  85. </fieldset>
  86. <?php } else { ?>
  87. <div class="form-group">
  88. <label class="group-name"><?= _t('conf.query.share.disabled.title') ?></label>
  89. <div class="group-controls">
  90. <?= _t('conf.query.share.disabled') ?>
  91. <p class="help"><?= _i('help') ?> <?= _t('conf.query.help') ?></a></p>
  92. </div>
  93. </div>
  94. <?php } ?>
  95. <fieldset>
  96. <legend><?= _t('conf.query.filter') ?></legend>
  97. <div class="form-group">
  98. <label class="group-name" for=""><?= _t('conf.query.filter.search') ?></label>
  99. <div class="group-controls">
  100. <input type="text" class="w100" id="query_search" name="query[search]" value="<?=
  101. htmlspecialchars($this->query->getSearch()->toString(expandUserQueries: false), ENT_COMPAT, 'UTF-8') ?>"/>
  102. <p class="help"><?= _i('help') ?> <?= _t('gen.menu.search_help') ?></a></p>
  103. </div>
  104. </div>
  105. <div class="form-group">
  106. <label class="group-name" for=""><?= _t('conf.query.filter.state') ?></label>
  107. <div class="group-controls">
  108. <label class="checkbox" for="show_read">
  109. <input type="checkbox" name="query[state][]" id="show_read"
  110. value="<?= FreshRSS_Entry::STATE_READ ?>" <?= FreshRSS_Entry::STATE_READ & $this->query->getState() ? 'checked="checked"' : ''?> />
  111. <?= _t('index.menu.read') ?>
  112. </label>
  113. <label class="checkbox" for="show_not_read">
  114. <input type="checkbox" name="query[state][]" id="show_not_read"
  115. value="<?= FreshRSS_Entry::STATE_NOT_READ ?>" <?= FreshRSS_Entry::STATE_NOT_READ & $this->query->getState() ? 'checked="checked"' : ''?> />
  116. <?= _t('index.menu.unread') ?>
  117. </label>
  118. <label class="checkbox" for="show_favorite">
  119. <input type="checkbox" name="query[state][]" id="show_favorite"
  120. value="<?= FreshRSS_Entry::STATE_FAVORITE ?>" <?= FreshRSS_Entry::STATE_FAVORITE & $this->query->getState() ? 'checked="checked"' : ''?> />
  121. <?= _t('index.menu.starred') ?>
  122. </label>
  123. <label class="checkbox" for="show_not_favorite">
  124. <input type="checkbox" name="query[state][]" id="show_not_favorite"
  125. value="<?= FreshRSS_Entry::STATE_NOT_FAVORITE ?>" <?= FreshRSS_Entry::STATE_NOT_FAVORITE & $this->query->getState() ? 'checked="checked"' : ''?> />
  126. <?= _t('index.menu.non-starred') ?>
  127. </label>
  128. </div>
  129. </div>
  130. <div class="form-group">
  131. <label class="group-name" for="query_get"><?= _t('conf.query.filter.type') ?></label>
  132. <div class="group-controls">
  133. <select name="query[get]" class="w100" id="query_get" size="10">
  134. <option value="Z" <?= 'Z' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('conf.query.get_Z') ?></option>
  135. <option value="A" <?= 'A' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('conf.query.get_A') ?></option>
  136. <option value="a" <?= in_array($this->query->getGet(), ['', 'a'], true) ? 'selected="selected"' : '' ?>><?= _t('index.feed.title') ?></option>
  137. <option value="i" <?= 'i' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('index.menu.important') ?></option>
  138. <option value="s" <?= 's' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('index.feed.title_fav') ?></option>
  139. <option value="T" <?= 'T' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('index.menu.mylabels') ?></option>
  140. <optgroup label="<?= _t('conf.query.filter.tags') ?>">
  141. <?php foreach ($this->tags as $tag): ?>
  142. <option value="t_<?= $tag->id() ?>" <?= "t_{$tag->id()}" === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= $tag->name() ?></option>
  143. <?php endforeach?>
  144. </optgroup>
  145. <optgroup label="<?= _t('conf.query.filter.categories') ?>">
  146. <?php foreach ($this->categories as $category): ?>
  147. <option value="c_<?= $category->id() ?>" <?= "c_{$category->id()}" === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= $category->name() ?></option>
  148. <?php endforeach?>
  149. </optgroup>
  150. <optgroup label="<?= _t('conf.query.filter.feeds') ?>">
  151. <?php foreach ($this->feeds as $feed): ?>
  152. <option value="f_<?= $feed->id() ?>" <?= "f_{$feed->id()}" === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= $feed->name() ?></option>
  153. <?php endforeach?>
  154. </optgroup>
  155. </select>
  156. </div>
  157. </div>
  158. <div class="form-group">
  159. <label class="group-name" for=""><?= _t('conf.query.filter.order') ?></label>
  160. <div class="group-controls">
  161. <select name="query[order]" class="w100" id="query_order">
  162. <option value=""></option>
  163. <option value="DESC" <?= 'DESC' === $this->query->getOrder() ? 'selected="selected"' : '' ?>><?= _t('conf.query.order_desc') ?></option>
  164. <option value="ASC" <?= 'ASC' === $this->query->getOrder() ? 'selected="selected"' : '' ?>><?= _t('conf.query.order_asc') ?></option>
  165. </select>
  166. </div>
  167. </div>
  168. <div class="form-group form-actions">
  169. <div class="group-controls">
  170. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  171. <button type="submit" class="btn btn-attention confirm"
  172. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  173. formaction="<?= _url('configure', 'deleteQuery', 'id', $this->queryId) ?>"
  174. formmethod="post"><?= _t('gen.action.remove') ?></button>
  175. </div>
  176. </div>
  177. </fieldset>
  178. </form>
  179. </div>