本文整理汇总了PHP中PluginHost::get方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginHost::get方法的具体用法?PHP PluginHost::get怎么用?PHP PluginHost::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginHost
的用法示例。
在下文中一共展示了PluginHost::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DOMDocument
function hook_render_article_cdm($article)
{
$feedId = $article['feed_id'];
$feeds = $this->host->get($this, 'feeds');
if (is_array($feeds) && in_array($feedId, array_keys($feeds))) {
$doc = new DOMDocument();
@$doc->loadHTML($article['content']);
if ($doc) {
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//img[@src])');
/** @var $entry DOMElement **/
$entry = null;
foreach ($entries as $entry) {
$origSrc = $entry->getAttribute("src");
$url = "backend.php?op=pluginhandler&method=redirect&plugin=af_refspoof&url={$origSrc}&ref={$article['link']}";
$entry->setAttribute("src", $url);
}
$article["content"] = $doc->saveXML();
}
}
return $article;
}
示例2: PluginHost
static function create_published_article($title, $url, $content, $labels_str, $owner_uid)
{
$guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid);
// include owner_uid to prevent global GUID clash
if (!$content) {
$pluginhost = new PluginHost();
$pluginhost->load_all(PluginHost::KIND_ALL, $owner_uid);
$pluginhost->load_data();
$af_readability = $pluginhost->get_plugin("Af_Readability");
if ($af_readability) {
$enable_share_anything = $pluginhost->get($af_readability, "enable_share_anything");
if ($enable_share_anything) {
$extracted_content = $af_readability->extract_content($url);
if ($extracted_content) {
$content = db_escape_string($extracted_content);
}
}
}
}
$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) {
$ref_id = db_fetch_result($result, 0, "id");
$result = db_query("SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' LIMIT 1");
if (db_num_rows($result) != 0) {
$int_id = db_fetch_result($result, 0, "int_id");
db_query("UPDATE ttrss_entries SET\n\t\t\t\t\tcontent = '{$content}', content_hash = '{$content_hash}' WHERE id = '{$ref_id}'");
db_query("UPDATE ttrss_user_entries SET published = true,\n\t\t\t\t\t\tlast_published = NOW() WHERE\n\t\t\t\t\t\tint_id = '{$int_id}' AND owner_uid = '{$owner_uid}'");
} else {
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,\n\t\t\t\t\t\tlast_read, note, unread, last_published)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$ref_id}', '', NULL, NULL, {$owner_uid}, true, '', '', NOW(), '', false, NOW())");
}
if (count($labels) != 0) {
foreach ($labels as $label) {
label_add_article($ref_id, trim($label), $owner_uid);
}
}
$rc = true;
} 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,\n\t\t\t\t\t\tlast_read, note, unread, last_published)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$ref_id}', '', NULL, NULL, {$owner_uid}, true, '', '', NOW(), '', false, NOW())");
if (count($labels) != 0) {
foreach ($labels as $label) {
label_add_article($ref_id, trim($label), $owner_uid);
}
}
$rc = true;
}
}
db_query("COMMIT");
return $rc;
}