本文整理汇总了PHP中label_add_article函数的典型用法代码示例。如果您正苦于以下问题:PHP label_add_article函数的具体用法?PHP label_add_article怎么用?PHP label_add_article使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了label_add_article函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hook_article_filter
function hook_article_filter($article)
{
$wpm = 180;
// arbitrary value, based on adult averages
$word_count = str_word_count($article["content"]);
$minutes = round($word_count / $wpm);
$minimum_time_bucket = 5;
// minutes
$time_label = $this->minutes_to_time_label($minutes, $minimum_time_bucket);
_debug("estimated reading time: {$minutes} min ({$time_label}), based on {$word_count} words at {$wpm} WPM");
$owner_uid = $article["owner_uid"];
if (!label_find_id($time_label, $owner_uid)) {
label_create($time_label);
}
$guid = $article["guid"];
$result = db_query("SELECT id FROM ttrss_entries WHERE guid = '{$guid}'");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
label_add_article($ref_id, $time_label, $owner_uid);
}
return $article;
}
示例2: setArticleLabel
function setArticleLabel()
{
$article_ids = array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_ids"])), is_numeric);
$label_id = (int) $this->dbh->escape_string($_REQUEST['label_id']);
$assign = (bool) $this->dbh->escape_string($_REQUEST['assign']) == "true";
$label = $this->dbh->escape_string(label_find_caption(feed_to_label_id($label_id), $_SESSION["uid"]));
$num_updated = 0;
if ($label) {
foreach ($article_ids as $id) {
if ($assign) {
label_add_article($id, $label, $_SESSION["uid"]);
} else {
label_remove_article($id, $label, $_SESSION["uid"]);
}
++$num_updated;
}
}
$this->wrap(self::STATUS_OK, array("status" => "OK", "updated" => $num_updated));
}
示例3: assign_article_to_label_filters
function assign_article_to_label_filters($id, $filters, $owner_uid, $article_labels)
{
foreach ($filters as $f) {
if ($f["type"] == "label") {
if (!labels_contains_caption($article_labels, $f["param"])) {
label_add_article($id, $f["param"], $owner_uid);
}
}
}
}
示例4: labelops
function labelops($assign)
{
$reply = array();
$ids = explode(",", db_escape_string($_REQUEST["ids"]));
$label_id = db_escape_string($_REQUEST["lid"]);
$label = db_escape_string(label_find_caption($this->link, $label_id, $_SESSION["uid"]));
$reply["info-for-headlines"] = array();
if ($label) {
foreach ($ids as $id) {
if ($assign) {
label_add_article($this->link, $id, $label, $_SESSION["uid"]);
} else {
label_remove_article($this->link, $id, $label, $_SESSION["uid"]);
}
$labels = get_article_labels($this->link, $id, $_SESSION["uid"]);
array_push($reply["info-for-headlines"], array("id" => $id, "labels" => format_article_labels($labels, $id)));
}
}
$reply["message"] = "UPDATE_COUNTERS";
print json_encode($reply);
}
示例5: create_archived_article
protected function create_archived_article($title, $url, $content, $labels_str, $owner_uid)
{
$guid = 'SHA1:' . sha1("tinybag:" . $url . $owner_uid);
// include owner_uid to prevent global GUID clash
$content_hash = sha1($content);
if ($labels_str != "") {
$labels = explode(",", $labels_str);
} else {
$labels = array();
}
$rc = false;
if (!$title) {
$title = $url;
}
if (!$title && !$url) {
return false;
}
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
return false;
}
db_query("BEGIN");
// only check for our user data here, others might have shared this with different content etc
$result = db_query("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE\n\t\t\tguid = '{$guid}' AND ref_id = id AND owner_uid = '{$owner_uid}' LIMIT 1");
if (db_num_rows($result) != 0) {
$rc = false;
} else {
$result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t(title, guid, link, updated, content, content_hash, date_entered, date_updated)\n\t\t\t\tVALUES\n\t\t\t\t('{$title}', '{$guid}', '{$url}', NOW(), '{$content}', '{$content_hash}', NOW(), NOW())");
$result = db_query("SELECT id FROM ttrss_entries WHERE guid = '{$guid}'");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t(ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, unread)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$ref_id}', '', NULL, NULL, {$owner_uid}, false, '', '', true)");
if (count($labels) != 0) {
foreach ($labels as $label) {
label_add_article($ref_id, trim($label), $owner_uid);
}
}
$rc = true;
}
}
db_query("COMMIT");
return $rc;
}
示例6: assign_article_to_labels
function assign_article_to_labels($link, $id, $filters, $owner_uid)
{
foreach ($filters as $f) {
if ($f[0] == "label") {
label_add_article($link, $id, $f[1], $owner_uid);
}
}
}
示例7: perform_data_import
//.........这里部分代码省略.........
}
if ($data) {
$doc = DOMDocument::loadXML($data);
}
}
libxml_disable_entity_loader(true);
if ($doc) {
$xpath = new DOMXpath($doc);
$container = $doc->firstChild;
if ($container && $container->hasAttribute('schema-version')) {
$schema_version = $container->getAttribute('schema-version');
if ($schema_version != SCHEMA_VERSION) {
print "<p>" . __("Could not import: incorrect schema version.") . "</p>";
return;
}
} else {
print "<p>" . __("Could not import: unrecognized document format.") . "</p>";
return;
}
$articles = $xpath->query("//article");
foreach ($articles as $article_node) {
if ($article_node->childNodes) {
$ref_id = 0;
$article = array();
foreach ($article_node->childNodes as $child) {
if ($child->nodeName != 'label_cache') {
$article[$child->nodeName] = db_escape_string($child->nodeValue);
} else {
$article[$child->nodeName] = $child->nodeValue;
}
}
//print_r($article);
if ($article['guid']) {
++$num_processed;
//db_query("BEGIN");
//print 'GUID:' . $article['guid'] . "\n";
$result = db_query("SELECT id FROM ttrss_entries\n\t\t\t\t\t\t\tWHERE guid = '" . $article['guid'] . "'");
if (db_num_rows($result) == 0) {
$result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t('" . $article['title'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['guid'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['link'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['updated'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['content'] . "',\n\t\t\t\t\t\t\t\t\t'" . sha1($article['content']) . "',\n\t\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t'')");
$result = db_query("SELECT id FROM ttrss_entries\n\t\t\t\t\t\t\t\tWHERE guid = '" . $article['guid'] . "'");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
}
} else {
$ref_id = db_fetch_result($result, 0, "id");
}
//print "Got ref ID: $ref_id\n";
if ($ref_id) {
$feed_url = $article['feed_url'];
$feed_title = $article['feed_title'];
$feed = 'NULL';
if ($feed_url && $feed_title) {
$result = db_query("SELECT id FROM ttrss_feeds\n\t\t\t\t\t\t\t\t\tWHERE feed_url = '{$feed_url}' AND owner_uid = '{$owner_uid}'");
if (db_num_rows($result) != 0) {
$feed = db_fetch_result($result, 0, "id");
} else {
// try autocreating feed in Uncategorized...
$result = db_query("INSERT INTO ttrss_feeds (owner_uid,\n\t\t\t\t\t\t\t\t\t\tfeed_url, title) VALUES ({$owner_uid}, '{$feed_url}', '{$feed_title}')");
$result = db_query("SELECT id FROM ttrss_feeds\n\t\t\t\t\t\t\t\t\t\tWHERE feed_url = '{$feed_url}' AND owner_uid = '{$owner_uid}'");
if (db_num_rows($result) != 0) {
++$num_feeds_created;
$feed = db_fetch_result($result, 0, "id");
}
}
}
if ($feed != 'NULL') {
$feed_qpart = "feed_id = {$feed}";
} else {
$feed_qpart = "feed_id IS NULL";
}
//print "$ref_id / $feed / " . $article['title'] . "\n";
$result = db_query("SELECT int_id FROM ttrss_user_entries\n\t\t\t\t\t\t\t\tWHERE ref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' AND {$feed_qpart}");
if (db_num_rows($result) == 0) {
$marked = bool_to_sql_bool(sql_bool_to_bool($article['marked']));
$published = bool_to_sql_bool(sql_bool_to_bool($article['published']));
$score = (int) $article['score'];
$tag_cache = $article['tag_cache'];
$label_cache = db_escape_string($article['label_cache']);
$note = $article['note'];
//print "Importing " . $article['title'] . "<br/>";
++$num_imported;
$result = db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t\t\t\t\t(ref_id, owner_uid, feed_id, unread, last_read, marked,\n\t\t\t\t\t\t\t\t\t\tpublished, score, tag_cache, label_cache, uuid, note)\n\t\t\t\t\t\t\t\t\tVALUES ({$ref_id}, {$owner_uid}, {$feed}, false,\n\t\t\t\t\t\t\t\t\t\tNULL, {$marked}, {$published}, {$score}, '{$tag_cache}',\n\t\t\t\t\t\t\t\t\t\t\t'{$label_cache}', '', '{$note}')");
$label_cache = json_decode($label_cache, true);
if (is_array($label_cache) && $label_cache["no-labels"] != 1) {
foreach ($label_cache as $label) {
label_create($label[1], $label[2], $label[3], $owner_uid);
label_add_article($ref_id, $label[1], $owner_uid);
}
}
//db_query("COMMIT");
}
}
}
}
}
print "<p>" . __("Finished: ") . vsprintf(_ngettext("%d article processed, ", "%d articles processed, ", $num_processed), $num_processed) . vsprintf(_ngettext("%d imported, ", "%d imported, ", $num_imported), $num_imported) . vsprintf(_ngettext("%d feed created.", "%d feeds created.", $num_feeds_created), $num_feeds_created) . "</p>";
} else {
print "<p>" . __("Could not load XML document.") . "</p>";
}
}