示例#1
0
<?php

require_once '../qcubed.inc.php';
// Setup the Feed, itself
$objRss = new QRssFeed('Examples Site Projects', 'http://examples.qcu.be/', 'An Example RSS feed of the Qcubed Examples Site Projects');
$objRss->Image = new QRssImage('http://www.qcu.be/sites/all/themes/qcubednew/images/QCubed.png');
$objRss->PubDate = new QDateTime(QDateTime::Now);
// Iterate through all the projects, and setup a QRssItem per project
// Limit it to the "10 most recently started projects"
foreach ($objProjects = Project::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Project()->StartDate, false), QQ::LimitInfo(10))) as $objProject) {
    $objItem = new QRssItem($objProject->Name, 'http://examples.qcu.be/examples/communication/rss.php/' . $objProject->Id, $objProject->Description);
    $objItem->Author = $objProject->ManagerPerson->FirstName . ' ' . $objProject->ManagerPerson->LastName;
    $objItem->PubDate = $objProject->StartDate;
    $objItem->Guid = $objItem->Link;
    $objItem->GuidPermaLink = true;
    $objItem->AddCategory(new QRssCategory('Some Project Category 1'));
    $objItem->AddCategory(new QRssCategory('Some Project Category 2'));
    $objRss->AddItem($objItem);
}
// Output/Run the feed
// Note that the Run method will reset the output buffer and setup the Headers to output XML,
// so any HTML or Text outputted until now will be lost.  If for whatever reason you just
// want the XML, you can call $objRss->GetXml(), which will return the XML string.
// Also, if you need to change the encoding of the XML, you can do so in QApplication::$EncodingType.
$objRss->Run();
示例#2
0
文件: rss.php 项目: Jobava/narro
         $objRssFeed->Image = new QRssImage(__HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/assets/images/narro.png', t('Narro - Translate, we\'re open!'), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/index.php');
         QApplication::$Cache->save($objRssFeed, $strCacheId, array(), 3600);
     }
     $objRssFeed->Run();
     break;
 case 'textcomment':
     if (isset($objProject) && $objProject instanceof NarroProject) {
         $strCacheId = sprintf('rssfeed_textcomment_%d_%d', $objProject->ProjectId, QApplication::QueryString('l'));
     } else {
         $strCacheId = sprintf('rssfeed_textcomment_%d', QApplication::QueryString('l'));
     }
     if (!($objRssFeed = QApplication::$Cache->load($strCacheId))) {
         if (isset($objProject) && $objProject instanceof NarroProject) {
             $objRssFeed = new QRssFeed(sprintf(t('Comments on texts from %s'), $objProject->ProjectName), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest debates on texts from the project %s'), $objProject->ProjectName));
         } else {
             $objRssFeed = new QRssFeed(t('Comments on texts'), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, t('Get the latest debates on texts'));
         }
         if (isset($objProject) && $objProject instanceof NarroProject) {
             $strSqlQuery = sprintf('SELECT DISTINCT narro_text_comment.* FROM narro_text_comment, narro_context WHERE narro_text_comment.text_id=narro_context.text_id AND narro_context.active=1 AND narro_context.project_id=%d AND narro_text_comment.language_id=%d ORDER BY created DESC LIMIT 0, 20', $objProject->ProjectId, QApplication::GetLanguageId());
         } else {
             $strSqlQuery = sprintf('SELECT DISTINCT narro_text_comment.* FROM narro_text_comment WHERE narro_text_comment.language_id=%d ORDER BY created DESC LIMIT 0, 20', QApplication::GetLanguageId());
         }
         $objDatabase = QApplication::$Database[1];
         $objDbResult = $objDatabase->Query($strSqlQuery);
         if ($objDbResult) {
             $arrTextComment = NarroTextComment::InstantiateDbResult($objDbResult);
             foreach ($arrTextComment as $objTextComment) {
                 if (isset($objProject) && $objProject instanceof NarroProject) {
                     $arrContext = NarroContext::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContext()->ProjectId, $objProject->ProjectId), QQ::Equal(QQN::NarroContext()->TextId, $objTextComment->TextId), QQ::Equal(QQN::NarroContext()->Active, 1)));
                 } else {
                     $arrContext = NarroContext::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContext()->TextId, $objTextComment->TextId), QQ::Equal(QQN::NarroContext()->Active, 1)));