Beispiel #1
0
 /**
  * Create an RSS Feed
  *
  * @param string $title - feed title
  * @param string $link - url feed title should point to
  * @param string $description - feed description
  * @param array $items - $items[0] = array('title'=>TITLE, 'link'=>URL, 'date'=>TIMESTAMP, 'description'=>DESCRIPTION)
  */
 public function rss($h, $title = '', $link = '', $description = '', $items = array())
 {
     require_once EXTENSIONS . 'RSSWriterClass/rsswriter.php';
     $feed = new RSS();
     $feed->title = stripslashes(html_entity_decode(urldecode($title), ENT_QUOTES, 'UTF-8'));
     $feed->link = html_entity_decode($link, ENT_QUOTES, 'UTF-8');
     $feed->description = $description;
     if ($items) {
         foreach ($items as $item) {
             $rssItem = new RSSItem();
             if (isset($item['title'])) {
                 $rssItem->title = stripslashes(html_entity_decode(urldecode($item['title']), ENT_QUOTES, 'UTF-8'));
             }
             if (isset($item['link'])) {
                 $rssItem->link = html_entity_decode($item['link'], ENT_QUOTES, 'UTF-8');
             }
             if (isset($item['date'])) {
                 $rssItem->setPubDate($item['date']);
             }
             if (isset($item['description'])) {
                 $rssItem->description = "<![CDATA[ " . stripslashes(urldecode($item['description'])) . " ]]>";
             }
             if (isset($item['enclosure'])) {
                 $rssItem->enclosure($item['enclosure']['url'], $item['enclosure']['type'], $item['enclosure']['length']);
             }
             if (isset($item['author'])) {
                 $rssItem->addTag('author', $item['author']);
             }
             $feed->addItem($rssItem);
         }
     }
     echo $feed->serve();
 }
 public function loadRecordset($result, $title, $link, $description, $pub_date)
 {
     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
         $item = new RSSItem();
         $item->title = $row[$title];
         $item->link = $row[$link];
         $item->description = $row[$description];
         $item->setPubDate($row[$pub_date]);
         $this->addItem($item);
     }
 }
 public function loadAtom()
 {
     foreach ($this->xml as $ve4d23e841d8e8804190027bce3180fa5 => $v6b992fa9cd5bc92bc5a1efc4738a707e) {
         if ($ve4d23e841d8e8804190027bce3180fa5 != "entry") {
             continue;
         }
         if ($v6b992fa9cd5bc92bc5a1efc4738a707e->content) {
             $v9a0364b9e99bb480dd25e1f0284c8555 = $v6b992fa9cd5bc92bc5a1efc4738a707e->content;
         } else {
             $v9a0364b9e99bb480dd25e1f0284c8555 = $v6b992fa9cd5bc92bc5a1efc4738a707e->summary;
         }
         $v447b7147e84be512208dcc0995d67ebc = new RSSItem();
         $v447b7147e84be512208dcc0995d67ebc->setTitle($v6b992fa9cd5bc92bc5a1efc4738a707e->title);
         $v447b7147e84be512208dcc0995d67ebc->setContent($v9a0364b9e99bb480dd25e1f0284c8555);
         $v447b7147e84be512208dcc0995d67ebc->setDate($v6b992fa9cd5bc92bc5a1efc4738a707e->published);
         $v447b7147e84be512208dcc0995d67ebc->setUrl($v6b992fa9cd5bc92bc5a1efc4738a707e->link['href']);
         $this->items[] = $v447b7147e84be512208dcc0995d67ebc;
     }
 }
 public function __construct($request)
 {
     parent::__construct($request, "index.php");
     $page = !empty($_GET['page']) ? $_GET['page'] : 1;
     if (!empty($_GET['s'])) {
         $this->context['rss_items'] = RSSItem::search_paginated($_GET['s'], $page, RSS_ITEM_PER_PAGE);
         $this->context['page_count'] = (int) (RSSItem::count_search_results($_GET['s']) / RSS_ITEM_PER_PAGE) + 1;
     } else {
         $this->context['rss_items'] = RSSItem::list_paginated($page, RSS_ITEM_PER_PAGE);
         $this->context['page_count'] = (int) (RSSItem::count_all() / RSS_ITEM_PER_PAGE) + 1;
     }
     $this->context['current_page'] = $page;
 }
Beispiel #5
0
 function index()
 {
     global $base_path;
     $album_id = intval($this->getGet('aid'));
     $search = array();
     $siteurl = $this->setting->get_conf('site.url');
     $sitename = $this->setting->get_conf('site.title');
     $description = $this->setting->get_conf('site.description');
     $sitedomain = substr($siteurl, 0, -1 * strlen($base_path));
     $feed =& loader::lib('rss');
     if ($album_id) {
         $search['album_id'] = $album_id;
         $album_info = $this->mdl_album->get_info($album_id);
         $feed->title = $album_info['name'] . ' - ' . $sitename;
     } else {
         $feed->title = $sitename;
     }
     $feed->link = $siteurl;
     $feed->description = $description;
     $this->mdl_photo->set_pageset(50);
     $data = $this->mdl_photo->get_all(1, $search, 'tu_desc');
     if ($data['ls']) {
         foreach ($data['ls'] as $v) {
             $item = new RSSItem();
             $item->title = "<![CDATA[ " . $v['name'] . " ]]>";
             $item->link = $sitedomain . site_link('photos', 'view', array('id' => $v['id']));
             $item->set_pubdate($v['create_time']);
             if (!$this->mdl_album->check_album_priv($album_id, isset($album_info) ? $album_info : null)) {
                 $img = lang('photo_has_priv') . '<br />';
             } else {
                 $img = '<img src="' . $siteurl . $v['path'] . '" /><br />';
             }
             $item->description = "<![CDATA[ " . $img . $v['desc'] . " ]]>";
             $feed->add_item($item);
         }
     }
     $feed->serve();
 }
Beispiel #6
0
function addPageToRSSFeed($html, RSSFeed $rssFeed)
{
    $html = preg_replace("#<script.*?</script>#is", "", $html);
    # Strip out <script> tags so loadHTML() parses the page correctly for $xpath->query()
    $dom = new DOMDocument();
    @$dom->loadHTML($html);
    $xpath = new DOMXPath($dom);
    # Get the post wrapper divs
    $postDivs = $xpath->query('/descendant::div[@id="posts"]/div[starts-with(@id,"edit") and @class="postbit-wrapper "]');
    # Thread URL
    $pageURL = current(iterator_to_array($xpath->query('/html/head/link[@rel="canonical"]/@href')))->nodeValue;
    # Title
    $title = current(iterator_to_array($xpath->query('//div[@id = "thread-header-bloglike"]//h1')))->nodeValue;
    $rssFeed->title = $title;
    # Get the post element divs
    foreach ($postDivs as $postDiv) {
        $rssItem = new RSSItem();
        # Title (author)
        $rssItem->title = '[Post]';
        // Default to "[Post]" on first post
        foreach ($xpath->query('.//a[starts-with(@class, "bigfusername")]', $postDiv) as $postAuthor) {
            $rssItem->title = trim($postAuthor->nodeValue);
            $rssItem->author = trim($postAuthor->nodeValue);
            break;
        }
        # Link, GUID
        $rssItem->link = $pageURL;
        // Default to page URL on first post
        $rssItem->guid = $rssItem->link;
        foreach ($xpath->query('.//a[@class="postCount"]/@href', $postDiv) as $postLink) {
            # Strip the 's' parameter out since it changes every so often....
            $parsedURL = parse_url($postLink->nodeValue);
            $queryStr = $parsedURL['query'];
            parse_str($queryStr, $queryParams);
            unset($queryParams['s']);
            $rssItem->link = 'http://forum.xda-developers.com/' . $parsedURL['path'] . '?' . http_build_query($queryParams);
            $rssItem->guid = $rssItem->link;
            break;
        }
        # Description
        foreach ($xpath->query('.//div[starts-with(@id, "post_message") and starts-with(@class, "post-text")]', $postDiv) as $postMsgDiv) {
            # Strip ad
            foreach ($xpath->query('.//div[@class="purchad"]', $postDiv) as $postAd) {
                $postAd->parentNode->removeChild($postAd);
            }
            $rssItem->description = cleanPostMessageHTML($dom->saveXML($postMsgDiv));
            break;
        }
        # Publication Date
        $rssItem->setPubDate(new DateTime('1900-01-01'));
        // Default to 1st JAN 1900 on first post... oh well...
        $rssFeed->setLastBuildDate($rssItem->getPubDate());
        foreach ($xpath->query('.//span[@class="time"]', $postDiv) as $postDateSpan) {
            $rssItem->setPubDate(getXDADate(trim($postDateSpan->nodeValue)));
            $rssFeed->setLastBuildDate($rssItem->getPubDate());
            # Set the feed's lastBuildDate to the last post's date
            break;
        }
        $rssFeed->addRSSItem($rssItem);
    }
}
Beispiel #7
0
 /**
  * Publish content as an RSS feed
  * Uses the 3rd party RSS Writer class.
  */
 public function rssFeed($h)
 {
     require_once EXTENSIONS . 'RSSWriterClass/rsswriter.php';
     $select = '*';
     $limit = $h->cage->get->getInt('limit');
     $user = $h->cage->get->testUsername('user');
     if (!$limit) {
         $limit = 10;
     }
     if ($user) {
         $userid = $h->getUserIdFromName($user);
     } else {
         $userid = 0;
     }
     $h->pluginHook('comments_rss_feed');
     $feed = new RSS();
     $feed->title = SITE_NAME;
     $feed->link = BASEURL;
     if ($user) {
         $feed->description = $h->lang["comment_rss_comments_from_user"] . " " . $user;
     } else {
         $feed->description = $h->lang["comment_rss_latest_comments"] . SITE_NAME;
     }
     // fetch comments from the database
     $comments = $h->comment->getAllComments($h, 0, "desc", $limit, $userid);
     if ($comments) {
         foreach ($comments as $comment) {
             $h->readPost($comment->comment_post_id);
             $author = $h->getUserNameFromId($comment->comment_user_id);
             $item = new RSSItem();
             if ($user) {
                 $title = $h->lang["comment_rss_comment_on"] . html_entity_decode(urldecode($h->post->title), ENT_QUOTES, 'UTF-8');
             } else {
                 $title = $author . $h->lang["comment_rss_commented_on"] . html_entity_decode(urldecode($h->post->title), ENT_QUOTES, 'UTF-8');
             }
             $item->title = stripslashes($title);
             $item->link = $h->url(array('page' => $comment->comment_post_id)) . "#c" . $comment->comment_id;
             $item->setPubDate($comment->comment_date);
             $item->description = "<![CDATA[ " . stripslashes(urldecode($comment->comment_content)) . " ]]>";
             $feed->addItem($item);
         }
     }
     echo $feed->serve();
 }
 /**
  * Assign values to $feed object and serve the feed
  *
  * @param object $results - post rows
  */
 public function doPostRssFeed($h, $results = NULL)
 {
     if (!$results) {
         return false;
     }
     require_once EXTENSIONS . 'RSSWriterClass/rsswriter.php';
     $feed = new RSS();
     $feed->title = $h->vars['postRssFeed']['title'];
     $feed->link = $h->vars['postRssFeed']['link'];
     $feed->description = $h->vars['postRssFeed']['description'] = $h->vars['postRssFeed']['description'];
     // get sb base settings
     $sb_base_settings = $h->getSerializedSettings('sb_base');
     foreach ($results as $result) {
         $h->post->url = $result->post_url;
         // used in Hotaru's url function
         $h->post->category = $result->post_category;
         // used in Hotaru's url function
         $item = new RSSItem();
         $title = html_entity_decode(urldecode($result->post_title), ENT_QUOTES, 'UTF-8');
         $item->title = stripslashes($title);
         // if RSS redirecting is enabled, append forward=1 to the url
         if (isset($sb_base_settings['rss_redirect']) && !empty($sb_base_settings['rss_redirect'])) {
             $item->link = html_entity_decode($h->url(array('page' => $result->post_id, 'forward' => $result->post_id)), ENT_QUOTES, 'UTF-8');
         } else {
             $item->link = $h->url(array('page' => $result->post_id));
         }
         $item->setPubDate($result->post_date);
         $item->description = "<![CDATA[ " . stripslashes(urldecode($result->post_content)) . " ]]>";
         $feed->addItem($item);
     }
     // do it!
     echo $feed->serve();
 }
Beispiel #9
0
 /**
  * Add an Asset to the feed
  * 
  * @param object Asset $asset
  * @return object RSSItem
  * @access public
  * @since 8/8/06
  */
 function getAssetItem($asset)
 {
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("IdManager");
     $assetId = $asset->getId();
     $repository = $asset->getRepository();
     $repositoryId = $repository->getId();
     $item = new RSSItem();
     $item->setTitle($asset->getDisplayName());
     $item->setLink($harmoni->request->quickURL('asset', 'view', array('collection_id' => $repositoryId->getIdString(), 'asset_id' => $assetId->getIdString())));
     if (RequestContext::value('order') == 'modification') {
         $item->setPubDate($asset->getModificationDate());
     } else {
         $item->setPubDate($asset->getCreationDate());
     }
     $type = $asset->getAssetType();
     $item->addCategory($type->getKeyword(), $type->getDomain());
     // The item HTML
     ob_start();
     print "<div>";
     /*********************************************************
      * Files
      *********************************************************/
     print "\n\t<div id='files' style='float: right; max-width: 60%;'>";
     $fileRecords = $asset->getRecordsByRecordStructure($idManager->getId("FILE"));
     while ($fileRecords->hasNext()) {
         $fileRecord = $fileRecords->next();
         $fileUrl = RepositoryInputOutputModuleManager::getFileUrlForRecord($asset, $fileRecord);
         print "\n\t<div style='height: 200px; width: 200px; text-align: center; vertical-align: middle; float: left;'>";
         print "\n\t\t<a href='" . $fileUrl . "'>";
         print "\n\t\t<img src='";
         print RepositoryInputOutputModuleManager::getThumbnailUrlForRecord($asset, $fileRecord);
         print "' style='vertical-align: middle;'/>";
         print "\n\t\t</a>";
         print "\n\t</div>";
         // Add it as an enclosure
         $fileSizeParts = $fileRecord->getPartsByPartStructure($idManager->getId('FILE_SIZE'));
         $fileSizePart = $fileSizeParts->next();
         $mimeTypeParts = $fileRecord->getPartsByPartStructure($idManager->getId('MIME_TYPE'));
         $mimeTypePart = $mimeTypeParts->next();
         $item->addEnclosure($fileUrl, $fileSizePart->getValue(), $mimeTypePart->getValue());
     }
     print "\n\t</div>";
     /*********************************************************
      * Basic metadata
      *********************************************************/
     print "\n\t<dl>";
     if ($asset->getDescription()) {
         $description = HtmlString::withValue($asset->getDescription());
         $description->clean();
         print "\n\t\t<dt style='font-weight: bold;'>" . _("Description:") . "</dt>";
         print "\n\t\t<dd>" . $description->asString() . "</dd>";
     }
     $date = $asset->getModificationDate();
     print "\n\t\t<dt style='font-weight: bold;'>";
     print _("Modification Date");
     print ":</dt>\n\t\t<dd >";
     print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation();
     print "</dd>";
     $date = $asset->getCreationDate();
     print "\n\t\t<dt style='font-weight: bold;'>";
     print _("Creation Date");
     print ":</dt>\n\t\t<dd >";
     print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation();
     print "</dd>";
     if (is_object($asset->getEffectiveDate())) {
         $date = $asset->getEffectiveDate();
         print "\n\t\t<dt style='font-weight: bold;'>";
         print _("Effective Date");
         print ":</dt>\n\t\t<dd >";
         print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation();
         print "</dd>";
     }
     if (is_object($asset->getExpirationDate())) {
         $date = $asset->getExpirationDate();
         print "\n\t\t<dt style='font-weight: bold;'>";
         print _("Expiration Date");
         print ":</dt>\n\t\t<dd >";
         print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation();
         print "</dd>";
     }
     print "\n\t</dl>";
     /*********************************************************
      * Other Info Records
      *********************************************************/
     // Get the set of RecordStructures so that we can print them in order.
     $setManager = Services::getService("Sets");
     $structSet = $setManager->getPersistentSet($repositoryId);
     $structSet->reset();
     // First, lets go through the info structures listed in the set and print out
     // the info records for those structures in order.
     while ($structSet->hasNext()) {
         $structureId = $structSet->next();
         if ($structureId->isEqual($idManager->getId("FILE"))) {
             continue;
         }
         $recordStructure = $repository->getRecordStructure($structureId);
         $records = $asset->getRecordsByRecordStructure($structureId);
         while ($records->hasNext()) {
             $record = $records->next();
             $recordId = $record->getId();
             print "\n\t<hr />";
             print "\n\t<h3>" . $recordStructure->getDisplayName() . "</h3>";
             $this->printRecord($repositoryId, $assetId, $record);
         }
     }
     print "</div>";
     print "\n\t<div style='clear: both;'>";
     print "</div>";
     $item->setDescription(ob_get_clean());
     return $item;
 }
Beispiel #10
0
require_once "maincore.php";
require_once INCLUDES . "feed.class.php";
isset($_GET['type']) || !empty($_GET['type']) ? $_GET['type'] : ($_GET['type'] = "404");
switch ($_GET['type']) {
    case "addon":
        $result = "\r\n\tSELECT tm.addon_id, tm.addon_name, tm.addon_description, tm.addon_date, tm.addon_download, tc.addon_cat_type, tc.addon_cat_name \r\n\tFROM " . DB_PREFIX . "addondb_cats tc\r\n\tLEFT JOIN " . DB_PREFIX . "addondb_addons tm USING(addon_cat_id)\r\n\tWHERE addon_status = 0\r\n\tORDER BY addon_date\r\n\tDESC LIMIT 10";
        $feed = new Feed();
        $feed->title = "Addons Feed";
        $feed->link = $settings['siteurl'] . FUSION_SELF . "?" . FUSION_QUERY;
        $feed->description = "Latest Addons on PHP-Fusion.";
        $feed->encoding = "iso-8859-1";
        $result = dbquery($result);
        while ($data = dbarray($result)) {
            $filesize = filesize(INFUSIONS . "addondb/files/" . $data['addon_download']);
            $item = new RSSItem();
            $item->title = $data['addon_name'];
            $item->link = $settings['siteurl'] . "infusions/addondb/view.php?addon_id=" . $data['addon_id'];
            $item->setPubDate($data['addon_date']);
            $item->description = $data['addon_description'];
            #$item->enclosure($settings['siteurl']."infusions/addondb/files/".$data['addon_download'], "application/zip", $filesize );
            $feed->addItem($item);
        }
        $feed->displayFeed();
        break;
}
if ($settings['login_method'] == "sessions") {
    session_write_close();
}
if (ob_get_length() !== FALSE) {
    ob_end_flush();
Beispiel #11
0
        $mode = "advanced";
    } else {
        $mode = "simple";
    }
    $queryField = getQueryField($search_language_code);
    $response = $solr->query($crit, $queryField, $querylang, '', 0, 0, 100, $fqitms, $word_variations, $filter_lang, $filter_country, $filter_mimetype, $filter_source, $filter_collection, $filter_tag, '', '', '', '', '', true, false);
    if ($response->getHttpStatus() == 200) {
        //print_r( $response->getRawResponse() );
        $url = $config->get("application.url");
        $title = $config->get("application.title");
        $feed = new RSS();
        $feed->title = $title;
        $feed->link = $url;
        $feed->description = "Recent articles matching your criteria : " . $crit;
        if ($response->response->numFound > 0) {
            foreach ($response->response->docs as $doc) {
                $item = new RSSItem();
                $item->title = $doc->title_dis;
                $item->link = $doc->id;
                $item->setPubDate($doc->createtime);
                $item->description = "<![CDATA[ {$doc->summary} ]]>";
                $feed->addItem($item);
            }
        }
        echo $feed->serve();
    }
}
function getQueryField($search_language_code)
{
    return "content_" . $search_language_code;
}
 /**
  * Add an Asset to the feed
  * 
  * @param object Asset $asset
  * @return object RSSItem
  * @access public
  * @since 8/8/06
  */
 function getAssetItem($asset)
 {
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("IdManager");
     $assetId = $asset->getId();
     $item = new RSSItem();
     $item->setTitle($asset->getDisplayName());
     $item->addCategory("Slideshow");
     $item->setPubDate($asset->getModificationDate());
     $item->setLink(VIEWER_URL . "?&amp;source=" . urlencode($harmoni->request->quickURL("exhibitions", "slideshowOutlineXml", array("slideshow_id" => $assetId->getIdString()))));
     /*********************************************************
      * Get number of slides and first thumbnail.
      *********************************************************/
     $slides = $asset->getAssets();
     $count = 0;
     while ($slides->hasNext()) {
         $slideAsset = $slides->next();
         $count++;
         if (!isset($firstMediaUrl)) {
             $slideRecords = $slideAsset->getRecordsByRecordStructure($idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure"));
             if ($slideRecords->hasNext()) {
                 $slideRecord = $slideRecords->next();
                 // Media
                 $mediaIdStringObj = $this->getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id", $slideRecord);
                 if (strlen($mediaIdStringObj->asString())) {
                     $mediaId = $idManager->getId($mediaIdStringObj->asString());
                     $firstMediaUrl = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($mediaId);
                 }
             }
         }
     }
     /*********************************************************
      * item description text.
      *********************************************************/
     ob_start();
     if (isset($firstMediaUrl)) {
         print "\n<img src='" . $firstMediaUrl . "' style='float: right'/>";
     }
     print "\n<div style='margin-bottom: 10px'>" . $asset->getDescription() . "</div>";
     print "\n<div style='clear: both'>(" . $count . " " . _("slides") . ")</div>";
     $item->setDescription(ob_get_clean());
     return $item;
 }