Пример #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();
 }
Пример #2
0
 /**
  * 文章feed
  * @param string $type 文章类型
  * @internal param $null 显示数量由 feed_num决定* 显示数量由 feed_num决定
  */
 public function listPost($type = 'single')
 {
     $PostsList = new PostsLogic();
     $post_list = $PostsList->getList(get_opinion('feed_num'), $type, 'post_date desc', true);
     $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
     // 站点标题的链接
     foreach ($post_list as $list) {
         $RSS->addItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . get_post_url($list), $list['post_content'], $list['post_date']);
     }
     $RSS->display();
 }
Пример #3
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)
  * @param string $content_type e.g. 'application/xml' or 'text/plain'
  */
 public function rss($h, $title = '', $link = '', $description = '', $items = array(), $content_type = 'application/xml')
 {
     require_once EXTENSIONS . 'RSSWriterClass/rsswriter.php';
     $feed = new \RSS($h->url(array('page' => '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) {
         $feed->addItem($items);
     }
     echo $feed->out($content_type);
 }
Пример #4
0
<?php

$rss = new RSS("Letzte Antworten - " . SiteConfig::val("page/title", "Q/A Forum"), "Die neusten Antworten aus dem Forum", get_path("/questions/rss"));
$db = new SQL(0);
$rows = $db->cmdrows(0, 'SELECT T1.*,T3.title,T2.username as authorname FROM answers as T1 LEFT JOIN user_list as T2 ON T1.author=T2.id LEFT JOIN questions as T3 ON T1.question=T3.id WHERE 1 ORDER BY date_created DESC LIMIT 0,30');
foreach ($rows as $row) {
    $item = new RSSItem("Antwort auf: " . $row["title"], $row["txt"] . '<br/><br/><div style="color:#8080ff;">SPAMcheck: ' . SpamText($row["isSPAM"]) . '<br/><i>' . html($row["authorname"]) . '</i></div>', Question::PermalinkByData($row["question"], $row["title"]) . "#answer-" . $row["id"]);
    $rss->addItem($item);
}
//die($rss->fetch());
$rss->display();
exit(1);
function SpamText($v)
{
    switch ($v) {
        case -2:
            return "Akismet gute Antwort";
        case -1:
            return "Ham";
        case 1:
            return "<b>Spam</b>";
        case 2:
            return "<b>Akismet SPAM</b>";
    }
}
Пример #5
0
 /**
  * displayRSS
  * 
  * Display the follow-ups of this artifact as a rss feed
  *
  */
 function displayRSS()
 {
     $uh = UserHelper::instance();
     $hp = Codendi_HTMLPurifier::instance();
     $group = $this->ArtifactType->getGroup();
     $rss = new RSS(array('title' => $group->getPublicName() . ' ' . $this->ArtifactType->getName() . ' #' . $this->getId() . ' - ' . $this->getValue('summary') . ' - ' . $GLOBALS['Language']->getText('tracker_include_artifact', 'follow_ups'), 'description' => '', 'link' => '<![CDATA[' . get_server_url() . '/tracker/?atid=' . $this->ArtifactType->getID() . '&group_id=' . $group->getGroupId() . ']]>', 'language' => 'en-us', 'copyright' => $GLOBALS['Language']->getText('rss', 'copyright', array($GLOBALS['sys_long_org_name'], $GLOBALS['sys_name'], date('Y', time()))), 'pubDate' => gmdate('D, d M Y h:i:s', $this->getLastUpdateDate()) . ' GMT'));
     $result = $this->getFollowups();
     for ($i = 0; $i < db_numrows($result); $i++) {
         $comment_type = db_result($result, $i, 'comment_type');
         $comment_type_id = db_result($result, $i, 'comment_type_id');
         $comment_id = db_result($result, $i, 'artifact_history_id');
         $field_name = db_result($result, $i, 'field_name');
         $orig_subm = $this->getOriginalCommentSubmitter($comment_id);
         $orig_date = $this->getOriginalCommentDate($comment_id);
         if ($comment_type_id == 100 || $comment_type == "") {
             $comment_type = '';
         } else {
             $comment_type = '<strong>[' . $comment_type . ']</strong><br />';
         }
         $rss->addItem(array('title' => '<![CDATA[' . $GLOBALS['Language']->getText('tracker_include_artifact', 'add_flup_comment') . ' #' . $comment_id . ']]>', 'description' => '<![CDATA[' . $comment_type . util_make_links(nl2br(db_result($result, $i, 'new_value')), $group->getGroupId(), $this->ArtifactType->getID()) . ']]>', 'pubDate' => gmdate('D, d M Y h:i:s', db_result($orig_date, 0, 'date')) . ' GMT', 'dc:creator' => $hp->purify($uh->getDisplayNameFromUserId(db_result($orig_subm, 0, 'mod_by'))), 'link' => '<![CDATA[' . get_server_url() . '/tracker/?func=detail&aid=' . $this->getId() . '&atid=' . $this->ArtifactType->getID() . '&group_id=' . $group->getGroupId() . '#comment_' . $comment_id . ']]>', 'guid' => '<![CDATA[' . get_server_url() . '/tracker/?func=detail&aid=' . $this->getId() . '&atid=' . $this->ArtifactType->getID() . '&group_id=' . $group->getGroupId() . '#comment_' . $comment_id . ']]>'));
     }
     $rss->display();
     exit;
 }
Пример #6
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();
 }
Пример #7
0
 /**
  * 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();
 }
 function displayRss()
 {
     $rss = new RSS(array('title' => 'Codendi - MyProjects', 'description' => 'My projects', 'link' => get_server_url(), 'language' => 'en-us', 'copyright' => 'Copyright Xerox', 'pubDate' => gmdate('D, d M Y G:i:s', time()) . ' GMT'));
     $result = db_query("SELECT groups.group_name," . "groups.group_id," . "groups.unix_group_name," . "groups.status," . "groups.access," . "user_group.admin_flags " . "FROM groups,user_group " . "WHERE groups.group_id=user_group.group_id " . "AND user_group.user_id='" . user_getid() . "' " . "AND groups.status='A' ORDER BY group_name");
     $rows = db_numrows($result);
     if (!$result || $rows < 1) {
         $rss->addItem(array('title' => 'Error', 'description' => $GLOBALS['Language']->getText('my_index', 'not_member') . db_error(), 'link' => get_server_url()));
     } else {
         for ($i = 0; $i < $rows; $i++) {
             $title = db_result($result, $i, 'group_name');
             if (db_result($result, $i, 'access') == Project::ACCESS_PRIVATE) {
                 $title .= ' (*)';
             }
             $desc = 'Project: ' . get_server_url() . '/project/admin/?group_id=' . db_result($result, $i, 'group_id') . "<br />\n";
             if (db_result($result, $i, 'admin_flags') == 'A') {
                 $desc .= 'Admin: ' . get_server_url() . '/project/admin/?group_id=' . db_result($result, $i, 'group_id');
             }
             $rss->addItem(array('title' => $title, 'description' => $desc, 'link' => get_server_url() . '/projects/' . db_result($result, $i, 'unix_group_name')));
         }
     }
     $rss->display();
 }
Пример #9
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;
}
Пример #10
0
<?php

// ## export sf front page news in RSS
require_once 'pre.php';
require_once 'www/news/news_utils.php';
require_once 'common/rss/RSS.class.php';
require 'rss_utils.inc';
//First, check for valid group_id
$request =& HTTPRequest::instance();
if ($request->exist('group_id')) {
    $pm = ProjectManager::instance();
    $project = $pm->getProject($request->get('group_id'));
    if (!$project) {
        $rss = new RSS(array('title' => $Language->getText('export_rss_sfnews', 'news', $GLOBALS['sys_name']), 'description' => $Language->getText('export_rss_sfnews', 'highlights', $GLOBALS['sys_name']), 'link' => get_server_url(), 'language' => 'en-us', 'copyright' => $Language->getText('export_rss_sfnewreleases', 'copyright', array($GLOBALS['sys_long_org_name'], $GLOBALS['sys_name'], date('Y', time()))), 'pubDate' => gmdate('D, d M Y G:i:s', time()) . ' GMT'));
        $rss->addItem(array('title' => 'Error', 'description' => 'Project not found', 'link' => get_server_url()));
        $rss->display();
        exit;
    }
}
header("Content-Type: text/xml");
print '<?xml version="1.0"  encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl"  href="/export/rss.xsl" ?>
<rss version="0.91">
';
// ## default limit
if (!isset($limit) || !$limit) {
    $limit = 10;
}
if ($limit > 100) {
    $limit = 100;
}