move order_by to SQL override logic into a separate function
This commit is contained in:
parent
48be005774
commit
dfa65e9374
|
@ -214,21 +214,7 @@ class API extends Handler {
|
||||||
|
|
||||||
$_SESSION['hasSandbox'] = $has_sandbox;
|
$_SESSION['hasSandbox'] = $has_sandbox;
|
||||||
|
|
||||||
$skip_first_id_check = false;
|
list($override_order, $skip_first_id_check) = Feeds::order_to_override_query(clean($_REQUEST["order_by"]));
|
||||||
|
|
||||||
$override_order = false;
|
|
||||||
switch (clean($_REQUEST["order_by"])) {
|
|
||||||
case "title":
|
|
||||||
$override_order = "ttrss_entries.title, date_entered, updated";
|
|
||||||
break;
|
|
||||||
case "date_reverse":
|
|
||||||
$override_order = "updated";
|
|
||||||
$skip_first_id_check = true;
|
|
||||||
break;
|
|
||||||
case "feed_dates":
|
|
||||||
$override_order = "updated DESC";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do not rely on params below */
|
/* do not rely on params below */
|
||||||
|
|
||||||
|
|
|
@ -529,21 +529,7 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
$reply['headlines'] = [];
|
$reply['headlines'] = [];
|
||||||
|
|
||||||
$override_order = false;
|
list($override_order, $skip_first_id_check) = Feeds::order_to_override_query($order_by);
|
||||||
$skip_first_id_check = false;
|
|
||||||
|
|
||||||
switch ($order_by) {
|
|
||||||
case "title":
|
|
||||||
$override_order = "ttrss_entries.title, date_entered, updated";
|
|
||||||
break;
|
|
||||||
case "date_reverse":
|
|
||||||
$override_order = "updated";
|
|
||||||
$skip_first_id_check = true;
|
|
||||||
break;
|
|
||||||
case "feed_dates":
|
|
||||||
$override_order = "updated DESC";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ret = $this->format_headlines_list($feed, $method,
|
$ret = $this->format_headlines_list($feed, $method,
|
||||||
$view_mode, $limit, $cat_view, $offset,
|
$view_mode, $limit, $cat_view, $offset,
|
||||||
|
@ -2348,5 +2334,25 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
return array($search_query_part, $search_words);
|
return array($search_query_part, $search_words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function order_to_override_query($order) {
|
||||||
|
$query = "";
|
||||||
|
$skip_first_id = false;
|
||||||
|
|
||||||
|
switch ($order) {
|
||||||
|
case "title":
|
||||||
|
$query = "ttrss_entries.title, date_entered, updated";
|
||||||
|
break;
|
||||||
|
case "date_reverse":
|
||||||
|
$query = "updated";
|
||||||
|
$skip_first_id = true;
|
||||||
|
break;
|
||||||
|
case "feed_dates":
|
||||||
|
$query = "updated DESC";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$query, $skip_first_id];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,24 +12,16 @@ class Handler_Public extends Handler {
|
||||||
|
|
||||||
if (!$limit) $limit = 60;
|
if (!$limit) $limit = 60;
|
||||||
|
|
||||||
$date_sort_field = "date_entered DESC, updated DESC";
|
list($override_order, $skip_first_id_check) = Feeds::order_to_override_query($order);
|
||||||
|
|
||||||
if ($feed == -2 && !$is_cat) {
|
if (!$override_order) {
|
||||||
$date_sort_field = "last_published DESC";
|
$override_order = "date_entered DESC, updated DESC";
|
||||||
} else if ($feed == -1 && !$is_cat) {
|
|
||||||
$date_sort_field = "last_marked DESC";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($order) {
|
if ($feed == -2 && !$is_cat) {
|
||||||
case "title":
|
$override_order = "last_published DESC";
|
||||||
$date_sort_field = "ttrss_entries.title, date_entered, updated";
|
} else if ($feed == -1 && !$is_cat) {
|
||||||
break;
|
$override_order = "last_marked DESC";
|
||||||
case "date_reverse":
|
}
|
||||||
$date_sort_field = "updated";
|
|
||||||
break;
|
|
||||||
case "feed_dates":
|
|
||||||
$date_sort_field = "updated DESC";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
|
@ -39,7 +31,7 @@ class Handler_Public extends Handler {
|
||||||
"view_mode" => $view_mode,
|
"view_mode" => $view_mode,
|
||||||
"cat_view" => $is_cat,
|
"cat_view" => $is_cat,
|
||||||
"search" => $search,
|
"search" => $search,
|
||||||
"override_order" => $date_sort_field,
|
"override_order" => $override_order,
|
||||||
"include_children" => true,
|
"include_children" => true,
|
||||||
"ignore_vfeed_group" => true,
|
"ignore_vfeed_group" => true,
|
||||||
"offset" => $offset,
|
"offset" => $offset,
|
||||||
|
|
Loading…
Reference in New Issue