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


PHP SimplePie::strip_attributes方法代码示例

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


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

示例1: _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

示例2: 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

示例3: 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

示例4: 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

示例5: ikit_national_remote_fetch_page

/**
 * Reads in the pages RSS feed as determined by the settings
 * and adds/updates/deletes based on that feed, also sets
 * the external source for the item so that it doesn't get deleted
 * or edited by the user. The page content can then be placed
 * within other pages using the ikit page shortcode.
 */
function ikit_national_remote_fetch_page()
{
    $page_feed_url = IKIT_NATIONAL_FEED_PAGE_URL;
    // Use SimplePie to parse the feeds
    // note that we turn off cacheing, because this fetch
    // is called at the proper interval and should always
    // be freshest
    $feed = new SimplePie();
    $feed->set_feed_url($page_feed_url);
    $feed->enable_cache(false);
    $feed->strip_attributes(false);
    $feed->init();
    $feed->handle_content_type();
    $feed_page_slugs = array();
    foreach ($feed->get_items() as $item) {
        $page_title = $item->get_title();
        $page_description = $item->get_description();
        // Extract the slug
        $page_slug_el = $item->get_item_tags(IKIT_XML_NAMESPACE_URI, 'pageSlug');
        $page_slug = $page_slug_el[0]['data'];
        $feed_page_slugs[$page_slug] = true;
        // Add or update existing sponsor
        $associated_post = array('post_title' => $page_title, 'post_name' => $page_slug, 'post_type' => 'page', 'post_status' => 'publish', 'post_content' => $page_description);
        $existing_associated_post = ikit_get_post_by_slug($page_slug, 'page');
        if ($existing_associated_post == null) {
            $new_associated_post_id = wp_insert_post($associated_post);
            if ($new_associated_post_id > 0) {
                // Add custom fields
                add_post_meta($new_associated_post_id, IKIT_CUSTOM_FIELD_GENERIC_EXTERNAL_SOURCE, IKIT_EXTERNAL_SOURCE_NATIONAL, true);
            }
        } else {
            $associated_post['ID'] = $existing_associated_post->ID;
            $updated_associated_post_id = wp_update_post($associated_post);
            if ($updated_associated_post_id > 0) {
                ikit_add_or_update_post_meta($updated_associated_post_id, IKIT_CUSTOM_FIELD_GENERIC_EXTERNAL_SOURCE, IKIT_EXTERNAL_SOURCE_NATIONAL, true);
            }
        }
    }
    if (count($feed_page_slugs) > 0 && count($feed->get_items()) == count($feed_page_slugs)) {
        // Safety check to not just delete randomly, should be at least one page in the feed
        // Delete any non-existing sponsors marked with same external source
        $args = array('post_type' => 'page', 'meta_key' => IKIT_CUSTOM_FIELD_GENERIC_EXTERNAL_SOURCE, 'meta_value' => IKIT_EXTERNAL_SOURCE_NATIONAL);
        $pages = get_posts($args);
        foreach ($pages as $page) {
            if (array_key_exists($page->post_name, $feed_page_slugs) == false) {
                // Delete
                wp_delete_post($page->ID, true);
            }
        }
    }
}
开发者ID:aiga-chicago,项目名称:chicago.aiga.org,代码行数:58,代码来源:national.php

示例6: 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

示例7: GetRssItems

 private function GetRssItems($isPreview, $text)
 {
     // Make sure we have the cache location configured
     $file = new File($this->db);
     File::EnsureLibraryExists();
     // Make sure we have a $media/$layout object to use
     $media = new Media();
     $layout = new Layout();
     // Parse the text template
     $matches = '';
     preg_match_all('/\\[.*?\\]/', $text, $matches);
     Debug::LogEntry('audit', 'Loading SimplePie to handle RSS parsing.' . urldecode($this->GetOption('uri')));
     // Use SimplePie to get the feed
     include_once '3rdparty/simplepie/autoloader.php';
     $feed = new SimplePie();
     $feed->set_cache_location($file->GetLibraryCacheUri());
     $feed->set_feed_url(urldecode($this->GetOption('uri')));
     $feed->force_feed(true);
     $feed->set_cache_duration($this->GetOption('updateInterval', 3600) * 60);
     $feed->handle_content_type();
     // Get a list of allowed attributes
     if ($this->GetOption('allowedAttributes') != '') {
         $attrsStrip = array_diff($feed->strip_attributes, explode(',', $this->GetOption('allowedAttributes')));
         //Debug::Audit(var_export($attrsStrip, true));
         $feed->strip_attributes($attrsStrip);
     }
     // Disable date sorting?
     if ($this->GetOption('disableDateSort') == 1) {
         $feed->enable_order_by_date(false);
     }
     // Init
     $feed->init();
     $dateFormat = $this->GetOption('dateFormat');
     if ($feed->error()) {
         Debug::LogEntry('audit', 'Feed Error: ' . $feed->error());
         return array();
     }
     // Set an expiry time for the media
     $expires = time() + $this->GetOption('updateInterval', 3600) * 60;
     // Store our formatted items
     $items = array();
     foreach ($feed->get_items() as $item) {
         /* @var SimplePie_Item $item */
         // Substitute for all matches in the template
         $rowString = $text;
         // Substitute
         foreach ($matches[0] as $sub) {
             $replace = '';
             // Pick the appropriate column out
             if (strstr($sub, '|') !== false) {
                 // Use the provided name space to extract a tag
                 $attribs = NULL;
                 if (substr_count($sub, '|') > 1) {
                     list($tag, $namespace, $attribs) = explode('|', $sub);
                 } else {
                     list($tag, $namespace) = explode('|', $sub);
                 }
                 // What are we looking at
                 Debug::Audit('Namespace: ' . str_replace(']', '', $namespace) . '. Tag: ' . str_replace('[', '', $tag) . '. ');
                 // Are we an image place holder?
                 if (strstr($namespace, 'image') != false) {
                     // Try to get a link for the image
                     $link = null;
                     switch (str_replace('[', '', $tag)) {
                         case 'Link':
                             if ($enclosure = $item->get_enclosure()) {
                                 // Use the link to get the image
                                 $link = $enclosure->get_link();
                             }
                             break;
                         default:
                             // Default behaviour just tries to get the content from the tag provided (without a name space).
                             $tags = $item->get_item_tags('', str_replace('[', '', $tag));
                             if ($tags != null) {
                                 $link = is_array($tags) ? $tags[0]['data'] : '';
                             }
                     }
                     if ($link == NULL) {
                         $dom = new DOMDocument();
                         $dom->loadHTML($item->get_content());
                         // Full
                         $images = $dom->getElementsByTagName('img');
                         foreach ($images as $key => $value) {
                             if ($key == 0) {
                                 $link = html_entity_decode($images->item($key)->getAttribute('src'));
                             }
                         }
                     }
                     if ($link == NULL) {
                         $dom = new DOMDocument();
                         $dom->loadHTML($item->get_description());
                         //Summary
                         $images = $dom->getElementsByTagName('img');
                         foreach ($images as $key => $value) {
                             if ($key == 0) {
                                 $link = html_entity_decode($images->item($key)->getAttribute('src'));
                             }
                         }
                     }
                     // If we have managed to resolve a link, download it and replace the tag with the downloaded
//.........这里部分代码省略.........
开发者ID:fignew,项目名称:xibo-cms,代码行数:101,代码来源:ticker.module.php

示例8: _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

示例9: SimplePie

            } else {
                if ($newsType == 'entertainment') {
                    // Entertainment
                    $feed = new SimplePie();
                    $feed->set_feed_url(array('http://www.eonline.com/syndication/feeds/rssfeeds/topstories.xml', 'http://rss.news.yahoo.com/rss/entertainment', 'http://rss.news.yahoo.com/rss/fashion', 'http://feeds.digg.com/digg/container/entertainment/popular.rss', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=e&output=rss', 'http://rss.ew.com/web/ew/rss/todayslatest/index.xml', 'http://www.tmz.com/rss.xml'));
                    $feed->set_stupidly_fast(true);
                    $feed->set_cache_location('./cache');
                    $feed->set_cache_duration(900);
                    //		$feed->strip_htmltags(array_merge($feed->strip_htmltags, array('center'));
                    $feed->strip_attributes(array_merge($feed->strip_attributes, array('border')));
                    $feed->enable_order_by_date(true);
                    $feed->init();
                    $plug = 'Entertainment';
                } else {
                    // Regular News
                    $feed = new SimplePie();
                    $feed->set_feed_url(array('http://feeds.reuters.com/reuters/topNews', 'http://rss.cnn.com/rss/cnn_topstories.rss', 'http://online.wsj.com/xml/rss/3_7011.xml', 'http://feeds.digg.com/digg/popular.rss', 'http://www.businessweek.com/rss/bwdaily.rss', 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss'));
                    $feed->set_stupidly_fast(true);
                    $feed->set_cache_location('./cache');
                    $feed->set_cache_duration(900);
                    //		$feed->strip_htmltags(array_merge($feed->strip_htmltags, array('center'));
                    $feed->strip_attributes(array_merge($feed->strip_attributes, array('border')));
                    $feed->enable_order_by_date(true);
                    $feed->init();
                    $plug = 'News';
                }
            }
        }
    }
}
$feed->handle_content_type();
开发者ID:neomelonas,项目名称:NewsDigest,代码行数:31,代码来源:feeds.php

示例10: SimplePie

<div class="col-sm-5" id="home-outputs">
	<h2 class="home-list-cat-name"><a href="http://www.apn-gcr.org/resources/items/browse?collection=2"><?php 
_e('Updates from E-Lib', 'APN2015');
?>
</a></h2>
	<ul class="home-list-ul">
		<?php 
$feed = new SimplePie();
$feed->set_feed_url('http://www.apn-gcr.org/resources/items?output=atom&sort_field=modified&sort_dir=d');
$feed->strip_attributes(false);
$success = $feed->init();
$feed->handle_content_type();
if ($success) {
    foreach ($feed->get_items(0, 3) as $item) {
        ?>
			<li class="home-list-li">
				<div class="home-list-meta">
					<?php 
        $content = $item->get_content();
        $html = str_get_html($content);
        $section_pj_ref = $html->find('#project-item-type-metadata-project-reference-nos', 0);
        //get the last line of Project Reference Number if exists
        if (strlen($section_pj_ref) > 0) {
            $pj_ref = $section_pj_ref->children(1)->innertext;
            $pos = strripos($pj_ref, '<br>') ? strripos($pj_ref, '<br>') + 4 : 0;
            $pj_ref = substr($pj_ref, $pos);
            ?>
					<span class="entry-meta-heavy"><i class="glyphicon glyphicon-book"> </i> <?php 
            echo $pj_ref;
            ?>
</span>
开发者ID:hktang,项目名称:apntwentyfifteen,代码行数:31,代码来源:home-projects.php


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