if (!$registered_title || $registered_title == "[Unknown]") {
- $feed_title = db_escape_string(mb_substr($rss->get_title(), 0, 199);
+ $feed_title = db_escape_string(mb_substr($rss->get_title(), 0, 199));
if ($feed_title) {
_debug("registering title: $feed_title", $debug_enabled);
if (db_num_rows($result) != 0) {
$base_entry_id = db_fetch_result($result, 0, "id");
$entry_stored_hash = db_fetch_result($result, 0, "content_hash");
+ $article_labels = get_article_labels($base_entry_id, $owner_uid);
} else {
$base_entry_id = false;
$entry_stored_hash = "";
+ $article_labels = array();
}
$article = array("owner_uid" => $owner_uid, // read only
"title" => $entry_title,
"content" => $entry_content,
"link" => $entry_link,
+ "labels" => $article_labels, // current limitation: can add labels to article, can't remove them
"tags" => $entry_tags,
"author" => $entry_author,
+ "force_catchup" => false, // ugly hack for the time being
"language" => $entry_language, // read only
"feed" => array("id" => $feed,
"fetch_url" => $fetch_url,
db_query("UPDATE ttrss_entries SET date_updated = NOW()
WHERE id = '$base_entry_id'");
- // if we allow duplicate posts, we have to continue to
+ // if we allow duplicate posts, we have to continue to
// create the user entries for this feed
if (!get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
continue;
$entry_author = db_escape_string($article["author"]);
$entry_link = db_escape_string($article["link"]);
$entry_content = $article["content"]; // escaped below
+ $entry_force_catchup = $article["force_catchup"];
+ $article_labels = $article["labels"];
+
+ if ($debug_enabled) {
+ _debug("article labels:", $debug_enabled);
+ print_r($article_labels);
+ }
+
+ _debug("force catchup: $entry_force_catchup");
if ($cache_images && is_writable(CACHE_DIR . '/images'))
cache_images($entry_content, $site_url, $debug_enabled);
'$entry_language',
'$entry_author')");
- $article_labels = array();
-
} else {
$base_entry_id = db_fetch_result($result, 0, "id");
-
- $article_labels = get_article_labels($base_entry_id, $owner_uid);
}
// now it should exist, if not - bad luck then
_debug("user record not found, creating...", $debug_enabled);
- if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
+ if ($score >= -500 && !find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) {
$unread = 'true';
$last_read_qpart = 'NULL';
} else {
// N-grams
- if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
+ /* if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
$result = db_query("SELECT COUNT(*) AS similar FROM
ttrss_entries,ttrss_user_entries
if ($ngram_similar > 0) {
$unread = 'false';
}
- }
+ } */
$last_marked = ($marked == 'true') ? 'NOW()' : 'NULL';
$last_published = ($published == 'true') ? 'NOW()' : 'NULL';
db_query("COMMIT");
- _debug("assigning labels...", $debug_enabled);
+ _debug("assigning labels [other]...", $debug_enabled);
+
+ foreach ($article_labels as $label) {
+ label_add_article($entry_ref_id, $label[1], $owner_uid);
+ }
+
+ _debug("assigning labels [filters]...", $debug_enabled);
assign_article_to_label_filters($entry_ref_id, $article_filters,
$owner_uid, $article_labels);
db_query("COMMIT");
}
- if (get_pref("AUTO_ASSIGN_LABELS", $owner_uid, false)) {
- _debug("auto-assigning labels...", $debug_enabled);
-
- foreach ($labels as $label) {
- $caption = preg_quote($label["caption"]);
-
- if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($entry_content) . " $entry_title")) {
- if (!labels_contains_caption($article_labels, $caption)) {
- label_add_article($entry_ref_id, $caption, $owner_uid);
- }
- }
- }
- }
-
_debug("article processed", $debug_enabled);
}
file_put_contents($local_filename, $file_content);
}
}
-
- /* if (file_exists($local_filename)) {
- $entry->setAttribute('src', SELF_URL_PATH . '/image.php?url=' .
- base64_encode($src));
- } */
}
}
-
- //$node = $doc->getElementsByTagName('body')->item(0);
- //return $doc->saveXML($node);
}
function expire_error_log($debug) {