/**
  * Adds a site to the buffer.
  *
  * @param object site $site The site to add.
  * @param integer $indent The indent level of the object
  */
 function addSite(&$site)
 {
     // Add flags for when to add permissions rows
     $site->spiderDownLockedFlag();
     $siteElement =& $this->_document->createElement('site');
     $this->_document->appendChild($siteElement);
     // site id and type
     $siteElement->setAttribute('owner', slot::getOwner($site->getField('name')));
     $siteElement->setAttribute('type', $site->getField('type'));
     // Media quota
     $slot = new Slot($site->getField('name'));
     $quota = $slot->getField('quota');
     if ($quota) {
         $siteElement->setAttribute('mediaQuota', $quota);
     }
     $this->addCommonProporties($site, $siteElement);
     // use the slot-name for backwards-compatability
     $siteElement->setAttribute('id', $site->getField('name'));
     // header
     $header =& $this->_document->createElement('header');
     $siteElement->appendChild($header);
     $header->appendChild($this->_document->createTextNode(htmlspecialchars($site->getField('header'))));
     // footer
     $footer =& $this->_document->createElement('footer');
     $siteElement->appendChild($footer);
     $footer->appendChild($this->_document->createTextNode(htmlspecialchars($site->getField('footer'))));
     // Theme
     $this->addTheme($site, $siteElement);
     // Media
     $this->addMedia($site, $siteElement);
     // sections
     foreach ($site->sections as $key => $val) {
         if ($site->sections[$key]->getField('type') == 'link') {
             $this->addSectionNavLink($site->sections[$key], $siteElement);
         } else {
             if ($site->sections[$key]->getField('type') == 'heading') {
                 $this->addHeading($site->sections[$key], $siteElement);
             } else {
                 if ($site->sections[$key]->getField('type') == 'divider') {
                     $this->addDivider($site->sections[$key], $siteElement);
                 } else {
                     $this->addSection($site->sections[$key], $siteElement);
                 }
             }
         }
     }
 }