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


PHP SimplePie::get_registry方法代码示例

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


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

示例1: testDirectOverrideNew

 /**
  * @expectedException Exception_Success
  */
 public function testDirectOverrideNew()
 {
     $feed = new SimplePie();
     $feed->get_registry()->register('Cache', 'Mock_CacheNew');
     $feed->get_registry()->register('File', 'MockSimplePie_File');
     $feed->set_feed_url('http://example.com/feed/');
     $feed->init();
 }
开发者ID:sintoris,项目名称:Known,代码行数:11,代码来源:CacheTest.php

示例2: parse

 /**
  * Parse the atom file
  *
  * @param string $file Path to XML file for parsing
  * @return SimplePie object of the feed
  */
 function parse($file)
 {
     $data = file_get_contents($file);
     // parse the feed
     $feed = new SimplePie();
     //set_xxxx methods depreciated (and not working?) replaced with get_registry as per docs
     $reg = $feed->get_registry();
     $reg->register('Sanitize', 'Blogger_Importer_Sanitize');
     $feed->sanitize = $reg->create('Sanitize');
     //Should not really need to do this but there seems to be an issue with the SimplePie class?
     $reg->register('Item', 'WP_SimplePie_Blog_Item');
     $feed->set_raw_data($data);
     $feed->init();
     return $feed;
 }
开发者ID:nihrain,项目名称:accelerate,代码行数:21,代码来源:blogger-importer.php

示例3: array

        function import_comments($connector)
        {
            if (isset($this->comments_start_index))
                $start_index = (int)$this->comments_start_index;
            else
                $start_index = 1;

            if ($start_index > 0 && $this->total_comments > 0)
            {

                $this->mode = 'comments';
                do
                {
                    $index = $struct = $entries = array();

                    //So we can link up the comments as we go we need to load them in reverse order
                    //Reverse the start index as the GData Blogger feed can't be sorted
                    $batch = ((floor(($this->total_comments - $start_index) / Blogger_Import::MAX_RESULTS) * Blogger_Import::MAX_RESULTS) + 1);

                    $response = $connector->oauth_get($this->comments_url,array('max-results' => Blogger_Import::MAX_RESULTS, 'start-index' => $batch));
                    // parse the feed
                    $feed = new SimplePie();
                    //3/1/2012 Updated syntax for registering the item
                    $reg = $feed->get_registry();
                    $reg->register('Item', 'WP_SimplePie_Blog_Item');
                    // Use the standard "stricter" sanitize class for comments
                    $feed->set_raw_data($response);
                    $feed->init();

                    //Reverse the batch so we load the oldest comments first and hence can link up nested comments
                    $comments = array_reverse($feed->get_items());

                    if (!is_null($comments))
                    {
                        foreach ($comments as $item)
                        {
                            $commententry = new CommentEntry();

                            $commententry->id = $item->get_id();
                            $commententry->updated = $item->get_updated();
                            $commententry->content = $item->get_content();
                            $commententry->author = $item->get_author()->get_name();
                            $commententry->authoruri = $item->get_author()->get_link();
                            $commententry->authoremail = $item->get_author()->get_email();

                            $commententry->source = $item->get_source();
                            $parts = parse_url($commententry->source);
                            $commententry->old_post_permalink = $parts['path']; //Will be something like this '/feeds/417730729915399755/posts/default/8397846992898424746'
                                            
                            $commententry->post_ID = BloggerEntry::get_post_by_oldID($commententry->old_post_permalink);

                            //Get the links
                            $commententry->links = $item->get_links(array('edit', 'self', 'alternate', 'related'));
                            $commententry->parselinks();

                            // Nested comment?
                            if (isset($commententry->related))
                            {
                                $commententry->parentcommentid = CommentEntry::get_comment_by_oldID($commententry->related);
                            }

                            //Perhaps could log errors here?
                            if ($commententry->post_ID != 0)
                            {
                                // Checks for duplicates
                                if ($comment_id = $commententry->exists())
                                {
                                    $this->comments_skipped++;
                                } else
                                {
                                    $comment_id = $commententry->import();
                                    $this->comments_done++;
                                }
                            } else
                            {
                                $this->comments_skipped++;
                            }
                            $this->save_vars();
                            $start_index++;
                        }
                    }

                    $this->comments_start_index = $start_index;
                    $this->save_vars();
                } while ($this->total_comments > $start_index && $this->have_time());
            }
            return ($this->total_comments <= $start_index);
        }
开发者ID:niamherinoc,项目名称:rctractors,代码行数:88,代码来源:blogger-importer-blog.php


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