本文整理汇总了PHP中SimplePie::get_type方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::get_type方法的具体用法?PHP SimplePie::get_type怎么用?PHP SimplePie::get_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimplePie
的用法示例。
在下文中一共展示了SimplePie::get_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
*/
public function add()
{
$feed_user_title = $this->input->post('feed_title', TRUE);
$feed_url = $this->input->post('feed_url');
$usercat = $this->input->post('category');
$feed_filter_type = $this->input->post('feed_type');
$_icon = $this->input->post('favicon_icon');
$favicon_icon = $_icon;
if (!isset($feed_url) || $feed_url == '') {
$this->stencil->title('Feeds');
$this->stencil->layout('admin_layout');
$this->stencil->css(array('admin_css/bootstrap.min', 'admin_css/bootstrap-responsive.min', 'admin_css/styles'));
$this->stencil->js(array('vendors/datatables/js/jquery.dataTables.min.js', 'DT_bootstrap'));
$this->stencil->paint('admin/feeds/add');
} else {
$check = $this->validateUrl($feed_url);
if ($check == FALSE) {
echo json_encode(array('result' => 'fail', 'msg' => '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>Url Already exists in the database!</div>'));
die;
}
$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->set_cache_location(APPPATH . '/cache');
$feed->set_output_encoding('ISO-8859-1');
$feed->init();
$feed->handle_content_type();
// Language
$lang = $feed->get_language();
$language = isset($lang) ? $lang : 'en-us';
if ($feed->get_type() & SIMPLEPIE_TYPE_NONE) {
$feed_type = 'Unknown';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
$feed_type = 'RSS';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
$feed_type = 'Atom';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_ALL) {
$feed_type = 'Supported';
}
// Author
if ($author = $feed->get_author()) {
$feedAuthor = $author->get_name();
} else {
$feedAuthor = '';
}
if ($feed->error()) {
echo json_encode(array('result' => 'fail', 'msg' => '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>Found error while making request</div>'));
} else {
// $return = $this->feed_model->addFeeds($feed->get_items(0, 500));
$feed_image_link = $feed->get_image_link();
$feed_image_url = $feed->get_image_url();
$feed_image_title = $feed->get_image_title();
$return = $this->feedModel->addFeeds($feed->get_items(0, 500), $feed_image_link, $feed_image_url, $feed_image_title, $usercat, $feed_url, $language, $feed_type, $feedAuthor, $feed_filter_type, $feed_user_title, $favicon_icon);
if ($return) {
echo json_encode(array('result' => 'success', 'msg' => '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>Blog is added successfully</div>'));
} else {
echo json_encode(array('result' => 'fail', 'msg' => '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>Found error while making request</div>'));
}
}
}
}
示例2: setCron
public function setCron()
{
$getUnique = $this->getAllFeedUrls();
if (!empty($getUnique)) {
foreach ($getUnique as $feedTableData) {
$feed_user_title = $feedTableData->feed_user_title;
$feed_url = $feedTableData->feed_admin_url;
$usercat = $feedTableData->feed_user_category;
$feed_filter_type = $feedTableData->feed_filter_type;
$favicon_icon = $feedTableData->feed_favicon;
$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->set_cache_location(APPPATH . '/cache');
$feed->set_output_encoding('ISO-8859-1');
$feed->init();
$feed->handle_content_type();
// Language
$lang = $feed->get_language();
$language = isset($lang) ? $lang : 'en-us';
if ($feed->get_type() & SIMPLEPIE_TYPE_NONE) {
$feed_type = 'Unknown';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
$feed_type = 'RSS';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
$feed_type = 'Atom';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_ALL) {
$feed_type = 'Supported';
}
// Author
if ($author = $feed->get_author()) {
$feedAuthor = $author->get_name();
} else {
$feedAuthor = '';
}
if ($feed->error()) {
die;
} else {
$feed_image_link = $feed->get_image_link();
$feed_image_url = $feed->get_image_url();
$feed_image_title = $feed->get_image_title();
$this->addFeeds($feed->get_items(0, 500), $feed_image_link, $feed_image_url, $feed_image_title, $usercat, $feed_url, $language, $feed_type, $feedAuthor, $feed_filter_type, $feed_user_title, $favicon_icon);
}
}
}
}
示例3:
function get_type()
{
// Allow filters to pre-empt a type determination from SimplePie
$ret = apply_filters('feedwordpie_get_type', NULL, $this);
// If not preempted by a filter, fall back on SimplePie
if (is_null($ret)) {
$ret = parent::get_type();
}
return $ret;
}
示例4: items
//.........这里部分代码省略.........
$nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
}
}
}
$this->db->set('fed_nextcrawl', $nextcrawl);
}
$this->db->where('fed_id', $fed->fed_id);
$this->db->update('feeds');
} catch (Facebook\Exceptions\FacebookResponseException $e) {
$errors++;
$this->db->set('fed_lasterror', 'Graph returned an error: ' . $e->getMessage());
$this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
$this->db->where('fed_id', $fed->fed_id);
$this->db->update('feeds');
} catch (Facebook\Exceptions\FacebookSDKException $e) {
$errors++;
$this->db->set('fed_lasterror', 'Facebook SDK returned an error: ' . $e->getMessage());
$this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
$this->db->where('fed_id', $fed->fed_id);
$this->db->update('feeds');
}
} else {
$sp_feed = new SimplePie();
$sp_feed->set_feed_url(convert_to_ascii($fed->fed_link));
$sp_feed->enable_cache(false);
$sp_feed->set_timeout(5);
$sp_feed->force_feed(true);
$sp_feed->init();
$sp_feed->handle_content_type();
if ($sp_feed->error()) {
$errors++;
$this->db->set('fed_lasterror', $sp_feed->error());
$this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
$this->db->where('fed_id', $fed->fed_id);
$this->db->update('feeds');
} else {
$this->readerself_library->crawl_items($fed->fed_id, $sp_feed->get_items());
$lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row();
$parse_url = parse_url($sp_feed->get_link());
$this->db->set('fed_title', $sp_feed->get_title());
$this->db->set('fed_url', $sp_feed->get_link());
$this->db->set('fed_link', $sp_feed->subscribe_url());
if (isset($parse_url['host']) == 1) {
$this->db->set('fed_host', $parse_url['host']);
}
if ($sp_feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
$this->db->set('fed_type', 'rss');
} else {
if ($sp_feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
$this->db->set('fed_type', 'atom');
}
}
if ($sp_feed->get_image_url()) {
$this->db->set('fed_image', $sp_feed->get_image_url());
}
$this->db->set('fed_description', $sp_feed->get_description());
$this->db->set('fed_lasterror', '');
$this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
if ($lastitem) {
$nextcrawl = '';
//older than 96 hours, next crawl in 12 hours
if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) {
$nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12);
//older than 48 hours, next crawl in 6 hours
} else {
if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) {
$nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6);
//older than 24 hours, next crawl in 3 hours
} else {
if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) {
$nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
}
}
}
$this->db->set('fed_nextcrawl', $nextcrawl);
}
$this->db->where('fed_id', $fed->fed_id);
$this->db->update('feeds');
}
$sp_feed->__destruct();
unset($sp_feed);
}
}
$this->db->set('crr_time', microtime(1) - $microtime_start);
if (function_exists('memory_get_peak_usage')) {
$this->db->set('crr_memory', memory_get_peak_usage());
}
$this->db->set('crr_feeds', $query->num_rows());
if ($errors > 0) {
$this->db->set('crr_errors', $errors);
}
$this->db->set('crr_datecreated', date('Y-m-d H:i:s'));
$this->db->insert('crawler');
if ($this->db->dbdriver == 'mysqli') {
$this->db->query('OPTIMIZE TABLE categories, connections, enclosures, favorites, feeds, folders, history, items, members, share, subscriptions');
}
}
}
$this->readerself_library->set_content($content);
}
示例5: _setSimplePieModxPlaceholders
//.........这里部分代码省略.........
if (isset($spie['stripComments']))
$feed->strip_comments($spie['stripComments']);
if (isset($spie['stripHtmlTags']))
$feed->strip_htmltags(array_merge($feed->strip_htmltags, $spie['stripHtmlTags']));
/**
* Initiating the Feeding.
* This always be placed AFTER all the settings above.
*/
if (!$feed->init()) {
echo $feed->error();
return FALSE;
}
$countItems = count($feed->get_items());
if (1 > $countItems) {
continue;
}
$feed->handle_content_type();
$countLimit = 0;
foreach ($feed->get_items($getItemStart, $getItemEnd) as $item) {
if (isset($spie['setItemLimit']) && $spie['setItemLimit'] == $countLimit)
continue;
$phArray[$joinKey]['favicon'] = $feed->get_favicon();
$phArray[$joinKey]['link'] = $item->get_link();
$phArray[$joinKey]['title'] = $item->get_title();
$phArray[$joinKey]['description'] = $item->get_description();
$phArray[$joinKey]['content'] = $item->get_content();
$phArray[$joinKey]['permalink'] = $item->get_permalink();
$parsedUrl = parse_url($phArray[$joinKey]['permalink']);
$implodedParsedUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
$imageLink = $feed->get_image_link() != '' ? $feed->get_image_link() : $implodedParsedUrl;
$phArray[$joinKey]['imageLink'] = $imageLink;
$phArray[$joinKey]['imageTitle'] = $feed->get_image_title();
$phArray[$joinKey]['imageUrl'] = $feed->get_image_url();
$phArray[$joinKey]['imageWidth'] = $feed->get_image_width();
$phArray[$joinKey]['imageHeight'] = $feed->get_image_height();
$phArray[$joinKey]['date'] = $item->get_date($spie['dateFormat']);
$phArray[$joinKey]['localDate'] = $item->get_local_date($spie['localDateFormat']);
$phArray[$joinKey]['copyright'] = $item->get_copyright();
$phArray[$joinKey]['latitude'] = $feed->get_latitude();
$phArray[$joinKey]['longitude'] = $feed->get_longitude();
$phArray[$joinKey]['language'] = $feed->get_language();
$phArray[$joinKey]['encoding'] = $feed->get_encoding();
if ($item->get_authors()) {
foreach ($item->get_authors() as $authorObject) {
$authorName = $authorObject->get_name();
$authorLink = $authorObject->get_link();
$authorEmail = $authorObject->get_email();
}
$phArray[$joinKey]['authorName'] = $authorName;
$phArray[$joinKey]['authorLink'] = $authorLink;
$phArray[$joinKey]['authorEmail'] = $authorEmail;
}
$category = $item->get_category();
if ($category) {
$phArray[$joinKey]['category'] = htmlspecialchars_decode($category->get_label(), ENT_QUOTES);
}
$contributor = $item->get_contributor();
$phArray[$joinKey]['contributor'] = '';
if ($contributor) {
$phArray[$joinKey]['contributor'] = $contributor->get_name();
}
if ($feed->get_type() & SIMPLEPIE_TYPE_NONE) {
$phArray[$joinKey]['getType'] = 'Unknown';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
$phArray[$joinKey]['getType'] = 'RSS';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
$phArray[$joinKey]['getType'] = 'Atom';
} elseif ($feed->get_type() & SIMPLEPIE_TYPE_ALL) {
$phArray[$joinKey]['getType'] = 'Supported';
}
// Media from Flickr RSS stream
if ($enclosure = $item->get_enclosure()) {
$phArray[$joinKey]['itemImageThumbnailUrl'] = $enclosure->get_thumbnail();
$phArray[$joinKey]['itemImageWidth'] = $enclosure->get_width();
$phArray[$joinKey]['itemImageHeight'] = $enclosure->get_height();
}
$countLimit++;
$joinKey++;
} // foreach ($feed->get_items($getItemStart, $getItemEnd) as $item)
} // foreach ($spie['setFeedUrl'] as $setFeedUrl)
return $this->_filterModxTags($phArray);
}