Example #1
0
 public function export($objVisitors, $csv_delimiter, $intVisitorKatId)
 {
     if (file_exists(TL_ROOT . "/plugins/xls_export/xls_export.php")) {
         include TL_ROOT . "/plugins/xls_export/xls_export.php";
         $xls = new xlsexport();
         $sheet = 'VisitorsStatExport-' . $intVisitorKatId . '';
         $xls->addworksheet($sheet);
         //Kopfdaten
         $arrVisitorsStatHeader = explode(",", html_entity_decode($GLOBALS['TL_LANG']['MSC']['tl_visitors_stat']['export_headline'], ENT_NOQUOTES, 'UTF-8'));
         $intRowCounter = 1;
         for ($c = 1; $c <= 7; $c++) {
             $xls->setcolwidth($sheet, $c - 1, 0x1000);
             $xls->setcell(array("sheetname" => $sheet, "row" => 0, "col" => $c - 1, 'fontweight' => XLSFONT_BOLD, 'hallign' => XLSXF_HALLIGN_CENTER, "data" => utf8_decode($arrVisitorsStatHeader[$c - 1])));
         }
         while ($objVisitors->next()) {
             $arrVisitorsStat[0] = utf8_decode($objVisitors->category_title);
             $arrVisitorsStat[1] = $objVisitors->visitors_id;
             $arrVisitorsStat[2] = utf8_decode($objVisitors->visitors_name);
             $arrVisitorsStat[3] = $objVisitors->published == '' ? $GLOBALS['TL_LANG']['MSC']['tl_visitors_stat']['pub_no'] : $GLOBALS['TL_LANG']['MSC']['tl_visitors_stat']['pub_yes'];
             $arrVisitorsStat[4] = date($GLOBALS['TL_CONFIG']['dateFormat'], strtotime($objVisitors->visitors_date));
             $arrVisitorsStat[5] = $objVisitors->visitors_visit == '' ? '0' : $objVisitors->visitors_visit;
             $arrVisitorsStat[6] = $objVisitors->visitors_hit == '' ? '0' : $objVisitors->visitors_hit;
             for ($c = 1; $c <= 7; $c++) {
                 $xls->setcell(array("sheetname" => $sheet, "row" => $intRowCounter, "col" => $c - 1, 'hallign' => XLSXF_HALLIGN_CENTER, "data" => $arrVisitorsStat[$c - 1]));
             }
             $intRowCounter++;
         }
         // while
         $xls->sendFile($sheet . ".xls");
     } else {
         echo "<html><head><title>Need extension xls_export</title></head><body>" . "Please install the extension 'xls_export'.<br /><br />" . "Bitte die Erweiterung 'xls_export' installieren.<br /><br />" . "Installer l'extension 'xls_export' s'il vous plaît." . "</body></html>";
     }
 }
Example #2
0
 public function export($strMode = 'csv')
 {
     if (strlen($this->Input->get('expmode'))) {
         $strMode = $this->Input->get('expmode');
     }
     $return = '';
     $blnCustomXlsExport = false;
     $blnCustomExport = false;
     $arrHookData = array();
     $arrHookDataColumns = array();
     if ($strMode == 'xls') {
         // check for HOOK efgExportXls
         if (array_key_exists('efgExportXls', $GLOBALS['TL_HOOKS']) && is_array($GLOBALS['TL_HOOKS']['efgExportXls'])) {
             $blnCustomXlsExport = true;
         } else {
             include TL_ROOT . '/plugins/xls_export/xls_export.php';
         }
     } elseif ($strMode != 'csv') {
         $blnCustomExport = true;
     }
     // filter or search for values
     $session = $this->Session->getData();
     $showFields = array_merge($this->arrBaseFields, $this->arrDetailFields);
     $ignoreFields = array('tstamp', 'sorting');
     if (is_array($this->arrExportIgnoreFields) && count($this->arrExportIgnoreFields) > 0) {
         $ignoreFields = array_unique(array_merge($ignoreFields, $this->arrExportIgnoreFields));
     }
     $table = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6 ? $this->ptable : $this->strTable;
     $table_alias = $table == 'tl_formdata' ? ' f' : '';
     $orderBy = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['fields'];
     $firstOrderBy = preg_replace('/\\s+.*$/i', '', $orderBy[0]);
     if (is_array($this->orderBy) && strlen($this->orderBy[0])) {
         $orderBy = $this->orderBy;
         $firstOrderBy = $this->firstOrderBy;
     }
     if ($this->Input->get('table') && $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable'] && $this->Database->fieldExists('pid', $this->strTable)) {
         $this->procedure[] = 'pid=?';
         $this->values[] = $this->Input->get('id');
     }
     $query = "SELECT * " . (count($this->arrSqlDetails) > 0 ? ', ' . implode(',', array_values($this->arrSqlDetails)) : '') . " FROM " . $this->strTable . $table_alias;
     $sqlWhere = '';
     // Set search value from session
     $strSessionKey = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 4 ? $this->strTable . '_' . CURRENT_ID : strlen($this->strFormKey) ? $this->strFormKey : $this->strTable;
     if (strlen($session['search'][$strSessionKey]['value'])) {
         $sqlSearchField = $session['search'][$strSessionKey]['field'];
         if (in_array($sqlSearchField, $this->arrDetailFields)) {
             $sqlSearchField = '(SELECT value FROM tl_formdata_details WHERE ff_name=\'' . $session['search'][$strSessionKey]['field'] . '\' AND pid=f.id)';
         }
         $this->procedure[] = "CAST(" . $sqlSearchField . " AS CHAR) REGEXP ?";
         $this->values[] = $session['search'][$strSessionKey]['value'];
     }
     // Set filter from session
     $arrFilterFields = array();
     foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'] as $k => $v) {
         if ($v['filter']) {
             $arrFilterFields[] = $k;
         }
     }
     if (count($arrFilterFields)) {
         foreach ($arrFilterFields as $field) {
             if (isset($session['filter'][$strSessionKey][$field])) {
                 $sqlFilterField = $field;
                 if (in_array($field, $this->arrDetailFields)) {
                     $sqlFilterField = '(SELECT value FROM tl_formdata_details WHERE ff_name=\'' . $field . '\' AND pid=f.id)';
                 }
                 // Sort by day
                 if (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(5, 6))) {
                     if ($session['filter'][$strSessionKey][$field] == '') {
                         $this->procedure[] = $sqlFilterField . "=''";
                     } else {
                         $objDate = new Date($session['filter'][$strSessionKey][$field]);
                         $this->procedure[] = $sqlFilterField . ' BETWEEN ? AND ?';
                         $this->values[] = $objDate->dayBegin;
                         $this->values[] = $objDate->dayEnd;
                     }
                 } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(7, 8))) {
                     if ($session['filter'][$strSessionKey][$field] == '') {
                         $this->procedure[] = $sqlFilterField . "=''";
                     } else {
                         $objDate = new Date($session['filter'][$strSessionKey][$field]);
                         $this->procedure[] = $sqlFilterField . ' BETWEEN ? AND ?';
                         $this->values[] = $objDate->monthBegin;
                         $this->values[] = $objDate->monthEnd;
                     }
                 } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(9, 10))) {
                     if ($session['filter'][$strSessionKey][$field] == '') {
                         $this->procedure[] = $sqlFilterField . "=''";
                     } else {
                         $objDate = new Date($session['filter'][$strSessionKey][$field]);
                         $this->procedure[] = $sqlFilterField . ' BETWEEN ? AND ?';
                         $this->values[] = $objDate->yearBegin;
                         $this->values[] = $objDate->yearEnd;
                     }
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['multiple']) {
                     $this->procedure[] = $sqlFilterField . ' LIKE ?';
                     $this->values[] = '%"' . $session['filter'][$strSessionKey][$field] . '"%';
                 } else {
                     $this->procedure[] = $sqlFilterField . '=?';
                     $this->values[] = $session['filter'][$strSessionKey][$field];
                 }
             }
         }
     }
     if (count($this->procedure)) {
         $arrProcedure = $this->procedure;
         foreach ($arrProcedure as $kProc => $vProc) {
             $strProcField = substr($vProc, 0, strpos($vProc, '='));
             if (in_array($strProcField, $this->arrDetailFields)) {
                 $arrProcedure[$kProc] = "(SELECT value FROM tl_formdata_details WHERE ff_name='" . $strProcField . "' AND pid=f.id)=?";
             }
         }
         $sqlWhere .= ($sqlWhere != '' ? " AND " : " WHERE ") . implode(' AND ', $arrProcedure);
     }
     if ($sqlWhere != '') {
         $query .= $sqlWhere;
     }
     if (is_array($orderBy) && strlen($orderBy[0])) {
         foreach ($orderBy as $o => $strVal) {
             $arrOrderField = explode(' ', $strVal);
             $strOrderField = $arrOrderField[0];
             unset($arrOrderField);
             if (!in_array($strOrderField, $this->arrBaseFields)) {
                 $orderBy[$o] = "(SELECT value FROM tl_formdata_details WHERE ff_name='" . $strOrderField . "' AND pid=f.id)";
             }
         }
         $query .= " ORDER BY " . implode(', ', $orderBy);
     }
     if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 1 && $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['flag'] % 2 == 0) {
         $query .= " DESC";
     }
     $objRowStmt = $this->Database->prepare($query);
     $objRow = $objRowStmt->execute($this->values);
     $intRowCounter = -1;
     $strExpEncl = '';
     $strExpSep = ';';
     $useFormValues = $this->arrStoreForms[substr($this->strFormKey, 3)]['useFormValues'];
     $useFieldNames = $this->arrStoreForms[substr($this->strFormKey, 3)]['useFieldNames'];
     if ($strMode == 'csv') {
         header('Content-Type: appplication/csv; charset=' . ($this->blnExportUTF8Decode ? 'CP1252' : 'utf-8'));
         header('Content-Transfer-Encoding: binary');
         header('Content-Disposition: attachment; filename="export_' . $this->strFormKey . '_' . date("Ymd_His") . '.csv"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Expires: 0');
     } elseif ($strMode == 'xls') {
         if (!$blnCustomXlsExport) {
             $xls = new xlsexport();
             $strXlsSheet = "Export";
             $xls->addworksheet($strXlsSheet);
         }
     }
     // List records
     if ($objRow->numRows) {
         $result = $objRow->fetchAllAssoc();
         // Rename each pid to its label and resort the result (sort by parent table)
         if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 3 && $this->Database->fieldExists('pid', $this->strTable)) {
             $firstOrderBy = 'pid';
             foreach ($result as $k => $v) {
                 $objField = $this->Database->prepare("SELECT " . $showFields[0] . " FROM " . $this->ptable . " WHERE id=?")->limit(1)->execute($v['pid']);
                 $result[$k]['pid'] = $objField->{$showFields}[0];
             }
             $aux = array();
             foreach ($result as $row) {
                 $aux[] = $row['pid'];
             }
             array_multisort($aux, SORT_ASC, $result);
         }
         // Process result and format values
         foreach ($result as $row) {
             $intRowCounter++;
             $args = array();
             $this->current[] = $row['id'];
             //$showFields = $GLOBALS['TL_DCA'][$table]['list']['label']['fields'];
             if ($intRowCounter == 0) {
                 if ($strMode == 'xls') {
                     if (!$blnCustomXlsExport) {
                         $xls->totalcol = count($showFields);
                     }
                 }
                 $strExpEncl = '"';
                 $strExpSep = '';
                 $intColCounter = -1;
                 foreach ($showFields as $k => $v) {
                     if (in_array($v, $ignoreFields)) {
                         continue;
                     }
                     $intColCounter++;
                     if ($useFieldNames) {
                         $strName = $v;
                     } elseif (strlen($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['label'][0])) {
                         $strName = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['label'][0];
                     } elseif (strlen($GLOBALS['TL_LANG']['tl_formdata'][$v][0])) {
                         $strName = $GLOBALS['TL_LANG']['tl_formdata'][$v][0];
                     } else {
                         $strName = strtoupper($v);
                     }
                     if (strlen($strName)) {
                         $strName = $this->String->decodeEntities($strName);
                     }
                     if ($this->blnExportUTF8Decode || $strMode == 'xls' && !$blnCustomXlsExport) {
                         $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
                     }
                     if ($strMode == 'csv') {
                         $strName = str_replace('"', '""', $strName);
                         echo $strExpSep . $strExpEncl . $strName . $strExpEncl;
                         $strExpSep = ";";
                     } elseif ($strMode == 'xls') {
                         if (!$blnCustomXlsExport) {
                             $xls->setcell(array("sheetname" => $strXlsSheet, "row" => $intRowCounter, "col" => $intColCounter, "data" => $strName, "fontweight" => XLSFONT_BOLD, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL));
                             $xls->setcolwidth($strXlsSheet, $intColCounter, 0x1aff);
                         } else {
                             $arrHookDataColumns[$v] = $strName;
                         }
                     } elseif ($blnCustomExport) {
                         $arrHookDataColumns[$v] = $strName;
                     }
                 }
                 $intRowCounter++;
                 if ($strMode == 'csv') {
                     echo "\n";
                 }
             }
             // intRowCounter 0
             $strExpSep = '';
             $intColCounter = -1;
             // Prepare field value
             foreach ($showFields as $k => $v) {
                 if (in_array($v, $ignoreFields)) {
                     continue;
                 }
                 $intColCounter++;
                 $strVal = '';
                 $strVal = $row[$v];
                 if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'date' && in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) {
                     $strVal = $row[$v] ? date($GLOBALS['TL_CONFIG']['dateFormat'], $row[$v]) : '';
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'datim' && in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) {
                     $strVal = $row[$v] ? date($GLOBALS['TL_CONFIG']['datimFormat'], $row[$v]) : '';
                 } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) {
                     $strVal = $row[$v] ? date($GLOBALS['TL_CONFIG']['datimFormat'], $row[$v]) : '';
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['multiple']) {
                     if ($useFormValues == 1) {
                         // single value checkboxes don't have options
                         if (is_array($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) && count($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) > 0) {
                             $strVal = strlen($row[$v]) ? key($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) : '';
                         } else {
                             $strVal = $row[$v];
                         }
                     } else {
                         $strVal = strlen($row[$v]) ? $GLOBALS['TL_DCA'][$table]['fields'][$v]['label'][0] : '-';
                     }
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'radio' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'efgLookupRadio' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'select' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'conditionalselect' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'efgLookupSelect' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'checkbox' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'efgLookupCheckbox') {
                     // take the assigned value instead of the user readable output
                     if ($useFormValues == 1) {
                         if (strpos($row[$v], "|") == FALSE && (is_array($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) && count($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) > 0)) {
                             // handle grouped options
                             $arrOptions = array();
                             foreach ($GLOBALS['TL_DCA'][$table]['fields'][$v]['options'] as $o => $mxVal) {
                                 if (!is_array($mxVal)) {
                                     $arrOptions[$o] = $mxVal;
                                 } else {
                                     foreach ($mxVal as $ov => $mxOVal) {
                                         $arrOptions[$ov] = $mxOVal;
                                     }
                                 }
                             }
                             //$options = array_flip($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']);
                             $options = array_flip($arrOptions);
                             $strVal = $options[$row[$v]];
                         } else {
                             if (is_array($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) && count($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']) > 0) {
                                 // handle grouped options
                                 $arrOptions = array();
                                 foreach ($GLOBALS['TL_DCA'][$table]['fields'][$v]['options'] as $o => $mxVal) {
                                     if (!is_array($mxVal)) {
                                         $arrOptions[$o] = $mxVal;
                                     } else {
                                         foreach ($mxVal as $ov => $mxOVal) {
                                             $arrOptions[$ov] = $mxOVal;
                                         }
                                     }
                                 }
                                 //$options = array_flip($GLOBALS['TL_DCA'][$table]['fields'][$v]['options']);
                                 $options = array_flip($arrOptions);
                                 $tmparr = split("\\|", $row[$v]);
                                 $fieldvalues = array();
                                 foreach ($tmparr as $valuedesc) {
                                     array_push($fieldvalues, $options[$valuedesc]);
                                 }
                                 $strVal = join(",\n", $fieldvalues);
                             } else {
                                 $strVal = strlen($row[$v]) ? str_replace('|', ",\n", $row[$v]) : '';
                             }
                         }
                     } else {
                         $strVal = strlen($row[$v]) ? str_replace('|', ",\n", $row[$v]) : '';
                     }
                 } else {
                     $row_v = deserialize($row[$v]);
                     if (is_array($row_v)) {
                         $args_k = array();
                         foreach ($row_v as $option) {
                             $args_k[] = strlen($GLOBALS['TL_DCA'][$table]['fields'][$v]['reference'][$option]) ? $GLOBALS['TL_DCA'][$table]['fields'][$v]['reference'][$option] : $option;
                         }
                         $args[$k] = implode(",\n", $args_k);
                     } elseif (is_array($GLOBALS['TL_DCA'][$table]['fields'][$v]['reference'][$row[$v]])) {
                         $args[$k] = is_array($GLOBALS['TL_DCA'][$table]['fields'][$v]['reference'][$row[$v]]) ? $GLOBALS['TL_DCA'][$table]['fields'][$v]['reference'][$row[$v]][0] : $GLOBALS['TL_DCA'][$table]['fields'][$v]['reference'][$row[$v]];
                     } else {
                         $args[$k] = $row[$v];
                     }
                     $strVal = is_null($args[$k]) ? $args[$k] : vsprintf('%s', $args[$k]);
                 }
                 if (in_array($v, $this->arrBaseFields) || in_array($v, $this->arrOwnerFields)) {
                     if ($v == 'fd_member') {
                         $strVal = $this->arrMembers[intval($row[$v])];
                     } elseif ($v == 'fd_user') {
                         $strVal = $this->arrUsers[intval($row[$v])];
                     } elseif ($v == 'fd_member_group') {
                         $strVal = $this->arrMemberGroups[intval($row[$v])];
                     } elseif ($v == 'fd_user_group') {
                         $strVal = $this->arrUserGroups[intval($row[$v])];
                     }
                 }
                 if (strlen($strVal)) {
                     $strVal = $this->String->decodeEntities($strVal);
                     $strVal = preg_replace(array('/<br.*\\/*>/si'), array("\n"), $strVal);
                     if ($this->blnExportUTF8Decode || $strMode == 'xls' && !$blnCustomXlsExport) {
                         $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
                     }
                 }
                 if ($strMode == 'csv') {
                     $strVal = str_replace('"', '""', $strVal);
                     echo $strExpSep . $strExpEncl . $strVal . $strExpEncl;
                     $strExpSep = ";";
                 } elseif ($strMode == 'xls') {
                     if (!$blnCustomXlsExport) {
                         $xls->setcell(array("sheetname" => $strXlsSheet, "row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL));
                     } else {
                         $arrHookData[$intRowCounter][$v] = $strVal;
                     }
                 } elseif ($blnCustomExport) {
                     $arrHookData[$intRowCounter][$v] = $strVal;
                 }
             }
             if ($strMode == 'csv') {
                 $strExpSep = '';
                 echo "\n";
             }
         }
         // foreach ($result as $row)
     }
     // if objRow->numRows
     if ($strMode == 'xls') {
         if (!$blnCustomXlsExport) {
             $xls->sendfile("export_" . $this->strFormKey . "_" . date("Ymd_His") . ".xls");
             exit;
         } else {
             foreach ($GLOBALS['TL_HOOKS']['efgExportXls'] as $key => $callback) {
                 $this->import($callback[0]);
                 $res = $this->{$callback}[0]->{$callback}[1]($arrHookDataColumns, $arrHookData);
             }
         }
     } elseif ($blnCustomExport) {
         foreach ($GLOBALS['TL_HOOKS']['efgExport'] as $key => $callback) {
             $this->import($callback[0]);
             $res = $this->{$callback}[0]->{$callback}[1]($arrHookDataColumns, $arrHookData, $strMode);
         }
     }
     exit;
 }
 /**
  * Export a single record
  */
 protected function exportSingleRecord($strExportMode = 'csv')
 {
     /**
      * Prepare URL
      */
     $strUrl = preg_replace('/\\?.*$/', '', urldecode($this->Environment->request));
     $strUrlParams = '';
     $strUrlSuffix = $GLOBALS['TL_CONFIG']['urlSuffix'];
     $blnQuery = false;
     foreach (preg_split('/&(amp;)?/', urldecode($_SERVER['QUERY_STRING'])) as $fragment) {
         if (strlen($fragment)) {
             if (strncasecmp($fragment, 'file', 5) !== 0 && strncasecmp($fragment, $this->strDetailKey, strlen($this->strDetailKey)) !== 0 && strncasecmp($fragment, 'order_by', 8) !== 0 && strncasecmp($fragment, 'sort', 4) !== 0 && strncasecmp($fragment, 'page', 4) !== 0) {
                 $strUrlParams .= (!$blnQuery ? '' : '&amp;') . $fragment;
                 $blnQuery = true;
             }
         }
     }
     $strVarConnector = $blnQuery ? '&amp;' : '?';
     // check record
     if (is_null($this->intRecordId) || intval($this->intRecordId) < 1) {
         return;
     }
     // check access
     if (strlen($this->efg_list_access) && $this->efg_list_access != 'public') {
         $objOwner = $this->Database->prepare("SELECT fd_member FROM tl_formdata WHERE id=?")->execute($this->intRecordId);
         $varOwner = $objOwner->fetchAssoc();
         if (!in_array(intval($varOwner['fd_member']), $this->arrAllowedOwnerIds)) {
             $strRed = preg_replace(array('/\\/' . $this->strDetailKey . '\\/' . $this->Input->get($this->strDetailKey) . '/i', '/' . $this->strDetailKey . '=' . $this->Input->get($this->strDetailKey) . '/i'), array('', ''), $strUrl) . (strlen($strUrlParams) ? '?' . $strUrlParams : '');
             $this->redirect($strRed);
         }
     }
     // check export access
     $blnExportAllowed = false;
     if ($this->efg_fe_export_access == 'none') {
         $blnExportAllowed = false;
     } elseif ($this->efg_fe_export_access == 'public') {
         $blnExportAllowed = true;
     } elseif (strlen($this->efg_fe_export_access)) {
         $objOwner = $this->Database->prepare("SELECT fd_member FROM tl_formdata WHERE id=?")->execute($this->intRecordId);
         $varOwner = $objOwner->fetchAssoc();
         if (in_array(intval($varOwner['fd_member']), $this->arrAllowedExportOwnerIds)) {
             $blnExportAllowed = true;
         }
     }
     $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
     $this->list_info = deserialize($this->list_info);
     $arrListFields = explode(',', $this->list_info);
     $strSep = '';
     // wildcards * and -
     if ($arrListFields[0] == '*') {
         $arrTempFields = array_merge($this->arrBaseFields, $this->arrDetailFields);
         foreach ($arrListFields as $field) {
             if (substr($field, 0, 1) == '-') {
                 $intKey = array_search(substr($field, 1), $arrTempFields);
                 if (!is_bool($intKey)) {
                     unset($arrTempFields[$intKey]);
                 }
             }
         }
         $arrListFields = $arrTempFields;
     }
     $strQuery = "SELECT ";
     $strWhere = '';
     foreach ($arrListFields as $field) {
         if (in_array($field, $this->arrBaseFields)) {
             $strQuery .= $strSep . $field;
             $strSep = ', ';
         }
         if (is_array($this->arrDetailFields) && count($this->arrDetailFields) && in_array($field, $this->arrDetailFields)) {
             $strQuery .= $strSep . '(SELECT value FROM tl_formdata_details WHERE ff_name="' . $field . '" AND pid=f.id ) AS `' . $field . '`';
             $strSep = ', ';
         }
     }
     $strQuery .= " FROM " . $this->list_table . " f";
     $strWhere .= (strlen($strWhere) ? " AND " : " WHERE ") . "id=?";
     $strQuery .= $strWhere;
     $objRecords = $this->Database->prepare($strQuery)->limit(1)->execute($this->intRecordId);
     if ($objRecords->numRows < 1) {
         return;
     }
     $ignoreFields = array('id', 'alias', 'tstamp', 'sorting', 'ip', 'published');
     $showFields = array_diff($arrListFields, $ignoreFields);
     $intRowCounter = -1;
     $strExpEncl = '"';
     $strExpSep = '';
     $useFormValues = $this->FormData->arrStoreForms[substr($this->strFormKey, 3)]['useFormValues'];
     $useFieldNames = $this->FormData->arrStoreForms[substr($this->strFormKey, 3)]['useFieldNames'];
     $blnCustomXlsExport = false;
     $arrHookData = array();
     $arrHookDataColumns = array();
     if ($strExportMode == 'xls') {
         // check for HOOK efgExportXls
         if (array_key_exists('efgExportXls', $GLOBALS['TL_HOOKS']) && is_array($GLOBALS['TL_HOOKS']['efgExportXls'])) {
             $blnCustomXlsExport = true;
         } else {
             include TL_ROOT . '/system/modules/efg/plugins/xls_export/xls_export.php';
         }
     }
     if ($strExportMode == 'xls') {
         if (!$blnCustomXlsExport) {
             $xls = new xlsexport();
             $strXlsSheet = "Export";
             $xls->addworksheet($strXlsSheet);
         }
     } else {
         header('Content-Type: appplication/csv; charset=' . ($this->blnExportUTF8Decode ? 'CP1252' : 'utf-8'));
         header('Content-Transfer-Encoding: binary');
         header('Content-Disposition: attachment; filename="export_' . $this->strFormKey . '_' . date("Ymd_His") . '.csv"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Expires: 0');
     }
     // List records
     if ($objRecords->numRows) {
         $result = $objRecords->fetchAllAssoc();
         // Process result and format values
         foreach ($result as $row) {
             $intRowCounter++;
             $args = array();
             if ($intRowCounter == 0) {
                 if ($strExportMode == 'xls') {
                     if (!$blnCustomXlsExport) {
                         $xls->totalcol = count($showFields);
                     }
                 }
                 $strExpSep = '';
                 $intColCounter = -1;
                 foreach ($showFields as $k => $v) {
                     if (in_array($v, $ignoreFields)) {
                         continue;
                     }
                     $intColCounter++;
                     if ($useFieldNames) {
                         $strName = $v;
                     } elseif (strlen($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['label'][0])) {
                         $strName = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['label'][0];
                     } elseif (strlen($GLOBALS['TL_LANG']['tl_formdata'][$v][0])) {
                         $strName = $GLOBALS['TL_LANG']['tl_formdata'][$v][0];
                     } else {
                         $strName = strtoupper($v);
                     }
                     if (strlen($strName)) {
                         $strName = $this->String->decodeEntities($strName);
                         if ($this->blnExportUTF8Decode || $strExportMode == 'xls' && !$blnCustomXlsExport) {
                             $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
                         }
                     }
                     if ($strExportMode == 'csv') {
                         $strName = str_replace('"', '""', $strName);
                         echo $strExpSep . $strExpEncl . str_replace('"', '""', $strName) . $strExpEncl;
                         $strExpSep = ";";
                     }
                     if ($strExportMode == 'xls') {
                         if (!$blnCustomXlsExport) {
                             $xls->setcell(array("sheetname" => $strXlsSheet, "row" => $intRowCounter, "col" => $intColCounter, "data" => $strName, "fontweight" => XLSFONT_BOLD, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL));
                             $xls->setcolwidth($strXlsSheet, $intColCounter, 0x1aff);
                         } else {
                             $arrHookDataColumns[$v] = $strName;
                         }
                     }
                 }
                 $intRowCounter++;
                 if ($strExportMode == 'csv') {
                     echo "\n";
                 }
             }
             $strExpSep = '';
             $intColCounter = -1;
             // Prepare field value
             foreach ($showFields as $k => $v) {
                 if (in_array($v, $ignoreFields)) {
                     continue;
                 }
                 $intColCounter++;
                 $strVal = '';
                 $strVal = $row[$v];
                 if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'date') {
                     $strVal = $row[$v] ? date($GLOBALS['TL_CONFIG']['dateFormat'], $row[$v]) : '';
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'time') {
                     $strVal = $row[$v] ? date($GLOBALS['TL_CONFIG']['timeFormat'], $row[$v]) : '';
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['rgxp'] == 'datim') {
                     $strVal = $row[$v] ? date($GLOBALS['TL_CONFIG']['datimFormat'], $row[$v]) : '';
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['eval']['multiple']) {
                     if ($useFormValues == 1) {
                         // single value checkboxes don't have options
                         if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) && count($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) > 0) {
                             $strVal = strlen($row[$v]) ? key($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) : '';
                         } else {
                             $strVal = $row[$v];
                         }
                     } else {
                         $strVal = strlen($row[$v]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['label'][0] : '-';
                     }
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'radio' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'efgLookupRadio' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'select' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'efgLookupSelect' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'checkbox' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'efgLookupCheckbox') {
                     // take the assigned value instead of the user readable output
                     if ($useFormValues == 1) {
                         if (strpos($row[$v], "|") == FALSE && (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) && count($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) > 0)) {
                             $options = array_flip($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']);
                             $strVal = $options[$row[$v]];
                         } else {
                             if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) && count($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']) > 0) {
                                 $options = array_flip($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['options']);
                                 $tmparr = split("\\|", $row[$v]);
                                 $fieldvalues = array();
                                 foreach ($tmparr as $valuedesc) {
                                     array_push($fieldvalues, $options[$valuedesc]);
                                 }
                                 $strVal = join(",\n", $fieldvalues);
                             } else {
                                 $strVal = strlen($row[$v]) ? str_replace('|', ",\n", $row[$v]) : '';
                             }
                         }
                     } else {
                         $strVal = strlen($row[$v]) ? str_replace('|', ",\n", $row[$v]) : '';
                     }
                 } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['inputType'] == 'fileTree') {
                     if (is_string($row[$v]) && strpos($row[$v], '|') !== false) {
                         $strVal = implode(",\n", explode('|', $row[$v]));
                     } else {
                         $strVal = implode(",\n", deserialize($row[$v], true));
                     }
                 } else {
                     $row_v = deserialize($row[$v]);
                     if (is_array($row_v)) {
                         $args_k = array();
                         foreach ($row_v as $option) {
                             $args_k[] = strlen($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$option]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$option] : $option;
                         }
                         $args[$k] = implode(",\n", $args_k);
                     } elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]])) {
                         $args[$k] = is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$v]['reference'][$row[$v]];
                     } else {
                         $args[$k] = $row[$v];
                     }
                     $strVal = is_null($args[$k]) ? $args[$k] : vsprintf('%s', $args[$k]);
                 }
                 if (in_array($v, $this->arrBaseFields) || in_array($v, $this->arrOwnerFields)) {
                     if ($v == 'fd_member') {
                         $strVal = $this->arrMembers[intval($row[$v])];
                     }
                     if ($v == 'fd_user') {
                         $strVal = $this->arrUsers[intval($row[$v])];
                     }
                     if ($v == 'fd_member_group') {
                         $strVal = $this->arrMemberGroups[intval($row[$v])];
                     }
                     if ($v == 'fd_user_group') {
                         $strVal = $this->arrUserGroups[intval($row[$v])];
                     }
                 }
                 if (strlen($strVal)) {
                     $strVal = $this->String->decodeEntities($strVal);
                     $strVal = preg_replace(array('/<br.*\\/*>/si'), array("\n"), $strVal);
                     if ($this->blnExportUTF8Decode || $strExportMode == 'xls' && !$blnCustomXlsExport) {
                         $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
                     }
                 }
                 if ($strExportMode == 'csv') {
                     $strVal = str_replace('"', '""', $strVal);
                     echo $strExpSep . $strExpEncl . $strVal . $strExpEncl;
                     $strExpSep = ";";
                 }
                 if ($strExportMode == 'xls') {
                     if (!$blnCustomXlsExport) {
                         $xls->setcell(array("sheetname" => $strXlsSheet, "row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL));
                     } else {
                         $arrHookData[$intRowCounter][$v] = $strVal;
                     }
                 }
             }
             if ($strExportMode == 'csv') {
                 $strExpSep = '';
                 echo "\n";
             }
         }
         // foreach ($result as $row)
     }
     // if objRow->numRows
     if ($strExportMode == 'xls') {
         if (!$blnCustomXlsExport) {
             $xls->sendfile("export_" . $this->strFormKey . "_" . date("Ymd") . ".xls");
             exit;
         } else {
             foreach ($GLOBALS['TL_HOOKS']['efgExportXls'] as $key => $callback) {
                 $this->import($callback[0]);
                 $res = $this->{$callback}[0]->{$callback}[1]($arrHookDataColumns, $arrHookData);
             }
         }
     }
     exit;
 }