当前位置: 首页>>代码示例>>PHP>>正文


PHP SimplePie::strip_htmltags方法代码示例

本文整理汇总了PHP中SimplePie::strip_htmltags方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::strip_htmltags方法的具体用法?PHP SimplePie::strip_htmltags怎么用?PHP SimplePie::strip_htmltags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimplePie的用法示例。


在下文中一共展示了SimplePie::strip_htmltags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: list_posts

function list_posts($cfg)
{
    require_once 'inc/simplepie.inc';
    $feed = new SimplePie();
    // Set which feed to process.
    // handle the different feeds
    // blogging
    if ($cfg['tumblr'] != "") {
        $feeds[] = 'http://' . $cfg['tumblr'] . '.tumblr.com/rss';
    }
    if ($cfg['blogger'] != "") {
        $feeds[] = 'http://' . $cfg['blogger'] . '.blogspot.com/feeds/posts/default?alt=rss';
    }
    if ($cfg['medium'] != "") {
        $feeds[] = 'https://medium.com/feed/@' . $cfg['medium'] . '/';
    }
    if ($cfg['ghost'] != "") {
        $feeds[] = 'http://' . $cfg['ghost'] . '.ghost.io/rss/';
    }
    if ($cfg['postachio'] != "") {
        $feeds[] = 'http://' . $cfg['postachio'] . '.postach.io/feed.xml';
    }
    if ($cfg['custom'] != "") {
        $feeds[] = $cfg['custom'];
    }
    // plugins
    if (file_exists('plugins')) {
        $plugins = listFiles('plugins');
        if (count($plugins) > 0) {
            foreach ($plugins as $plugin) {
                $feeds[] = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/plugins/' . $plugin . '/index.php';
            }
        }
    }
    $feed->set_feed_url($feeds);
    // allow iframe embeds
    $strip_htmltags = $feed->strip_htmltags;
    array_splice($strip_htmltags, array_search('iframe', $strip_htmltags), 1);
    $feed->strip_htmltags($strip_htmltags);
    // Run SimplePie.
    $feed->init();
    // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
    $feed->handle_content_type();
    return $feed;
}
开发者ID:getfacade,项目名称:Facade,代码行数:45,代码来源:functions.php

示例2: feed

 /**
  * returns a simplepie feed object.
  *
  */
 function feed($feed_url, $limit = 0)
 {
     if (!file_exists($this->cache)) {
         $folder = new Folder();
         $folder->mkdir($this->cache);
     }
     //setup SimplePie
     $feed = new SimplePie();
     $feed->set_feed_url($feed_url);
     $feed->set_cache_location($this->cache);
     $feed->set_item_limit($limit);
     $feed->strip_htmltags(array('img'));
     //retrieve the feed
     $feed->init();
     //get the feed items
     $items = $feed->get_items();
     //return
     if ($items) {
         return $items;
     } else {
         return false;
     }
 }
开发者ID:ejholmes,项目名称:Synodic-Solutions-Code-Scraps,代码行数:27,代码来源:simplepie.php

示例3: parseFeed

 /**
  * Opens an RSS feed, parses and loads the contents.
  *
  * @param string $url         The URL of the RSS feed
  * @param bool   $nativeOrder If true, disable order by date to preserve native ordering
  * @param bool   $force       Force SimplePie to parse the feed despite errors
  *
  * @return object An object that encapsulates the feed contents and operations on those contents.
  * @throws FeedParserException If opening or parsing feed fails
  **/
 public function parseFeed($url, $nativeOrder = false, $force = false)
 {
     require_once PATH_SYSTEM . '/vendors/SimplePie.php';
     $feed = new SimplePie();
     $feed->set_timeout($this->timeout);
     $feed->set_feed_url($url);
     $feed->enable_order_by_date(!$nativeOrder);
     $feed->force_feed($force);
     if ($this->cacheDuration != null) {
         $feed->set_cache_duration(intval($this->cacheDuration));
     }
     if ($this->cacheDirectory != null) {
         $feed->set_cache_location($this->cacheDirectory);
     }
     if ($this->stripHtmlTags != null) {
         $feed->strip_htmltags($this->stripHtmlTags);
     }
     @$feed->init();
     if ($err = $feed->error()) {
         throw new FeedParserException($err);
     }
     return $feed;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:33,代码来源:FeedParser.php

示例4: combine_feeds

function combine_feeds($feed_list, $max_items = 10, $delimiter = '~', $remove_html = true)
{
    if (empty($feed_list)) {
        return false;
    }
    $combined_feed = array();
    foreach ($feed_list as $url) {
        $feed = new SimplePie();
        $feed->set_feed_url($url);
        $feed->set_cache_location(ABSPATH . '/cache');
        //$feed->replace_headers(true);
        if ($remove_html) {
            $feed->strip_htmltags(array('img', 'a', 'object', 'embed', 'param', 'iframe', 'p', 'br', 'div', 'span', 'li', 'ul'));
        }
        $feed->set_output_encoding(CHARSET);
        $feed->init();
        foreach ($feed->get_items(0, $max_items) as $item) {
            $combined_feed[$item->get_date('U') . $delimiter . $feed->get_title() . $delimiter . $url] = $item;
        }
        unset($feed);
    }
    krsort($combined_feed);
    return array_slice($combined_feed, 0, $max_items);
}
开发者ID:vertino,项目名称:pez,代码行数:24,代码来源:functions.php

示例5: SimplePieWP

/**
 * The actual function that can be called on webpages.
 */
function SimplePieWP($feed_url, $options = null)
{
    // Quit if the SimplePie class isn't loaded.
    if (!class_exists('SimplePie')) {
        die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> There is a problem with the SimplePie Plugin for WordPress. Check your <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">Installation Status</a> for more information.</p>');
    }
    if (isset($locale) && !empty($locale) && $locale != 'auto') {
        setlocale(LC_TIME, $locale);
    }
    // Default general settings
    $template = get_option('simplepie_template');
    $items = get_option('simplepie_items');
    $items_per_feed = get_option('simplepie_items_per_feed');
    $date_format = get_option('simplepie_date_format');
    $enable_cache = get_option('simplepie_enable_cache');
    $set_cache_location = get_option('simplepie_set_cache_location');
    $set_cache_duration = get_option('simplepie_set_cache_duration');
    $enable_order_by_date = get_option('simplepie_enable_order_by_date');
    $set_timeout = get_option('simplepie_set_timeout');
    // Default text-shortening settings
    $truncate_feed_title = get_option('simplepie_truncate_feed_title');
    $truncate_feed_description = get_option('simplepie_truncate_feed_description');
    $truncate_item_title = get_option('simplepie_truncate_item_title');
    $truncate_item_description = get_option('simplepie_truncate_item_description');
    // Default advanced settings
    $processing = get_option('simplepie_processing');
    $locale = get_option('simplepie_locale');
    $local_date_format = get_option('simplepie_local_date_format');
    $strip_htmltags = get_option('simplepie_strip_htmltags');
    $strip_attributes = get_option('simplepie_strip_attributes');
    $set_max_checked_feeds = get_option('simplepie_set_max_checked_feeds');
    // Overridden settings
    if ($options) {
        // Fix the template location if one was passed in.
        if (isset($options['template']) && !empty($options['template'])) {
            $options['template'] = SIMPLEPIE_PLUGINDIR . '/templates/' . strtolower(str_replace(' ', '_', $options['template'])) . '.tmpl';
        }
        // Fix the processing location if one was passed in.
        if (isset($options['processing']) && !empty($options['processing'])) {
            $options['processing'] = SIMPLEPIE_PLUGINDIR . '/processing/' . strtolower(str_replace(' ', '_', $options['processing'])) . '.php';
        }
        extract($options);
    }
    // Load post-processing file.
    if ($processing && $processing != '') {
        include_once $processing;
    }
    // If template doesn't exist, die.
    if (!file_exists($template) || !is_readable($template)) {
        die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> The SimplePie template file is not readable by WordPress. Check the <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">WordPress Control Panel</a> for more information.</p>');
    }
    // Initialize SimplePie
    $feed = new SimplePie();
    $feed->set_feed_url($feed_url);
    $feed->enable_cache($enable_cache);
    $feed->set_item_limit($items_per_feed);
    $feed->set_cache_location($set_cache_location);
    $feed->set_cache_duration($set_cache_duration);
    $feed->enable_order_by_date($enable_order_by_date);
    $feed->set_timeout($set_timeout);
    $feed->strip_htmltags(explode(' ', $strip_htmltags));
    $feed->strip_attributes(explode(' ', $strip_attributes));
    $feed->set_max_checked_feeds($set_max_checked_feeds);
    $feed->init();
    // Load up the selected template file
    $handle = fopen($template, 'r');
    $tmpl = fread($handle, filesize($template));
    fclose($handle);
    /**************************************************************************************************************/
    // ERRORS
    // I'm absolutely sure that there is a better way to do this.
    // Define what we're looking for
    $error_start_tag = '{IF_ERROR_BEGIN}';
    $error_end_tag = '{IF_ERROR_END}';
    $error_start_length = strlen($error_start_tag);
    $error_end_length = strlen($error_end_tag);
    // Find what we're looking for
    $error_start_pos = strpos($tmpl, $error_start_tag);
    $error_end_pos = strpos($tmpl, $error_end_tag);
    $error_length_pos = $error_end_pos - $error_start_pos;
    // Grab what we're looking for
    $error_string = substr($tmpl, $error_start_pos + $error_start_length, $error_length_pos - $error_start_length);
    $replacable_string = $error_start_tag . $error_string . $error_end_tag;
    if ($error_message = $feed->error()) {
        $tmpl = str_replace($replacable_string, $error_string, $tmpl);
        $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', $error_message), $tmpl);
    } elseif ($feed->get_item_quantity() == 0) {
        $tmpl = str_replace($replacable_string, $error_string, $tmpl);
        $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', 'There are no items in this feed.'), $tmpl);
    } else {
        $tmpl = str_replace($replacable_string, '', $tmpl);
    }
    /**************************************************************************************************************/
    // FEED
    // FEED_AUTHOR_EMAIL
    /*	if ($author = $feed->get_author())
    	{
//.........这里部分代码省略.........
开发者ID:petulko391,项目名称:linux.alian.info,代码行数:101,代码来源:simplepie_wordpress_2.php

示例6: feedzy_rss

function feedzy_rss($atts, $content = '')
{
    global $feedzyStyle;
    $feedzyStyle = true;
    $count = 0;
    //Load SimplePie if not already
    if (!class_exists('SimplePie')) {
        require_once ABSPATH . WPINC . '/class-feed.php';
    }
    //Retrieve & extract shorcode parameters
    extract(shortcode_atts(array("feeds" => '', "max" => '5', "feed_title" => 'yes', "target" => '_blank', "title" => '', "meta" => 'yes', "summary" => 'yes', "summarylength" => '', "thumb" => 'yes', "default" => '', "size" => '', "keywords_title" => ''), $atts, 'feedzy_default'));
    //Use "shortcode_atts_feedzy_default" filter to edit shortcode parameters default values or add your owns.
    if (!empty($feeds)) {
        $feeds = rtrim($feeds, ',');
        $feeds = explode(',', $feeds);
        //Remove SSL from HTTP request to prevent fetching errors
        foreach ($feeds as $feed) {
            $feedURL[] = preg_replace("/^https:/i", "http:", $feed);
        }
        if (count($feedURL) === 1) {
            $feedURL = $feedURL[0];
        }
    }
    if ($max == '0') {
        $max = '999';
    } else {
        if (empty($max) || !ctype_digit($max)) {
            $max = '5';
        }
    }
    if (empty($size) || !ctype_digit($size)) {
        $size = '150';
    }
    $sizes = array('width' => $size, 'height' => $size);
    $sizes = apply_filters('feedzy_thumb_sizes', $sizes, $feedURL);
    if (!empty($title) && !ctype_digit($title)) {
        $title = '';
    }
    if (!empty($keywords_title)) {
        $keywords_title = rtrim($keywords_title, ',');
        $keywords_title = array_map('trim', explode(',', $keywords_title));
    }
    if (!empty($summarylength) && !ctype_digit($summarylength)) {
        $summarylength = '';
    }
    if (!empty($default)) {
        $default = $default;
    } else {
        $default = apply_filters('feedzy_default_image', $default, $feedURL);
    }
    //Load SimplePie Instance
    $feed = new SimplePie();
    $feed->set_feed_url($feedURL);
    $feed->enable_cache(true);
    $feed->enable_order_by_date(true);
    $feed->set_cache_class('WP_Feed_Cache');
    $feed->set_file_class('WP_SimplePie_File');
    $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 7200, $feedURL));
    do_action_ref_array('wp_feed_options', array($feed, $feedURL));
    $feed->strip_comments(true);
    $feed->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'));
    $feed->init();
    $feed->handle_content_type();
    // Display the error message
    if ($feed->error()) {
        $content .= apply_filters('feedzy_default_error', $feed->error(), $feedURL);
    }
    $content .= '<div class="feedzy-rss">';
    if ($feed_title == 'yes') {
        $content .= '<div class="rss_header">';
        $content .= '<h2><a href="' . $feed->get_permalink() . '" class="rss_title">' . html_entity_decode($feed->get_title()) . '</a> <span class="rss_description"> ' . $feed->get_description() . '</span></h2>';
        $content .= '</div>';
    }
    $content .= '<ul>';
    //Loop through RSS feed
    $items = apply_filters('feedzy_feed_items', $feed->get_items(), $feedURL);
    foreach ((array) $items as $item) {
        $continue = apply_filters('feedzy_item_keyword', true, $keywords_title, $item, $feedURL);
        if ($continue == true) {
            //Count items
            if ($count >= $max) {
                break;
            }
            $count++;
            //Fetch image thumbnail
            if ($thumb == 'yes' || $thumb == 'auto') {
                $thethumbnail = feedzy_retrieve_image($item);
            }
            $itemAttr = apply_filters('feedzy_item_attributes', $itemAttr = '', $sizes, $item, $feedURL);
            //Build element DOM
            $content .= '<li ' . $itemAttr . '>';
            if ($thumb == 'yes' || $thumb == 'auto') {
                $contentThumb = '';
                if (!empty($thethumbnail) && $thumb == 'auto' || $thumb == 'yes') {
                    $contentThumb .= '<div class="rss_image" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px;">';
                    $contentThumb .= '<a href="' . $item->get_permalink() . '" target="' . $target . '" title="' . $item->get_title() . '" >';
                    if (!empty($thethumbnail)) {
                        $thethumbnail = feedzy_image_encode($thethumbnail);
                        $contentThumb .= '<span class="default" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image:  url(' . $default . ');" alt="' . $item->get_title() . '"></span>';
                        $contentThumb .= '<span class="fetched" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image:  url(' . $thethumbnail . ');" alt="' . $item->get_title() . '"></span>';
//.........这里部分代码省略.........
开发者ID:fritzdenim,项目名称:pangMoves,代码行数:101,代码来源:feedzy-rss-feeds-shortcode.php

示例7: import

 function import($feedObj, $maxItems = 0)
 {
     jimport('simplepie.simplepie');
     $config = EasyBlogHelper::getConfig();
     $itemMigrated = 0;
     $isDomSupported = false;
     $defaultAllowedHTML = '<img>,<a>,<br>,<table>,<tbody>,<th>,<tr>,<td>,<div>,<span>,<p>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>';
     if (class_exists('DomDocument')) {
         $isDomSupported = true;
         require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'readability' . DIRECTORY_SEPARATOR . 'Readability.php';
     }
     $params = EasyBlogHelper::getRegistry($feedObj->params);
     $maxItems = $maxItems ? $maxItems : $params->get('feedamount', 0);
     $feedURL = $feedObj->url;
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'connectors.php';
     $connector = new EasyBlogConnectorsHelper();
     $connector->addUrl($feedURL);
     $connector->execute();
     $content = $connector->getResult($feedURL);
     // to ensure the leading no text before the <?xml> tag
     //$pattern	= '/(.*?)(?=<\?xml)/ims';
     $pattern = '/(.*?)<\\?xml version/is';
     $replacement = '<?xml version';
     $content = preg_replace($pattern, $replacement, $content, 1);
     if (strpos($content, '<?xml version') === false) {
         // look like the content missing the xml header. lets manually add in.
         $content = '<?xml version="1.0" encoding="utf-8"?>' . $content;
     }
     $parser = new SimplePie();
     $parser->strip_htmltags(false);
     $parser->set_raw_data($content);
     $parser->init();
     $items = '';
     $items = $parser->get_items();
     if (count($items) > 0) {
         //lets process the data insert
         $myCnt = 0;
         foreach ($items as $item) {
             @ini_set('max_execution_time', 180);
             if (!empty($maxItems) && $myCnt == $maxItems) {
                 break;
             }
             $timezoneSec = $item->get_date('Z');
             $itemdate = $item->get_date('U');
             $itemdate = $itemdate - $timezoneSec;
             $mydate = date('Y-m-d H:i:s', $itemdate);
             $feedUid = $item->get_id();
             $feedPath = $item->get_link();
             $feedHistory = EasyBlogHelper::getTable('FeedHistory');
             $newHistoryId = '';
             if ($feedHistory->isExists($feedObj->id, $feedUid)) {
                 continue;
             } else {
                 //log the feed item so that in future it will not process again.
                 $date = EasyBlogHelper::getDate();
                 $newHistory = EasyBlogHelper::getTable('FeedHistory');
                 $newHistory->feed_id = $feedObj->id;
                 $newHistory->uid = $feedUid;
                 $newHistory->created = $date->toMySQL();
                 $newHistory->store();
                 $newHistoryId = $newHistory->id;
             }
             $blogObj = new stdClass();
             // set the default setting from the feed configuration via backend.
             $blogObj->category_id = $feedObj->item_category;
             $blogObj->published = $feedObj->item_published;
             $blogObj->frontpage = $feedObj->item_frontpage;
             $blogObj->created_by = $feedObj->item_creator;
             $blogObj->allowcomment = $config->get('main_comment', 1);
             $blogObj->subscription = $config->get('main_subscription', 1);
             $blogObj->issitewide = '1';
             $text = $item->get_content();
             // @rule: Append copyright text
             $blogObj->copyrights = $params->get('copyrights', '');
             if ($feedObj->item_get_fulltext && $isDomSupported) {
                 $feedItemUrl = urldecode($item->get_link());
                 $fiConnector = new EasyBlogConnectorsHelper();
                 $fiConnector->addUrl($feedItemUrl);
                 $fiConnector->execute();
                 $fiContent = $fiConnector->getResult($feedItemUrl);
                 // to ensure the leading no text before the <?xml> tag
                 $pattern = '/(.*?)<html/is';
                 $replacement = '<html';
                 $fiContent = preg_replace($pattern, $replacement, $fiContent, 1);
                 if (!empty($fiContent)) {
                     $fiContent = EasyBlogHelper::getHelper('string')->forceUTF8($fiContent);
                     $readability = new Readability($fiContent);
                     $readability->debug = false;
                     $readability->convertLinksToFootnotes = false;
                     $result = $readability->init();
                     if ($result) {
                         $content = $readability->getContent()->innerHTML;
                         //$content	= EasyBlogHelper::getHelper( 'string' )->fixUTF8( $content );
                         $content = EasyBlogFeedsHelper::tidyContent($content);
                         if (stristr(html_entity_decode($content), '<!DOCTYPE html') === false) {
                             $text = $content;
                             $text = $this->_processRelLinktoAbs($text, $feedPath);
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:Tommar,项目名称:vino2,代码行数:101,代码来源:feeds.php

示例8: customSimplePie

function customSimplePie()
{
    $simplePie = new SimplePie();
    $simplePie->set_useragent(Minz_Translate::t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
    $simplePie->set_cache_location(CACHE_PATH);
    $simplePie->set_cache_duration(1500);
    $simplePie->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'link', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'plaintext', 'script', 'style'));
    $simplePie->strip_attributes(array_merge($simplePie->strip_attributes, array('autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless')));
    $simplePie->add_attributes(array('img' => array('lazyload' => ''), 'audio' => array('preload' => 'none'), 'iframe' => array('postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('postpone' => '', 'preload' => 'none')));
    $simplePie->set_url_replacements(array('a' => 'href', 'area' => 'href', 'audio' => 'src', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'iframe' => 'src', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite', 'source' => 'src', 'track' => 'src', 'video' => array('poster', 'src')));
    return $simplePie;
}
开发者ID:woshilapin,项目名称:FreshRSS,代码行数:12,代码来源:lib_rss.php

示例9: WPZOOM_Dashboard

function WPZOOM_Dashboard()
{
    ?>
<div class="table table_news">
    <p class="sub">From our Blog</p>
    <div class="rss-widget">
        <?php 
    /**
     * Get RSS Feed(s)
     */
    $items = get_transient('wpzoom_dashboard_widget_news');
    if (!(is_array($items) && count($items))) {
        include_once ABSPATH . WPINC . '/class-simplepie.php';
        $rss = new SimplePie();
        $rss->set_timeout(5);
        $rss->set_feed_url('http://www.wpzoom.com/feed/');
        $rss->strip_htmltags(array_merge($rss->strip_htmltags, array('h1', 'a', 'img')));
        $rss->enable_cache(false);
        $rss->init();
        $items = $rss->get_items(0, 3);
        $cached = array();
        foreach ($items as $item) {
            $cached[] = array('url' => $item->get_permalink(), 'title' => $item->get_title(), 'date' => $item->get_date("d M Y"), 'content' => substr(strip_tags($item->get_content()), 0, 128) . "...");
        }
        $items = $cached;
        set_transient('wpzoom_dashboard_widget_news', $cached, 60 * 60 * 24);
    }
    ?>

        <ul class="news">
            <?php 
    if (empty($items)) {
        echo '<li>No items</li>';
    } else {
        foreach ($items as $item) {
            ?>

                <li class="post">
                    <a href="<?php 
            echo $item['url'];
            ?>
" class="rsswidget"><?php 
            echo $item['title'];
            ?>
</a>
                    <span class="rss-date"><?php 
            echo $item['date'];
            ?>
</span>
                    <div class="rssSummary"><?php 
            echo $item['content'];
            ?>
</div>
                </li>

            <?php 
        }
    }
    ?>
        </ul><!-- end of .news -->
    </div>
</div>

<div class="table table_theme">
    <p class="sub">Latest Theme</p>
    <div class="theme_thumb">
        <?php 
    $lastTheme = get_transient('wpzoom_dashboard_widget_theme');
    if (!$lastTheme) {
        $lastTheme = @file_get_contents('http://www.wpzoom.com/themes/?last-theme=true');
        if ($lastTheme) {
            set_transient('wpzoom_dashboard_widget_theme', $lastTheme, 60 * 60 * 24);
        }
    }
    ?>

        <?php 
    if ($lastTheme) {
        echo $lastTheme;
    }
    ?>

    </div>

    <a href="http://wpzoom.com/themes/" target="_blank" alt="Browse our wide selection of WordPress themes to find the right one for you" class="button">Browse more &rarr;</a>
</div>

<div class="clear">&nbsp;</div>
<?php 
}
开发者ID:siriuzwhite,项目名称:alpha,代码行数:90,代码来源:dashboard.php

示例10: fetchFeed

 /**
  * Parses a feed with SimplePie
  *
  * @param   boolean     $stupidly_fast    Set fast mode. Best for checks
  * @param   integer     $max              Limit of items to fetch
  * @return  SimplePie_Item    Feed object
  **/
 public static function fetchFeed($url, $stupidly_fast = false, $max = 0)
 {
     # SimplePie
     $cfg = get_option(WPeMatico::OPTION_KEY);
     if ($cfg['force_mysimplepie']) {
         include_once dirname(__FILE__) . '/lib/simplepie.inc.php';
     } else {
         if (!class_exists('SimplePie')) {
             if (is_file(ABSPATH . WPINC . '/class-simplepie.php')) {
                 include_once ABSPATH . WPINC . '/class-simplepie.php';
             } else {
                 if (is_file(ABSPATH . 'wp-admin/includes/class-simplepie.php')) {
                     include_once ABSPATH . 'wp-admin/includes/class-simplepie.php';
                 } else {
                     include_once dirname(__FILE__) . '/lib/simplepie.inc.php';
                 }
             }
         }
     }
     $feed = new SimplePie();
     $feed->enable_order_by_date(false);
     $feed->set_feed_url($url);
     $feed->feed_url = rawurldecode($feed->feed_url);
     $feed->set_item_limit($max);
     $feed->set_stupidly_fast($stupidly_fast);
     if (!$stupidly_fast) {
         if ($cfg['simplepie_strip_htmltags']) {
             $strip_htmltags = sanitize_text_field($cfg['strip_htmltags']);
             $strip_htmltags = isset($strip_htmltags) && empty($strip_htmltags) ? $strip_htmltags = array() : explode(',', $strip_htmltags);
             $strip_htmltags = array_map('trim', $strip_htmltags);
             $feed->strip_htmltags($strip_htmltags);
             $feed->strip_htmltags = $strip_htmltags;
         }
         if ($cfg['simplepie_strip_attributes']) {
             $feed->strip_attributes($cfg['strip_htmlattr']);
         }
     }
     if (has_filter('wpematico_fetchfeed')) {
         $feed = apply_filters('wpematico_fetchfeed', $feed, $url);
     }
     $feed->enable_cache(false);
     $feed->init();
     $feed->handle_content_type();
     return $feed;
 }
开发者ID:samuelsh,项目名称:wpematico-modified,代码行数:52,代码来源:wpematico_functions.php

示例11: mkdir

echo $rsswidgetheight;
?>
px; overflow:scroll;">
<?php 
if (!is_dir("/tmp/simplepie")) {
    mkdir("/tmp/simplepie");
    mkdir("/tmp/simplepie/cache");
}
exec("chmod a+rw /tmp/simplepie/.");
exec("chmod a+rw /tmp/simplepie/cache/.");
$feed = new SimplePie();
$feed->set_cache_location("/tmp/simplepie/");
$feed->set_feed_url($rss_feed_s);
$feed->init();
$feed->handle_content_type();
$feed->strip_htmltags();
$counter = 1;
foreach ($feed->get_items() as $item) {
    echo "<a target='blank' href='" . $item->get_permalink() . "'>" . $item->get_title() . "</a><br />";
    $content = $item->get_content();
    $content = strip_tags($content);
    echo textLimit($content, $rsswidgettextlength) . "<br />";
    echo "Source: <a target='_blank' href='" . $item->get_permalink() . "'>" . $feed->get_title() . "</a><br />";
    $counter++;
    if ($counter > $max_items) {
        break;
    }
    echo "<hr/>";
}
?>
</div>
开发者ID:oparoz,项目名称:core-1,代码行数:31,代码来源:rss.widget.php

示例12: _setSimplePieModxPlaceholders

    /**
     * Processing the parameters into placeholders
     * @param string    $spie   snippet parameters
     * @return array    placeholders
     */
    private function _setSimplePieModxPlaceholders($spie) {
        /**
         * @link http://github.com/simplepie/simplepie/tree/one-dot-two
         */
        if (!file_exists($spie['simplePieClassFile'])) {
            return 'File ' . $spie['simplePieClassFile'] . ' does not exist.';
        }
        include_once $spie['simplePieClassFile'];
        $feed = new SimplePie();
        $joinKey = 0;
        foreach ($spie['setFeedUrl'] as $setFeedUrl) {
            $feed->set_cache_location($spie['setCacheLocation']);
            $feed->set_feed_url($setFeedUrl);

            if (isset($spie['setInputEncoding'])) {
                $feed->set_input_encoding($spie['setInputEncoding']);
            }
            if (isset($spie['setOutputEncoding'])) {
                $feed->set_output_encoding($spie['setOutputEncoding']);
            }
            // if no cURL, try fsockopen
            if (isset($spie['forceFSockopen'])) {
                $feed->force_fsockopen(true);
            }
            if (isset($spie['enableCache']))
                $feed->enable_cache($spie['enableCache']);
            if (isset($spie['enableOrderByDate']))
                $feed->enable_order_by_date($spie['enableOrderByDate']);
            if (isset($spie['setCacheDuration']))
                $feed->set_cache_duration($spie['setCacheDuration']);
            if (!empty($spie['setFaviconHandler']))
                $feed->set_favicon_handler($spie['setFaviconHandler'][0], $spie['setFaviconHandler'][1]);
            if (!empty($spie['setImageHandler'])) {
                // handler_image.php?image=67d5fa9a87bad230fb03ea68b9f71090
                $feed->set_image_handler($spie['setImageHandler'][0], $spie['setImageHandler'][1]);
            }

            // disabled since these are all splitted into a single fetching
            // it's  been used with different way, see below looping
//            if (isset($spie['setItemLimit']))
//                $feed->set_item_limit((int) $spie['setItemLimit']);

            if (isset($spie['setJavascript']))
                $feed->set_javascript($spie['setJavascript']);
            if (isset($spie['stripAttributes']))
                $feed->strip_attributes(array_merge($feed->strip_attributes, $spie['stripAttributes']));
            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();
//.........这里部分代码省略.........
开发者ID:ncrossland,项目名称:spiefeed,代码行数:101,代码来源:spiefeed.class.php

示例13: GetSimplePieContentEntries

 function GetSimplePieContentEntries($feedUrl, $logger, $channel)
 {
     //Include the Simple Pie Framework to get and parse feeds
     $config = \Swiftriver\Core\Setup::Configuration();
     $simplePiePath = $config->ModulesDirectory . "/SimplePie/simplepie.inc";
     include_once $simplePiePath;
     //Include the Simple Pie YouTube Framework
     $simpleTubePiePath = $config->ModulesDirectory . "/SimplePie/simpletube.inc";
     include_once $simpleTubePiePath;
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [END: Including the SimplePie module]", \PEAR_LOG_DEBUG);
     //Construct a new SimplePie Parser
     $feed = new \SimplePie();
     //Get the cache directory
     $cacheDirectory = $config->CachingDirectory;
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [Setting the caching directory to {$cacheDirectory}]", \PEAR_LOG_DEBUG);
     //Set the caching directory
     $feed->set_cache_location($cacheDirectory);
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [Setting the feed url to {$feedUrl}]", \PEAR_LOG_DEBUG);
     //Pass the feed URL to the SImplePie object
     $feed->set_feed_url($feedUrl);
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [Initializing the feed]", \PEAR_LOG_DEBUG);
     //Run the SimplePie
     $feed->init();
     //Strip HTML
     $feed->strip_htmltags(array('span', 'font', 'style', 'table', 'td', 'tr', 'div', 'p', 'br', 'a'));
     //Create the Content array
     $contentItems = array();
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [START: Parsing feed items]", \PEAR_LOG_DEBUG);
     $feeditems = $feed->get_items();
     if (!$feeditems || $feeditems == null || !is_array($feeditems) || count($feeditems) < 1) {
         $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [No feeditems recovered from the feed]", \PEAR_LOG_DEBUG);
     }
     $lastSuccess = $channel->lastSuccess;
     //Loop through the Feed Items
     foreach ($feeditems as $feedItem) {
         //Extract the date of the content
         $contentdate = strtotime($feedItem->get_date());
         if (isset($lastSuccess) && is_numeric($lastSuccess) && isset($contentdate) && is_numeric($contentdate)) {
             if ($contentdate < $lastSuccess) {
                 $textContentDate = date("c", $contentdate);
                 $textlastSuccess = date("c", $lastSuccess);
                 $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [Skipped feed item as date {$textContentDate} less than last sucessful run ({$textlastSuccess})]", \PEAR_LOG_DEBUG);
                 continue;
             }
         }
         $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [Adding feed item]", \PEAR_LOG_DEBUG);
         //Get source data
         $source_name = $feedItem->get_author()->name;
         $source_name = $source_name == null || $source_name == "" ? "Google News Search -" . $this->searchPhrase : $source_name . " @ " . "Google News Search - " . $this->searchPhrase;
         $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name, $channel->trusted);
         $source->name = $source_name;
         $source->email = $feedItem->get_author()->email;
         $source->parent = $channel->id;
         $source->type = $channel->type;
         $source->subType = $channel->subType;
         //Extract all the relevant feedItem info
         $title = $feedItem->get_title();
         $description = $feedItem->get_description();
         $contentLink = $feedItem->get_permalink();
         $date = $feedItem->get_date();
         //Create a new Content item
         $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
         //Fill the Content Item
         $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $title, array($description));
         $item->link = $contentLink;
         $item->date = strtotime($date);
         //Add the item to the Content array
         $contentItems[] = $item;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [END: Parsing feed items]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetSimplePieContentEntries [Method finished]", \PEAR_LOG_DEBUG);
     //return the content array
     return $contentItems;
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:74,代码来源:GoogleNewsParser.php

示例14: _displayRSS

 /**
  * _displayRSS
  * 
  * @param string $url
  * @param int $num_items
  */
 protected function _displayRSS($url, $num_items = -1)
 {
     $rss = new SimplePie();
     $rss->strip_htmltags(array_diff($rss->strip_htmltags, array('style')));
     $rss->strip_attributes(array_diff($rss->strip_attributes, array('style', 'class', 'id')));
     $rss->set_feed_url($url);
     $rss->set_cache_class('WP_Feed_Cache');
     $rss->set_file_class('WP_SimplePie_File');
     $rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
     do_action_ref_array('wp_feed_options', array(&$rss, $url));
     $rss->init();
     $rss->handle_content_type();
     if (!$rss->error()) {
         $maxitems = $rss->get_item_quantity(25);
         $rss_items = $rss->get_items(0, $maxitems);
         echo '<ul>';
         if ($num_items !== -1) {
             $rss_items = array_slice($rss_items, 0, $num_items);
         }
         if ($rss_items) {
             foreach ((array) $rss_items as $item) {
                 printf('<li><div class="date">%4$s</div><div class="thethefly-news-item">%2$s</div></li>', esc_url($item->get_permalink()), $item->get_description(), esc_html($item->get_title()), $item->get_date('D, d M Y'));
             }
         } else {
             echo "<li>";
             _e('Unfortunately the news channel is temporarily closed', 'thethe-captcha');
             echo "</li>";
         }
         echo '</ul>';
     } else {
         _e('An error has occurred, which probably means the feed is down. Try again later.', 'thethe-captcha');
     }
 }
开发者ID:jacko5,项目名称:bjj,代码行数:39,代码来源:lib.plugin.php

示例15: do_rss

 /**
  *
  * @param object $bookmark
  * @param object $owner
  */
 protected function do_rss($bookmark, $owner)
 {
     // no bookmark, no fun
     if (empty($bookmark) || !is_object($bookmark)) {
         return false;
     }
     // no owner means no email, so no reason to parse
     if (empty($owner) || !is_object($owner)) {
         return false;
     }
     // instead of the way too simple fetch_feed, we'll use SimplePie itself
     if (!class_exists('SimplePie')) {
         require_once ABSPATH . WPINC . '/class-simplepie.php';
     }
     $url = htmlspecialchars_decode($bookmark->link_rss);
     $last_updated = strtotime($bookmark->link_updated);
     static::debug('Fetching: ' . $url, 6);
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_cache_duration(static::revisit_time - 10);
     $feed->set_cache_location($this->cachedir);
     $feed->force_feed(true);
     // optimization
     $feed->enable_order_by_date(true);
     $feed->remove_div(true);
     $feed->strip_comments(true);
     $feed->strip_htmltags(false);
     $feed->strip_attributes(true);
     $feed->set_image_handler(false);
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         $err = new WP_Error('simplepie-error', $feed->error());
         static::debug('Error: ' . $err->get_error_message(), 4);
         $this->failed($owner->user_email, $url, $err->get_error_message());
         return $err;
     }
     // set max items to 12
     // especially useful with first runs
     $maxitems = $feed->get_item_quantity(12);
     $feed_items = $feed->get_items(0, $maxitems);
     $feed_title = $feed->get_title();
     // set the link name from the RSS title
     if (!empty($feed_title) && $bookmark->link_name != $feed_title) {
         global $wpdb;
         $wpdb->update($wpdb->prefix . 'links', array('link_name' => $feed_title), array('link_id' => $bookmark->link_id));
     }
     // if there's a feed author, get it, we may need it if there's no entry
     // author
     $feed_author = $feed->get_author();
     $last_updated_ = 0;
     if ($maxitems > 0) {
         foreach ($feed_items as $item) {
             // U stands for Unix Time
             $date = $item->get_date('U');
             if ($date > $last_updated) {
                 $fromname = $feed_title;
                 $author = $item->get_author();
                 if ($author) {
                     $fromname = $fromname . ': ' . $author->get_name();
                 } elseif ($feed_author) {
                     $fromname = $fromname . ': ' . $feed_author->get_name();
                 }
                 // this is to set the sender mail from our own domain
                 $frommail = get_user_meta($owner->ID, 'blogroll2email_email', true);
                 if (!$frommail) {
                     $sitedomain = parse_url(get_bloginfo('url'), PHP_URL_HOST);
                     $frommail = static::schedule . '@' . $sitedomain;
                 }
                 $from = $fromname . '<' . $frommail . '>';
                 $content = $item->get_content();
                 $matches = array();
                 preg_match_all('/farm[0-9]\\.staticflickr\\.com\\/[0-9]+\\/([0-9]+_[0-9a-zA-Z]+_m\\.jpg)/s', $content, $matches);
                 if (!empty($matches[0])) {
                     foreach ($matches[0] as $to_replace) {
                         $clean = str_replace('_m.jpg', '_c.jpg', $to_replace);
                         $content = str_replace($to_replace, $clean, $content);
                     }
                     $content = preg_replace("/(width|height)=\"(.*?)\" ?/is", '', $content);
                 }
                 $content = apply_filters('blogroll2email_message', $content);
                 if ($this->send($owner->user_email, $item->get_link(), $item->get_title(), $from, $url, $item->get_content(), $date)) {
                     if ($date > $last_updated_) {
                         $last_updated_ = $date;
                     }
                 }
             }
         }
     }
     // poke the link's last update field, so we know what was the last sent
     // entry's date
     $this->update_link_date($bookmark, $last_updated_);
 }
开发者ID:petermolnar,项目名称:blogroll2email,代码行数:98,代码来源:blogroll2email.php


注:本文中的SimplePie::strip_htmltags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。