query.phtml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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->sharedUrlGreader() ?>"><?= _i('link') ?> <?= _t('conf.query.share.greader') ?></a></li>
  48. <li><a href="<?= $this->query->sharedUrlRss() ?>"><?= _i('link') ?> <?= _t('conf.query.share.rss') ?></a></li>
  49. </ul>
  50. <label class="checkbox" for="publishLabelsInsteadOfTags">
  51. <input type="checkbox" name="query[publishLabelsInsteadOfTags]" id="publishLabelsInsteadOfTags" value="1" <?= $this->query->publishLabelsInsteadOfTags() ? 'checked="checked"' : ''?> />
  52. <?= _t('conf.query.filter.publish_labels_instead_of_tags') ?>
  53. </label>
  54. <?php endif; ?>
  55. </div>
  56. <div class="group-controls">
  57. <label class="checkbox" for="shareOpml">
  58. <input type="checkbox" name="query[shareOpml]" id="shareOpml" value="1" <?= $this->query->shareOpml() && $this->query->safeForOpml() ? 'checked="checked"' : '' ?>
  59. <?= $this->query->safeForOpml() ? '' : 'disabled="disabled"' ?> />
  60. <?= _t('conf.query.filter.shareOpml') ?>
  61. </label>
  62. <?php if ($this->query->sharedUrlOpml() !== ''): ?>
  63. <ul>
  64. <li><a href="<?= $this->query->sharedUrlOpml() ?>"><?= _i('link') ?> <?= _t('conf.query.share.opml') ?></a></li>
  65. </ul>
  66. <?php endif; ?>
  67. </div>
  68. <p class="help"><?= _i('help') ?> <?= _t('conf.query.share.help') ?></a></p>
  69. <p class="help"><?= _i('help') ?> <?= _t('conf.query.help') ?></a></p>
  70. </div>
  71. <div class="form-group form-actions">
  72. <div class="group-controls">
  73. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  74. </div>
  75. </div>
  76. </fieldset>
  77. <?php } else { ?>
  78. <div class="form-group">
  79. <label class="group-name"><?= _t('conf.query.share.disabled.title') ?></label>
  80. <div class="group-controls">
  81. <?= _t('conf.query.share.disabled') ?>
  82. <p class="help"><?= _i('help') ?> <?= _t('conf.query.help') ?></a></p>
  83. </div>
  84. </div>
  85. <?php } ?>
  86. <fieldset>
  87. <legend><?= _t('conf.query.filter') ?></legend>
  88. <div class="form-group">
  89. <label class="group-name" for=""><?= _t('conf.query.filter.search') ?></label>
  90. <div class="group-controls">
  91. <input type="text" class="w100" id="query_search" name="query[search]" value="<?=
  92. htmlspecialchars($this->query->getSearch()->toString(expandUserQueries: false), ENT_COMPAT, 'UTF-8') ?>"/>
  93. <p class="help"><?= _i('help') ?> <?= _t('gen.menu.search_help') ?></a></p>
  94. </div>
  95. </div>
  96. <div class="form-group">
  97. <label class="group-name" for=""><?= _t('conf.query.filter.state') ?></label>
  98. <div class="group-controls">
  99. <label class="checkbox" for="show_read">
  100. <input type="checkbox" name="query[state][]" id="show_read"
  101. value="<?= FreshRSS_Entry::STATE_READ ?>" <?= FreshRSS_Entry::STATE_READ & $this->query->getState() ? 'checked="checked"' : ''?> />
  102. <?= _t('index.menu.read') ?>
  103. </label>
  104. <label class="checkbox" for="show_not_read">
  105. <input type="checkbox" name="query[state][]" id="show_not_read"
  106. value="<?= FreshRSS_Entry::STATE_NOT_READ ?>" <?= FreshRSS_Entry::STATE_NOT_READ & $this->query->getState() ? 'checked="checked"' : ''?> />
  107. <?= _t('index.menu.unread') ?>
  108. </label>
  109. <label class="checkbox" for="show_favorite">
  110. <input type="checkbox" name="query[state][]" id="show_favorite"
  111. value="<?= FreshRSS_Entry::STATE_FAVORITE ?>" <?= FreshRSS_Entry::STATE_FAVORITE & $this->query->getState() ? 'checked="checked"' : ''?> />
  112. <?= _t('index.menu.starred') ?>
  113. </label>
  114. <label class="checkbox" for="show_not_favorite">
  115. <input type="checkbox" name="query[state][]" id="show_not_favorite"
  116. value="<?= FreshRSS_Entry::STATE_NOT_FAVORITE ?>" <?= FreshRSS_Entry::STATE_NOT_FAVORITE & $this->query->getState() ? 'checked="checked"' : ''?> />
  117. <?= _t('index.menu.non-starred') ?>
  118. </label>
  119. </div>
  120. </div>
  121. <div class="form-group">
  122. <label class="group-name" for="query_get"><?= _t('conf.query.filter.type') ?></label>
  123. <div class="group-controls">
  124. <select name="query[get]" class="w100" id="query_get" size="10">
  125. <option value="Z" <?= 'Z' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('conf.query.get_Z') ?></option>
  126. <option value="A" <?= 'A' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('conf.query.get_A') ?></option>
  127. <option value="a" <?= in_array($this->query->getGet(), ['', 'a'], true) ? 'selected="selected"' : '' ?>><?= _t('index.feed.title') ?></option>
  128. <option value="i" <?= 'i' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('index.menu.important') ?></option>
  129. <option value="s" <?= 's' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('index.feed.title_fav') ?></option>
  130. <option value="T" <?= 'T' === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= _t('index.menu.mylabels') ?></option>
  131. <optgroup label="<?= _t('conf.query.filter.tags') ?>">
  132. <?php foreach ($this->tags as $tag): ?>
  133. <option value="t_<?= $tag->id() ?>" <?= "t_{$tag->id()}" === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= $tag->name() ?></option>
  134. <?php endforeach?>
  135. </optgroup>
  136. <optgroup label="<?= _t('conf.query.filter.categories') ?>">
  137. <?php foreach ($this->categories as $category): ?>
  138. <option value="c_<?= $category->id() ?>" <?= "c_{$category->id()}" === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= $category->name() ?></option>
  139. <?php endforeach?>
  140. </optgroup>
  141. <optgroup label="<?= _t('conf.query.filter.feeds') ?>">
  142. <?php foreach ($this->feeds as $feed): ?>
  143. <option value="f_<?= $feed->id() ?>" <?= "f_{$feed->id()}" === $this->query->getGet() ? 'selected="selected"' : '' ?>><?= $feed->name() ?></option>
  144. <?php endforeach?>
  145. </optgroup>
  146. </select>
  147. </div>
  148. </div>
  149. <div class="form-group">
  150. <label class="group-name" for=""><?= _t('conf.query.filter.order') ?></label>
  151. <div class="group-controls">
  152. <select name="query[order]" class="w100" id="query_order">
  153. <option value=""></option>
  154. <option value="DESC" <?= 'DESC' === $this->query->getOrder() ? 'selected="selected"' : '' ?>><?= _t('conf.query.order_desc') ?></option>
  155. <option value="ASC" <?= 'ASC' === $this->query->getOrder() ? 'selected="selected"' : '' ?>><?= _t('conf.query.order_asc') ?></option>
  156. </select>
  157. </div>
  158. </div>
  159. <div class="form-group form-actions">
  160. <div class="group-controls">
  161. <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
  162. <button type="submit" class="btn btn-attention confirm"
  163. data-str-confirm="<?= _t('gen.js.confirm_action_feed_cat') ?>"
  164. formaction="<?= _url('configure', 'deleteQuery', 'id', $this->queryId) ?>"
  165. formmethod="post"><?= _t('gen.action.remove') ?></button>
  166. </div>
  167. </div>
  168. </fieldset>
  169. </form>
  170. </div>