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


PHP Feed::addItem方法代码示例

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


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

示例1: USING

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();
}
mysql_close($db_connect);
开发者ID:xXxthebeastxXx,项目名称:addondb,代码行数:31,代码来源:rss.php

示例2: rss

 /**
  * Render RSS feed for a spcific filter
  *
  * @param void
  * @return null
  */
 function rss()
 {
     if ($this->active_filter->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_filter->canUse($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     require_once ANGIE_PATH . '/classes/feed/init.php';
     $feed = new Feed($this->owner_company->getName() . ' - ' . $this->active_filter->getName(), $this->active_filter->getUrl());
     $assignments = AssignmentFilters::executeFilter($this->logged_user, $this->active_filter, false);
     if (is_foreachable($assignments)) {
         $project_ids = array();
         foreach ($assignments as $assignment) {
             if (!in_array($assignment->getProjectId(), $project_ids)) {
                 $project_ids[] = $assignment->getProjectId();
             }
             // if
         }
         // foreach
         $projects = array();
         if (is_foreachable($project_ids)) {
             $rows = db_execute_all('SELECT id, name FROM ' . TABLE_PREFIX . 'projects WHERE id IN (?)', $project_ids);
             if (is_foreachable($rows)) {
                 foreach ($rows as $row) {
                     $projects[$row['id']] = $row['name'];
                 }
                 // foreach
             }
             // if
         }
         // if
         foreach ($assignments as $assignment) {
             $title = '[' . array_var($projects, $assignment->getProjectId()) . '] ' . $assignment->getVerboseType() . ' "' . $assignment->getName() . '"';
             $this->smarty->assign('_assignment', $assignment);
             $body = $this->smarty->fetch(get_template_path('_feed_body', 'assignment_filters', RESOURCES_MODULE));
             $item = new FeedItem($title, $assignment->getViewUrl(), $body, $assignment->getCreatedOn());
             $item->setId($assignment->getViewUrl());
             $feed->addItem($item);
         }
         // foreach
     }
     // if
     print render_rss_feed($feed);
     die;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:54,代码来源:AssignmentFiltersController.class.php

示例3: addItem

 /**
  * {@inheritdoc}
  */
 protected function addItem($title, $link, $description = null, $pubDate = null, $id = null)
 {
     if (empty($id)) {
         $id = $link;
     }
     if (empty($pubDate)) {
         $pubDate = date('Y-m-d');
     }
     parent::addItem($title, $link, $description, $pubDate, $id);
 }
开发者ID:alphadevx,项目名称:alpha,代码行数:13,代码来源:Atom.php

示例4: generateFiles

 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrArchive)
 {
     $time = time();
     $strType = $arrArchive['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrArchive['feedBase'] != '' ? $arrArchive['feedBase'] : $this->Environment->base;
     $strFile = $arrArchive['feedName'];
     $objFeed = new Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrArchive['title'];
     $objFeed->description = $arrArchive['description'];
     $objFeed->language = $arrArchive['language'];
     $objFeed->published = $arrArchive['tstamp'];
     // Get items
     $objArticleStmt = $this->Database->prepare("SELECT *, (SELECT name FROM tl_user u WHERE u.id=n.author) AS authorName\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM tl_news4ward_article n\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pid=? AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND status='published'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY start DESC");
     if ($arrArchive['maxItems'] > 0) {
         $objArticleStmt->limit($arrArchive['maxItems']);
     }
     $objArticle = $objArticleStmt->execute($arrArchive['id']);
     // Get the default URL
     $objParent = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($arrArchive['jumpTo']);
     if ($objParent->numRows < 1) {
         return;
     }
     $objParent = $this->getPageDetails($objParent->id);
     $strUrl = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s', $objParent->language);
     // Parse items
     while ($objArticle->next()) {
         $objItem = new FeedItem();
         $objItem->title = $objArticle->title;
         $objItem->link = $this->generateUrl($objArticle, $strUrl);
         $objItem->published = $objArticle->start;
         $objItem->author = $objArticle->authorName;
         // Prepare the description
         if ($arrArchive['source'] == 'source_text') {
             /* generate the content-elements */
             $objContentelements = $this->Database->prepare('SELECT id FROM tl_content WHERE pid=? AND do="news4ward" AND invisible="" ORDER BY sorting')->execute($objArticle->id);
             $strDescription = '';
             while ($objContentelements->next()) {
                 $strDescription .= $this->getContentElement($objContentelements->id);
             }
         } else {
             $strDescription = $objArticle->teaser;
         }
         $strDescription = $this->replaceInsertTags($strDescription);
         $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
         // Add the article image as enclosure
         if ($objArticle->addImage) {
             $objItem->addEnclosure($objArticle->singleSRC);
         }
         // Enclosure
         if ($objArticle->addEnclosure) {
             $arrEnclosure = deserialize($objArticle->enclosure, true);
             if (is_array($arrEnclosure)) {
                 foreach ($arrEnclosure as $strEnclosure) {
                     if (is_file(TL_ROOT . '/' . $strEnclosure)) {
                         $objItem->addEnclosure($strEnclosure);
                     }
                 }
             }
         }
         $objFeed->addItem($objItem);
     }
     // Create file
     $objRss = new File($strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }
开发者ID:jens-wetzel,项目名称:use2,代码行数:71,代码来源:News4wardHelper.php

示例5: generateFiles


//.........这里部分代码省略.........
         $GLOBALS['NEWS_FILTER_CATEGORIES'] = true;
         $GLOBALS['NEWS_FILTER_DEFAULT'] = $arrCategories;
     } else {
         $GLOBALS['NEWS_FILTER_CATEGORIES'] = false;
     }
     // Get the items
     if ($arrFeed['maxItems'] > 0) {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives, null, $arrFeed['maxItems']);
     } else {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives);
     }
     // Parse the items
     if ($objArticle !== null) {
         $arrUrls = array();
         while ($objArticle->next()) {
             $jumpTo = $objArticle->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = \PageModel::findWithDetails($jumpTo);
                 // A jumpTo page is set but does no longer exist (see #5781)
                 if ($objParent === null) {
                     $arrUrls[$jumpTo] = false;
                 } else {
                     $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/%s' : '/items/%s', $objParent->language);
                 }
             }
             // Skip the event if it requires a jumpTo URL but there is none
             if ($arrUrls[$jumpTo] === false && $objArticle->source == 'default') {
                 continue;
             }
             // Get the categories
             if ($arrFeed['categories_show']) {
                 $arrCategories = array();
                 if (($objCategories = NewsCategoryModel::findPublishedByIds(deserialize($objArticle->categories, true))) !== null) {
                     $arrCategories = $objCategories->fetchEach('title');
                 }
             }
             $strUrl = $arrUrls[$jumpTo];
             $objItem = new \FeedItem();
             // Add the categories to the title
             if ($arrFeed['categories_show'] == 'title') {
                 $objItem->title = sprintf('[%s] %s', implode(', ', $arrCategories), $objArticle->headline);
             } else {
                 $objItem->title = $objArticle->headline;
             }
             $objItem->link = $this->getLink($objArticle, $strUrl, $strLink);
             $objItem->published = $objArticle->date;
             $objItem->author = $objArticle->authorName;
             // Prepare the description
             if ($arrFeed['source'] == 'source_text') {
                 $strDescription = '';
                 $objElement = \ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news');
                 if ($objElement !== null) {
                     while ($objElement->next()) {
                         $strDescription .= $this->getContentElement($objElement->id);
                     }
                 }
             } else {
                 $strDescription = $objArticle->teaser;
             }
             // Add the categories to the description
             if ($arrFeed['categories_show'] == 'text_before' || $arrFeed['categories_show'] == 'text_after') {
                 $strCategories = '<p>' . $GLOBALS['TL_LANG']['MSC']['newsCategories'] . ' ' . implode(', ', $arrCategories) . '</p>';
                 if ($arrFeed['categories_show'] == 'text_before') {
                     $strDescription = $strCategories . $strDescription;
                 } else {
                     $strDescription .= $strCategories;
                 }
             }
             $strDescription = $this->replaceInsertTags($strDescription, false);
             $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
             // Add the article image as enclosure
             if ($objArticle->addImage) {
                 $objFile = \FilesModel::findByUuid($objArticle->singleSRC);
                 if ($objFile !== null) {
                     $objItem->addEnclosure($objFile->path);
                 }
             }
             // Enclosures
             if ($objArticle->addEnclosure) {
                 $arrEnclosure = deserialize($objArticle->enclosure, true);
                 if (is_array($arrEnclosure)) {
                     $objFile = \FilesModel::findMultipleByUuids($arrEnclosure);
                     if ($objFile !== null) {
                         while ($objFile->next()) {
                             $objItem->addEnclosure($objFile->path);
                         }
                     }
                 }
             }
             $objFeed->addItem($objItem);
         }
     }
     // Create the file
     \File::putContent('share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->{$strType}(), false));
 }
开发者ID:hielsnoppe,项目名称:contao-test-plugin,代码行数:101,代码来源:News.php

示例6: Feed

<?php

/**
 * User: elkuku
 * Date: 07.06.12
 * Time: 11:27
 */
$f = new Feed();
$f->title = 'Der erste Feed';
$f->link = 'http://qqq';
$f->description = 'Die erste Beschreibung';
$i = new FeedItem();
$i->title = 'Item titel';
$i->description = 'Item Besxchreibung';
$i->link = 'http://yyyy';
$f->addItem($i);
echo $f;
echo "\n\n";
echo $f->printPretty();
/**
 * Feed class.
 */
class Feed
{
    public $title = '';
    public $link = '';
    public $description = '';
    public $language = '';
    /**
     * @var array FeedItem
     */
开发者ID:aminodrago,项目名称:EasyCreator,代码行数:31,代码来源:createfeed.php

示例7: rss

 /**
  * Render recent activities feed
  *
  * @param void
  * @return null
  */
 function rss()
 {
     require_once ANGIE_PATH . '/classes/feed/init.php';
     $projects = Projects::findNamesByUser($this->logged_user);
     $feed = new Feed($this->owner_company->getName() . ' - ' . lang('Recent activities'), ROOT_URL);
     $feed->setDescription(lang('Recent activities in active projects'));
     $activities = ActivityLogs::findActiveProjectsActivitiesByUser($this->logged_user, 50);
     if (is_foreachable($activities)) {
         foreach ($activities as $activity) {
             $object = $activity->getObject();
             $activity_title = $activity_body = $activity->renderHead();
             $activity_title = strip_tags($activity_title);
             if ($activity->has_body && ($body = trim($activity->renderBody()))) {
                 $activity_body .= $body;
             }
             // if
             $item = new FeedItem($activity_title, $object->getViewUrl(), $activity_body, $activity->getCreatedOn());
             $item->setId(extend_url($object->getViewUrl(), array('guid' => $activity->getId())));
             $feed->addItem($item);
         }
         // foreach
     }
     // if
     print render_rss_feed($feed);
     die;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:32,代码来源:DashboardController.class.php

示例8: generateFiles


//.........这里部分代码省略.........
     $objFeed->published = $arrFeed['tstamp'];
     $arrUrls = array();
     $this->arrEvents = array();
     $time = time();
     // Get the upcoming events
     $objArticle = \CalendarEventsModel::findUpcomingByPids($arrCalendars, $arrFeed['maxItems']);
     // Parse the items
     if ($objArticle !== null) {
         while ($objArticle->next()) {
             $jumpTo = $objArticle->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = \PageModel::findWithDetails($jumpTo);
                 // A jumpTo page is set but does no longer exist (see #5781)
                 if ($objParent === null) {
                     $arrUrls[$jumpTo] = false;
                 } else {
                     $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s', $objParent->language);
                 }
             }
             // Skip the event if it requires a jumpTo URL but there is none
             if ($arrUrls[$jumpTo] === false && $objArticle->source == 'default') {
                 continue;
             }
             $strUrl = $arrUrls[$jumpTo];
             $this->addEvent($objArticle, $objArticle->startTime, $objArticle->endTime, $strUrl, $strLink);
             // Recurring events
             if ($objArticle->recurring) {
                 $arrRepeat = deserialize($objArticle->repeatEach);
                 if ($arrRepeat['value'] < 1) {
                     continue;
                 }
                 $count = 0;
                 $intStartTime = $objArticle->startTime;
                 $intEndTime = $objArticle->endTime;
                 $strtotime = '+ ' . $arrRepeat['value'] . ' ' . $arrRepeat['unit'];
                 // Do not include more than 20 recurrences
                 while ($count++ < 20) {
                     if ($objArticle->recurrences > 0 && $count >= $objArticle->recurrences) {
                         break;
                     }
                     $intStartTime = strtotime($strtotime, $intStartTime);
                     $intEndTime = strtotime($strtotime, $intEndTime);
                     if ($intStartTime >= $time) {
                         $this->addEvent($objArticle, $intStartTime, $intEndTime, $strUrl, $strLink);
                     }
                 }
             }
         }
     }
     $count = 0;
     ksort($this->arrEvents);
     // Add the feed items
     foreach ($this->arrEvents as $days) {
         foreach ($days as $events) {
             foreach ($events as $event) {
                 if ($arrFeed['maxItems'] > 0 && $count++ >= $arrFeed['maxItems']) {
                     break 3;
                 }
                 $objItem = new \FeedItem();
                 $objItem->title = $event['title'];
                 $objItem->link = $event['link'];
                 $objItem->published = $event['tstamp'];
                 $objItem->begin = $event['begin'];
                 $objItem->end = $event['end'];
                 $objItem->author = $event['authorName'];
                 // Prepare the description
                 if ($arrFeed['source'] == 'source_text') {
                     $strDescription = '';
                     $objElement = \ContentModel::findPublishedByPidAndTable($event['id'], 'tl_calendar_events');
                     if ($objElement !== null) {
                         // Overwrite the request (see #7756)
                         $strRequest = \Environment::get('request');
                         \Environment::set('request', $objItem->link);
                         while ($objElement->next()) {
                             $strDescription .= $this->getContentElement($objElement->current());
                         }
                         \Environment::set('request', $strRequest);
                     }
                 } else {
                     $strDescription = $event['teaser'];
                 }
                 $strDescription = $this->replaceInsertTags($strDescription, false);
                 $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
                 if (is_array($event['enclosure'])) {
                     foreach ($event['enclosure'] as $enclosure) {
                         $objItem->addEnclosure($enclosure);
                     }
                 }
                 $objFeed->addItem($objItem);
             }
         }
     }
     // Create the file
     \File::putContent('share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->{$strType}(), false));
 }
开发者ID:Jobu,项目名称:core,代码行数:101,代码来源:Calendar.php

示例9: addItem

 /**
  * {@inheritdoc}
  */
 protected function addItem($title, $link, $description = null, $pubDate = null, $id = null)
 {
     parent::addItem($title, $link, $description, $pubDate, $id);
     $this->addToItems($link);
 }
开发者ID:alphadevx,项目名称:alpha,代码行数:8,代码来源:RSS.php

示例10: generateFiles

 /**
  * Generate an XML file and save it to the root directory
  * @param array
  */
 protected function generateFiles($arrFeed)
 {
     $arrCalendars = deserialize($arrFeed['calendars']);
     if (!is_array($arrCalendars) || empty($arrCalendars)) {
         return;
     }
     $strType = $arrFeed['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrFeed['feedBase'] ?: \Environment::get('base');
     $strFile = $arrFeed['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrFeed['title'];
     $objFeed->description = $arrFeed['description'];
     $objFeed->language = $arrFeed['language'];
     $objFeed->published = $arrFeed['tstamp'];
     $arrUrls = array();
     $this->arrEvents = array();
     $time = time();
     // Get the upcoming events
     $objArticle = \CalendarEventsModel::findUpcomingByPids($arrCalendars, $arrFeed['maxItems']);
     // Parse the items
     if ($objArticle !== null) {
         while ($objArticle->next()) {
             $jumpTo = $objArticle->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = $this->getPageDetails($jumpTo);
                 $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/events/%s', $objParent->language);
             }
             $strUrl = $arrUrls[$jumpTo];
             $this->addEvent($objArticle, $objArticle->startTime, $objArticle->endTime, $strUrl, $strLink);
             // Recurring events
             if ($objArticle->recurring) {
                 $count = 0;
                 $arrRepeat = deserialize($objArticle->repeatEach);
                 // Do not include more than 20 recurrences
                 while ($count++ < 20) {
                     if ($objArticle->recurrences > 0 && $count >= $objArticle->recurrences) {
                         break;
                     }
                     $arg = $arrRepeat['value'];
                     $unit = $arrRepeat['unit'];
                     $strtotime = '+ ' . $arg . ' ' . $unit;
                     $objArticle->startTime = strtotime($strtotime, $objArticle->startTime);
                     $objArticle->endTime = strtotime($strtotime, $objArticle->endTime);
                     if ($objArticle->startTime >= $time) {
                         $this->addEvent($objArticle, $objArticle->startTime, $objArticle->endTime, $strUrl, $strLink);
                     }
                 }
             }
         }
     }
     $count = 0;
     ksort($this->arrEvents);
     // Add the feed items
     foreach ($this->arrEvents as $days) {
         foreach ($days as $events) {
             foreach ($events as $event) {
                 if ($arrFeed['maxItems'] > 0 && $count++ >= $arrFeed['maxItems']) {
                     break 3;
                 }
                 $objItem = new \FeedItem();
                 $objItem->title = $event['title'];
                 $objItem->link = $event['link'];
                 $objItem->published = $event['published'];
                 $objItem->start = $event['start'];
                 $objItem->end = $event['end'];
                 $objItem->author = $event['authorName'];
                 // Prepare the description
                 if ($arrFeed['source'] == 'source_text') {
                     $strDescription = '';
                     $objElement = \ContentModel::findPublishedByPidAndTable($event['id'], 'tl_calendar_events');
                     if ($objElement !== null) {
                         while ($objElement->next()) {
                             $strDescription .= $this->getContentElement($objElement->id);
                         }
                     }
                 } else {
                     $strDescription = $event['teaser'];
                 }
                 $strDescription = $this->replaceInsertTags($strDescription);
                 $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
                 if (is_array($event['enclosure'])) {
                     foreach ($event['enclosure'] as $enclosure) {
                         $objItem->addEnclosure($enclosure);
                     }
                 }
                 $objFeed->addItem($objItem);
             }
         }
     }
     // Create file
//.........这里部分代码省略.........
开发者ID:rburch,项目名称:core,代码行数:101,代码来源:Calendar.php

示例11: generateFiles


//.........这里部分代码省略.........
     if (!is_array($arrArchives) || empty($arrArchives)) {
         return null;
     }
     $strType = $arrFeed['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrFeed['feedBase'] ?: Environment::get('base');
     $strFile = $arrFeed['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrFeed['title'];
     $objFeed->description = $arrFeed['description'];
     $objFeed->language = $arrFeed['language'];
     $objFeed->published = $arrFeed['tstamp'];
     if ($arrFeed['maxItems'] > 0) {
         $objArticle = $this->findPublishedByPids($arrArchives, $arrFeed['maxItems'], $arrFeed['fmodule'] . '_data');
     } else {
         $objArticle = $this->findPublishedByPids($arrArchives, 0, $arrFeed['fmodule'] . '_data');
     }
     if ($objArticle !== null) {
         $arrUrls = array();
         $strUrl = '';
         while ($objArticle->next()) {
             $pid = $objArticle->pid;
             $wrapperDB = $this->Database->prepare('SELECT * FROM ' . $arrFeed['fmodule'] . ' WHERE id = ?')->execute($pid)->row();
             if ($wrapperDB['addDetailPage'] == '1') {
                 $rootPage = $wrapperDB['rootPage'];
                 if (!isset($arrUrls[$rootPage])) {
                     $objParent = PageModel::findWithDetails($rootPage);
                     if ($objParent === null) {
                         $arrUrls[$rootPage] = false;
                     } else {
                         $arrUrls[$rootPage] = $this->generateFrontendUrl($objParent->row(), Config::get('useAutoItem') && !Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
                     }
                 }
                 $strUrl = $arrUrls[$rootPage];
             }
             $authorName = '';
             if ($objArticle->author) {
                 $authorDB = $this->Database->prepare('SELECT * FROM tl_user WHERE id = ?')->execute($objArticle->author)->row();
                 $authorName = $authorDB['name'];
             }
             $objItem = new \FeedItem();
             $objItem->title = $objArticle->title;
             $objItem->link = HelperModel::getLink($objArticle, $strUrl, $strLink);
             $objItem->published = $objArticle->date ? $objArticle->date : $arrFeed['tstamp'];
             $objItem->author = $authorName;
             // Prepare the description
             if ($arrFeed['source'] == 'source_text') {
                 $strDescription = '';
                 $objElement = ContentModelExtend::findPublishedByPidAndTable($objArticle->id, $arrFeed['fmodule'] . '_data', array('fview' => 'detail'));
                 if ($objElement !== null) {
                     // Overwrite the request (see #7756)
                     $strRequest = Environment::get('request');
                     Environment::set('request', $objItem->link);
                     while ($objElement->next()) {
                         $strDescription .= $this->getContentElement($objElement->current());
                     }
                     Environment::set('request', $strRequest);
                 }
             } else {
                 $strDescription = '';
                 $objElement = ContentModelExtend::findPublishedByPidAndTable($objArticle->id, $arrFeed['fmodule'] . '_data', array('fview' => 'list'));
                 if ($objElement !== null) {
                     // Overwrite the request (see #7756)
                     $strRequest = Environment::get('request');
                     Environment::set('request', $objItem->link);
                     while ($objElement->next()) {
                         $strDescription .= $this->getContentElement($objElement->current());
                     }
                     Environment::set('request', $strRequest);
                 }
                 if (!$strDescription) {
                     $strDescription = $objArticle->description;
                 }
             }
             $strDescription = $this->replaceInsertTags($strDescription, false);
             $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
             // Add the article image as enclosure
             if ($objArticle->addImage) {
                 $objFile = \FilesModel::findByUuid($objArticle->singleSRC);
                 if ($objFile !== null) {
                     $objItem->addEnclosure($objFile->path);
                 }
             }
             // Enclosures
             if ($objArticle->addEnclosure) {
                 $arrEnclosure = deserialize($objArticle->enclosure, true);
                 if (is_array($arrEnclosure)) {
                     $objFile = \FilesModel::findMultipleByUuids($arrEnclosure);
                     if ($objFile !== null) {
                         while ($objFile->next()) {
                             $objItem->addEnclosure($objFile->path);
                         }
                     }
                 }
             }
             $objFeed->addItem($objItem);
         }
     }
     File::putContent('share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->{$strType}(), false));
 }
开发者ID:alnv,项目名称:fmodul,代码行数:101,代码来源:FModule.php

示例12: generateFiles

 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrFeed)
 {
     $arrArchives = deserialize($arrFeed['archives']);
     if (!is_array($arrArchives) || empty($arrArchives)) {
         return;
     }
     $strType = $arrFeed['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrFeed['feedBase'] ?: \Environment::get('base');
     $strFile = $arrFeed['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrFeed['title'];
     $objFeed->description = $arrFeed['description'];
     $objFeed->language = $arrFeed['language'];
     $objFeed->published = $arrFeed['tstamp'];
     // Get the items
     if ($arrFeed['maxItems'] > 0) {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives, null, $arrFeed['maxItems']);
     } else {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives);
     }
     // Parse the items
     if ($objArticle !== null) {
         $arrUrls = array();
         while ($objArticle->next()) {
             $jumpTo = $objArticle->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = $this->getPageDetails($jumpTo);
                 $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrUrls[$jumpTo];
             $objItem = new \FeedItem();
             $objItem->title = $objArticle->headline;
             $objItem->link = $this->getLink($objArticle, $strUrl, $strLink);
             $objItem->published = $objArticle->date;
             $objItem->author = $objArticle->authorName;
             // Prepare the description
             if ($arrFeed['source'] == 'source_text') {
                 $strDescription = '';
                 $objElement = \ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news');
                 if ($objElement !== null) {
                     while ($objElement->next()) {
                         $strDescription .= $this->getContentElement($objElement->id);
                     }
                 }
             } else {
                 $strDescription = $objArticle->teaser;
             }
             $strDescription = $this->replaceInsertTags($strDescription);
             $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
             // Add the article image as enclosure
             if ($objArticle->addImage) {
                 $objFile = \FilesModel::findByPk($objArticle->singleSRC);
                 if ($objFile !== null) {
                     $objItem->addEnclosure($objFile->path);
                 }
             }
             // Enclosures
             if ($objArticle->addEnclosure) {
                 $arrEnclosure = deserialize($objArticle->enclosure, true);
                 if (is_array($arrEnclosure)) {
                     $objFile = \FilesModel::findMultipleByIds($arrEnclosure);
                     while ($objFile->next()) {
                         $objItem->addEnclosure($objFile->path);
                     }
                 }
             }
             $objFeed->addItem($objItem);
         }
     }
     // Create the file
     $objRss = new \File('share/' . $strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }
开发者ID:rburch,项目名称:core,代码行数:84,代码来源:News.php

示例13: generateFiles

 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrArchive)
 {
     $this->import('Database');
     $time = time();
     $strType = $arrArchive['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrArchive['feedBase'] != '' ? $arrArchive['feedBase'] : $this->Environment->base;
     $strFile = $arrArchive['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrArchive['title'];
     $objFeed->description = $arrArchive['description'];
     $objFeed->language = $arrArchive['language'];
     $objFeed->published = $arrArchive['tstamp'];
     // Get items
     $objArticleStmt = $this->Database->prepare("SELECT *, (SELECT name FROM tl_user u WHERE u.id=p.author) AS authorName FROM tl_photoalbums2_album p WHERE pid=? AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1 ORDER BY sorting ASC");
     if ($arrArchive['maxItems'] > 0) {
         $objArticleStmt->limit($arrArchive['maxItems']);
     }
     $objArticle = $objArticleStmt->execute($arrArchive['id']);
     // Get the default URL
     $objParent = \PageModel::findByPk($arrArchive['modulePage']);
     if ($objParent == null) {
         return;
     }
     $objParent = $this->getPageDetails($objParent->id);
     $strUrl = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/album/%s', $objParent->language);
     // Parse items
     if ($objArticle !== null) {
         while ($objArticle->next()) {
             // Deserialize image arrays
             $objArticle->images = deserialize($objArticle->images);
             $objArticle->imageSort = deserialize($objArticle->imageSort);
             // Sort images
             $objPa2ImageSorter = new \Pa2ImageSorter($objArticle->imageSortType, $objArticle->images, $objArticle->imageSort);
             $this->arrImages = $objPa2ImageSorter->getSortedUuids();
             $objItem = new \FeedItem();
             $objItem->title = $objArticle->title;
             $objItem->link = sprintf($strLink . $strUrl, $objArticle->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objArticle->alias : $objArticle->id);
             $objItem->published = $objArticle->startdate;
             $objItem->author = $objArticle->authorName;
             if (is_array($objArticle->arrImages) && count($objArticle->arrImages) > 0) {
                 foreach ($objArticle->arrImages as $image) {
                     if (is_file(TL_ROOT . '/' . $image)) {
                         $objItem->addEnclosure($image);
                     }
                 }
             }
             $objItem->description = $this->replaceInsertTags($objArticle->description);
             $objFeed->addItem($objItem);
         }
     }
     // Create file
     $objRss = new \file($strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }
开发者ID:craffft,项目名称:contao-photoalbums2,代码行数:60,代码来源:Pa2.php

示例14: getFeed

 public function getFeed($sub, $params)
 {
     zf_debug('getting feed from cache ', DBG_FEED);
     if (ZF_DEBUG & DBG_FEED) {
         var_dump($sub);
         var_dump($params);
     }
     if (is_array($sub)) {
         $max = array_key_exists('max', $params) ? $params['max'] : 1000;
         /*foreach($sub as $subscription) {
         			$target[] = $subscription->source->id;
         		}*/
         $target = array_keys($sub);
     } else {
         $max = array_key_exists('max', $params) ? $params['max'] : $sub->shownItems;
         $target = array($sub->source->id);
     }
     $sincePubdate = array_key_exists('sincePubdate', $params) ? $params['sincePubdate'] : 0;
     $impressedSince = array_key_exists('impressedSince', $params) ? $params['impressedSince'] : 0;
     $db = DBProxy::getInstance();
     $items = $db->getItems($target, $max, $sincePubdate, $impressedSince);
     $feed = new Feed();
     if (!is_array($sub)) {
         $feed->source = $sub->source;
         $feed->last_fetched = $db->getLastUpdated($sub->source->id);
     }
     $sessionStart = time() - ZF_SESSION_DURATION;
     foreach ($items as $item) {
         $source = is_array($sub) ? $sub[$item['source_id']]->source : $sub->source;
         $feed->addItem(NewsItem::createFromFlatArray($source, $item, $sessionStart));
     }
     $db->markItemsAsImpressed(array_column($items, 'id'));
     return $feed;
 }
开发者ID:mm999,项目名称:zebrafeeds,代码行数:34,代码来源:feed_cache.php

示例15: rss

 /**
  * Rss for status updates
  * 
  * @param void
  * @return void
  */
 function rss()
 {
     require_once ANGIE_PATH . '/classes/feed/init.php';
     $archive_url = assemble_url('status_updates');
     $selected_user = $this->request->get('user_id');
     if ($selected_user) {
         if (!in_array($selected_user, $this->logged_user->visibleUserIds())) {
             $this->httpError(HTTP_ERR_FORBIDDEN);
         }
         // if
         $user = Users::findById($selected_user);
         if (!instance_of($user, 'User')) {
             $this->httpError(HTTP_ERR_NOT_FOUND);
         }
         // if
         $archive_url = assemble_url('status_updates', array('user_id' => $user->getId()));
         $latest_status_updates = StatusUpdates::findByUser($user, 20);
         $feed = new Feed(lang(":display_name's Status Updates", array('display_name' => $user->getDisplayName())), $archive_url);
     } else {
         $latest_status_updates = StatusUpdates::findVisibleForUser($this->logged_user, 20);
         $feed = new Feed(lang('Status Updates'), $archive_url);
     }
     // if
     if (is_foreachable($latest_status_updates)) {
         foreach ($latest_status_updates as $status_update) {
             $this->smarty->assign(array('status_update' => $status_update));
             $item = new FeedItem(str_excerpt($status_update->getMessage(), 50), $status_update->getViewUrl(), $this->smarty->fetch(get_template_path('feed_item', 'status', STATUS_MODULE)), $status_update->getLastUpdateOn());
             $item->setId($status_update->getId());
             $feed->addItem($item);
         }
         // foreach
     }
     // if
     print render_rss_feed($feed);
     die;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:42,代码来源:StatusController.class.php


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