RSS1
RSS1
Wrapper for creating RSS2 feeds
Generate RSS 1.0, RSS2.0 and ATOM Feeds
setPagination(string $nextURL = null, string $previousURL = null, string $firstURL = null, string $lastURL = null) : self
Set the URLs for feed pagination.
See RFC 5005, chapter 3. At least one page URL must be specified.
string | $nextURL | The URL to the next page of this feed. Optional. |
string | $previousURL | The URL to the previous page of this feed. Optional. |
string | $firstURL | The URL to the first page of this feed. Optional. |
string | $lastURL | The URL to the last page of this feed. Optional. |
if none of the parameters are set.
addNamespace(string $prefix, string $uri) : self
Add a XML namespace to the internal list of namespaces. After that, custom channel elements can be used properly to generate a valid feed.
string | $prefix | namespace prefix |
string | $uri | namespace name (URI) |
if the prefix or uri is empty or NULL.
setChannelElement(string $elementName, string $content, array $attributes = null, $multiple = false) : self
Add a channel element to the feed.
string | $elementName | name of the channel tag |
string | $content | content of the channel tag |
array | $attributes | |
$multiple |
if the element name is not a string, empty or NULL.
printFeed( $useGenericContentType = false) : void
Print the actual RSS/ATOM file
Sets a Content-Type header and echoes the contents of the feed. Should only be used in situations where direct output is desired; if you need to pass a string around, use generateFeed() instead.
$useGenericContentType |
if the useGenericContentType parameter is not boolean.
createNewItem() : \FeedWriter\Item
Create a new Item.
instance of Item class
addItem(\FeedWriter\Item $feedItem) : self
Add a FeedItem to the main class
\FeedWriter\Item | $feedItem | instance of Item class |
if the given item version mismatches.
setDate( $date) : self
Set the date when the feed was lastly updated.
This adds the 'updated' element to the feed. The value of the date parameter can be either an instance of the DateTime class, an integer containing a UNIX timestamp or a string which is parseable by PHP's 'strtotime' function.
Not supported in RSS1 feeds.
$date |
if the given date is not an instance of DateTime, a UNIX timestamp or a date string.
if this method is called on an RSS1 feed.
setAtomLink(string $href, string $rel = null, string $type = null, string $hreflang = null, string $title = null, integer $length = null) : self
Set custom 'link' channel elements.
In ATOM feeds, only one link with alternate relation and the same combination of type and hreflang values.
string | $href | URI of this link |
string | $rel | relation type of the resource |
string | $type | MIME type of the target resource |
string | $hreflang | language of the resource |
string | $title | human-readable information about the resource |
integer | $length | length of the resource in bytes |
on multiple occasions.
if the same link with the same attributes was already added to the feed.
setImage(string $url, string $title = null, string $link = null) : self
Set the 'image' channel element
string | $url | URL of the image |
string | $title | Title of the image. RSS only. |
string | $link | Link target URL of the image. RSS only. |
if the url is invalid.
if the title and link parameter are not a string or empty.
setChannelAbout(string $url) : self
Set the channel 'rdf:about' attribute, which is used in RSS1 feeds only.
string | $url | value of 'rdf:about' attribute of the channel element |
if this method is called and the feed is not of type RSS1.
if the given URL is invalid.
uuid(string $key = null, string $prefix = '') : string
Generate an UUID.
The UUID is based on an MD5 hash. If no key is given, a unique ID as the input for the MD5 hash is generated.
string | $key | optional key on which the UUID is generated |
string | $prefix | an optional prefix |
the formatted UUID
getNamespacePrefixes() : array
Returns all used XML namespace prefixes in this instance.
This includes all channel elements and feed items. Unfortunately some namespace prefixes are not included, because they are hardcoded, e.g. rdf.
Array with namespace prefix as value.
makeNode(string $tagName, mixed $tagContent, array $attributes = null, boolean $omitEndTag = false) : string
Creates a single node in XML format
string | $tagName | name of the tag |
mixed | $tagContent | tag value as string or array of nested tags in 'tagName' => 'tagValue' format |
array | $attributes | Attributes (if any) in 'attrName' => 'attrValue' format |
boolean | $omitEndTag | True if the end tag should be omitted. Defaults to false. |
if the tagContent is not an array and not a string.
formatted xml tag
startItem(string $about = false) : string
Make the starting tag of channels
string | $about | The value of about attribute which is used for RSS 1.0 only. |
if this object misses the data for the about attribute.
The starting XML tag of an feed item.
sanitizeCDATA(string $text) : string
Sanitizes data which will be later on returned as CDATA in the feed.
A "]]>" respectively "<![CDATA" in the data would break the CDATA in the XML, so the brackets are converted to a HTML entity.
string | $text | Data to be sanitized |
Sanitized data