Changeset 1325324
- Timestamp:
- 01/10/2016 04:41:59 PM (10 years ago)
- Location:
- gravity-forms-to-excel-addon/trunk
- Files:
-
- 2 edited
-
gf2excel-addon.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gravity-forms-to-excel-addon/trunk/gf2excel-addon.php
r1193247 r1325324 4 4 Plugin URI: http://wp4office.winball2.de/gf2excel 5 5 Description: Gravity Forms AddOn which saves form data into a given Excel document and attaches it to notification emails 6 Version: 0.1. 37 Author: winball.de6 Version: 0.1.4 7 Author: Dieter Pfenning 8 8 Author URI: http://winball.de/ 9 9 License: GPLv2 or later … … 11 11 12 12 ------------------------------------------------------------------------ 13 Copyright 2012-201 5winball.de (PG Consulting GmbH)14 15 Publishing date: 201 5-06-14 22:47:5213 Copyright 2012-2016 winball.de (PG Consulting GmbH) 14 15 Publishing date: 2016-01-10 16:22:52 16 16 17 17 This program is free software; you can redistribute it and/or modify … … 53 53 parent::init(); 54 54 55 56 57 // ********** define wordpress root directory ********** 58 function get_wp_root_path() { 59 $base = dirname(__FILE__); 60 $path = false; 61 if (@file_exists(dirname(dirname($base))."/wp-load.php")) { 62 $path = dirname(dirname($base))."/wp-load.php"; 63 } else if (@file_exists(dirname(dirname(dirname($base)))."/wp-load.php")) { 64 $path = dirname(dirname(dirname($base)))."/wp-load.php"; 65 } else { 66 $path = false; 67 } 68 if ($path != false) { 69 $path = str_replace("\\", "/", $path); 70 $path = str_replace("/wp-load.php", "/", $path); 71 } 72 return $path; 73 } 74 define('DIPS_ABSPATH', get_wp_root_path()); 75 76 55 77 // ********** add excel (xlsx) mime type, if not already allowed ********** 56 78 $wp4o_allowed_mime_types = get_allowed_mime_types(); … … 68 90 // enqueue javascripts and styles (required for media upload) 69 91 function wp4o_enqueue(){ 70 if( $_GET['page'] == 'gf_edit_forms' && $_GET['subview'] == 'gf2excel-addon' ){92 if( isset($_GET['page']) && $_GET['page'] == 'gf_edit_forms' && $_GET['subview'] == 'gf2excel-addon' ){ 71 93 wp_enqueue_script('jquery'); 72 94 wp_enqueue_media(); … … 114 136 // open excel template file into excel object and set active sheet by index 115 137 $dips_excel = PHPExcel_IOFactory::createReader('Excel2007'); 116 try { 117 $dips_excel = $dips_excel->load(ABSPATH.$settings['excel_template_path']); 138 // Tell the reader to include charts when it loads a file (fix for 0.1.4) 139 $dips_excel->setIncludeCharts(TRUE); 140 try { 141 $dips_excel = $dips_excel->load(DIPS_ABSPATH.$settings['excel_template_path']); 118 142 $old_sheet_index = $dips_excel->getActiveSheetIndex(); 119 143 } … … 130 154 // loop all entries and save into excel object 131 155 $i = 1; 132 foreach ($entry as $key => $value) { 133 $dips_excel->getActiveSheet()->setCellValue('C'.$i, $key) ->setCellValue('B'.$i, $value) ->setCellValue('A'.$i, $dips_lables[$key]); 156 foreach ($entry as $key => $value) { 157 //error_log(print_R($entry,TRUE)); 158 $dips_excel->getActiveSheet()->setCellValue('C'.$i, $key) ->setCellValue('B'.$i, $value) ->setCellValue('A'.$i, $dips_lables[strval(intval($key))]); 134 159 $i++; 135 160 } … … 138 163 $dips_excel->setActiveSheetIndex($old_sheet_index); // set to first sheet 139 164 $objWriter = PHPExcel_IOFactory::createWriter($dips_excel, 'Excel2007'); 165 // Tell the writer to include charts when it writes the object (fix for 0.1.4) 166 $objWriter->setIncludeCharts(TRUE); 140 167 $excel_file_name = pathinfo ( $settings['excel_template_path'] , PATHINFO_FILENAME );// no .xlsx 141 168 $filename = $excel_file_name.'_wp4o_'.$entry['id'].'.xlsx';// add entry id to end of filename … … 206 233 } 207 234 } 208 235 $old_settings = $form['gf2excel-addon']; 209 236 return array( 210 237 array( … … 253 280 require_once (__DIR__.'/includes/PHPExcel/IOFactory.php'); 254 281 try { 255 $filetype = PHPExcel_IOFactory::identify( ABSPATH.$excel_template_path);282 $filetype = PHPExcel_IOFactory::identify(DIPS_ABSPATH.$excel_template_path); 256 283 } 257 284 catch (Exception $e) { … … 270 297 271 298 // check if file path points to an existing file 272 if ($excel_template_path!='' && !file_exists ( ABSPATH.$excel_template_path )){299 if ($excel_template_path!='' && !file_exists ( DIPS_ABSPATH.$excel_template_path )){ 273 300 GFAddOn::set_field_error( array('name' =>'excel_template_path'), __('There is no Excel file under your specified path','gf2excel-addon') ); 274 301 return false;//There is no Excel file under your specified path … … 288 315 $dips_excel = PHPExcel_IOFactory::createReader('Excel2007'); 289 316 try { 290 $dips_excel = $dips_excel->load( ABSPATH.$excel_template_path);317 $dips_excel = $dips_excel->load(DIPS_ABSPATH.$excel_template_path); 291 318 $sheetCount = $dips_excel->getSheetCount()-1;// because index starts with 0 292 319 // try to close file and object -
gravity-forms-to-excel-addon/trunk/readme.txt
r1193228 r1325324 1 1 === Gravity Forms To Excel AddOn === 2 Contributors: 2 Contributors: Dieter Pfenning 3 3 Tags: gravityforms, excel, excel export, forms, attachment, email, notification, no CSV 4 4 Donate link: 5 5 Requires at least: 3.7 6 Tested up to: 4. 2.27 Stable tag: 0.1. 36 Tested up to: 4.4.1 7 Stable tag: 0.1.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 54 54 55 55 == Changelog == 56 = 0.1.4 = 57 * changed saving of values from multiple selected checkboxes in multiple lines to single line (like Multi Select) 58 * fixed missing admin labels for checkboxes 59 * added check for missing GET field 60 * fixed file not found bug (for excel templates) with WordPress installations in subdirectories, replaced ABSPATH 61 * fixed missing charts in output excel to templates containing charts 62 56 63 = 0.1.3 = 57 64 * make first sheet (index 0) active, not the sheet, where the form data is stored
Note: See TracChangeset
for help on using the changeset viewer.