queryfeedheadlines: PDOize (1)
This commit is contained in:
parent
29f1908e03
commit
b5791f11c5
|
@ -303,8 +303,6 @@ class Feeds extends Handler_Protected {
|
|||
$feed, $cat_view, $search,
|
||||
$last_error, $last_updated);
|
||||
|
||||
$headlines_count = is_numeric($result) ? 0 : db_num_rows($result);
|
||||
|
||||
if ($offset == 0) {
|
||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
|
||||
$reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
|
||||
|
@ -313,17 +311,16 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
$reply['content'] = '';
|
||||
|
||||
if ($headlines_count > 0) {
|
||||
$headlines_count = 0;
|
||||
|
||||
$lnum = $offset;
|
||||
|
||||
$num_unread = 0;
|
||||
|
||||
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
|
||||
|
||||
$expand_cdm = get_pref('CDM_EXPANDED');
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
while ($line = $result->fetch()) {
|
||||
|
||||
++$headlines_count;
|
||||
|
||||
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
|
||||
|
||||
|
@ -392,17 +389,6 @@ class Feeds extends Handler_Protected {
|
|||
alt=\"Publish article\" onclick='togglePub($id)'>";
|
||||
}
|
||||
|
||||
# $content_link = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"".$line["link"]."\">" .
|
||||
# $line["title"] . "</a>";
|
||||
|
||||
# $content_link = "<a
|
||||
# href=\"" . htmlspecialchars($line["link"]) . "\"
|
||||
# onclick=\"view($id,$feed_id);\">" .
|
||||
# $line["title"] . "</a>";
|
||||
|
||||
# $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
|
||||
# $line["title"] . "</a>";
|
||||
|
||||
$updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
|
||||
$date_entered_fmt = T_sprintf("Imported at %s",
|
||||
make_local_datetime($line["date_entered"], false));
|
||||
|
@ -411,10 +397,6 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
$score_pic = "images/" . get_score_pic($score);
|
||||
|
||||
/* $score_title = __("(Click to change)");
|
||||
$score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
|
||||
onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
|
||||
|
||||
$score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
|
||||
title=\"$score\">";
|
||||
|
||||
|
@ -752,9 +734,6 @@ class Feeds extends Handler_Protected {
|
|||
$tmp_content .= "</span>";
|
||||
$tmp_content .= "<div>";
|
||||
|
||||
// $tmp_content .= "$marked_pic";
|
||||
// $tmp_content .= "$published_pic";
|
||||
|
||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
|
||||
$tmp_content .= $p->hook_article_button($line);
|
||||
}
|
||||
|
@ -777,8 +756,9 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
|
||||
|
||||
} else if (!is_numeric($result)) {
|
||||
$message = "";
|
||||
if (!$headlines_count) {
|
||||
|
||||
if (!is_numeric($result)) {
|
||||
|
||||
switch ($view_mode) {
|
||||
case "unread":
|
||||
|
@ -803,7 +783,7 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
$reply['content'] .= "<p><span class=\"insensitive\">";
|
||||
|
||||
$sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
|
||||
$sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
|
||||
WHERE owner_uid = ?");
|
||||
$sth->execute([$_SESSION['uid']]);
|
||||
$row = $sth->fetch();
|
||||
|
@ -821,8 +801,8 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
if ($num_errors > 0) {
|
||||
$reply['content'] .= "<br/>";
|
||||
$reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
|
||||
__('Some feeds have update errors (click for details)')."</a>";
|
||||
$reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" .
|
||||
__('Some feeds have update errors (click for details)') . "</a>";
|
||||
}
|
||||
$reply['content'] .= "</span></p></div>";
|
||||
|
||||
|
@ -830,6 +810,7 @@ class Feeds extends Handler_Protected {
|
|||
} else if (is_numeric($result) && $result == -1) {
|
||||
$reply['first_id_changed'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
|
||||
|
||||
|
@ -2121,10 +2102,10 @@ class Feeds extends Handler_Protected {
|
|||
print $query;
|
||||
}
|
||||
|
||||
$result = db_query($query);
|
||||
$res = $pdo->query($query);
|
||||
|
||||
if ($result && db_num_rows($result) > 0) {
|
||||
$first_id = (int)db_fetch_result($result, 0, "id");
|
||||
if ($row = $res->fetch()) {
|
||||
$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);
|
||||
|
@ -2167,7 +2148,7 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
if ($_REQUEST["debug"]) print $query;
|
||||
|
||||
$result = db_query($query);
|
||||
$res = $pdo->query($query);
|
||||
|
||||
} else {
|
||||
// browsing by tag
|
||||
|
@ -2211,20 +2192,23 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
if ($_REQUEST["debug"]) print $query;
|
||||
|
||||
$result = db_query($query);
|
||||
$res = $pdo->query($query);
|
||||
}
|
||||
|
||||
return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
|
||||
return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
|
||||
|
||||
}
|
||||
|
||||
static function getParentCategories($cat, $owner_uid) {
|
||||
$rv = array();
|
||||
|
||||
$result = db_query("SELECT parent_cat FROM ttrss_feed_categories
|
||||
WHERE id = '$cat' AND parent_cat IS NOT NULL AND owner_uid = $owner_uid");
|
||||
$pdo = Db::pdo();
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
$sth = $pdo->prepare("SELECT parent_cat FROM ttrss_feed_categories
|
||||
WHERE id = ? AND parent_cat IS NOT NULL AND owner_uid = ?");
|
||||
$sth->execute([$cat, $owner_uid]);
|
||||
|
||||
while ($line = $sth->fetch()) {
|
||||
array_push($rv, $line["parent_cat"]);
|
||||
$rv = array_merge($rv, Feeds::getParentCategories($line["parent_cat"], $owner_uid));
|
||||
}
|
||||
|
@ -2235,10 +2219,13 @@ class Feeds extends Handler_Protected {
|
|||
static function getChildCategories($cat, $owner_uid) {
|
||||
$rv = array();
|
||||
|
||||
$result = db_query("SELECT id FROM ttrss_feed_categories
|
||||
WHERE parent_cat = '$cat' AND owner_uid = $owner_uid");
|
||||
$pdo = Db::pdo();
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
$sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories
|
||||
WHERE parent_cat = ? AND owner_uid = ?");
|
||||
$sth->execute([$cat, $owner_uid]);
|
||||
|
||||
while ($line = $sth->fetch()) {
|
||||
array_push($rv, $line["id"]);
|
||||
$rv = array_merge($rv, Feeds::getChildCategories($line["id"], $owner_uid));
|
||||
}
|
||||
|
@ -2247,11 +2234,14 @@ class Feeds extends Handler_Protected {
|
|||
}
|
||||
|
||||
static function getFeedCategory($feed) {
|
||||
$result = db_query("SELECT cat_id FROM ttrss_feeds
|
||||
WHERE id = '$feed'");
|
||||
$pdo = Db::pdo();
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
return db_fetch_result($result, 0, "cat_id");
|
||||
$sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds
|
||||
WHERE id = ?");
|
||||
$sth->execute([$feed]);
|
||||
|
||||
if ($row = $sth->fetch()) {
|
||||
return $row["cat_id"];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue