mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-14 00:07:51 -05:00
* Tweaks for Vienna RSS https://github.com/FreshRSS/FreshRSS/issues/2091 https://github.com/ViennaRSS/vienna-rss/issues/1197 * Fix get feed by URL * Fix get item ids returning starred elements * API add item ids by feed URL * Add API filter `it` https://feedhq.readthedocs.io/en/latest/api/reference.html#stream-items-ids * API add `nt=` filter + refactoring * No ; prefix for author https://github.com/FreshRSS/FreshRSS/issues/2091#issuecomment-435562495 * Add id long form prefix and accept short id form https://github.com/FreshRSS/FreshRSS/issues/2091#issuecomment-435631259 * Fix quote problem https://github.com/FreshRSS/FreshRSS/issues/2091#issuecomment-435683930 * Isolate bug fix for News+ https://github.com/FreshRSS/FreshRSS/issues/2091#issuecomment-435687041 * Rework encoding conventions https://github.com/FreshRSS/FreshRSS/issues/2091#issuecomment-437441834 * Unicode escaping alternative Alternative approach to encode XML special characters and other problematic characters into their Unicode fullwidth version when we cannot use HTML-encoding because clients disagree wether they should HTML-decode or not. https://github.com/FreshRSS/FreshRSS/issues/2091#issuecomment-436059559
64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Contains Boolean search from the search form.
|
|
*/
|
|
class FreshRSS_BooleanSearch {
|
|
|
|
private $raw_input = '';
|
|
private $searches = array();
|
|
|
|
public function __construct($input) {
|
|
$input = trim($input);
|
|
if ($input == '') {
|
|
return;
|
|
}
|
|
$this->raw_input = $input;
|
|
|
|
$input = preg_replace('/:"(.*?)"/', ':"\1"', $input);
|
|
$splits = preg_split('/\b(OR)\b/i', $input, -1, PREG_SPLIT_DELIM_CAPTURE);
|
|
|
|
$segment = '';
|
|
$ns = count($splits);
|
|
for ($i = 0; $i < $ns; $i++) {
|
|
$segment = $segment . $splits[$i];
|
|
if (trim($segment) == '' || strcasecmp($segment, 'OR') === 0) {
|
|
$segment = '';
|
|
} else {
|
|
$quotes = substr_count($segment, '"') + substr_count($segment, '"');
|
|
if ($quotes % 2 === 0) {
|
|
$segment = trim($segment);
|
|
if ($segment != '') {
|
|
$this->searches[] = new FreshRSS_Search($segment);
|
|
}
|
|
$segment = '';
|
|
}
|
|
}
|
|
}
|
|
$segment = trim($segment);
|
|
if ($segment != '') {
|
|
$this->searches[] = new FreshRSS_Search($segment);
|
|
}
|
|
}
|
|
|
|
public function searches() {
|
|
return $this->searches;
|
|
}
|
|
|
|
public function add($search) {
|
|
if ($search instanceof FreshRSS_Search) {
|
|
$this->searches[] = $search;
|
|
return $search;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function __toString() {
|
|
return $this->getRawInput();
|
|
}
|
|
|
|
public function getRawInput() {
|
|
return $this->raw_input;
|
|
}
|
|
}
|