/** * Creates a special Recordlist that can be used for exporting to files or to make it printable. * * @param Node $node The node to use as definition for the columns. * @param array $recordset The records to render * @param string $compression Compression technique (bzip / gzip) * @param array $suppressList List of attributes from $node that should be ignored * @param array $outputparams Key-Value parameters for output. Currently existing: * filename - the name of the file (without extension .csv) * @param bool $titlerow Should titlerow be rendered or not * @param bool $decode Should data be decoded or not (for exports) * * @return string */ public function render(&$node, $recordset, $compression = '', $suppressList = [], $outputparams = [], $titlerow = true, $decode = false) { return parent::render($node, $recordset, '<tr>', '<td>', '</td>', "<tr>\n", '0', $compression, $suppressList, $outputparams, 'list', $titlerow, $decode, '', '<br>'); }
/** * Creates a special Recordlist that can be used for exporting to files or to make it printable. * * @param Node $node The node to use as definition for the columns. * @param array $recordset The records to render * @param string $compression Compression technique (bzip / gzip) * @param array $suppressList List of attributes from $node that should be ignored * @param array $outputparams Key-Value parameters for output. Currently existing: * filename - the name of the file (without extension .csv) * @param bool $titlerow Should titlerow be rendered or not * @param bool $decode Should data be decoded or not (for exports) */ public function render(&$node, $recordset, $compression = '', $suppressList = '', $outputparams = [], $titlerow = true, $decode = false) { parent::render($node, $recordset, '', '"', '"', "\n", '1', $compression, $suppressList, $outputparams, 'csv', $titlerow, $decode, ';', $this->lfreplace); }
/** * the real import function * import the uploaded csv file for real. */ public function doExport() { $enclosure = $this->m_postvars['enclosure']; $delimiter = $this->m_postvars['delimiter']; $source = $this->m_postvars; $list_includes = []; foreach ($source as $name => $value) { $pos = strpos($name, 'export_'); if (is_integer($pos) and $pos == 0) { $list_includes[] = substr($name, strlen('export_')); } } $sm = SessionManager::getInstance(); $sessionData =& SessionManager::getSession(); $session_back = $sessionData['default']['stack'][$sm->atkStackID()][$sm->atkLevel() - 1]; $atkorderby = $session_back['atkorderby']; $node = $this->m_node; $node_bk = $node; $num_atts = count($node_bk->m_attribList); $atts =& $node_bk->m_attribList; foreach ($atts as $name => $object) { $att = $node_bk->getAttribute($name); if (in_array($name, $list_includes) && $att->hasFlag(Attribute::AF_HIDE_LIST)) { $att->removeFlag(Attribute::AF_HIDE_LIST); } elseif (!in_array($name, $list_includes)) { $att->addFlag(Attribute::AF_HIDE_LIST); } } $rl = new CustomRecordList(); $flags = ($node_bk->hasFlag(Node::NF_MRA) ? RecordList::RL_MRA : 0) | ($node_bk->hasFlag(Node::NF_MRPA) ? RecordList::RL_MRPA : 0); $node_bk->m_postvars = $session_back; if (isset($session_back['atkdg']['admin']['atksearch'])) { $node_bk->m_postvars['atksearch'] = $session_back['atkdg']['admin']['atksearch']; } if (isset($session_back['atkdg']['admin']['atksearchmode'])) { $node_bk->m_postvars['atksearchmode'] = $session_back['atkdg']['admin']['atksearchmode']; } $atkfilter = Tools::atkArrayNvl($source, 'atkfilter', ''); $condition = $session_back['atkselector'] . ($session_back['atkselector'] != '' && $atkfilter != '' ? ' AND ' : '') . $atkfilter; $recordset = $node_bk->select($condition)->orderBy($atkorderby)->includes($list_includes)->mode('export')->getAllRows(); if (method_exists($this->m_node, 'assignExportData')) { $this->m_node->assignExportData($list_includes, $recordset); } $recordset_new = []; foreach ($recordset as $row) { foreach ($row as $name => $value) { if (in_array($name, $list_includes)) { $value = str_replace("\r\n", '\\n', $value); $value = str_replace("\n", '\\n', $value); $value = str_replace("\t", '\\t', $value); $row[$name] = $value; } } $recordset_new[] = $row; } $filename = 'export_' . strtolower(str_replace(' ', '_', $this->getUi()->nodeTitle($node))); $rl->render($node_bk, $recordset_new, '', $enclosure, $enclosure, "\r\n", 1, '', '', array('filename' => $filename), 'csv', $source['generatetitlerow'], true, $delimiter); return true; }