protected function _generateExport()
 {
     $csv = new CsvWriter();
     $csv->open();
     $content = $this->set->firstContent;
     $fields = array();
     do {
         if ($content->config->get('visible')) {
             $fields[] = $content->config->get('label');
         }
     } while ($content = $content->nextContent);
     $csv->append($fields);
     while ($set = $this->sets->getNext()) {
         $fields = array();
         $this->_onRenderSetChanged();
         $content = $this->set->firstContent;
         do {
             if ($content->config->get('visible')) {
                 $fields[] = $content->render(Set::MODE_EXPORT);
             }
         } while ($content = $content->nextContent);
         $csv->append($fields);
     }
     $data = chr(239) . chr(187) . chr(191) . $csv->getContents();
     $csv->close();
     $res = $this->response();
     $res->asDownload($this->_getExportFilename());
     $res->postContent($data);
 }
Ejemplo n.º 2
0
 public function renderTable()
 {
     $q = $this->factory()->appQuick();
     $u = $this->factory()->appUi();
     $globalDelete = $this->set->allowDelete;
     $globalEdit = $this->set->allowEdit;
     $table = '<table><thead><tr>';
     $capabilities = $this->set->getCapabilities();
     $content = $this->set->firstContent;
     do {
         if ($content->config->get('visible')) {
             $c = $content->config->get('label');
             if ($content->config->get('escapeLabel', true)) {
                 $c = $q->e($c);
             }
             if ($capabilities->sort && $content->sortable) {
                 $arguments = $this->getUrlArguments('sort');
                 $arguments['sortBy'] = $content->name;
                 if ($this->sortBy == $content->name && $this->sortDirection == 'desc') {
                     $arguments['sortDirection'] = 'asc';
                 } else {
                     $arguments['sortDirection'] = 'desc';
                 }
                 $url = $this->pageUrl . $this->encodeArgs($arguments);
                 $c = '<a href="' . $q->e($url) . '">' . $c . '</a>';
             }
             $table .= '<td>' . $c . '</td>';
         }
     } while ($content = $content->nextContent);
     if ($globalEdit) {
         $table .= '<td>' . $q->t('Bearbeiten') . '</td>';
     }
     if ($globalDelete) {
         $table .= '<td>' . $q->t('Löschen') . '</td>';
     }
     $table .= '</tr></thead><tbody>';
     while ($set = $this->sets->getNext()) {
         $this->_onRenderTableSetChanged();
         $content = $this->set->firstContent;
         $table .= '<tr>';
         do {
             if ($content->config->get('visible')) {
                 $table .= '<td>' . $content->render('list');
             }
         } while ($content = $content->nextContent);
         if ($globalEdit) {
             if ($this->set->allowEdit) {
                 $table .= '<td>' . $u->link($this->getEditUrl($this->set->getId()), $q->t('Bearbeiten')) . '</td>';
             } else {
                 $table .= '<td></td>';
             }
         }
         if ($globalDelete) {
             if ($this->set->allowDelete) {
                 $table .= '<td>' . $u->link($this->getDeleteUrl($this->set->getId()), $q->t('Löschen')) . '</td>';
             } else {
                 $table .= '<td></td>';
             }
         }
         $table .= '</tr>';
     }
     $table .= '</tbody></table>';
     return $table;
 }