summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php97
1 files changed, 68 insertions, 29 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index 07677a8cd..86fa45ea7 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -54,7 +54,7 @@ class Feeds extends Handler_Protected {
$reply .= "<span class=\"right\">";
$reply .= "<span id='selected_prompt'></span>";
$reply .= "&nbsp;";
- $reply .= "<select dojoType=\"dijit.form.Select\"
+ $reply .= "<select dojoType=\"fox.form.Select\"
onchange=\"Headlines.onActionChanged(this)\">";
$reply .= "<option value=\"0\" disabled='1'>".__('Select...')."</option>";
@@ -210,6 +210,8 @@ class Feeds extends Handler_Protected {
$highlight_words = $qfh_ret[5];
$reply['first_id'] = $qfh_ret[6];
$reply['is_vfeed'] = $qfh_ret[7];
+ $query_error_override = $qfh_ret[8];
+
$reply['search_query'] = [$search, $search_language];
$reply['vfeed_group_enabled'] = $vfeed_group_enabled;
@@ -387,22 +389,26 @@ class Feeds extends Handler_Protected {
if (is_object($result)) {
- switch ($view_mode) {
- case "unread":
- $message = __("No unread articles found to display.");
- break;
- case "updated":
- $message = __("No updated articles found to display.");
- break;
- case "marked":
- $message = __("No starred articles found to display.");
- break;
- default:
- if ($feed < LABEL_BASE_INDEX) {
- $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
- } else {
- $message = __("No articles found to display.");
- }
+ if ($query_error_override) {
+ $message = $query_error_override;
+ } else {
+ switch ($view_mode) {
+ case "unread":
+ $message = __("No unread articles found to display.");
+ break;
+ case "updated":
+ $message = __("No updated articles found to display.");
+ break;
+ case "marked":
+ $message = __("No starred articles found to display.");
+ break;
+ default:
+ if ($feed < LABEL_BASE_INDEX) {
+ $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
+ } else {
+ $message = __("No articles found to display.");
+ }
+ }
}
if (!$offset && $message) {
@@ -659,7 +665,7 @@ class Feeds extends Handler_Protected {
if (get_pref('ENABLE_FEED_CATS')) {
print "<label class='inline'>" . __('Place in category:') . "</label> ";
- print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
+ print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"');
}
print "</fieldset>";
@@ -671,7 +677,7 @@ class Feeds extends Handler_Protected {
<section>
<fieldset>
<select id="feedDlg_feedContainerSelect"
- dojoType="dijit.form.Select" size="3">
+ dojoType="fox.form.Select" size="3">
<script type="dojo/method" event="onChange" args="value">
dijit.byId("feedDlg_feedUrl").attr("value", value);
</script>
@@ -724,17 +730,17 @@ class Feeds extends Handler_Protected {
print "<section>";
print "<fieldset>";
- print "<input dojoType='dijit.form.ValidationTextBox'
+ print "<input dojoType='dijit.form.ValidationTextBox' id='search_query'
style='font-size : 16px; width : 540px;'
placeHolder=\"".T_sprintf("Search %s...", $this->getFeedTitle($active_feed_id, $is_cat))."\"
- required='1' name='query' type='search' value=''>";
+ name='query' type='search' value=''>";
print "</fieldset>";
if (DB_TYPE == "pgsql") {
print "<fieldset>";
print "<label class='inline'>" . __("Language:") . "</label>";
- print_select("search_language", "", Pref_Feeds::get_ts_languages(),
- "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
+ print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(),
+ "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\"");
print "</fieldset>";
}
@@ -844,9 +850,23 @@ class Feeds extends Handler_Protected {
$pdo = Db::pdo();
- // Todo: all this interval stuff needs some generic generator function
+ if (is_array($search) && $search[0]) {
+ $search_qpart = "";
- $search_qpart = is_array($search) && $search[0] ? search_to_sql($search[0], $search[1])[0] : 'true';
+ foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) {
+ list($search_qpart, $search_words) = $plugin->hook_search($search[0]);
+ break;
+ }
+
+ // fall back in case of no plugins
+ if (!$search_qpart) {
+ list($search_qpart, $search_words) = search_to_sql($search[0], $search[1]);
+ }
+ } else {
+ $search_qpart = "true";
+ }
+
+ // TODO: all this interval stuff needs some generic generator function
switch ($mode) {
case "1day":
@@ -1111,6 +1131,7 @@ class Feeds extends Handler_Protected {
global $fetch_last_error;
global $fetch_last_error_content;
+ global $fetch_last_content_type;
$pdo = Db::pdo();
@@ -1132,7 +1153,7 @@ class Feeds extends Handler_Protected {
return array("code" => 5, "message" => $fetch_last_error);
}
- if (is_html($contents)) {
+ if (mb_strpos($fetch_last_content_type, "html") !== FALSE && is_html($contents)) {
$feedUrls = get_feeds_from_html($url, $contents);
if (count($feedUrls) == 0) {
@@ -1421,10 +1442,13 @@ class Feeds extends Handler_Protected {
$ext_tables_part = "";
$limit_query_part = "";
+ $query_error_override = "";
- $search_words = array();
+ $search_words = [];
if ($search) {
+ $search_query_part = "";
+
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) {
list($search_query_part, $search_words) = $plugin->hook_search($search);
break;
@@ -1434,6 +1458,21 @@ class Feeds extends Handler_Protected {
if (!$search_query_part) {
list($search_query_part, $search_words) = search_to_sql($search, $search_language);
}
+
+ if (DB_TYPE == "pgsql") {
+ $test_sth = $pdo->prepare("select $search_query_part
+ FROM ttrss_entries, ttrss_user_entries WHERE id = ref_id limit 1");
+
+ try {
+ $test_sth->execute();
+ } catch (PDOException $e) {
+ // looks like tsquery syntax is invalid
+ $search_query_part = "false";
+
+ $query_error_override = T_sprintf("Incorrect search syntax: %s.", implode(" ", $search_words));
+ }
+ }
+
$search_query_part .= " AND ";
} else {
$search_query_part = "";
@@ -1725,7 +1764,7 @@ class Feeds extends Handler_Protected {
$first_id = (int)$row["id"];
if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) {
- return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "");
+ return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override);
}
}
}
@@ -1814,7 +1853,7 @@ class Feeds extends Handler_Protected {
$res = $pdo->query($query);
}
- return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "");
+ return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override);
}