FeedWriter Class Reference
[Feeds]
Basic Feedwriter, extended by IRenderer to fit Gyro style. More...
Public Member Functions |
|
__construct (FeedWriterTitle $title, $items) | |
Constructor. |
|
get_mime_type () | |
Return mime type of feed. |
|
render ($policy=self::NONE) | |
Renders what should be rendered. |
|
Protected Member Functions |
|
escape ($obj) | |
Escape properties. |
|
relative_to_absolute ($text, $base) | |
Helper. |
|
render_end ($title, $items) | |
Render feed closing. |
|
render_item (FeedWriterItem $item) | |
Render an item. |
|
render_title (FeedWriterTitle $title) | |
Render feed title section. |
|
strip_html ($text) | |
Strip off html from. |
|
Protected Attributes |
|
$items | |
$title |
Detailed Description
Basic Feedwriter, extended by IRenderer to fit Gyro style.
Definition at line 109 of file feedwriter.cls.php.
Constructor & Destructor Documentation
FeedWriter::__construct | ( | FeedWriterTitle $ | title, | |
$ | items | |||
) |
Constructor.
- Parameters:
-
FeedWriterTitle $title array $items
Definition at line 122 of file feedwriter.cls.php.
Member Function Documentation
FeedWriter::escape | ( | $ | obj | ) | [protected] |
Escape properties.
Definition at line 159 of file feedwriter.cls.php.
00159 { 00160 return String::escape($obj, String::XML); 00161 }
FeedWriter::get_mime_type | ( | ) |
Return mime type of feed.
- Returns:
- string
Reimplemented in AtomWriter, and RSSWriter.
Definition at line 132 of file feedwriter.cls.php.
FeedWriter::relative_to_absolute | ( | $ | text, | |
$ | base | |||
) | [protected] |
Helper.
Turn relative URLs in text to an absolute one
- Parameters:
-
string $text Text containing URLs string $base baseurl
Definition at line 207 of file feedwriter.cls.php.
00207 { 00208 if (empty($base)) { 00209 return $text; 00210 } 00211 00212 if (substr($base, -1, 1) != "/") { $base .= "/"; } 00213 $domain = Url::create($base)->clear_query()->set_path('')->build(Url::ABSOLUTE); 00214 00215 // Replace href="/abc" with domain 00216 $pattern = '|<a(.*?) href="/(.*?)"|'; 00217 $replace = '<a$1 href="' . $domain . '$2"'; 00218 $text = preg_replace($pattern, $replace, $text); 00219 00220 // Replace href="abc" with base 00221 $pattern = '|<a(.*?) href="(?!\w+://)(.*?)"|'; 00222 $replace = '<a$1 href="' . $base . '$2"'; 00223 $text = preg_replace($pattern, $replace, $text); 00224 00225 // Replace src="/abc" with domain 00226 $pattern = '|<img(.*?) src="/(.*?)"|'; 00227 $replace = '<img$1 src="' . $domain . '$2"'; 00228 $text = preg_replace($pattern, $replace, $text); 00229 00230 // Replace src="abc" with base 00231 $pattern = '|<img(.*?) src="(?!\w+://)(.*?)"|'; 00232 $replace = '<img$1 src="' . $base . '$2"'; 00233 $text = preg_replace($pattern, $replace, $text); 00234 00235 return $text; 00236 }
FeedWriter::render | ( | $ | policy =
self::NONE |
) |
Renders what should be rendered.
- Parameters:
-
int $policy Defines how to render, meaning depends on implementation
- Returns:
- string The rendered content
Implements IRenderer.
Definition at line 142 of file feedwriter.cls.php.
00142 { 00143 $items = ''; 00144 foreach($this->items as $item) { 00145 $items .= $this->render_item($item); 00146 } 00147 00148 // Render title after items, so data collected from items can be used 00149 // in title 00150 $title = $this->render_title($this->title); 00151 00152 $ret = $this->render_end($title, $items); 00153 return $ret; 00154 }
FeedWriter::render_end | ( | $ | title, | |
$ | items | |||
) | [protected] |
Render feed closing.
- Parameters:
-
string $title string $items
- Returns:
- string
Reimplemented in AtomWriter, and RSSWriter.
Definition at line 190 of file feedwriter.cls.php.
FeedWriter::render_item | ( | FeedWriterItem $ | item | ) | [protected] |
Render an item.
- Parameters:
-
FeedWriterItem $item
- Returns:
- string
Reimplemented in AtomWriter, and RSSWriter.
Definition at line 169 of file feedwriter.cls.php.
FeedWriter::render_title | ( | FeedWriterTitle $ | title | ) | [protected] |
Render feed title section.
- Parameters:
-
FeedWriterTitle $title
- Returns:
- string
Reimplemented in AtomWriter, and RSSWriter.
Definition at line 179 of file feedwriter.cls.php.
FeedWriter::strip_html | ( | $ | text | ) | [protected] |
Strip off html from.
Definition at line 197 of file feedwriter.cls.php.
00197 { 00198 return String::clear_html(String::unescape(str_replace(" ", '', $text))); 00199 }
Member Data Documentation
FeedWriter::$items
[protected] |
Definition at line 110 of file feedwriter.cls.php.
FeedWriter::$title
[protected] |
Definition at line 114 of file feedwriter.cls.php.
The documentation for this class was generated from the following file:
- contributions/feeds/lib/components/feedwriter/feedwriter.cls.php