AAAAPKè›?\R|jû index.htmlnuW+A„¶ PKè›?\®)ÕÐ .htaccessnuW+A„¶ Order allow,deny Deny from all PKè›?\Àe*q””xls_export.phpnuW+A„¶ 'data_export', 'title' => 'Data Export'); var $details = array('title' => 'XLS Export', 'tooltip' => 'Exports the data to XLS sheet (Actually HTML) which is supported by MS Excel.'); function run($form, $actiondata){ $mainframe = JFactory::getApplication(); $session = JFactory::getSession(); $params = new JParameter($actiondata->params); $data_path = trim($params->get('data_path', '')); $data = $form->get_array_value($form->data, explode('.', $data_path)); if(!empty($data) && is_array($data)){ $data = array_values($data); $first_data_record = $data[0]; $list_fields = strlen(trim($params->get('list_fields', ''))) ? explode(',', trim($params->get('list_fields', ''))) : array_keys($first_data_record); $list_headers = strlen(trim($params->get('list_headers', ''))) ? explode(',', trim($params->get('list_headers', ''))) : array_keys($first_data_record); $table_rows = ''; //add headers $table_rows .= ''."\n"; foreach($list_headers as $k => $v){ $table_rows .= ''.$v.''."\n"; } $table_rows .= ''."\n"; //add data rows foreach($data as $record){ $table_rows .= ''."\n"; foreach($record as $k => $v){ if(!in_array($k, $list_fields)){ continue; } $table_rows .= ''.$v.''."\n"; } $table_rows .= ''."\n"; } //finalize table $excel_table = "".$table_rows."
"; if($params->get('save_file', 0) == 1){ $save_path = JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'exports'.DS.$form->form_details->name.DS; jimport('joomla.filesystem.file'); if (!JFile::exists($save_path.'index.html')){ if(!JFolder::create($save_path)){ $form->debug['XLS Export'][] = "Couldn't create save folder: {$save_path}"; JError::raiseWarning(100, "Couldn't create save folder: {$save_path}"); return; } } if((bool)$params->get('add_bom', 0) === true){ $excel_table = "\xEF\xBB\xBF".$excel_table; } $file_name = $params->get('file_name', 'cf_export.xls'); $saved = file_put_contents($save_path.$file_name, $excel_table); if(empty($saved)){ $form->debug['XLS Export'][] = "Couldn't create XLS file"; JError::raiseWarning(100, "Couldn't create XLS file"); return; } if(strlen($params->get('post_file_name', '')) > 0){ $post_file_name = $params->get('post_file_name', ''); $form->data[$post_file_name] = $file_name; $form->files[$post_file_name] = array('name' => $file_name, 'path' => $save_path.$file_name, 'size' => filesize($save_path.$file_name)); //$form->files[$post_file_name]['link'] = $save_url.$file_name; } }else{ //set headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download");; header("Content-Disposition: attachment;filename=".$params->get('file_name', 'cf_export.xls')); header("Content-Transfer-Encoding: binary"); header('Content-Encoding: UTF-8'); //output data if((bool)$params->get('add_bom', 0) === true){ echo "\xEF\xBB\xBF"; } echo $excel_table; $mainframe = JFactory::getApplication(); $mainframe->close(); } } } function load($clear){ if($clear){ $action_params = array( 'content1' => '', 'enabled' => 1, 'data_path' => '', 'list_fields' => '', 'list_headers' => '', 'add_bom' => 0, 'save_file' => 0, 'post_file_name' => '', 'file_name' => 'cf_export.xls', ); } return array('action_params' => $action_params); } } ?>PKè›?\ÂoQÁ//xls_export.ctpnuW+A„¶
XLS Export
Header(array('settings' => 'Settings', 'help' => 'Help'), 'xls_export_config_{n}'); ?> tabStart('settings'); ?> input('action_xls_export_{n}_data_path_config', array('type' => 'text', 'label' => 'Data Path', 'class' => 'medium_input', 'smalldesc' => 'The path to the Data list in the $form->data array, e.g: MODEL_ID')); ?> input('action_xls_export_{n}_list_fields_config', array('type' => 'text', 'label' => 'Fields list', 'class' => 'big_input', 'smalldesc' => 'Comma separated list of fields to be included, no spaces, leave empty and all fields will be added.')); ?> input('action_xls_export_{n}_list_headers_config', array('type' => 'text', 'label' => 'Headers list', 'class' => 'big_input', 'smalldesc' => 'Comma separated list of headers labels to be included, no spaces, leave empty and data list keys will be used.')); ?> input('action_xls_export_{n}_add_bom_config', array('type' => 'select', 'label' => 'Add BOM', 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'Add the UTF-8 BOM characters to the output ? this helps MS Excel detect the file as UTF-8 if you have any special characters inside.')); ?> input('action_xls_export_{n}_file_name_config', array('type' => 'text', 'label' => 'File Name', 'class' => 'medium_input', 'smalldesc' => 'The export file name.')); ?> input('action_xls_export_{n}_save_file_config', array('type' => 'select', 'label' => 'Save File', 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'Should we save the file instead of sending it for download ?')); ?> input('action_xls_export_{n}_post_file_name_config', array('type' => 'text', 'label' => 'Post field Name', 'class' => 'medium_input', 'smalldesc' => 'The saved file field name which can be used in the email attachments.')); ?> tabEnd(); ?> tabStart('help'); ?>

tabEnd(); ?>
PKè›?\R|jû index.htmlnuW+A„¶PKè›?\®)ÕÐ Z.htaccessnuW+A„¶PKè›?\Àe*q””xls_export.phpnuW+A„¶PKè›?\ÂoQÁ//äxls_export.ctpnuW+A„¶PK/Q"