public function buildDataXML($data)
 {
     $sections = new SectionIterator();
     $sections_xml = $this->document->createElement('sections');
     foreach ($sections as $s) {
         $section = $this->document->createElement('section');
         $entry_count = 0;
         $result = Symphony::Database()->query("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tcount(*) AS `count`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_entries` AS e\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\te.section = '%s'\n\t\t\t\t\t", array($s->handle));
         if ($result->valid()) {
             $entry_count = (int) $result->current()->count;
         }
         $section->setAttribute('entries', $entry_count);
         $name = $this->document->createElement('name', $s->name);
         $name->setAttribute('handle', $s->handle);
         $section->appendChild($name);
         $section->appendChild($this->document->createElement('navigation-group', $s->{'navigation-group'}));
         $section->appendChild($this->document->createElement('status', Section::syncroniseStatistics($s)->synced ? 'Synced' : 'Not Synced'));
         $sections_xml->appendChild($section);
     }
     $data->appendChild($sections_xml);
 }
 protected function appendSyncAlert()
 {
     $sync = Section::syncroniseStatistics($this->section);
     if ($sync->synced === true) {
         return;
     }
     $table_fields = array();
     $table_actions = array();
     $table_totals = array();
     $table = $this->createElement('table');
     $table->setAttribute('class', 'sync-table');
     // Find all fields:
     foreach ($sync as $name => $action) {
         if (is_array($action)) {
             $table_actions[$name] = count($action);
             foreach ($action as $guid => $data) {
                 $table_fields[$guid] = $data;
             }
         }
     }
     // Sort actions:
     uksort($table_actions, array($this, '__sortActions'));
     // Sort fields:
     uasort($table_fields, array($this, '__sortFields'));
     // Header:
     $row = $this->createElement('tr');
     $row->appendChild($this->createElement('th', __('Name')));
     foreach ($table_actions as $action => $count) {
         $row->appendChild($this->createElement('th', __(ucwords($action))));
     }
     $table->appendChild($row);
     $row = $this->createElement('tr');
     $cell = $this->createElement('th');
     if ($sync->section->rename) {
         $cell->appendChild($this->createTextNode($sync->section->new->name . ' '));
         $span = $this->createElement('span');
         $span->setAttribute('class', 'old');
         $span->appendChild($this->createEntityReference('larr'));
         $span->appendChild($this->createTextNode(' ' . $sync->section->old->name));
         $cell->appendChild($span);
         $row->appendChild($cell);
         foreach ($table_actions as $action => $count) {
             $cell = $this->createElement('td', __('No'));
             $cell->setAttribute('class', 'no');
             if ($action == 'rename') {
                 $cell->setValue(__('Yes'));
                 $cell->setAttribute('class', 'yes');
             }
             $row->appendChild($cell);
         }
     } else {
         $cell->setValue($sync->section->new->name);
         $row->appendChild($cell);
         foreach ($table_actions as $action => $count) {
             $cell = $this->createElement('td', __('No'));
             $cell->setAttribute('class', 'no');
             if ($action == 'create' and $sync->section->create) {
                 $cell->setValue(__('Yes'));
                 $cell->setAttribute('class', 'yes');
             }
             if ($action == 'update' and !$sync->section->create) {
                 $cell->setValue(__('Yes'));
                 $cell->setAttribute('class', 'yes');
             }
             $row->appendChild($cell);
         }
     }
     $table->appendChild($row);
     // Body:
     foreach ($table_fields as $guid => $data) {
         $row = $this->createElement('tr');
         $cell = $this->createElement('th');
         if (isset($sync->rename[$guid])) {
             $cell->appendChild($this->createTextNode($data->new->{'publish-label'} . ' '));
             $span = $this->createElement('span');
             $span->setAttribute('class', 'old');
             $span->appendChild($this->createEntityReference('larr'));
             $span->appendChild($this->createTextNode(' ' . $data->old->{'publish-label'}));
             $cell->appendChild($span);
         } else {
             $cell->setValue($data->{'publish-label'});
         }
         $row->appendChild($cell);
         foreach ($table_actions as $action => $count) {
             $cell = $this->createElement('td', __('No'));
             $cell->setAttribute('class', 'no');
             if (array_key_exists($guid, $sync->{$action})) {
                 $cell->setValue(__('Yes'));
                 $cell->setAttribute('class', 'yes');
             }
             $row->appendChild($cell);
         }
         $table->appendChild($row);
     }
     $div = $this->createElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Submit('action[sync]', __('Apply Changes')));
     $wrapper = $this->createElement('div');
     $wrapper->appendChild($table);
     $wrapper->appendChild($this->createElement('p', __('These changes will be applied to your database when you save this section.')));
     $this->alerts()->append(__('Your section tables don\'t match your section file, save this page to update your tables. <a class="more">Show sync information.</a>'), AlertStack::ERROR, $wrapper);
 }