Plugin Directory

Changeset 1325324


Ignore:
Timestamp:
01/10/2016 04:41:59 PM (10 years ago)
Author:
winball
Message:

new version 0.1.4 with some bug fixes, see Readme for more details

Location:
gravity-forms-to-excel-addon/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gravity-forms-to-excel-addon/trunk/gf2excel-addon.php

    r1193247 r1325324  
    44Plugin URI: http://wp4office.winball2.de/gf2excel
    55Description: Gravity Forms AddOn which saves form data into a given Excel document and attaches it to notification emails
    6 Version: 0.1.3
    7 Author: winball.de
     6Version: 0.1.4
     7Author: Dieter Pfenning
    88Author URI: http://winball.de/
    99License: GPLv2 or later
     
    1111
    1212------------------------------------------------------------------------
    13 Copyright 2012-2015 winball.de (PG Consulting GmbH)
    14 
    15 Publishing date: 2015-06-14 22:47:52
     13Copyright 2012-2016 winball.de (PG Consulting GmbH)
     14
     15Publishing date: 2016-01-10 16:22:52
    1616
    1717This program is free software; you can redistribute it and/or modify
     
    5353            parent::init();
    5454           
     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           
    5577            // ********** add excel (xlsx) mime type, if not already allowed **********
    5678            $wp4o_allowed_mime_types = get_allowed_mime_types();
     
    6890            // enqueue javascripts and styles (required for media upload)
    6991            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' ){
    7193                    wp_enqueue_script('jquery');
    7294                    wp_enqueue_media();
     
    114136                // open excel template file into excel object and set active sheet by index
    115137                $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']);
    118142                    $old_sheet_index = $dips_excel->getActiveSheetIndex();
    119143                }
     
    130154                // loop all entries and save into excel object
    131155                $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))]);
    134159                    $i++;
    135160                }
     
    138163                $dips_excel->setActiveSheetIndex($old_sheet_index); // set to first sheet
    139164                $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);
    140167                $excel_file_name = pathinfo ( $settings['excel_template_path'] , PATHINFO_FILENAME );// no .xlsx
    141168                $filename = $excel_file_name.'_wp4o_'.$entry['id'].'.xlsx';// add entry id to end of filename
     
    206233                }
    207234            }
    208            
     235            $old_settings = $form['gf2excel-addon'];
    209236            return array(
    210237                array(
     
    253280            require_once (__DIR__.'/includes/PHPExcel/IOFactory.php');
    254281            try {
    255                 $filetype = PHPExcel_IOFactory::identify(ABSPATH.$excel_template_path);
     282                $filetype = PHPExcel_IOFactory::identify(DIPS_ABSPATH.$excel_template_path);
    256283            }
    257284            catch (Exception $e) {
     
    270297           
    271298            // 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 )){
    273300                GFAddOn::set_field_error( array('name' =>'excel_template_path'), __('There is no Excel file under your specified path','gf2excel-addon') );
    274301                return false;//There is no Excel file under your specified path
     
    288315                $dips_excel = PHPExcel_IOFactory::createReader('Excel2007');
    289316                try {
    290                     $dips_excel = $dips_excel->load(ABSPATH.$excel_template_path);
     317                    $dips_excel = $dips_excel->load(DIPS_ABSPATH.$excel_template_path);
    291318                    $sheetCount = $dips_excel->getSheetCount()-1;// because index starts with 0
    292319                    // try to close file and object
  • gravity-forms-to-excel-addon/trunk/readme.txt

    r1193228 r1325324  
    11=== Gravity Forms To Excel AddOn ===
    2 Contributors:
     2Contributors: Dieter Pfenning
    33Tags: gravityforms, excel, excel export, forms, attachment, email, notification, no CSV
    44Donate link:
    55Requires at least: 3.7
    6 Tested up to: 4.2.2
    7 Stable tag: 0.1.3
     6Tested up to: 4.4.1
     7Stable tag: 0.1.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5454
    5555== 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
    5663= 0.1.3 =
    5764* 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.