예제 #1
0
 /**
  * Creates an item for the sitemap or sitemap index
  *
  * @param array $options various options pertaining to the item
  * @return string The item
  * @author Jose Diaz-Gonzalez
  **/
 public function item($options = array())
 {
     $options = array_merge(array('loc' => NULL, 'lastmod' => NULL, 'changefreq' => NULL, 'priority' => NULL, 'encode' => true), $options);
     if (!empty($options['loc'])) {
         if (!empty($options['lastmod'])) {
             $time = new TimeHelper();
             $options['lastmod'] = $time->toAtom($options['lastmod']);
         }
         if ($options['encode']) {
             $options['loc'] = $this->_xmlspecialchars($options['loc']);
         }
         if ($this->sitemap) {
             //Construct a sitemapindex item
             $item = array();
             $item['openEntity'] = "<sitemap>";
             $item['loc'] = $this->_entityMaker("loc", $options['loc']);
             $item['lastmod'] = $this->_entityMaker("lastmod", $options['lastmod']);
             $item['closeEntity'] = "</sitemap>\n";
             return $this->_mergeArrayEntities($item);
         } else {
             //Construct a sitemap item
             $item = array();
             $item['openEntity'] = "<url>";
             $item['loc'] = $this->_entityMaker("loc", $options['loc']);
             $item['lastmod'] = $this->_entityMaker("lastmod", $options['lastmod']);
             $item['changefreq'] = $this->_entityMaker("changefreq", $options['changefreq']);
             $item['priority'] = $this->_entityMaker("priority", $options['priority']);
             $item['closeEntity'] = "</url>\n";
             return $this->_mergeArrayEntities($item);
         }
     }
     return false;
 }
예제 #2
0
 /**
  * Returns a date formatted for Atom RSS feeds.
  *
  * @param string $dateString Datetime string or Unix timestamp
  * @param int $userOffset User's offset from GMT (in hours)
  * @return string Formatted date string
  * @access public
  * @link http://book.cakephp.org/view/1471/Formatting
  */
 function toAtom($dateString, $userOffset = null)
 {
     return parent::toAtom($dateString, $this->__userOffset($dateString, $userOffset));
 }