.

GSiteMapItemFormatter Class Reference

Class to format item in sitemap. More...

List of all members.

Public Member Functions

  __construct ($url, $data)
  as_html ()
  Render as HTML.
  as_xml ()
  Render as XML.

Protected Member Functions

  get_xml_tags ()
  Collect tags to output.
  xml_from_tags ($tags)
  Turn associative array of tag => content into XML.

Protected Attributes

  $data = array()
  $url = ''

Detailed Description

Class to format item in sitemap.

Definition at line 5 of file gsitemapitemformatter.cls.php.


Constructor & Destructor Documentation

GSiteMapItemFormatter::__construct ( url,
data  
)
Parameters:
string  $url
array  $data

Definition at line 14 of file gsitemapitemformatter.cls.php.

00014                                                  {
00015                 $this->url = $url;
00016                 $this->data = $data;
00017         }

Member Function Documentation

GSiteMapItemFormatter::as_html (  ) 

Render as HTML.

Returns:
string

Definition at line 48 of file gsitemapitemformatter.cls.php.

00048                                   {
00049                 $s_url = String::escape($this->url);
00050                 return "<a href=\"$s_url\">$s_url</a>";
00051         }
GSiteMapItemFormatter::as_xml (  ) 

Render as XML.

Returns:
string

Definition at line 24 of file gsitemapitemformatter.cls.php.

00024                                  {
00025                 $tags = $this->get_xml_tags();
00026                 return '<url>' . $this->xml_from_tags($tags) . '</url>';
00027         }
GSiteMapItemFormatter::get_xml_tags (  )  [protected]

Collect tags to output.

Returns:
array

Definition at line 33 of file gsitemapitemformatter.cls.php.

00033                                           {
00034                 $tags = array();
00035                 $tags['loc'] = $this->url;
00036                 if (Arr::get_item($this->data, 'lastmod', 0) > 0) { $tags['lastmod'] = GyroDate::iso_date($this->data['lastmod']); }
00037                 if (!empty($this->data['priority'])) { $tags['priority'] = $this->data['priority']; }
00038                 if (!empty($this->data['changefreq'])) { $tags['changefreq'] = $this->data['changefreq']; }
00039 
00040                 return $tags;
00041         }
GSiteMapItemFormatter::xml_from_tags ( tags  )  [protected]

Turn associative array of tag => content into XML.

Parameters:
array  $tags
Returns:
string

Definition at line 59 of file gsitemapitemformatter.cls.php.

00059                                                 {
00060                 $ret = '';
00061                 foreach($tags as $tag => $content) {
00062                         $c = is_array($content) ? $this->xml_from_tags($content) : String::escape($content, String::XML);
00063                         $ret .= "<$tag>" . $c . "</$tag>\n";
00064                 }
00065                 return $ret;
00066         }

Member Data Documentation

GSiteMapItemFormatter::$data = array() [protected]

Definition at line 7 of file gsitemapitemformatter.cls.php.

GSiteMapItemFormatter::$url = '' [protected]

Definition at line 6 of file gsitemapitemformatter.cls.php.


The documentation for this class was generated from the following file: