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


PHP SimplePie::get_description方法代码示例

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


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

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     if ($this->rss_template != 'rss_default') {
         $this->strTemplate = $this->rss_template;
         /** @var FrontendTemplate|object $objTemplate */
         $objTemplate = new \FrontendTemplate($this->strTemplate);
         $this->Template = $objTemplate;
         $this->Template->setData($this->arrData);
     }
     $this->Template->link = $this->objFeed->get_link();
     $this->Template->title = $this->objFeed->get_title();
     $this->Template->language = $this->objFeed->get_language();
     $this->Template->description = $this->objFeed->get_description();
     $this->Template->copyright = $this->objFeed->get_copyright();
     // Add image
     if ($this->objFeed->get_image_url()) {
         $this->Template->image = true;
         $this->Template->src = $this->objFeed->get_image_url();
         $this->Template->alt = $this->objFeed->get_image_title();
         $this->Template->href = $this->objFeed->get_image_link();
         $this->Template->height = $this->objFeed->get_image_height();
         $this->Template->width = $this->objFeed->get_image_width();
     }
     // Get the items (see #6107)
     $arrItems = array_slice($this->objFeed->get_items(0, intval($this->numberOfItems) + intval($this->skipFirst)), intval($this->skipFirst), intval($this->numberOfItems) ?: null);
     $limit = count($arrItems);
     $offset = 0;
     // Split pages
     if ($this->perPage > 0) {
         // Get the current page
         $id = 'page_r' . $this->id;
         $page = \Input::get($id) !== null ? \Input::get($id) : 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil(count($arrItems) / $this->perPage), 1)) {
             throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
         }
         // Set limit and offset
         $offset = ($page - 1) * $this->perPage;
         $limit = $this->perPage + $offset;
         $objPagination = new \Pagination(count($arrItems), $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $items = array();
     $last = min($limit, count($arrItems)) - 1;
     /** @var \SimplePie_Item[] $arrItems */
     for ($i = $offset, $c = count($arrItems); $i < $limit && $i < $c; $i++) {
         $items[$i] = array('link' => $arrItems[$i]->get_link(), 'title' => $arrItems[$i]->get_title(), 'permalink' => $arrItems[$i]->get_permalink(), 'description' => str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $arrItems[$i]->get_description()), 'class' => ($i == 0 ? ' first' : '') . ($i == $last ? ' last' : '') . ($i % 2 == 0 ? ' even' : ' odd'), 'pubdate' => \Date::parse($objPage->datimFormat, $arrItems[$i]->get_date('U')), 'category' => $arrItems[$i]->get_category(0), 'object' => $arrItems[$i]);
         // Add author
         if (($objAuthor = $arrItems[$i]->get_author(0)) != false) {
             $items[$i]['author'] = trim($objAuthor->name . ' ' . $objAuthor->email);
         }
         // Add enclosure
         if (($objEnclosure = $arrItems[$i]->get_enclosure(0)) != false) {
             $items[$i]['enclosure'] = $objEnclosure->get_link();
         }
     }
     $this->Template->items = array_values($items);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:63,代码来源:ModuleRssReader.php

示例2: tagAction

 function tagAction()
 {
     $tag = $this->_request->getParam('tag');
     if (empty($tag)) {
         $this->_redirect('/index');
     }
     $feed = new SimplePie("http://baphled.wordpress.com/tag/{$tag}/feed");
     $feed->init();
     $this->view->description = $feed->get_description();
     $this->view->title = $feed->get_title();
     $this->view->items = $feed->get_items();
     $this->render('feed');
 }
开发者ID:baphled,项目名称:boodah,代码行数:13,代码来源:BlogController.php

示例3: addAction

 public function addAction()
 {
     require_once PLUGIN_DIR . "/FeedImporter/libraries/SimplePie/simplepie.inc";
     $feed = new SimplePie();
     $varName = strtolower($this->_modelClass);
     $class = $this->_modelClass;
     $record = new FeedImporter_Feed();
     //Need an id to work with the tags, so save it now, even though it might be sloppy/confusing
     $record->save();
     if ($_GET['feed_url']) {
         $feed_url = $_GET['feed_url'];
         $debug = new stdClass();
         $feed->set_feed_url($feed_url);
         // Run SimplePie.
         $feed->init();
         $feed->handle_content_type();
         if ($feed->error()) {
             $this->flash($feed->error());
             //return here?
         }
         $debug->title = $feed->get_title();
         $debug->description = $feed->get_description();
         //Set up the tag configurations for the first import
         $import = new FeedImporter_Import();
         $import->processFeedTags($feed, $record->id);
         $record->feed_url = $feed_url;
         $record->feed_title = $feed->get_title();
         $record->feed_description = $feed->get_description();
     }
     $record->save();
     // Create a new FakeCron_Task for the feed
     $fc_task = new FakeCron_Task();
     $fc_task->interval = 0;
     $fc_task->name = "Cron for feed " . $record->feed_title;
     $fc_task->plugin_class = "FeedImporter_FakeCronTask";
     $fc_task->plugin_name = 'FeedImporter';
     $fc_task->params = serialize(array($record->id));
     $fc_task->save();
     $record->task_id = $fc_task->id;
     $_POST['task_id'] = $fc_task->id;
     $this->view->assign(array($varName => $record));
     try {
         if ($record->saveForm($_POST)) {
             $this->redirect->goto('browse');
         }
     } catch (Omeka_Validator_Exception $e) {
         $this->flashValidationErrors($e);
     } catch (Exception $e) {
         $this->flash($e->getMessage());
     }
 }
开发者ID:patrickmj,项目名称:FeedImporter,代码行数:51,代码来源:FeedsController.php

示例4: data

 /**
  * Handles all of the heavy lifting for getting the feed, parsing it, and managing customizations.
  *
  * @access private
  * @param mixed $url Either a single feed URL (as a string) or an array of feed URLs (as an array of strings).
  * @param array $options An associative array of options that the function should take into account when rendering the markup.
  * <ul>
  *     <li>string $classname  - The classname that the <div> surrounding the feed should have. Defaults to nb-list for newsblocks::listing() and nb-wide for newsblocks::wide().</li>
  *     <li>string $copyright - The copyright string to use for a feed. Not part of the standard output, but it's available if you want to use it. Defaults to NULL with multifeeds; Use $item->get_feed()->get_copyright() instead.</li>
  *     <li>string $date_format - The format to use when displaying dates on items. Uses values from http://php.net/strftime, NOT http://php.net/date.</li>
  *     <li>string $description - The description for the feed (not the item). Not part of the standard output, but it's available if you want to use it. Defaults to NULL with multifeeds; Use $item->get_feed()->get_description() instead.</li>
  *     <li>string $direction - The direction of the text. Valid values are "ltr" and "rtl". Defaults to "ltr".</li>
  *     <li>string $favicon - The favicon URL to use for the feed. Since favicon URLs aren't actually located in feeds, SimplePie guesses. Sometimes that guess is wrong. Give it the correct favicon with this option. Defaults to NULL with multifeeds; Use $item->get_feed()->get_favicon() instead.</li>
  *     <li>string $id - The ID attribute that the <div> surrounding the feed should have. This value should be unique per feed. Defaults to a SHA1 hash value based on the URL(s).</li>
  *     <li>string $item_classname - The classname for the items. Useful for styling with CSS. Also useful for JavaScript in creating custom tooltips for a feed. Defaults to "tips".</li>
  *     <li>integer $items - The number of items to show (the rest are hidden until "More" is clicked). Defaults to 10.</li>
  *     <li>string $language - The language of the feed. Not part of the standard output, but it's available if you want to use it. Defaults to NULL with multifeeds; Use $item->get_feed()->get_language() instead.</li>
  *     <li>integer $length - The maximum character length of the item description in the tooltip. Defaults to 200.</li>
  *     <li>string $more - The text to use for the "More" link. Defaults to "More &raquo;"</li>
  *     <li>boolean $more_move - Whether the "More" link should move when it's clicked. Defaults to FALSE (i.e. stays in the same place).</li>
  *     <li>boolean $more_fx - Whether the secondary list should slide or simply appear/disappear when the "More" link is clicked. Defaults to TRUE (i.e. slides).</li>
  *     <li>string $permalink - The permalink for the feed (not the item). Defaults to NULL with multifeeds; Use $item->get_feed()->get_permalink() instead.</li>
  *     <li>boolean $show_title - Whether to show the title of the feed. Defaults to TRUE.</li>
  *     <li>integer $since - A Unix timestamp. Anything posted more recently than this timestamp will get the "New" image applied to it. Defaults to 24 hours ago.</li>
  *     <li>$string $title - The title for the feed (not the item). Defaults to multiple titles with multifeeds, so you should manually set it in that case.</li>
  * </ul>
  * @return string The (X)HTML markup to display on the page.
  */
 function data($url, $options = null)
 {
     // Create a new SimplePie instance with this feed
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->init();
     // Prep URL values to hash later.
     if (!is_array($url)) {
         $hash_str = array($url);
     } else {
         $hash_str = $url;
     }
     // Set the default values.
     $classname = null;
     $copyright = $feed->get_copyright();
     $date_format = '%a, %e %b %Y, %I:%M %p';
     $description = $feed->get_description();
     $direction = 'ltr';
     $favicon = $feed->get_favicon();
     $id = 'a' . sha1(implode('', $hash_str));
     $item_classname = 'tips';
     $items = 10;
     $language = $feed->get_language();
     $length = 200;
     $more = 'More &raquo;';
     $more_move = false;
     $more_fx = true;
     $permalink = $feed->get_permalink();
     $show_title = true;
     $since = time() - 24 * 60 * 60;
     // 24 hours ago.
     $title = $feed->get_title();
     // Override defaults with passed-in values.
     extract($options);
     // Set values for those that are still null
     if (!$favicon) {
         $favicon = NB_FAVICON_DEFAULT;
     }
     if (!$title) {
         if (is_array($url)) {
             $feed_title = array();
             foreach ($url as $u) {
                 $feed_title[] = newsblocks::name($u);
             }
             $title = implode(', ', $feed_title);
         }
     }
     // Send the data back to the calling function.
     return array('classname' => $classname, 'copyright' => $copyright, 'date_format' => $date_format, 'description' => $description, 'direction' => $direction, 'favicon' => $favicon, 'feed' => $feed, 'id' => $id, 'item_classname' => $item_classname, 'items' => $items, 'language' => $language, 'length' => $length, 'more' => $more, 'more_move' => $more_move, 'more_fx' => $more_fx, 'permalink' => $permalink, 'show_title' => $show_title, 'since' => $since, 'title' => $title);
 }
开发者ID:postprefix,项目名称:newsblocks,代码行数:78,代码来源:newsblocks.inc.php

示例5: buildDocument

 /**
  * Implements CollectionAbstract::buildDocument().
  *
  * @param IndexDocument $document
  * @param \SimplePie_Item $data
  */
 public function buildDocument(IndexDocument $document, $data)
 {
     $document->source = $this->_feed->get_title();
     $document->subject = $this->_feed->get_description();
     $document->title = $data->get_title();
     $document->link = $data->get_link();
     $document->description = $data->get_description();
     $document->creator = (array) $data->get_author();
     $document->date = $data->get_date();
     // PHP properties cannot have dashes (-), and the fields below have
     // dashes in the field name.
     $document->source_link = $this->_feed->get_link();
     $document->getField('source_link')->setName('source-link');
     $document->item_subject = $this->_feed->get_link();
     $document->getField('item_subject')->setName('item-subject');
 }
开发者ID:cpliakas,项目名称:feed-collection,代码行数:22,代码来源:FeedCollection.php

示例6: view

 private function view()
 {
     $feeds = $this->_db->queryAll('SELECT id, url, title FROM feeds WHERE user = ? ORDER BY title, url', $this->getIdUser());
     $this->info = array();
     foreach ($feeds as $feed) {
         $pie = new SimplePie();
         $pie->set_feed_url($feed['url']);
         $pie->set_cache_location(rtrim(DIR_TPL_COMPILE, '/'));
         $pie->init();
         $pie->handle_content_type();
         $items = $pie->get_items(0, self::FEED_MAX_ITEMS);
         $now = time();
         for ($i = count($items) - 1; $i != 0; --$i) {
             $time = $items[$i]->get_date('U');
             if ($time && $now - $time > self::FEED_MAX_DAYS * 86400) {
                 array_pop($items);
             }
         }
         $this->info[] = array('title' => empty($feed['title']) ? $pie->get_title() : $feed['title'], 'id' => $feed['id'], 'description' => $pie->get_description(), 'news' => $items);
     }
 }
开发者ID:santa01,项目名称:wtorrent,代码行数:21,代码来源:Feeds.cls.php

示例7: probe_url


//.........这里部分代码省略.........
                    }
                    if (isset($noscrapedata["dfrn-request"])) {
                        $request = $noscrapedata["dfrn-request"];
                    }
                    if (isset($noscrapedata["dfrn-confirm"])) {
                        $confirm = $noscrapedata["dfrn-confirm"];
                    }
                    if (isset($noscrapedata["dfrn-notify"])) {
                        $notify = $noscrapedata["dfrn-notify"];
                    }
                    if (isset($noscrapedata["dfrn-poll"])) {
                        $poll = $noscrapedata["dfrn-poll"];
                    }
                }
            }
            if (!$vcard['photo'] && strlen($email)) {
                $vcard['photo'] = avatar_img($email);
            }
            if ($poll === $profile) {
                $lnk = $feed->get_permalink();
            }
            if (isset($lnk) && strlen($lnk)) {
                $profile = $lnk;
            }
            if (!$network) {
                $network = NETWORK_FEED;
                // If it is a feed, don't take the author name as feed name
                unset($vcard['fn']);
            }
            if (!x($vcard, 'fn')) {
                $vcard['fn'] = notags($feed->get_title());
            }
            if (!x($vcard, 'fn')) {
                $vcard['fn'] = notags($feed->get_description());
            }
            if (strpos($vcard['fn'], 'Twitter / ') !== false) {
                $vcard['fn'] = substr($vcard['fn'], strpos($vcard['fn'], '/') + 1);
                $vcard['fn'] = trim($vcard['fn']);
            }
            if (!x($vcard, 'nick')) {
                $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn'])));
                if (strpos($vcard['nick'], ' ')) {
                    $vcard['nick'] = trim(substr($vcard['nick'], 0, strpos($vcard['nick'], ' ')));
                }
            }
            if (!$priority) {
                $priority = 2;
            }
        }
    }
    if (!x($vcard, 'photo')) {
        $a = get_app();
        $vcard['photo'] = $a->get_baseurl() . '/images/person-175.jpg';
    }
    if (!$profile) {
        $profile = $url;
    }
    // No human could be associated with this link, use the URL as the contact name
    if ($network === NETWORK_FEED && $poll && !x($vcard, 'fn')) {
        $vcard['fn'] = $url;
    }
    if ($notify != "" and $poll != "") {
        $baseurl = matching(normalise_link($notify), normalise_link($poll));
        $baseurl2 = matching($baseurl, normalise_link($profile));
        if ($baseurl2 != "") {
            $baseurl = $baseurl2;
开发者ID:vinzv,项目名称:friendica,代码行数:67,代码来源:Scrape.php

示例8: create


//.........这里部分代码省略.........
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}');
                         $response = $fb->getClient()->sendRequest($request);
                         $posts = $response->getDecodedBody();
                         $this->readerself_library->crawl_items_facebook($fed_id, $posts['feed']['data']);
                         redirect(base_url() . 'subscriptions/read/' . $sub_id);
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
                     }
                 } else {
                     include_once 'thirdparty/simplepie/autoloader.php';
                     include_once 'thirdparty/simplepie/idn/idna_convert.class.php';
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($this->input->post('url')));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(60);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $data['error'] = $sp_feed->error();
                     } else {
                         $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_description', $sp_feed->get_description());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $data['sub_id'] = $sub_id;
                         $data['fed_title'] = $sp_feed->get_title();
                         $this->readerself_library->crawl_items($fed_id, $sp_feed->get_items());
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
         } else {
             $fed = $query->row();
             if (!$fed->sub_id) {
                 $this->db->set('mbr_id', $this->member->mbr_id);
                 $this->db->set('fed_id', $fed->fed_id);
                 if ($this->config->item('folders')) {
                     if ($folder) {
                         $this->db->set('flr_id', $folder);
                     }
                 }
                 $this->db->set('sub_priority', $this->input->post('priority'));
                 $this->db->set('sub_direction', $this->input->post('direction'));
                 $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                 $this->db->insert('subscriptions');
                 $sub_id = $this->db->insert_id();
             } else {
                 $sub_id = $fed->sub_id;
             }
             $data['sub_id'] = $sub_id;
             $data['fed_title'] = $fed->fed_title;
         }
         if ($data['error']) {
             $content = $this->load->view('subscriptions_create', $data, TRUE);
         } else {
             redirect(base_url() . 'subscriptions/read/' . $sub_id);
         }
     }
     $this->readerself_library->set_content($content);
 }
开发者ID:slowmotion,项目名称:readerself,代码行数:101,代码来源:Subscriptions.php

示例9: 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);
 }
开发者ID:esironal,项目名称:readerself,代码行数:101,代码来源:refresh.php

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

示例11: SimplePie

<input name="url" type="text" value="<?php 
echo $_POST['url'];
?>
" style="width:400px;"><input name="Submit" type="submit" value="Get Feed">
</form>
<?php 
if (isset($_POST['url']) && $_POST['url'] != "") {
    $url = $_POST['url'];
    include_once 'Simple/autoloader.php';
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->enable_cache(false);
    $feed->set_output_encoding('Windows-1252');
    $feed->init();
    echo "<span><h1>" . $feed->get_title() . "</h1>";
    echo "<b>" . $feed->get_description() . "</b></span><hr />";
    $itemCount = $feed->get_item_quantity();
    $items = $feed->get_items();
    foreach ($items as $item) {
        ?>
<div><a href="<?php 
        echo $item->get_permalink();
        ?>
"><?php 
        echo $item->get_title();
        ?>
</a><br />
<em style="font-size:.7em;color:#666666"><?php 
        echo $item->get_date();
        ?>
</em>
开发者ID:parsinegar2015,项目名称:parsinegar,代码行数:31,代码来源:index.php

示例12: getPosts

 /**
  *
  * Get posts from feeds:
  * @param array $feeds Array with the feeds.
  * @return array Array with the posts.
  */
 public function getPosts($feeds)
 {
     $posts = array();
     foreach ($feeds as $name => $feed) {
         Debug::info("Getting posts from " . $feed['url']);
         $rss = new SimplePie($feed['url']);
         $rss->handle_content_type();
         $rss->force_feed(true);
         $counter = 1;
         foreach ($rss->get_items() as $item) {
             Debug::info("  post {$counter} of " . MAXPOSTS . ".");
             if (!is_object($item)) {
                 Debug::error("Parsing item (" . $item . ").");
             } else {
                 if (strstr($item->get_title(), "[minipost]")) {
                     Debug::say("Minipost...passing.");
                 } else {
                     $counter++;
                     $timestamp = strtotime($item->get_date());
                     # Post:
                     $posts[$timestamp]['id'] = "p" . $timestamp . "-" . $counter;
                     $posts[$timestamp]['pubdate'] = $item->get_date('r');
                     $posts[$timestamp]['date'] = $item->get_local_date();
                     $posts[$timestamp]['time'] = $item->get_local_date("%T");
                     $posts[$timestamp]['permalink'] = $item->get_permalink();
                     $posts[$timestamp]['title'] = $item->get_title();
                     $posts[$timestamp]['description'] = $item->get_description();
                     $posts[$timestamp]['content'] = $item->get_content();
                     if ($posts[$timestamp]['description'] == $posts[$timestamp]['content'] and strlen($posts[$timestamp]['content']) < 400) {
                         $posts[$timestamp]['description'] = Html::Cut(Html::BurnerClean($item->get_description()));
                         $posts[$timestamp]['content'] = "";
                         $posts[$timestamp]['toggle'] = "";
                     } else {
                         $posts[$timestamp]['description'] = Html::Cut(Html::BurnerClean($item->get_description()));
                         $posts[$timestamp]['content'] = Html::Clean($item->get_content());
                         $posts[$timestamp]['toggle'] = "<a onclick='ToggleContent(\"" . $posts[$timestamp]['id'] . "\"); return false;' href=\"#\">&dArr; Read more</a>";
                     }
                     // Microblogging posts have same description as title
                     if (FALSE !== strpos($posts[$timestamp]['title'], $posts[$timestamp]['description'])) {
                         $posts[$timestamp]['description'] = "";
                         $posts[$timestamp]['content'] = "";
                         $posts[$timestamp]['toggle'] = "";
                     }
                     # Rss:
                     $posts[$timestamp]['description_rss'] = $posts[$timestamp]['description'];
                     $posts[$timestamp]['content_rss'] = $posts[$timestamp]['content'];
                     # author:
                     if (method_exists($item, 'get_author') and is_object($item->get_author())) {
                         # The feed ones:
                         $posts[$timestamp]['author'] = $item->get_author()->get_name();
                         $posts[$timestamp]['author_link'] = $item->get_author()->get_link();
                     } else {
                         Debug::say("No author data feed " . $name);
                         $posts[$timestamp]['author'] = $name;
                         $posts[$timestamp]['author_link'] = $rss->get_permalink();
                     }
                     # Si han quedado vacíos pese a todo:
                     if (empty($posts[$timestamp]['author'])) {
                         $posts[$timestamp]['author'] = $name;
                     }
                     if (empty($posts[$timestamp]['author_link'])) {
                         $posts[$timestamp]['author_link'] = $feed['url'];
                     }
                     $posts[$timestamp]['author_email'] = $feed['email'];
                     # Gravatar:
                     if (strlen($feed['avatar'])) {
                         $posts[$timestamp]['author_avatar'] = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5($feed['avatar']) . "&amp;size=40&amp;default=" . urlencode(DEFAULT_AVATAR);
                     } else {
                         if (strlen($feed['avatar_url'])) {
                             $posts[$timestamp]['author_avatar'] = $feed['avatar_url'];
                         }
                     }
                     # Blog:
                     $posts[$timestamp]['blog_title'] = $rss->get_title();
                     $posts[$timestamp]['blog_url'] = $rss->get_permalink();
                     $posts[$timestamp]['blog_desc'] = $rss->get_description();
                     # Logo:
                     $posts[$timestamp]['logo_url'] = $rss->get_image_url();
                     $posts[$timestamp]['logo_link'] = $rss->get_image_link();
                     $posts[$timestamp]['logo_title'] = $rss->get_image_title();
                 }
             }
             if ($counter > MAXPOSTS) {
                 break;
             }
         }
     }
     krsort($posts);
     #Debug::dump($posts);
     return $posts;
 }
开发者ID:jorgefuertes,项目名称:qPlanet,代码行数:97,代码来源:Rss.class.php

示例13: parse_single_feed

 public function parse_single_feed($flux)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($_POST['url']);
     $feed->init();
     if (!$feed->error()) {
         $feed->enable_cache(false);
         $feed->handle_content_type();
         $feed_title = strip_tags($feed->get_title());
         if (strlen($feed_title) > 50) {
             $feed_title = substr($feed_title, 0, 47) . '...';
         }
         $exist = $this->getConnectionWrapper()->addFlux($_POST['url'], $feed_title, $feed->get_description());
         $idFlux = $this->getConnectionWrapper()->getFluxId($feed_title);
         $this->NON_CLASSE = $this->getConnectionWrapper()->getFolderId($this->session_get("user_id", null), 'Non classé');
         $this->getConnectionWrapper()->addAbonnement($this->session_get("user_id", null), $this->NON_CLASSE, $idFlux);
         if (!$exist) {
             foreach ($feed->get_items() as $item) {
                 $item_title = strip_tags($item->get_title());
                 if (strlen($item_title) > 50) {
                     $item_title = substr($item_title, 0, 47) . '...';
                 }
                 $item_desc = $item->get_description();
                 if (strlen($item_desc) == 0) {
                     $item_desc = 'Aucune description disponible: ' . $item->get_permalink();
                 }
                 $item_content = $item->get_content();
                 if (strlen($item_content) == 0) {
                     $item_content = 'Aucun contenu supplémentaire disponible: ' . $item->get_permalink();
                 }
                 $this->getConnectionWrapper()->addArticle($idFlux, $item_title, $item->get_permalink(), $item_desc, $item_content, $item->get_date('Y-m-j G:i:s'));
             }
         }
     }
     $this->redirect_to('listing');
 }
开发者ID:laiello,项目名称:msgr,代码行数:36,代码来源:rss.php

示例14: discover_by_url


//.........这里部分代码省略.........
    if (!$x['success']) {
        logger('probe_url: feed fetch failed for ' . $poll);
        return false;
    }
    $xml = $x['body'];
    logger('probe_url: fetch feed: ' . $guid . ' returns: ' . $xml, LOGGER_DATA);
    logger('probe_url: scrape_feed: headers: ' . $x['header'], LOGGER_DATA);
    // Don't try and parse an empty string
    $feed->set_raw_data($xml ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></xml>');
    $feed->init();
    if ($feed->error()) {
        logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error());
    }
    $name = unxmlify(trim($feed->get_title()));
    $photo = $feed->get_image_url();
    $author = $feed->get_author();
    if ($author) {
        if (!$name) {
            $name = unxmlify(trim($author->get_name()));
        }
        if (!$name) {
            $name = trim(unxmlify($author->get_email()));
            if (strpos($name, '@') !== false) {
                $name = substr($name, 0, strpos($name, '@'));
            }
        }
        if (!$profile && $author->get_link()) {
            $profile = trim(unxmlify($author->get_link()));
        }
        if (!$photo) {
            $rawtags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
            if ($rawtags) {
                $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
                if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') {
                    $photo = $elems['link'][0]['attribs']['']['href'];
                }
            }
        }
    } else {
        $item = $feed->get_item(0);
        if ($item) {
            $author = $item->get_author();
            if ($author) {
                if (!$name) {
                    $name = trim(unxmlify($author->get_name()));
                    if (!$name) {
                        $name = trim(unxmlify($author->get_email()));
                    }
                    if (strpos($name, '@') !== false) {
                        $name = substr($name, 0, strpos($name, '@'));
                    }
                }
                if (!$profile && $author->get_link()) {
                    $profile = trim(unxmlify($author->get_link()));
                }
            }
            if (!$photo) {
                $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/', 'thumbnail');
                if ($rawmedia && $rawmedia[0]['attribs']['']['url']) {
                    $photo = unxmlify($rawmedia[0]['attribs']['']['url']);
                }
            }
            if (!$photo) {
                $rawtags = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
                if ($rawtags) {
                    $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
                    if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') {
                        $photo = $elems['link'][0]['attribs']['']['href'];
                    }
                }
            }
        }
    }
    if ($poll === $profile) {
        $lnk = $feed->get_permalink();
    }
    if (isset($lnk) && strlen($lnk)) {
        $profile = $lnk;
    }
    if (!$network) {
        $network = 'rss';
    }
    if (!$name) {
        $name = notags($feed->get_description());
    }
    if (!$guid) {
        return false;
    }
    $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($guid));
    if ($r) {
        return true;
    }
    if (!$photo) {
        $photo = z_root() . '/images/rss_icon.png';
    }
    $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", dbesc($guid), dbesc($guid), dbesc($pubkey), dbesc($addr), dbesc($profile), dbesc($name), dbesc($network), dbesc(z_root()), dbesc(datetime_convert()));
    $photos = import_xchan_photo($photo, $guid);
    $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($guid));
    return true;
}
开发者ID:bashrc,项目名称:hubzilla,代码行数:101,代码来源:network.php

示例15: SimplePie

<?php 
require_once('simplepie.inc');
$feed = new SimplePie();

$path = 'file';
$path = $path.'.xml';
$filename = $path.'.js';
$feed->set_feed_url($path);
$feed->init();
$feed->handle_content_type();
echo "Wrote:<br />";
$return = 'var data = {' . "\n";
$return .= '"info" : [{' . "\n";
$return .= '"title": "'.$feed->get_title().'",' . "\n";
$return .= '"description": "'.$feed->get_description().'"' . "\n";
$return .= '}],' . "\n";
$amount = $feed->get_item_quantity();
$return .= '"playlist" : [' . "\n";
foreach ($feed->get_items() as $item) {
	$return .= '{' . "\n";
	$return .= '"title": "'.$item->get_title().'",' . "\n";
	$return .= '"description": "'.$item->get_description().'",' . "\n";
	$return .= '"href": "'.$item->get_permalink().'",' . "\n";
	if ($enclosure = $item->get_enclosure()) {
		$return .= '"url": "'.$enclosure->get_link().'",' . "\n";
		$return .= '"thumbnail": "'.str_replace('.png', '_thumbnail.png', $enclosure->get_thumbnail()).'",' . "\n";
		$return .= '"time": "'.$enclosure->get_duration(true).'"' . "\n";
	}
	$return .= '}, ';
}
$return = rtrim($return, ", ");
开发者ID:Gingah,项目名称:Quick-XML-to-JSON,代码行数:31,代码来源:xml2json.php


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