protected function generateFiles($arrFeed)
	{
		$arrArchives = StringUtil::deserialize($arrFeed['archives']);

		if (empty($arrArchives) || !\is_array($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 = PageModel::findWithDetails($jumpTo);

					// A jumpTo page is set but does no longer exist (see #5781)
					if ($objParent === null)
					{
						$arrUrls[$jumpTo] = false;
					}
					else
					{
						$arrUrls[$jumpTo] = $objParent->getAbsoluteUrl(Config::get('useAutoItem') ? '/%s' : '/items/%s');
					}
				}

				// Skip the event if it requires a jumpTo URL but there is none
				if ($arrUrls[$jumpTo] === false && $objArticle->source == 'default')
				{
					continue;
				}

				$strUrl = $arrUrls[$jumpTo];

				$objItem = new FeedItem();
				$objItem->title = $objArticle->headline;
				$objItem->link = $this->getLink($objArticle, $strUrl);
				$objItem->published = $objArticle->date;

				/** @var UserModel $objAuthor */
				if (($objAuthor = $objArticle->getRelated('author')) instanceof UserModel)
				{
					$objItem->author = $objAuthor->name;
				}

				// Prepare the description
				if ($arrFeed['source'] == 'source_text')
				{
					$strDescription = '';
					$objElement = ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news');

					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 = $objArticle->teaser;
				}

				$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, $strLink, 'media:content');
					}
				}

				// Enclosures
				if ($objArticle->addEnclosure)
				{
					$arrEnclosure = StringUtil::deserialize($objArticle->enclosure, true);

					if (\is_array($arrEnclosure))
					{
						$objFile = FilesModel::findMultipleByUuids($arrEnclosure);

						if ($objFile !== null)
						{
							while ($objFile->next())
							{
								$objItem->addEnclosure($objFile->path, $strLink);
							}
						}
					}
				}

				$objFeed->addItem($objItem);
			}
		}

		// Create the file
		File::putContent('web/share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->$strType(), false));
	}
protected function generateFiles($arrFeed)
	{
		$arrArchives = StringUtil::deserialize($arrFeed['archives']);

		if (empty($arrArchives) || !\is_array($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'];

		
		if ($arrFeed['maxItems'] > 0)
		{
			$objArticle = NewsModel::findPublishedByPids($arrArchives, null, $arrFeed['maxItems']);
		}
		else
		{
			$objArticle = NewsModel::findPublishedByPids($arrArchives);
		}

		
		if ($objArticle !== null)
		{
			$arrUrls = array();

			while ($objArticle->next())
			{
				$jumpTo = $objArticle->getRelated('pid')->jumpTo;

				
				if (!$jumpTo)
				{
					continue;
				}

				
				if (!isset($arrUrls[$jumpTo]))
				{
					$objParent = PageModel::findWithDetails($jumpTo);

					
					if ($objParent === null)
					{
						$arrUrls[$jumpTo] = false;
					}
					else
					{
						$arrUrls[$jumpTo] = $objParent->getAbsoluteUrl(Config::get('useAutoItem') ? '/%s' : '/items/%s');
					}
				}

				
				if ($arrUrls[$jumpTo] === false && $objArticle->source == 'default')
				{
					continue;
				}

				$strUrl = $arrUrls[$jumpTo];

				$objItem = new FeedItem();
				$objItem->title = $objArticle->headline;
				$objItem->link = $this->getLink($objArticle, $strUrl);
				$objItem->published = $objArticle->date;

				
				if (($objAuthor = $objArticle->getRelated('author')) instanceof UserModel)
				{
					$objItem->author = $objAuthor->name;
				}

				
				if ($arrFeed['source'] == 'source_text')
				{
					$strDescription = '';
					$objElement = ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news');

					if ($objElement !== null)
					{
						
						$strRequest = Environment::get('request');
						Environment::set('request', $objItem->link);

						while ($objElement->next())
						{
							$strDescription .= $this->getContentElement($objElement->current());
						}

						Environment::set('request', $strRequest);
					}
				}
				else
				{
					$strDescription = $objArticle->teaser;
				}

				$strDescription = $this->replaceInsertTags($strDescription, false);
				$objItem->description = $this->convertRelativeUrls($strDescription, $strLink);

				
				if ($objArticle->addImage)
				{
					$objFile = FilesModel::findByUuid($objArticle->singleSRC);

					if ($objFile !== null)
					{
						$objItem->addEnclosure($objFile->path, $strLink, 'media:content');
					}
				}

				
				if ($objArticle->addEnclosure)
				{
					$arrEnclosure = StringUtil::deserialize($objArticle->enclosure, true);

					if (\is_array($arrEnclosure))
					{
						$objFile = FilesModel::findMultipleByUuids($arrEnclosure);

						if ($objFile !== null)
						{
							while ($objFile->next())
							{
								$objItem->addEnclosure($objFile->path, $strLink);
							}
						}
					}
				}

				$objFeed->addItem($objItem);
			}
		}

		
		File::putContent('web/share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->$strType(), false));
	}
protected function generateFiles ( $ arrFeed ) { $ arrArchives = StringUtil :: deserialize ( $ arrFeed [ 'archives' ] ) ; if ( empty ( $ arrArchives ) || ! \ is_array ( $ 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 = PageModel :: findWithDetails ( $ jumpTo ) ; // A jumpTo page is set but does no longer exist (see #5781) if ( $ objParent === null ) { $ arrUrls [ $ jumpTo ] = false ; } else { $ arrUrls [ $ jumpTo ] = $ objParent -> getAbsoluteUrl ( Config :: get ( 'useAutoItem' ) ? '/%s' : '/items/%s' ) ; } } // Skip the event if it requires a jumpTo URL but there is none if ( $ arrUrls [ $ jumpTo ] === false && $ objArticle -> source == 'default' ) { continue ; } $ strUrl = $ arrUrls [ $ jumpTo ] ; $ objItem = new FeedItem ( ) ; $ objItem -> title = $ objArticle -> headline ; $ objItem -> link = $ this -> getLink ( $ objArticle , $ strUrl ) ; $ objItem -> published = $ objArticle -> date ; /** @var UserModel $objAuthor */ if ( ( $ objAuthor = $ objArticle -> getRelated ( 'author' ) ) instanceof UserModel ) { $ objItem -> author = $ objAuthor -> name ; } // Prepare the description if ( $ arrFeed [ 'source' ] == 'source_text' ) { $ strDescription = '' ; $ objElement = ContentModel :: findPublishedByPidAndTable ( $ objArticle -> id , 'tl_news' ) ; 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 = $ objArticle -> teaser ; } $ 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 , $ strLink , 'media:content' ) ; } } // Enclosures if ( $ objArticle -> addEnclosure ) { $ arrEnclosure = StringUtil :: deserialize ( $ objArticle -> enclosure , true ) ; if ( \ is_array ( $ arrEnclosure ) ) { $ objFile = FilesModel :: findMultipleByUuids ( $ arrEnclosure ) ; if ( $ objFile !== null ) { while ( $ objFile -> next ( ) ) { $ objItem -> addEnclosure ( $ objFile -> path , $ strLink ) ; } } } } $ objFeed -> addItem ( $ objItem ) ; } } // Create the file File :: putContent ( 'web/share/' . $ strFile . '.xml' , $ this -> replaceInsertTags ( $ objFeed -> $ strType ( ) , false ) ) ; }
Generate an XML files and save them to the root directory

@param array $arrFeed
Generate an XML files and save them to the root directory