* For more info about params see: * @link http://www.sitemaps.org/protocol.html */ class SitemapWriter { const FREQ_ALWAYS = 0; const FREQ_HOURLY = 1; const FREQ_DAILY = 2; const FREQ_WEEKLY = 3; const FREQ_MONTHLY = 4; const FREQ_YEARLY = 5; const FREQ_NEVER = 6; private static $freq = array( 'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'newer'); private $_pull = array(); public function addPage($location, $lastmod = null, $changefreq = null, $priority = null) { $this->_pull[] = array( $location, $lastmod, $changefreq, $priority ); } public function generateXml($processOutput = false) { if ($processOutput) { ob_start(); } echo '',"\n", '',"\n"; foreach ($this->_pull as &$item) { echo " ",'',"\n ",'', htmlentities($item[0]), '',"\n"; if (isset($item[1])) { echo " ",'', $item[1], '',"\n"; } if (isset($item[1])) { echo " ",'', self::$freq[$item[2]], '',"\n"; } if (isset($item[1])) { echo " ",'', $item[3], '',"\n"; } echo " ",'',"\n"; } echo ''; $res = null; if ($processOutput) { $res = ob_get_clean(); } return $res; } }