mirror of
https://tt-rss.org/git/tt-rss.git
synced 2024-06-26 11:59:02 +02:00
move opml-specific get_feed_category to opml.php
This commit is contained in:
parent
9549e33c2c
commit
e60d5b0a84
|
@ -386,7 +386,7 @@ class Opml extends Handler_Protected {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
|
private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
|
||||||
$default_cat_id = (int) get_feed_category('Imported feeds', false);
|
$default_cat_id = (int) $this->get_feed_category('Imported feeds', false);
|
||||||
|
|
||||||
if ($root_node) {
|
if ($root_node) {
|
||||||
$cat_title = $this->dbh->escape_string(mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250));
|
$cat_title = $this->dbh->escape_string(mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250));
|
||||||
|
@ -395,11 +395,11 @@ class Opml extends Handler_Protected {
|
||||||
$cat_title = $this->dbh->escape_string(mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250));
|
$cat_title = $this->dbh->escape_string(mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250));
|
||||||
|
|
||||||
if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
|
if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
|
||||||
$cat_id = get_feed_category($cat_title, $parent_id);
|
$cat_id = $this->get_feed_category($cat_title, $parent_id);
|
||||||
$this->dbh->query("BEGIN");
|
$this->dbh->query("BEGIN");
|
||||||
if ($cat_id === false) {
|
if ($cat_id === false) {
|
||||||
add_feed_category($cat_title, $parent_id);
|
add_feed_category($cat_title, $parent_id);
|
||||||
$cat_id = get_feed_category($cat_title, $parent_id);
|
$cat_id = $this->get_feed_category($cat_title, $parent_id);
|
||||||
}
|
}
|
||||||
$this->dbh->query("COMMIT");
|
$this->dbh->query("COMMIT");
|
||||||
} else {
|
} else {
|
||||||
|
@ -513,5 +513,25 @@ class Opml extends Handler_Protected {
|
||||||
return $url_path;
|
return $url_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_feed_category($feed_cat, $parent_cat_id = false) {
|
||||||
|
if ($parent_cat_id) {
|
||||||
|
$parent_qpart = "parent_cat = '$parent_cat_id'";
|
||||||
|
$parent_insert = "'$parent_cat_id'";
|
||||||
|
} else {
|
||||||
|
$parent_qpart = "parent_cat IS NULL";
|
||||||
|
$parent_insert = "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = db_query(
|
||||||
|
"SELECT id FROM ttrss_feed_categories
|
||||||
|
WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 0) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return db_fetch_result($result, 0, "id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1635,26 +1635,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_feed_category($feed_cat, $parent_cat_id = false) {
|
|
||||||
if ($parent_cat_id) {
|
|
||||||
$parent_qpart = "parent_cat = '$parent_cat_id'";
|
|
||||||
$parent_insert = "'$parent_cat_id'";
|
|
||||||
} else {
|
|
||||||
$parent_qpart = "parent_cat IS NULL";
|
|
||||||
$parent_insert = "NULL";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = db_query(
|
|
||||||
"SELECT id FROM ttrss_feed_categories
|
|
||||||
WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
|
|
||||||
|
|
||||||
if (db_num_rows($result) == 0) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return db_fetch_result($result, 0, "id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_feed_category($feed_cat, $parent_cat_id = false) {
|
function add_feed_category($feed_cat, $parent_cat_id = false) {
|
||||||
|
|
||||||
if (!$feed_cat) return false;
|
if (!$feed_cat) return false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user